Commit 8fd1214e authored by Christos Stavrakakis's avatar Christos Stavrakakis

cyclades: Handle VMs connected to unknown networks

Catch InvalidBackendIdError when reconciling instances that are
connected to networks that do not belong to Synnefo.
parent 02082ac1
......@@ -311,7 +311,12 @@ def update_vm_nics(vm, nics, etime=None):
@rtype: List of dictionaries
"""
ganeti_nics = parse_instance_nics(nics)
try:
ganeti_nics = parse_instance_nics(nics)
except Network.InvalidBackendIdError as e:
log.warning("Server %s is connected to unknown network %s"
" Cannot reconcile server." % (vm.id, str(e)))
return []
db_nics = dict([(nic.id, nic) for nic in vm.nics.select_related("network")
.prefetch_related("ips")])
......
......@@ -284,7 +284,12 @@ class BackendReconciler(object):
created__lte=building_time) \
.order_by("id")
gnt_nics = gnt_server["nics"]
gnt_nics_parsed = backend_mod.parse_instance_nics(gnt_nics)
try:
gnt_nics_parsed = backend_mod.parse_instance_nics(gnt_nics)
except Network.InvalidBackendIdError as e:
self.log.warning("Server %s is connected to unknown network %s"
" Cannot reconcile server." % (server_id, str(e)))
return
nics_changed = len(db_nics) != len(gnt_nics)
for db_nic, gnt_nic in zip(db_nics, sorted(gnt_nics_parsed.items())):
gnt_nic_id, gnt_nic = gnt_nic
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment