get wan_vm_ip/mac from vrouter tenant
diff --git a/xos/services/cord/models.py b/xos/services/cord/models.py
index 6e7a917..22bc391 100644
--- a/xos/services/cord/models.py
+++ b/xos/services/cord/models.py
@@ -611,6 +611,30 @@
return self.ip_to_mac(self.wan_container_ip)
@property
+ def wan_vm_ip(self):
+ tags = Tag.select_by_content_object(self.instance).filter(name="vm_vrouter_tenant")
+ if tags:
+ tenant = VRouterTenant.objects.get(id=tags[0].value)
+ return tenant.public_ip
+ else:
+ if CORD_USE_VTN:
+ raise Exception("no vm_vrouter_tenant tag for instance %s" % o.instance)
+ else:
+ return ""
+
+ @property
+ def wan_vm_mac(self):
+ tags = Tag.select_by_content_object(self.instance).filter(name="vm_vrouter_tenant")
+ if tags:
+ tenant = VRouterTenant.objects.get(id=tags[0].value)
+ return tenant.public_mac
+ else:
+ if CORD_USE_VTN:
+ raise Exception("no vm_vrouter_tenant tag for instance %s" % o.instance)
+ else:
+ return ""
+
+ @property
def private_ip(self):
return self.addresses.get("private", (None, None) )[0]
diff --git a/xos/synchronizers/vcpe/steps/sync_vcpetenant.py b/xos/synchronizers/vcpe/steps/sync_vcpetenant.py
index d52f075..c28b3c1 100644
--- a/xos/synchronizers/vcpe/steps/sync_vcpetenant.py
+++ b/xos/synchronizers/vcpe/steps/sync_vcpetenant.py
@@ -153,18 +153,8 @@
if mac:
safe_macs.append(mac)
- wan_vm_ip=""
- wan_vm_mac=""
- tags = Tag.select_by_content_object(o.instance).filter(name="vm_wan_addr")
- if tags:
- parts=tags[0].value.split(",")
- if len(parts)!=3:
- raise Exception("vm_wan_addr tag is malformed: %s" % value)
- wan_vm_ip = parts[1]
- wan_vm_mac = parts[2]
- else:
- if CORD_USE_VTN:
- raise Exception("no vm_wan_addr tag for instance %s" % o.instance)
+ wan_vm_ip=o.wan_vm_ip
+ wan_vm_mac=o.wan_vm_mac
fields = {"vlan_ids": vlan_ids, # XXX remove this
"s_tags": s_tags,