CORD-525 Fix bug in Service.get_service_instance_class

Change-Id: I62a1d0488bbf1dbff6b5c07a8029e53b9a66bc64
diff --git a/xos/xos_client/xosapi/convenience/service.py b/xos/xos_client/xosapi/convenience/service.py
index 4220f91..063e73c 100644
--- a/xos/xos_client/xosapi/convenience/service.py
+++ b/xos/xos_client/xosapi/convenience/service.py
@@ -46,7 +46,7 @@
         return self.leaf_model_name + "Instance"
 
     def get_service_instance_class(self):
-        return getattr(self.stub, self.get_service_instance_class_name)
+        return getattr(self.stub, self.get_service_instance_class_name())
 
 
 register_convenience_wrapper("Service", ORMWrapperService)
diff --git a/xos/xos_client/xosapi/fake_stub.py b/xos/xos_client/xosapi/fake_stub.py
index cc112e8..edccf21 100644
--- a/xos/xos_client/xosapi/fake_stub.py
+++ b/xos/xos_client/xosapi/fake_stub.py
@@ -184,6 +184,16 @@
 
     DESCRIPTOR = FakeDescriptor("Service")
 
+class ServiceInstance(FakeObj):
+    FIELDS = ( {"name": "id", "default": 0},
+               {"name": "owher", "default": 0, "fk_model": "Service"},
+               {"name": "leaf_model_name", "default": "ServiceInstance"})
+
+    def __init__(self, **kwargs):
+        return super(ServiceInstance, self).__init__(self.FIELDS, **kwargs)
+
+    DESCRIPTOR = FakeDescriptor("ServiceInstance")
+
 class ONOSService(FakeObj):
     FIELDS = ( {"name": "id", "default": 0},
                {"name": "name", "default": ""},
@@ -267,7 +277,7 @@
     def __init__(self):
         self.id_counter = 1
         self.objs = {}
-        for name in ["Controller", "Deployment", "Slice", "Site", "Tag", "Service", "ONOSService", "User", "Network", "NetworkTemplate", "ControllerNetwork", "NetworkSlice"]:
+        for name in ["Controller", "Deployment", "Slice", "Site", "Tag", "Service", "ServiceInstance", "ONOSService", "User", "Network", "NetworkTemplate", "ControllerNetwork", "NetworkSlice"]:
             setattr(self, "Get%s" % name, functools.partial(self.get, name))
             setattr(self, "List%s" % name, functools.partial(self.list, name))
             setattr(self, "Create%s" % name, functools.partial(self.create, name))
@@ -317,7 +327,7 @@
 class FakeSymDb(object):
     def __init__(self):
         self._classes = {}
-        for name in ["Controller", "Deployment", "Slice", "Site", "ID", "Tag", "Service", "ONOSService", "User", "Network", "NetworkTemplate", "ControllerNetwork", "NetworkSlice"]:
+        for name in ["Controller", "Deployment", "Slice", "Site", "ID", "Tag", "Service", "ServiceInstance", "ONOSService", "User", "Network", "NetworkTemplate", "ControllerNetwork", "NetworkSlice"]:
             self._classes["xos.%s" % name] = globals()[name]
 
 
diff --git a/xos/xos_client/xosapi/wrapper_test.py b/xos/xos_client/xosapi/wrapper_test.py
index 0b7703a..ef230b2 100644
--- a/xos/xos_client/xosapi/wrapper_test.py
+++ b/xos/xos_client/xosapi/wrapper_test.py
@@ -78,6 +78,42 @@
         self.assertEqual(len(cns), 1)
         self.assertEqual(cns[0].id, network_one.id)
 
+    def test_service_get_service_instance_class_name(self):
+        orm = self.make_coreapi()
+        deployment = orm.Deployment(name="test_deployment")
+        deployment.save()
+        controller = orm.Controller(name="test_controller", deployment_id = deployment.id)
+        controller.save()
+        site = orm.Site(name="testsite")
+        site.save()
+        user = orm.User(email="fake_" + ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10)), site_id=site.id)
+        user.save()
+        vsg_access_template = orm.NetworkTemplate(name="vsg_access", vtn_kind="VSG")
+        vsg_access_template.save()
+        service_one = orm.Service(name="service_one")
+        service_one.save()
+
+        self.assertEqual(service_one.get_service_instance_class_name(), "ServiceInstance")
+
+    def test_service_get_service_instance_class(self):
+        orm = self.make_coreapi()
+        deployment = orm.Deployment(name="test_deployment")
+        deployment.save()
+        controller = orm.Controller(name="test_controller", deployment_id=deployment.id)
+        controller.save()
+        site = orm.Site(name="testsite")
+        site.save()
+        user = orm.User(
+            email="fake_" + ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10)),
+            site_id=site.id)
+        user.save()
+        vsg_access_template = orm.NetworkTemplate(name="vsg_access", vtn_kind="VSG")
+        vsg_access_template.save()
+        service_one = orm.Service(name="service_one")
+        service_one.save()
+
+        self.assertEqual(service_one.get_service_instance_class().model_name, "ServiceInstance")
+
 if USE_FAKE_STUB:
     sys.path.append("..")