SEBA-497 delayering, Makefile, and tox for fabric-crossconnect-synchronizer
Change-Id: Ibcf8fd06b9ad94d3f198887c18be7adfa4d5a954
diff --git a/xos/synchronizer/steps/sync_fabric_crossconnect_service_instance.py b/xos/synchronizer/steps/sync_fabric_crossconnect_service_instance.py
index 2481af8..5814c19 100644
--- a/xos/synchronizer/steps/sync_fabric_crossconnect_service_instance.py
+++ b/xos/synchronizer/steps/sync_fabric_crossconnect_service_instance.py
@@ -13,11 +13,13 @@
# limitations under the License.
from xossynchronizer.steps.syncstep import SyncStep, DeferredException
-from xossynchronizer.modelaccessor import model_accessor, FabricCrossconnectServiceInstance, ServiceInstance, BNGPortMapping
+from xossynchronizer.modelaccessor import model_accessor, \
+ FabricCrossconnectServiceInstance, \
+ ServiceInstance, \
+ BNGPortMapping
from xosconfig import Config
from multistructlog import create_logger
-import urllib
import requests
from requests.auth import HTTPBasicAuth
@@ -50,10 +52,12 @@
fabric_onos = fabric_onos[0]
return {
- 'url': SyncFabricCrossconnectServiceInstance.format_url("%s:%s" % (fabric_onos.rest_hostname, fabric_onos.rest_port)),
+ 'url': SyncFabricCrossconnectServiceInstance.format_url(
+ "%s:%s" %
+ (fabric_onos.rest_hostname,
+ fabric_onos.rest_port)),
'user': fabric_onos.rest_username,
- 'pass': fabric_onos.rest_password
- }
+ 'pass': fabric_onos.rest_password}
def make_handle(self, s_tag, switch_datapath_id):
# Generate a backend_handle that uniquely identifies the cross connect. ONOS doesn't provide us a handle, so
@@ -62,24 +66,24 @@
return "%d/%s" % (s_tag, switch_datapath_id)
def extract_handle(self, backend_handle):
- (s_tag, switch_datapath_id) = backend_handle.split("/",1)
+ (s_tag, switch_datapath_id) = backend_handle.split("/", 1)
s_tag = int(s_tag)
return (s_tag, switch_datapath_id)
def range_matches(self, value, pattern):
- value=int(value)
+ value = int(value)
for this_range in pattern.split(","):
this_range = this_range.strip()
if "-" in this_range:
(first, last) = this_range.split("-")
first = int(first.strip())
last = int(last.strip())
- if (value>=first) and (value<=last):
+ if (value >= first) and (value <= last):
return True
- elif this_range.lower()=="any":
+ elif this_range.lower() == "any":
return True
else:
- if (value==int(this_range)):
+ if (value == int(this_range)):
return True
return False
@@ -95,7 +99,7 @@
# See if there are any ranges or "any" that match
for bng_mapping in BNGPortMapping.objects.all():
if self.range_matches(s_tag, bng_mapping.s_tag):
- return bng_mapping
+ return bng_mapping
return None
@@ -107,7 +111,7 @@
onos = self.get_fabric_onos_info(o)
- si = ServiceInstance.objects.get(id=o.id)
+ ServiceInstance.objects.get(id=o.id)
if (o.s_tag is None):
raise Exception("Cannot sync FabricCrossconnectServiceInstance if s_tag is None on fcsi %s" % o.id)
@@ -116,16 +120,18 @@
raise Exception("Cannot sync FabricCrossconnectServiceInstance if source_port is None on fcsi %s" % o.id)
if (not o.switch_datapath_id):
- raise Exception("Cannot sync FabricCrossconnectServiceInstance if switch_datapath_id is unset on fcsi %s" % o.id)
+ raise Exception(
+ "Cannot sync FabricCrossconnectServiceInstance if switch_datapath_id is unset on fcsi %s" %
+ o.id)
- bng_mapping = self.find_bng(s_tag = o.s_tag)
+ bng_mapping = self.find_bng(s_tag=o.s_tag)
if not bng_mapping:
raise Exception("Unable to determine BNG port for s_tag %s" % o.s_tag)
east_port = bng_mapping.switch_port
- data = { "deviceId": o.switch_datapath_id,
- "vlanId": o.s_tag,
- "ports": [ int(o.source_port), int(east_port) ] }
+ data = {"deviceId": o.switch_datapath_id,
+ "vlanId": o.s_tag,
+ "ports": [int(o.source_port), int(east_port)]}
url = onos['url'] + '/onos/segmentrouting/xconnect'
@@ -155,8 +161,8 @@
# backend_handle has everything we need in it to delete this entry.
(s_tag, switch_datapath_id) = self.extract_handle(o.backend_handle)
- data = { "deviceId": switch_datapath_id,
- "vlanId": s_tag }
+ data = {"deviceId": switch_datapath_id,
+ "vlanId": s_tag}
url = onos['url'] + '/onos/segmentrouting/xconnect'