[CORD-3004] Refactor, improve XOS OLT service
Change-Id: I33aedccacde0737b741a113cf3455f90a5902394
diff --git a/xos/synchronizer/steps/sync_volt_service_instance.py b/xos/synchronizer/steps/sync_volt_service_instance.py
index dccac6a..eef6f7e 100644
--- a/xos/synchronizer/steps/sync_volt_service_instance.py
+++ b/xos/synchronizer/steps/sync_volt_service_instance.py
@@ -35,7 +35,7 @@
si = ServiceInstance.objects.get(id=o.id)
- log.info("sync'ing OLTServiceInstance", object=str(o), **o.tologdict())
+ log.info("Synching OLTServiceInstance", object=str(o), **o.tologdict())
c_tag = si.get_westbound_service_instance_properties("c_tag")
uni_port_id = si.get_westbound_service_instance_properties("uni_port_id")
@@ -48,21 +48,21 @@
raise DeferredException("Waiting for OLTDevice %s to be synchronized" % olt_device.name)
log.debug("Adding subscriber with info",
- c_tag=c_tag,
- uni_port_id=uni_port_id,
- dp_id=olt_device.dp_id)
+ c_tag = c_tag,
+ uni_port_id = uni_port_id,
+ dp_id = olt_device.dp_id)
- # sending request to ONOS
+ # Send request to ONOS
+ onos_voltha = Helpers.get_onos_voltha_info(volt_service)
+ onos_voltha_basic_auth = HTTPBasicAuth(onos_voltha['user'], onos_voltha['pass'])
- onos = Helpers.get_p_onos_info(volt_service)
+ 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)
- url = onos['url'] + "/onos/olt/oltapp/%s/%s/%s" % (olt_device.dp_id, uni_port_id, c_tag)
+ log.info("Sending request to onos-voltha", url=full_url)
- log.info("sending request to P_ONOS", url=url)
+ request = requests.post(full_url, auth=onos_voltha_basic_auth)
- r = requests.post(url,auth=HTTPBasicAuth(onos['user'], onos['pass']))
+ if request.status_code != 200:
+ raise Exception("Failed to add subscriber in onos-voltha: %s" % request.text)
- if r.status_code != 200:
- raise Exception("Failed to add subscriber in P_ONOS: %s" % r.text)
-
- log.info("P_ONOS response", res=r.text)
\ No newline at end of file
+ log.info("onos voltha response", response=request.text)
\ No newline at end of file