Revision c59f7e0f snf-cyclades-app/synnefo/logic/management/commands/reconcile-servers.py
b/snf-cyclades-app/synnefo/logic/management/commands/reconcile-servers.py | ||
---|---|---|
84 | 84 |
dest='fix_build_errors', default=False, |
85 | 85 |
help='Fix (remove) instances with build errors'), |
86 | 86 |
make_option('--fix-unsynced-nics', action='store_true', |
87 |
dest='fix_unsynced_nics', default=False,
|
|
88 |
help='Fix unsynced nics between DB and Ganeti'),
|
|
87 |
dest='fix_unsynced_nics', default=False, |
|
88 |
help='Fix unsynced nics between DB and Ganeti'), |
|
89 | 89 |
make_option('--fix-all', action='store_true', dest='fix_all', |
90 | 90 |
default=False, help='Enable all --fix-* arguments'), |
91 | 91 |
make_option('--backend-id', default=None, dest='backend-id', |
... | ... | |
160 | 160 |
if options['detect_build_errors']: |
161 | 161 |
build_errors = reconciliation.instances_with_build_errors(D, G) |
162 | 162 |
if len(build_errors) > 0: |
163 |
print >> sys.stderr, "The os for the following server IDs was "\ |
|
164 |
"not build successfully:" |
|
163 |
msg = "The os for the following server IDs was not build"\ |
|
164 |
" successfully:" |
|
165 |
print >> sys.stderr, msg |
|
165 | 166 |
print " " + "\n ".join( |
166 | 167 |
["%d" % x for x in build_errors]) |
167 | 168 |
elif verbosity == 2: |
... | ... | |
172 | 173 |
if not nics: |
173 | 174 |
print ''.ljust(18) + 'None' |
174 | 175 |
for index, info in nics.items(): |
175 |
print ''.ljust(18) + 'nic/' + str(index) + ': MAC: %s, IP: %s, Network: %s' % \ |
|
176 |
(info['mac'], info['ipv4'], info['network']) |
|
176 |
print ''.ljust(18) + 'nic/' + str(index) +\ |
|
177 |
': MAC: %s, IP: %s, Network: %s' % \ |
|
178 |
(info['mac'], info['ipv4'], info['network']) |
|
177 | 179 |
|
178 | 180 |
unsynced_nics = reconciliation.unsynced_nics(DBNics, GNics) |
179 | 181 |
if len(unsynced_nics) > 0: |
180 |
print >> sys.stderr, "The NICs of servers with the following IDs "\ |
|
181 |
"are unsynced:" |
|
182 |
msg = "The NICs of the servers with the following IDs are"\ |
|
183 |
" unsynced:" |
|
184 |
print >> sys.stderr, msg |
|
182 | 185 |
for id, nics in unsynced_nics.items(): |
183 | 186 |
print ''.ljust(2) + '%6d:' % id |
184 | 187 |
print ''.ljust(8) + '%8s:' % 'DB' |
... | ... | |
233 | 236 |
print >> sys.stderr, " ...done" |
234 | 237 |
|
235 | 238 |
if options['fix_build_errors'] and len(build_errors) > 0: |
236 |
print >> sys.stderr, "Setting the state of %d build-errors VMs:" % \
|
|
237 |
len(build_errors) |
|
239 |
print >> sys.stderr, "Setting the state of %d build-errors VMs:" %\ |
|
240 |
len(build_errors)
|
|
238 | 241 |
for id in build_errors: |
239 | 242 |
vm = VirtualMachine.objects.get(pk=id) |
240 | 243 |
event_time = datetime.datetime.now() |
241 |
backend_mod.process_op_status(vm=vm, etime=event_time, jobid=-0, |
|
244 |
backend_mod.process_op_status( |
|
245 |
vm=vm, etime=event_time, jobid=-0, |
|
242 | 246 |
opcode="OP_INSTANCE_CREATE", status='error', |
243 | 247 |
logmsg='Reconciliation: simulated Ganeti event') |
244 | 248 |
print >> sys.stderr, " ...done" |
245 | 249 |
|
246 | 250 |
if options['fix_unsynced_nics'] and len(unsynced_nics) > 0: |
247 | 251 |
print >> sys.stderr, "Setting the nics of %d out-of-sync VMs:" % \ |
248 |
len(unsynced_nics)
|
|
252 |
len(unsynced_nics) |
|
249 | 253 |
for id, nics in unsynced_nics.items(): |
250 | 254 |
vm = VirtualMachine.objects.get(pk=id) |
251 | 255 |
nics = nics[1] # Ganeti nics |
Also available in: Unified diff