Reading s_tag from the subscriber
Change-Id: Id0be35c520dfa0316885d84f7089ef045e58dc70
diff --git a/xos/synchronizer/steps/sync_volt_service_instance.py b/xos/synchronizer/steps/sync_volt_service_instance.py
index 9f005bd..10091cf 100644
--- a/xos/synchronizer/steps/sync_volt_service_instance.py
+++ b/xos/synchronizer/steps/sync_volt_service_instance.py
@@ -33,6 +33,10 @@
def sync_record(self, o):
+ if o.policy_code != 1:
+ raise DeferredException("Waiting for ModelPolicy to complete")
+
+
volt_service = VOLTService.objects.get(id=o.owner_id)
si = ServiceInstance.objects.get(id=o.id)
@@ -40,17 +44,23 @@
log.info("Synching OLTServiceInstance", object=str(o), **o.tologdict())
c_tag = si.get_westbound_service_instance_properties("c_tag")
+ s_tag = si.get_westbound_service_instance_properties("s_tag")
olt_device = o.onu_device.pon_port.olt_device
- # NOTE each ONU has only one UNI port!
- uni_port_id = o.onu_device.uni_ports.first().port_no
+ try:
+ # NOTE each ONU has only one UNI port!
+ uni_port_id = o.onu_device.uni_ports.first().port_no
+ except AttributeError:
+ # This is because the ONUDevice is set by model_policy
+ raise DeferredException("Waiting for ONUDevice %s " % olt_device.name)
if not olt_device.dp_id:
raise DeferredException("Waiting for OLTDevice %s to be synchronized" % olt_device.name)
log.debug("Adding subscriber with info",
c_tag = c_tag,
+ s_tag = s_tag,
uni_port_id = uni_port_id,
dp_id = olt_device.dp_id)
@@ -58,11 +68,18 @@
onos_voltha = Helpers.get_onos_voltha_info(volt_service)
onos_voltha_basic_auth = HTTPBasicAuth(onos_voltha['user'], onos_voltha['pass'])
- full_url = "%s:%d/onos/olt/oltapp/%s/%s/%s" % (onos_voltha['url'], onos_voltha['port'], olt_device.dp_id, uni_port_id, c_tag)
+ full_url = "%s:%d/onos/olt/oltapp/subscribers" % (onos_voltha['url'], onos_voltha['port'])
- log.info("Sending request to onos-voltha", url=full_url)
+ data = {
+ "deviceId" : olt_device.dp_id,
+ "port" : uni_port_id,
+ "sVlan" : s_tag,
+ "cVlan" : c_tag
+ }
- request = requests.post(full_url, auth=onos_voltha_basic_auth)
+ log.info("Sending request to onos-voltha", url=full_url, data=data)
+
+ request = requests.post(full_url, auth=onos_voltha_basic_auth, json=data)
if request.status_code != 200:
raise Exception("Failed to add subscriber in onos-voltha: %s" % request.text)