Merge branch 'master' of github.com:open-cloud/xos
diff --git a/xos/core/models/service.py b/xos/core/models/service.py
index 7cf2a6b..b5ba737 100644
--- a/xos/core/models/service.py
+++ b/xos/core/models/service.py
@@ -174,9 +174,9 @@
             for ns in slice.networkslices.all():
                 if not ns.network:
                     continue
-                if ns.network.template.access in ["direct", "indirect"]:
-                    # skip access networks; we want to use the private network
-                    continue
+#                if ns.network.template.access in ["direct", "indirect"]:
+#                    # skip access networks; we want to use the private network
+#                    continue
                 if ns.network.name in ["wan_network", "lan_network"]:
                     # we don't want to attach to the vCPE's lan or wan network
                     # we only want to attach to its private network
diff --git a/xos/observers/vtn/steps/sync_tenant.py b/xos/observers/vtn/steps/sync_tenant.py
index 7610177..8645159 100644
--- a/xos/observers/vtn/steps/sync_tenant.py
+++ b/xos/observers/vtn/steps/sync_tenant.py
@@ -10,6 +10,7 @@
 from core.models.service import COARSE_KIND
 from services.cord.models import Tenant
 from util.logger import Logger, logging
+from requests.auth import HTTPBasicAuth
 
 # hpclibrary will be in steps/..
 parentdir = os.path.join(os.path.dirname(__file__),"..")
@@ -28,6 +29,34 @@
     def __init__(self, **args):
         SyncStep.__init__(self, **args)
 
+    def get_vtn_onos_service(self):
+#        vtn_tenant = Tenant.objects.filter(name="VTN_ONOS_app")   # XXX fixme - hardcoded
+#        if not vtn_tenant:
+#            raise "No VTN Onos App found"
+#        vtn_tenant = vtn_tenant[0]
+#
+#        vtn_service = vtn_tenant.provider_service
+        vtn_service = Service.objects.filter(name="service_ONOS_VTN")  # XXX fixme - harcoded
+        if not vtn_service:
+            raise "No VTN Onos Service"
+
+        return vtn_service[0]
+
+    def get_vtn_addr(self):
+        vtn_service = self.get_vtn_onos_service()
+
+        if not vtn_service.slices.exists():
+            raise "VTN Service has no slices"
+
+        vtn_slice = vtn_service.slices.all()[0]
+
+        if not vtn_slice.instances.exists():
+            raise "VTN Slice has no instances"
+
+        vtn_instance = vtn_slice.instances.all()[0]
+
+        return vtn_instance.node.name
+
     def call(self, **args):
         global glo_saved_vtn_maps
 
@@ -43,14 +72,23 @@
 
         for vtn_map in vtn_maps:
             if not (vtn_map in glo_saved_vtn_maps):
-               print "XXX", vtn_map, glo_saved_vtn_maps
-               # call vtn rest api to add map
-               print "POST /onos/cordvtn/service-dependency/%s/%s" % (vtn_map[0], vtn_map[1])
+                # call vtn rest api to add map
+                url = "http://" + self.get_vtn_addr() + ":8181/onos/cordvtn/service-dependency/%s/%s" % (vtn_map[0], vtn_map[1])
+
+                print "POST %s" % url
+                r = requests.post(url, auth=HTTPBasicAuth('karaf', 'karaf') )    # XXX fixme - hardcoded auth
+                if (r.status_code != 200):
+                    raise Exception("Received error from vtn service (%d)" % r.status_code)
 
         for vtn_map in glo_saved_vtn_maps:
             if not vtn_map in vtn_maps:
                 # call vtn rest api to delete map
-                print "DELETE /onos/cordvtn/service-dependency/%s" % (vtn_map[0],)
+                url = "http://" + self.get_vtn_addr() + ":8181/onos/cordvtn/service-dependency/%s" % (vtn_map[0],)
+
+                print "DELETE %s" % url
+                r = requests.delete(url, auth=HTTPBasicAuth('karaf', 'karaf') )    # XXX fixme - hardcoded auth
+                if (r.status_code != 200):
+                    raise Exception("Received error from vtn service (%d)" % r.status_code)
 
         glo_saved_vtn_maps = vtn_maps
         # TODO: save this