1 |
commit: 6505a65933a1091252d93d206d9a570dae82cc5b |
2 |
Author: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Dec 27 22:51:11 2012 +0000 |
4 |
Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Dec 27 22:51:11 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=dev/zorry.git;a=commit;h=6505a659 |
7 |
|
8 |
Code change for the host/config split |
9 |
|
10 |
--- |
11 |
gobs/bin/gobs_guest_jobs | 7 ++++--- |
12 |
gobs/bin/gobs_host_jobs | 7 ++++--- |
13 |
gobs/pym/build_log.py | 15 +++++++++------ |
14 |
gobs/pym/mysql_querys.py | 18 +++++++++--------- |
15 |
gobs/pym/package.py | 13 ++++++------- |
16 |
gobs/pym/readconf.py | 2 ++ |
17 |
gobs/pym/sync.py | 15 ++++++++++----- |
18 |
gobs/pym/updatedb.py | 12 +++++++----- |
19 |
8 files changed, 51 insertions(+), 38 deletions(-) |
20 |
|
21 |
diff --git a/gobs/bin/gobs_guest_jobs b/gobs/bin/gobs_guest_jobs |
22 |
index 2333d62..b97e7ed 100755 |
23 |
--- a/gobs/bin/gobs_guest_jobs |
24 |
+++ b/gobs/bin/gobs_guest_jobs |
25 |
@@ -19,16 +19,17 @@ def main(): |
26 |
repeat = True |
27 |
reader = get_conf_settings() |
28 |
gobs_settings_dict=reader.read_gobs_settings_all() |
29 |
- config_profile = gobs_settings_dict['gobs_config'] |
30 |
+ config = gobs_settings_dict['gobs_config'] |
31 |
+ hostname = gobs_settings_dict['hostname'] |
32 |
CM=connectionManager() |
33 |
conn = CM.newConnection() |
34 |
- config_id = get_config_id(conn, config_profile) |
35 |
+ config_id = get_config_id(conn, config, hostname) |
36 |
add_gobs_logs(conn, "Job and build deamon started.", "info", config_id) |
37 |
init_build_job = build_job_action(conn, config_id) |
38 |
while repeat: |
39 |
if not conn.is_connected() is True: |
40 |
conn.reconnect(attempts=2, delay=1) |
41 |
- jobs_main(conn, config_profile) |
42 |
+ jobs_main(conn, config) |
43 |
if check_configure_guest(conn, config_id) is not True: |
44 |
time.sleep(6) |
45 |
continue |
46 |
|
47 |
diff --git a/gobs/bin/gobs_host_jobs b/gobs/bin/gobs_host_jobs |
48 |
index 162ac43..905d8af 100755 |
49 |
--- a/gobs/bin/gobs_host_jobs |
50 |
+++ b/gobs/bin/gobs_host_jobs |
51 |
@@ -13,14 +13,15 @@ def main(): |
52 |
# Main |
53 |
reader = get_conf_settings() |
54 |
gobs_settings_dict=reader.read_gobs_settings_all() |
55 |
- config_profile = gobs_settings_dict['gobs_config'] |
56 |
+ config = gobs_settings_dict['gobs_config'] |
57 |
+ hostname = gobs_settings_dict['hostname'] |
58 |
CM=connectionManager() |
59 |
conn = CM.newConnection() |
60 |
- config_id = get_config_id(conn, config_profile) |
61 |
+ config_id = get_config_id(conn, config, hostname) |
62 |
add_gobs_logs(conn, "Job deamon started", "info", config_id) |
63 |
repeat = True |
64 |
while repeat: |
65 |
- jobs_main(conn, config_profile) |
66 |
+ jobs_main(conn, config_id) |
67 |
repeat = False |
68 |
time.sleep(60) |
69 |
conn.close |
70 |
|
71 |
diff --git a/gobs/pym/build_log.py b/gobs/pym/build_log.py |
72 |
index 7b2fac4..3582406 100644 |
73 |
--- a/gobs/pym/build_log.py |
74 |
+++ b/gobs/pym/build_log.py |
75 |
@@ -216,8 +216,10 @@ def add_buildlog_process(settings, pkg): |
76 |
conn.reconnect(attempts=2, delay=1) |
77 |
reader=get_conf_settings() |
78 |
gobs_settings_dict=reader.read_gobs_settings_all() |
79 |
- config_profile = gobs_settings_dict['gobs_config'] |
80 |
- config_id = get_config_id(conn, config_profile) |
81 |
+ config = gobs_settings_dict['gobs_config'] |
82 |
+ hostname =gobs_settings_dict['gobs_hostname'] |
83 |
+ host_config = hostname + "/" + config |
84 |
+ config_id = get_config_id(conn, config, hostname) |
85 |
build_dict = get_build_dict_db(conn, config_id, settings, pkg) |
86 |
if build_dict is None: |
87 |
log_msg = "Package %s:%s is NOT logged." % (pkg.cpv, pkg.repo,) |
88 |
@@ -236,7 +238,7 @@ def add_buildlog_process(settings, pkg): |
89 |
log_hash.update(log_line) |
90 |
build_log_dict['build_error'] = build_error |
91 |
build_log_dict['log_hash'] = log_hash.hexdigest() |
92 |
- build_log_dict['logfilename'] = settings.get("PORTAGE_LOG_FILE").split(config_profile)[1] |
93 |
+ build_log_dict['logfilename'] = settings.get("PORTAGE_LOG_FILE").split(host_config)[1] |
94 |
log_msg = "Logfile name: %s" % (settings.get("PORTAGE_LOG_FILE"),) |
95 |
add_gobs_logs(conn, log_msg, "info", config_id) |
96 |
log_id = add_new_buildlog(conn, build_dict, build_log_dict) |
97 |
@@ -244,7 +246,7 @@ def add_buildlog_process(settings, pkg): |
98 |
msg = "" |
99 |
# emerge_info_logfilename = settings.get("PORTAGE_LOG_FILE")[:-3] + "emerge_log.log" |
100 |
if log_id is None: |
101 |
- os.chmod(settings.get("PORTAGE_LOG_FILE"), 0o664) |
102 |
+ # os.chmod(settings.get("PORTAGE_LOG_FILE"), 0o664) |
103 |
log_msg = "Package %s:%s is NOT logged." % (pkg.cpv, pkg.repo,) |
104 |
add_gobs_logs(conn, log_msg, "info", config_id) |
105 |
else: |
106 |
@@ -317,8 +319,9 @@ def log_fail_queru(conn, build_dict, settings): |
107 |
else: |
108 |
build_dict['build_useflags'] = None |
109 |
if settings.get("PORTAGE_LOG_FILE") is not None: |
110 |
- config_profile = get_config(conn, config_id) |
111 |
- build_log_dict['logfilename'] = settings.get("PORTAGE_LOG_FILE").split(config_profile)[1] |
112 |
+ hostname, config = get_config(conn, config_id) |
113 |
+ host_config = hostname +"/" + config |
114 |
+ build_log_dict['logfilename'] = settings.get("PORTAGE_LOG_FILE").split(host_config)[1] |
115 |
os.chmod(settings.get("PORTAGE_LOG_FILE"), 0o224) |
116 |
else: |
117 |
build_log_dict['logfilename'] = "" |
118 |
|
119 |
diff --git a/gobs/pym/mysql_querys.py b/gobs/pym/mysql_querys.py |
120 |
index f179d26..3d9d495 100644 |
121 |
--- a/gobs/pym/mysql_querys.py |
122 |
+++ b/gobs/pym/mysql_querys.py |
123 |
@@ -1,10 +1,10 @@ |
124 |
from __future__ import print_function |
125 |
|
126 |
# Queryes to add the logs |
127 |
-def get_config_id(connection, config): |
128 |
+def get_config_id(connection, config, host): |
129 |
cursor = connection.cursor() |
130 |
- sqlQ = 'SELECT config_id FROM configs WHERE config = %s' |
131 |
- cursor.execute(sqlQ,(config,)) |
132 |
+ sqlQ = 'SELECT config_id FROM configs WHERE config = %s AND hostname= host' |
133 |
+ cursor.execute(sqlQ,(config, host,)) |
134 |
entries = cursor.fetchone() |
135 |
cursor.close() |
136 |
if not entries is None: |
137 |
@@ -69,11 +69,11 @@ def get_config_list_all(connection): |
138 |
|
139 |
def get_config(connection, config_id): |
140 |
cursor = connection.cursor() |
141 |
- sqlQ ='SELECT config FROM configs WHERE config_id = %s' |
142 |
+ sqlQ ='SELECT host, config FROM configs WHERE config_id = %s' |
143 |
cursor.execute(sqlQ, (config_id,)) |
144 |
- config = cursor.fetchone() |
145 |
+ hostname, config = cursor.fetchone() |
146 |
cursor.close() |
147 |
- return config[0] |
148 |
+ return hostname[0], config[0] |
149 |
|
150 |
def update_make_conf(connection, configsDict): |
151 |
cursor = connection.cursor() |
152 |
@@ -85,11 +85,11 @@ def update_make_conf(connection, configsDict): |
153 |
|
154 |
def get_default_config(connection): |
155 |
cursor = connection.cursor() |
156 |
- sqlQ = "SELECT config FROM configs WHERE default_config = 'True'" |
157 |
+ sqlQ = "SELECT host, config FROM configs WHERE default_config = 'True'" |
158 |
cursor.execute(sqlQ) |
159 |
- entries = cursor.fetchone() |
160 |
+ hostname, config = cursor.fetchone() |
161 |
cursor.close() |
162 |
- return entries[0] |
163 |
+ return hostname[0], config[0] |
164 |
|
165 |
def get_repo_id(connection, repo): |
166 |
cursor = connection.cursor() |
167 |
|
168 |
diff --git a/gobs/pym/package.py b/gobs/pym/package.py |
169 |
index 03b6c21..a86d512 100644 |
170 |
--- a/gobs/pym/package.py |
171 |
+++ b/gobs/pym/package.py |
172 |
@@ -12,7 +12,6 @@ from gobs.mysql_querys import get_config, get_config_id, add_gobs_logs, get_defa |
173 |
from gobs.readconf import get_conf_settings |
174 |
reader=get_conf_settings() |
175 |
gobs_settings_dict=reader.read_gobs_settings_all() |
176 |
-config_profile = gobs_settings_dict['gobs_config'] |
177 |
|
178 |
class gobs_package(object): |
179 |
|
180 |
@@ -22,9 +21,9 @@ class gobs_package(object): |
181 |
self._myportdb = myportdb |
182 |
self._config_id = get_config_id(conn, config_profile) |
183 |
|
184 |
- def change_config(self, config_setup): |
185 |
+ def change_config(self, host_config): |
186 |
# Change config_root config_setup = table config |
187 |
- my_new_setup = "/var/cache/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/" + config_setup + "/" |
188 |
+ my_new_setup = "/var/cache/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/" + host_config + "/" |
189 |
mysettings_setup = portage.config(config_root = my_new_setup) |
190 |
return mysettings_setup |
191 |
|
192 |
@@ -35,8 +34,8 @@ class gobs_package(object): |
193 |
for config_id in config_id_list: |
194 |
|
195 |
# Change config/setup |
196 |
- config_setup = get_config(self._conn, config_id) |
197 |
- mysettings_setup = self.change_config(config_setup) |
198 |
+ hostname, config = get_config(self._conn, config_id) |
199 |
+ mysettings_setup = self.change_config(hostname + "/" + config) |
200 |
myportdb_setup = portage.portdbapi(mysettings=mysettings_setup) |
201 |
|
202 |
# Get the latest cpv from portage with the config that we can build |
203 |
@@ -155,10 +154,10 @@ class gobs_package(object): |
204 |
add_new_build_job(self._conn, ebuild_id, config_id, use_flagsDict) |
205 |
|
206 |
# B = Build cpv use-flags config |
207 |
- config_setup = get_config(self._conn, config_id) |
208 |
+ hostname, config = get_config(self._conn, config_id) |
209 |
|
210 |
# FIXME log_msg need a fix to log the use flags corect. |
211 |
- log_msg = "B %s:%s USE: %s %s" % (k, v['repo'], use_flagsDict, config_setup,) |
212 |
+ log_msg = "B %s:%s USE: %s %s:%s" % (k, v['repo'], use_flagsDict, hostname, config,) |
213 |
add_gobs_logs(self._conn, log_msg, "info", self._config_id) |
214 |
i = i +1 |
215 |
|
216 |
|
217 |
diff --git a/gobs/pym/readconf.py b/gobs/pym/readconf.py |
218 |
index 1a1c036..45ed10a 100644 |
219 |
--- a/gobs/pym/readconf.py |
220 |
+++ b/gobs/pym/readconf.py |
221 |
@@ -1,6 +1,7 @@ |
222 |
import os |
223 |
import sys |
224 |
import re |
225 |
+import socket |
226 |
|
227 |
class get_conf_settings(object): |
228 |
# open the /etc/buildhost/buildhost.conf file and get the needed |
229 |
@@ -45,5 +46,6 @@ class get_conf_settings(object): |
230 |
gobs_settings_dict['sql_passwd'] = get_sql_passwd.rstrip('\n') |
231 |
gobs_settings_dict['gobs_gitreponame'] = get_gobs_gitreponame.rstrip('\n') |
232 |
gobs_settings_dict['gobs_config'] = get_gobs_config.rstrip('\n') |
233 |
+ gobs_settings_dict['hostname'] = socket.gethostname() |
234 |
# gobs_settings_dict['gobs_logfile'] = get_gobs_logfile.rstrip('\n') |
235 |
return gobs_settings_dict |
236 |
|
237 |
diff --git a/gobs/pym/sync.py b/gobs/pym/sync.py |
238 |
index 085973a..3e25878 100644 |
239 |
--- a/gobs/pym/sync.py |
240 |
+++ b/gobs/pym/sync.py |
241 |
@@ -3,17 +3,21 @@ import portage |
242 |
import os |
243 |
import errno |
244 |
import sys |
245 |
+# Do not support python 3.* |
246 |
from git import * |
247 |
+ |
248 |
from _emerge.main import emerge_main |
249 |
from gobs.readconf import get_conf_settings |
250 |
from gobs.mysql_querys import get_config_id, add_gobs_logs, get_default_config |
251 |
|
252 |
reader=get_conf_settings() |
253 |
gobs_settings_dict=reader.read_gobs_settings_all() |
254 |
-config_profile = gobs_settings_dict['gobs_config'] |
255 |
+_config = gobs_settings_dict['gobs_config'] |
256 |
+_hostname =gobs_settings_dict['gobs_hostname'] |
257 |
|
258 |
def git_pull(conn): |
259 |
- config_id = get_config_id(conn, config_profile) |
260 |
+ #FIXME: Use git direct so we can use python 3.* |
261 |
+ config_id = get_config_id(conn, _config, _hostname) |
262 |
log_msg = "Git pull" |
263 |
add_gobs_logs(conn, log_msg, "info", config_id) |
264 |
repo = Repo("/var/cache/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/") |
265 |
@@ -27,9 +31,10 @@ def git_pull(conn): |
266 |
return True |
267 |
|
268 |
def sync_tree(conn): |
269 |
- config_id = get_config_id(conn, config_profile) |
270 |
- config_setup = get_default_config(conn) # HostConfigDir = table configs id |
271 |
- default_config_root = "/var/cache/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/" + config_setup + "/" |
272 |
+ config_id = get_config_id(conn, _config, _hostname) |
273 |
+ hostname, config = get_default_config(conn) # HostConfigDir = table configs id |
274 |
+ host_config = hostname +"/" + config |
275 |
+ default_config_root = "/var/cache/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/" + host_config + "/" |
276 |
mysettings = portage.config(config_root = default_config_root) |
277 |
tmpcmdline = [] |
278 |
tmpcmdline.append("--sync") |
279 |
|
280 |
diff --git a/gobs/pym/updatedb.py b/gobs/pym/updatedb.py |
281 |
old mode 100755 |
282 |
new mode 100644 |
283 |
index b33eb03..cc5681c |
284 |
--- a/gobs/pym/updatedb.py |
285 |
+++ b/gobs/pym/updatedb.py |
286 |
@@ -17,7 +17,8 @@ from gobs.package import gobs_package |
287 |
from gobs.readconf import get_conf_settings |
288 |
reader = get_conf_settings() |
289 |
gobs_settings_dict=reader.read_gobs_settings_all() |
290 |
-config_profile = gobs_settings_dict['gobs_config'] |
291 |
+_config = gobs_settings_dict['gobs_config'] |
292 |
+_hostname =gobs_settings_dict['gobs_hostname'] |
293 |
|
294 |
def init_portage_settings(conn, config_id): |
295 |
# check config setup |
296 |
@@ -26,12 +27,13 @@ def init_portage_settings(conn, config_id): |
297 |
add_gobs_logs(conn, log_msg, "info", config_id) |
298 |
|
299 |
# Get default config from the configs table and default_config=1 |
300 |
- config_setup = get_default_config(conn) # HostConfigDir = table configs id |
301 |
- default_config_root = "/var/cache/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/" + config_setup + "/" |
302 |
+ hostname, config = get_default_config(conn) # HostConfigDir = table configs id |
303 |
+ host_config = hostname +"/" + config |
304 |
+ default_config_root = "/var/cache/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/" + host_config + "/" |
305 |
|
306 |
# Set config_root (PORTAGE_CONFIGROOT) to default_config_root |
307 |
mysettings = portage.config(config_root = default_config_root) |
308 |
- log_msg = "Setting default config to: %s" % (config_setup,) |
309 |
+ log_msg = "Setting default config to: %s" % (host_config,) |
310 |
add_gobs_logs(conn, log_msg, "info", config_id) |
311 |
return mysettings |
312 |
|
313 |
@@ -116,7 +118,7 @@ def update_db_main(conn): |
314 |
# Main |
315 |
|
316 |
# Logging |
317 |
- config_id = get_config_id(conn, config_profile) |
318 |
+ config_id = get_config_id(conn, _config, _hostname) |
319 |
log_msg = "Update db started." |
320 |
add_gobs_logs(conn, log_msg, "info", config_id) |