Checking if subscriber is enabled before checking for attributes
Change-Id: Ica96295f2db40eafe81142880e76461293ccf64e
diff --git a/xos/synchronizer/steps/sync_vsg_hw_service_instance.py b/xos/synchronizer/steps/sync_vsg_hw_service_instance.py
index 5e1b378..871d68b 100644
--- a/xos/synchronizer/steps/sync_vsg_hw_service_instance.py
+++ b/xos/synchronizer/steps/sync_vsg_hw_service_instance.py
@@ -70,6 +70,14 @@
dpid = si.get_westbound_service_instance_properties("switch_datapath_id")
port = si.get_westbound_service_instance_properties("switch_port")
+ subscriber_status = si.get_westbound_service_instance_properties("status")
+
+ if subscriber_status != "enabled":
+ if o.enacted:
+ return self.delete_record(o)
+ else:
+ raise DeferredException("Deferring synchronization for VSG-HW Service Instance with id %s as subscriber is not enabled" % o.id)
+
try:
if not mac_address:
raise ValueError("mac_address")
@@ -86,14 +94,6 @@
except ValueError as e:
raise Exception("Skipping synchronization for VSG-HW Service Instance with id %s as westbound value %s is not available" % (o.id, e.message))
- subscriber_status = si.get_westbound_service_instance_properties("status")
-
- if subscriber_status != "enabled":
- if o.enacted:
- return self.delete_record(o)
- else:
- raise DeferredException("Deferring synchronization for VSG-HW Service Instance with id %s as subscriber is not enabled" % o.id)
-
data = {
'hosts': {
mac_address + "/" + str(s_tag): {
diff --git a/xos/synchronizer/steps/test_sync_vsg_hw_service_instance.py b/xos/synchronizer/steps/test_sync_vsg_hw_service_instance.py
index 6e85741..e05f597 100644
--- a/xos/synchronizer/steps/test_sync_vsg_hw_service_instance.py
+++ b/xos/synchronizer/steps/test_sync_vsg_hw_service_instance.py
@@ -131,6 +131,8 @@
def wb_si_prop(prop):
# fake prop not present
+ if prop == "status":
+ return "enabled"
if prop != i:
return prop
return ""