- new_xvu = row.external_ids.get("xs-vif-uuid", "")
- old_xvu = interfaces.get(row.name)
- if old_xvu != new_xvu:
- iface_id = get_iface_id(row.name, new_xvu)
- if iface_id and row.external_ids.get("iface-id") != iface_id:
- set_external_id(row, "iface-id", iface_id)
+ xvu = row.external_ids.get("xs-vif-uuid")
+ if xvu:
+ iface_id = (new_iface_ids.get(xvu)
+ or iface_ids.get(xvu)
+ or get_iface_id(row.name, xvu))
+ new_iface_ids[xvu] = iface_id
+ else:
+ # No xs-vif-uuid therefore no iface-id.
+ iface_id = None
+ set_external_id(row, "iface-id", iface_id)
+
+ # Map from xs-vm-uuid to vm-id.
+ xvmu = row.external_ids.get("xs-vm-uuid")
+ if xvmu:
+ vm_id = (new_vm_ids.get(xvmu)
+ or vm_ids.get(xvmu)
+ or get_vm_id(row.name, xvmu))
+ new_vm_ids[xvmu] = vm_id
+ else:
+ vm_id = None
+ set_external_id(row, "vm-id", vm_id)