diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2016-03-02 21:26:56 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-03-07 17:23:03 +0000 |
commit | a71d32ac53129e4f039f50fdde9a63026d667188 (patch) | |
tree | 6ecf9a3ccf699424ffb69d7db70a3599d9e7dab8 /bitbake/lib | |
parent | 3db71b408719d8588191edfc3b82554f72283e59 (diff) | |
download | poky-a71d32ac53129e4f039f50fdde9a63026d667188.tar.gz |
bitbake: toaster: remove sshbecontroller module
The code of this module is broken for a long time.
The functionality of it can be easily achieved by running
'manage.py runbuilds.py' on remote machine.
[YOCTO #8806]
(Bitbake rev: 975081eefdd7041a6b4bef6842c1bac9799a1b44)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/toaster/bldcontrol/sshbecontroller.py | 169 |
1 files changed, 0 insertions, 169 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/sshbecontroller.py b/bitbake/lib/toaster/bldcontrol/sshbecontroller.py deleted file mode 100644 index 17dd66c3bc..0000000000 --- a/bitbake/lib/toaster/bldcontrol/sshbecontroller.py +++ /dev/null | |||
@@ -1,169 +0,0 @@ | |||
1 | # | ||
2 | # ex:ts=4:sw=4:sts=4:et | ||
3 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
4 | # | ||
5 | # BitBake Toaster Implementation | ||
6 | # | ||
7 | # Copyright (C) 2014 Intel Corporation | ||
8 | # | ||
9 | # This program is free software; you can redistribute it and/or modify | ||
10 | # it under the terms of the GNU General Public License version 2 as | ||
11 | # published by the Free Software Foundation. | ||
12 | # | ||
13 | # This program is distributed in the hope that it will be useful, | ||
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | # GNU General Public License for more details. | ||
17 | # | ||
18 | # You should have received a copy of the GNU General Public License along | ||
19 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
21 | |||
22 | |||
23 | import sys | ||
24 | import re | ||
25 | from django.db import transaction | ||
26 | from django.db.models import Q | ||
27 | from bldcontrol.models import BuildEnvironment, BRLayer, BRVariable, BRTarget, BRBitbake | ||
28 | import subprocess | ||
29 | |||
30 | from toastermain import settings | ||
31 | |||
32 | from bbcontroller import BuildEnvironmentController, ShellCmdException, BuildSetupException | ||
33 | |||
34 | class NotImplementedException(Exception): | ||
35 | pass | ||
36 | |||
37 | def DN(path): | ||
38 | return "/".join(path.split("/")[0:-1]) | ||
39 | |||
40 | class SSHBEController(BuildEnvironmentController): | ||
41 | """ Implementation of the BuildEnvironmentController for the localhost; | ||
42 | this controller manages the default build directory, | ||
43 | the server setup and system start and stop for the localhost-type build environment | ||
44 | |||
45 | """ | ||
46 | |||
47 | def __init__(self, be): | ||
48 | super(SSHBEController, self).__init__(be) | ||
49 | self.dburl = settings.getDATABASE_URL() | ||
50 | self.pokydirname = None | ||
51 | self.islayerset = False | ||
52 | |||
53 | def _shellcmd(self, command, cwd = None): | ||
54 | if cwd is None: | ||
55 | cwd = self.be.sourcedir | ||
56 | |||
57 | p = subprocess.Popen("ssh %s 'cd %s && %s'" % (self.be.address, cwd, command), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) | ||
58 | (out,err) = p.communicate() | ||
59 | if p.returncode: | ||
60 | if len(err) == 0: | ||
61 | err = "command: %s \n%s" % (command, out) | ||
62 | else: | ||
63 | err = "command: %s \n%s" % (command, err) | ||
64 | raise ShellCmdException(err) | ||
65 | else: | ||
66 | return out.strip() | ||
67 | |||
68 | def _pathexists(self, path): | ||
69 | try: | ||
70 | self._shellcmd("test -e \"%s\"" % path) | ||
71 | return True | ||
72 | except ShellCmdException as e: | ||
73 | return False | ||
74 | |||
75 | def _pathcreate(self, path): | ||
76 | self._shellcmd("mkdir -p \"%s\"" % path) | ||
77 | |||
78 | def _setupBE(self): | ||
79 | assert self.pokydirname and self._pathexists(self.pokydirname) | ||
80 | self._pathcreate(self.be.builddir) | ||
81 | self._shellcmd("bash -c \"source %s/oe-init-build-env %s\"" % (self.pokydirname, self.be.builddir)) | ||
82 | |||
83 | def startBBServer(self, brbe): | ||
84 | assert self.pokydirname and self._pathexists(self.pokydirname) | ||
85 | assert self.islayerset | ||
86 | cmd = self._shellcmd("bash -c \"source %s/oe-init-build-env %s && DATABASE_URL=%s source toaster start noweb brbe=%s\"" % (self.pokydirname, self.be.builddir, self.dburl, brbe)) | ||
87 | |||
88 | port = "-1" | ||
89 | for i in cmd.split("\n"): | ||
90 | if i.startswith("Bitbake server address"): | ||
91 | port = i.split(" ")[-1] | ||
92 | print "Found bitbake server port ", port | ||
93 | |||
94 | |||
95 | assert self.be.sourcedir and self._pathexists(self.be.builddir) | ||
96 | self.be.bbaddress = self.be.address.split("@")[-1] | ||
97 | self.be.bbport = port | ||
98 | self.be.bbstate = BuildEnvironment.SERVER_STARTED | ||
99 | self.be.save() | ||
100 | |||
101 | def _copyFile(self, filepath1, filepath2): | ||
102 | p = subprocess.Popen("scp '%s' '%s'" % (filepath1, filepath2), stdout=subprocess.PIPE, stderr = subprocess.PIPE, shell=True) | ||
103 | (out, err) = p.communicate() | ||
104 | if p.returncode: | ||
105 | raise ShellCmdException(err) | ||
106 | |||
107 | def pullFile(self, local_filename, remote_filename): | ||
108 | _copyFile(local_filename, "%s:%s" % (self.be.address, remote_filename)) | ||
109 | |||
110 | def pushFile(self, local_filename, remote_filename): | ||
111 | _copyFile("%s:%s" % (self.be.address, remote_filename), local_filename) | ||
112 | |||
113 | def setLayers(self, bitbakes, layers): | ||
114 | """ a word of attention: by convention, the first layer for any build will be poky! """ | ||
115 | |||
116 | assert self.be.sourcedir is not None | ||
117 | assert len(bitbakes) == 1 | ||
118 | # set layers in the layersource | ||
119 | |||
120 | |||
121 | raise NotImplementedException("Not implemented: SSH setLayers") | ||
122 | # 3. configure the build environment, so we have a conf/bblayers.conf | ||
123 | assert self.pokydirname is not None | ||
124 | self._setupBE() | ||
125 | |||
126 | # 4. update the bblayers.conf | ||
127 | bblayerconf = os.path.join(self.be.builddir, "conf/bblayers.conf") | ||
128 | if not self._pathexists(bblayerconf): | ||
129 | raise BuildSetupException("BE is not consistent: bblayers.conf file missing at %s" % bblayerconf) | ||
130 | |||
131 | import uuid | ||
132 | local_bblayerconf = "/tmp/" + uuid.uuid4() + "-bblayer.conf" | ||
133 | |||
134 | self.pullFile(bblayerconf, local_bblayerconf) | ||
135 | |||
136 | BuildEnvironmentController._updateBBLayers(local_bblayerconf, layerlist) | ||
137 | self.pushFile(local_bblayerconf, bblayerconf) | ||
138 | |||
139 | os.unlink(local_bblayerconf) | ||
140 | |||
141 | self.islayerset = True | ||
142 | return True | ||
143 | |||
144 | def release(self): | ||
145 | assert self.be.sourcedir and self._pathexists(self.be.builddir) | ||
146 | import shutil | ||
147 | shutil.rmtree(os.path.join(self.be.sourcedir, "build")) | ||
148 | assert not self._pathexists(self.be.builddir) | ||
149 | |||
150 | def triggerBuild(self, bitbake, layers, variables, targets): | ||
151 | # set up the buid environment with the needed layers | ||
152 | self.setLayers(bitbake, layers) | ||
153 | self.writeConfFile("conf/toaster-pre.conf", ) | ||
154 | self.writeConfFile("conf/toaster.conf", raw = "INHERIT+=\"toaster buildhistory\"") | ||
155 | |||
156 | # get the bb server running with the build req id and build env id | ||
157 | bbctrl = self.getBBController() | ||
158 | |||
159 | # trigger the build command | ||
160 | task = reduce(lambda x, y: x if len(y)== 0 else y, map(lambda y: y.task, targets)) | ||
161 | if len(task) == 0: | ||
162 | task = None | ||
163 | |||
164 | bbctrl.build(list(map(lambda x:x.target, targets)), task) | ||
165 | |||
166 | logger.debug("localhostbecontroller: Build launched, exiting. Follow build logs at %s/toaster_ui.log" % self.be.builddir) | ||
167 | |||
168 | # disconnect from the server | ||
169 | bbctrl.disconnect() | ||