[CORD-3227] Support for dual-stack ips
Change-Id: Ia01abab7a9818743bce8dcd0f153ba3d9972cb3a
diff --git a/xos/synchronizer/steps/sync_vsg_hw_service_instance.py b/xos/synchronizer/steps/sync_vsg_hw_service_instance.py
index 871d68b..b30987f 100644
--- a/xos/synchronizer/steps/sync_vsg_hw_service_instance.py
+++ b/xos/synchronizer/steps/sync_vsg_hw_service_instance.py
@@ -21,6 +21,7 @@
import requests
from requests.auth import HTTPBasicAuth
+log = create_logger(Config().get('logging'))
class SyncVSGHWServiceInstance(SyncStep):
provides = [VSGHWServiceInstance]
@@ -56,15 +57,14 @@
}
def sync_record(self, o):
- self.log.info("Sync'ing VSG-HW Service Instance", service_instance=o)
-
+ log.info("Sync'ing VSG-HW Service Instance", service_instance=o)
onos = SyncVSGHWServiceInstance.get_fabric_onos_info(o)
si = ServiceInstance.objects.get(id=o.id)
mac_address = si.get_westbound_service_instance_properties("mac_address")
- ip = si.get_westbound_service_instance_properties("ip_address")
+ ips = si.get_westbound_service_instance_properties("ips")
s_tag = si.get_westbound_service_instance_properties("s_tag")
c_tag = si.get_westbound_service_instance_properties("c_tag")
dpid = si.get_westbound_service_instance_properties("switch_datapath_id")
@@ -81,8 +81,8 @@
try:
if not mac_address:
raise ValueError("mac_address")
- if not ip:
- raise ValueError("ip_address")
+ if len(ips.all()) == 0:
+ raise ValueError("ips")
if not s_tag:
raise ValueError("s_tag")
if not c_tag:
@@ -92,13 +92,14 @@
if not port:
raise ValueError("switch_port")
except ValueError as e:
+ log.info("Skipping synchronization for VSG-HW Service Instance with id %s as westbound value %s is not available" % (o.id, e.message))
raise Exception("Skipping synchronization for VSG-HW Service Instance with id %s as westbound value %s is not available" % (o.id, e.message))
data = {
'hosts': {
mac_address + "/" + str(s_tag): {
"basic": {
- "ips": [ip],
+ "ips": [ i.ip for i in ips.all() ],
"locations": ["%s/%s" % (dpid, port)],
"innerVlan": str(c_tag),
}
@@ -113,17 +114,17 @@
url = onos['url'] + '/onos/v1/network/configuration'
- self.log.info("Sending requests to ONOS", url=url, body=data)
+ log.info("Sending requests to ONOS", url=url, body=data)
r = requests.post(url, json=data, auth=HTTPBasicAuth(onos['user'], onos['pass']))
if r.status_code != 200:
raise Exception("Failed to terminate subscriber in ONOS: %s" % r.text)
- self.log.info("ONOS response", res=r.text)
+ log.info("ONOS response", res=r.text)
def delete_record(self, o):
- self.log.info("Deleting VSG-HW Service Instance", service_instance=o)
+ log.info("Deleting VSG-HW Service Instance", service_instance=o)
if o.enacted:
onos = SyncVSGHWServiceInstance.get_fabric_onos_info(o)
@@ -142,5 +143,5 @@
if r.status_code != 204:
raise Exception("Failed to remove subscriber termination in ONOS: %s" % r.text)
- self.log.info("ONOS response", res=r.text)
+ log.info("ONOS response", res=r.text)
pass
\ No newline at end of file