Updated Fabric service to read ONOS info through ServiceDependencies

Change-Id: I138f01376590c4aa1ccce8a1975617e202e06ba2
diff --git a/Dockerfile.synchronizer b/Dockerfile.synchronizer
index 46ae876..51d3c6d 100644
--- a/Dockerfile.synchronizer
+++ b/Dockerfile.synchronizer
@@ -13,6 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+# docker build -t xosproject/fabric-synchronizer:candidate -f Dockerfile.synchronizer .
 
 # xosproject/fabric-synchronizer
 FROM xosproject/xos-synchronizer-base:candidate
diff --git a/xos/synchronizer/steps/sync_fabric_port.py b/xos/synchronizer/steps/sync_fabric_port.py
index 0615b0f..a88874b 100644
--- a/xos/synchronizer/steps/sync_fabric_port.py
+++ b/xos/synchronizer/steps/sync_fabric_port.py
@@ -21,30 +21,14 @@
 from xosconfig import Config
 from multistructlog import create_logger
 
+from helpers import Helpers
+
 log = create_logger(Config().get('logging'))
 
 class SyncFabricPort(SyncStep):
     provides = [SwitchPort]
     observes = SwitchPort
 
-    def get_fabric_onos_service_internal(self):
-        # There will be a ServiceInstanceLink from the FabricService to the Fabric ONOS App
-        fs = FabricService.objects.first()
-        for link in fs.subscribed_links.all():
-            if link.provider_service_instance:
-                # Cast from ServiceInstance to ONOSApp
-                service_instance = link.provider_service_instance.leaf_model
-                # Cast from Service to ONOSService
-                return service_instance.owner.leaf_model
-
-        return None
-
-    def get_fabric_onos_service(self):
-        fos = self.get_fabric_onos_service_internal()
-        if not fos:
-            raise Exception("Fabric ONOS service not found")
-        return fos
-
     def sync_record(self, model):
         interfaces = []
         for intf in model.interfaces.all():
@@ -65,7 +49,7 @@
           }
         }
 
-        onos = self.get_fabric_onos_service()
+        onos = Helpers.get_onos_fabric_service()
 
         url = 'http://%s:%s/onos/v1/network/configuration/' % (onos.rest_hostname, onos.rest_port)
         r = requests.post(url, json=data, auth=HTTPBasicAuth(onos.rest_username, onos.rest_password))
diff --git a/xos/synchronizer/steps/sync_fabric_switch.py b/xos/synchronizer/steps/sync_fabric_switch.py
index b29ec91..e2e47ce 100644
--- a/xos/synchronizer/steps/sync_fabric_switch.py
+++ b/xos/synchronizer/steps/sync_fabric_switch.py
@@ -21,30 +21,14 @@
 from xosconfig import Config
 from multistructlog import create_logger
 
+from helpers import Helpers
+
 log = create_logger(Config().get('logging'))
 
 class SyncFabricSwitch(SyncStep):
     provides = [Switch]
     observes = Switch
 
-    def get_fabric_onos_service_internal(self):
-        # There will be a ServiceInstanceLink from the FabricService to the Fabric ONOS App
-        fs = FabricService.objects.first()
-        for link in fs.subscribed_links.all():
-            if link.provider_service_instance:
-                # cast from ServiceInstance to ONOSApp
-                service_instance = link.provider_service_instance.leaf_model
-                # cast from Service to ONOSService
-                return service_instance.owner.leaf_model
-
-        return None
-
-    def get_fabric_onos_service(self):
-        fos = self.get_fabric_onos_service_internal()
-        if not fos:
-            raise Exception("Fabric ONOS service not found")
-        return fos
-
     def sync_record(self, model):
         # Send device info to onos-fabric netcfg
         data = {
@@ -66,7 +50,7 @@
           }
         }
 
-        onos = self.get_fabric_onos_service()
+        onos = Helpers.get_onos_fabric_service()
 
         url = 'http://%s:%s/onos/v1/network/configuration/' % (onos.rest_hostname, onos.rest_port)
         r = requests.post(url, json=data, auth=HTTPBasicAuth(onos.rest_username, onos.rest_password))