Revision bf5c82dc snf-cyclades-app/synnefo/logic/backend.py
b/snf-cyclades-app/synnefo/logic/backend.py | ||
---|---|---|
217 | 217 |
|
218 | 218 |
def start_action(vm, action): |
219 | 219 |
"""Update the state of a VM when a new action is initiated.""" |
220 |
log.debug("Applying action %s to VM %s", action, vm) |
|
221 |
|
|
220 | 222 |
if not action in [x[0] for x in VirtualMachine.ACTIONS]: |
221 | 223 |
raise VirtualMachine.InvalidActionError(action) |
222 | 224 |
|
... | ... | |
326 | 328 |
|
327 | 329 |
# Defined in settings.GANETI_CREATEINSTANCE_KWARGS |
328 | 330 |
# kw['hvparams'] = dict(serial_console=False) |
331 |
log.debug("Creating instance %s", kw) |
|
329 | 332 |
with pooled_rapi_client(vm) as client: |
330 | 333 |
return client.CreateInstance(**kw) |
331 | 334 |
|
... | ... | |
339 | 342 |
def reboot_instance(vm, reboot_type): |
340 | 343 |
assert reboot_type in ('soft', 'hard') |
341 | 344 |
with pooled_rapi_client(vm) as client: |
342 |
return client.RebootInstance(vm.backend_vm_id, reboot_type, dry_run=settings.TEST) |
|
345 |
return client.RebootInstance(vm.backend_vm_id, reboot_type, |
|
346 |
dry_run=settings.TEST) |
|
343 | 347 |
|
344 | 348 |
|
345 | 349 |
def startup_instance(vm): |
... | ... | |
366 | 370 |
# the instance's primary node, and is probably |
367 | 371 |
# hypervisor-specific. |
368 | 372 |
# |
373 |
log.debug("Getting console for vm %s", vm) |
|
374 |
|
|
369 | 375 |
console = {} |
370 | 376 |
console['kind'] = 'vnc' |
371 | 377 |
|
... | ... | |
390 | 396 |
if not backends: |
391 | 397 |
backends = Backend.objects.exclude(offline=True) |
392 | 398 |
|
399 |
log.debug("Creating network %s in backends %s", network, backends) |
|
400 |
|
|
393 | 401 |
for backend in backends: |
394 | 402 |
create_jobID = _create_network(network, backend) |
395 | 403 |
if connect: |
... | ... | |
424 | 432 |
|
425 | 433 |
def connect_network(network, backend, depend_job=None, group=None): |
426 | 434 |
"""Connect a network to nodegroups.""" |
435 |
log.debug("Connecting network %s to backend %s", network, backend) |
|
436 |
|
|
427 | 437 |
mode = "routed" if "ROUTED" in network.type else "bridged" |
428 | 438 |
|
429 | 439 |
with pooled_rapi_client(backend) as client: |
... | ... | |
440 | 450 |
if not backends: |
441 | 451 |
backends = Backend.objects.exclude(offline=True) |
442 | 452 |
|
453 |
log.debug("Deleting network %s from backends %s", network, backends) |
|
454 |
|
|
443 | 455 |
for backend in backends: |
444 | 456 |
disconnect_jobIDs = [] |
445 | 457 |
if disconnect: |
... | ... | |
453 | 465 |
|
454 | 466 |
|
455 | 467 |
def disconnect_network(network, backend, group=None): |
468 |
log.debug("Disconnecting network %s to backend %s", network, backend) |
|
469 |
|
|
456 | 470 |
with pooled_rapi_client(backend) as client: |
457 | 471 |
if group: |
458 | 472 |
return [client.DisconnectNetwork(network.backend_id, group)] |
... | ... | |
467 | 481 |
def connect_to_network(vm, network, address): |
468 | 482 |
nic = {'ip': address, 'network': network.backend_id} |
469 | 483 |
|
484 |
log.debug("Connecting vm %s to network %s(%s)", vm, network, address) |
|
485 |
|
|
470 | 486 |
with pooled_rapi_client(vm) as client: |
471 | 487 |
return client.ModifyInstance(vm.backend_vm_id, nics=[('add', nic)], |
472 | 488 |
hotplug=settings.GANETI_USE_HOTPLUG, |
... | ... | |
475 | 491 |
|
476 | 492 |
def disconnect_from_network(vm, nic): |
477 | 493 |
op = [('remove', nic.index, {})] |
494 |
|
|
495 |
log.debug("Removing nic of VM %s, with index %s", vm, str(nic.index)) |
|
496 |
|
|
478 | 497 |
with pooled_rapi_client(vm) as client: |
479 | 498 |
return client.ModifyInstance(vm.backend_vm_id, nics=op, |
480 | 499 |
hotplug=settings.GANETI_USE_HOTPLUG, |
... | ... | |
487 | 506 |
except KeyError: |
488 | 507 |
raise ValueError("Unsopported Firewall Profile: %s" % profile) |
489 | 508 |
|
509 |
log.debug("Setting tag of VM %s to %s", vm, profile) |
|
510 |
|
|
490 | 511 |
with pooled_rapi_client(vm) as client: |
491 | 512 |
# Delete all firewall tags |
492 | 513 |
for t in _firewall_tags.values(): |
Also available in: Unified diff