CORD-879 Eliminate ServiceControllerResource model

Change-Id: I37ef5ab195bf826f75027519ca2c5bcf183ea6ec
diff --git a/xos/core/models/__init__.py b/xos/core/models/__init__.py
index 095a37d..7bfdb58 100644
--- a/xos/core/models/__init__.py
+++ b/xos/core/models/__init__.py
@@ -4,7 +4,7 @@
 from .xosmodel import XOS, XOSVolume
 from .service import Service, Tenant, TenantWithContainer, ServiceDependency, ServicePrivilege, TenantRoot, TenantRootPrivilege, TenantRootRole, TenantPrivilege, TenantRole
 from .service import ServiceAttribute, TenantAttribute, ServiceRole, ServiceMonitoringAgentInfo
-from .service import ServiceController, ServiceControllerResource, LoadableModule, LoadableModuleResource, Library
+from .service import ServiceController, LoadableModule, LoadableModuleResource, Library
 from .service import XOSComponent, XOSComponentLink, XOSComponentVolume, XOSComponentVolumeContainer
 from .tag import Tag
 from .role import Role
diff --git a/xos/core/models/service.py b/xos/core/models/service.py
index 08a5834..cd28553 100644
--- a/xos/core/models/service.py
+++ b/xos/core/models/service.py
@@ -263,10 +263,6 @@
     no_build = models.BooleanField(help_text="Do not build the Synchronizer container", default=False)
     no_deploy = models.BooleanField(help_text="Do not add synchronizer container to onboarding-docker-compose", default=False)
 
-class ServiceControllerResource(LoadableModuleResource):
-    class Meta:
-        proxy = True
-
 class Service(PlCoreBase, AttributeMixin):
     # when subclassing a service, redefine KIND to describe the new service
     KIND = "generic"
diff --git a/xos/synchronizers/onboarding/model-deps b/xos/synchronizers/onboarding/model-deps
index e887a31..4bf692a 100644
--- a/xos/synchronizers/onboarding/model-deps
+++ b/xos/synchronizers/onboarding/model-deps
@@ -4,9 +4,9 @@
         "Library"
     ], 
     "ServiceController": [
-        "ServiceControllerResource"
+        "LoadableModuleResource"
     ],
     "Library": [
-        "ServiceControllerResource"
+        "LoadableModuleResource"
     ]
 }
diff --git a/xos/synchronizers/onboarding/steps/sync_servicecontrollerresource.py b/xos/synchronizers/onboarding/steps/sync_loadablemoduleresource.py
similarity index 81%
rename from xos/synchronizers/onboarding/steps/sync_servicecontrollerresource.py
rename to xos/synchronizers/onboarding/steps/sync_loadablemoduleresource.py
index b9a8dfb..46734a9 100644
--- a/xos/synchronizers/onboarding/steps/sync_servicecontrollerresource.py
+++ b/xos/synchronizers/onboarding/steps/sync_loadablemoduleresource.py
@@ -4,7 +4,7 @@
 from django.db.models import F, Q
 from xos.config import Config
 from synchronizers.base.syncstep import SyncStep
-from core.models import Service, ServiceController, ServiceControllerResource
+from core.models import Service, ServiceController, LoadableModuleResource
 from xos.logger import Logger, logging
 
 # xosbuilder will be in steps/..
@@ -15,9 +15,9 @@
 
 logger = Logger(level=logging.INFO)
 
-class SyncServiceControllerResource(SyncStep, XOSBuilder):
-    provides=[ServiceControllerResource]
-    observes=ServiceControllerResource
+class SyncLoadableModuleResource(SyncStep, XOSBuilder):
+    provides=[LoadableModuleResource]
+    observes=LoadableModuleResource
     requested_interval=0
 
     def __init__(self, **args):
@@ -25,7 +25,7 @@
         XOSBuilder.__init__(self)
 
     def sync_record(self, scr):
-        logger.info("Sync'ing ServiceControllerResource %s" % scr)
+        logger.info("Sync'ing LoadableModuleResource %s" % scr)
         self.download_resource(scr)
 
         # TODO: The following should be redone with watchers
@@ -51,6 +51,6 @@
         pass
 
     def fetch_pending(self, deleted=False):
-        pend = super(SyncServiceControllerResource, self).fetch_pending(deleted)
+        pend = super(SyncLoadableModuleResource, self).fetch_pending(deleted)
         return pend
 
diff --git a/xos/synchronizers/onboarding/xosbuilder.py b/xos/synchronizers/onboarding/xosbuilder.py
index 44bdb59..4b879aa 100644
--- a/xos/synchronizers/onboarding/xosbuilder.py
+++ b/xos/synchronizers/onboarding/xosbuilder.py
@@ -8,7 +8,7 @@
 import xmlrpclib
 
 from xos.config import Config
-from core.models import Service, ServiceController, ServiceControllerResource, LoadableModule, LoadableModuleResource, XOS, XOSComponent
+from core.models import Service, ServiceController, LoadableModule, LoadableModuleResource, XOS, XOSComponent
 from xos.logger import Logger, logging
 
 from django.utils import timezone
diff --git a/xos/tosca/resources/servicecontroller.py b/xos/tosca/resources/servicecontroller.py
index d2bd10d..dbbd5a1 100644
--- a/xos/tosca/resources/servicecontroller.py
+++ b/xos/tosca/resources/servicecontroller.py
@@ -1,4 +1,4 @@
-from core.models import ServiceController, ServiceControllerResource, LoadableModule, LoadableModuleResource
+from core.models import ServiceController, LoadableModule, LoadableModuleResource
 
 from loadablemodule import XOSLoadableModule
 
diff --git a/xos/tosca/resources/servicecontrollerresource.py b/xos/tosca/resources/servicecontrollerresource.py
index ef37b19..49ab5a7 100644
--- a/xos/tosca/resources/servicecontrollerresource.py
+++ b/xos/tosca/resources/servicecontrollerresource.py
@@ -4,12 +4,12 @@
 import tempfile
 
 from toscaparser.tosca_template import ToscaTemplate
-from core.models import ServiceControllerResource, ServiceController, LoadableModuleResource, LoadableModule
+from core.models import LoadableModuleResource, ServiceController, LoadableModule
 from xosresource import XOSResource
 
 class XOSServiceControllerResource(XOSResource):
     provides = "tosca.nodes.ServiceControllerResource"
-    xos_model = ServiceControllerResource
+    xos_model = LoadableModuleResource
     copyin_props = ["kind", "format", "url"]
 
     def get_xos_args(self, throw_exception=True):
diff --git a/xos/xos/xosapi.py b/xos/xos/xosapi.py
index 594768a..d43d45f 100644
--- a/xos/xos/xosapi.py
+++ b/xos/xos/xosapi.py
@@ -39,8 +39,8 @@
     # legacy - deprecated
         url(r'^xos/$', api_root),
     
-        url(r'xos/servicecontrollerresources/$', ServiceControllerResourceList.as_view(), name='servicecontrollerresource-list-legacy'),
-        url(r'xos/servicecontrollerresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceControllerResourceDetail.as_view(), name ='servicecontrollerresource-detail-legacy'),
+        url(r'xos/xoscomponentvolumecontainers/$', XOSComponentVolumeContainerList.as_view(), name='xoscomponentvolumecontainer-list-legacy'),
+        url(r'xos/xoscomponentvolumecontainers/(?P<pk>[a-zA-Z0-9\-]+)/$', XOSComponentVolumeContainerDetail.as_view(), name ='xoscomponentvolumecontainer-detail-legacy'),
     
         url(r'xos/xosvolumes/$', XOSVolumeList.as_view(), name='xosvolume-list-legacy'),
         url(r'xos/xosvolumes/(?P<pk>[a-zA-Z0-9\-]+)/$', XOSVolumeDetail.as_view(), name ='xosvolume-detail-legacy'),
@@ -258,9 +258,6 @@
         url(r'xos/tenantrootprivileges/$', TenantRootPrivilegeList.as_view(), name='tenantrootprivilege-list-legacy'),
         url(r'xos/tenantrootprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', TenantRootPrivilegeDetail.as_view(), name ='tenantrootprivilege-detail-legacy'),
     
-        url(r'xos/xoscomponentvolumecontainers/$', XOSComponentVolumeContainerList.as_view(), name='xoscomponentvolumecontainer-list-legacy'),
-        url(r'xos/xoscomponentvolumecontainers/(?P<pk>[a-zA-Z0-9\-]+)/$', XOSComponentVolumeContainerDetail.as_view(), name ='xoscomponentvolumecontainer-detail-legacy'),
-    
         url(r'xos/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list-legacy'),
         url(r'xos/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail-legacy'),
     
@@ -286,8 +283,8 @@
     # new - use these instead of the above
         url(r'^api/core/$', api_root),
     
-        url(r'api/core/servicecontrollerresources/$', ServiceControllerResourceList.as_view(), name='servicecontrollerresource-list'),
-        url(r'api/core/servicecontrollerresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceControllerResourceDetail.as_view(), name ='servicecontrollerresource-detail'),
+        url(r'api/core/xoscomponentvolumecontainers/$', XOSComponentVolumeContainerList.as_view(), name='xoscomponentvolumecontainer-list'),
+        url(r'api/core/xoscomponentvolumecontainers/(?P<pk>[a-zA-Z0-9\-]+)/$', XOSComponentVolumeContainerDetail.as_view(), name ='xoscomponentvolumecontainer-detail'),
     
         url(r'api/core/xosvolumes/$', XOSVolumeList.as_view(), name='xosvolume-list'),
         url(r'api/core/xosvolumes/(?P<pk>[a-zA-Z0-9\-]+)/$', XOSVolumeDetail.as_view(), name ='xosvolume-detail'),
@@ -505,9 +502,6 @@
         url(r'api/core/tenantrootprivileges/$', TenantRootPrivilegeList.as_view(), name='tenantrootprivilege-list'),
         url(r'api/core/tenantrootprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', TenantRootPrivilegeDetail.as_view(), name ='tenantrootprivilege-detail'),
     
-        url(r'api/core/xoscomponentvolumecontainers/$', XOSComponentVolumeContainerList.as_view(), name='xoscomponentvolumecontainer-list'),
-        url(r'api/core/xoscomponentvolumecontainers/(?P<pk>[a-zA-Z0-9\-]+)/$', XOSComponentVolumeContainerDetail.as_view(), name ='xoscomponentvolumecontainer-detail'),
-    
         url(r'api/core/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'),
         url(r'api/core/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'),
     
@@ -534,7 +528,7 @@
 @api_view(['GET'])
 def api_root_legacy(request, format=None):
     return Response({
-        'servicecontrollerresources': reverse('servicecontrollerresource-list-legacy', request=request, format=format),
+        'xoscomponentvolumecontainers': reverse('xoscomponentvolumecontainer-list-legacy', request=request, format=format),
         'xosvolumes': reverse('xosvolume-list-legacy', request=request, format=format),
         'serviceattributes': reverse('serviceattribute-list-legacy', request=request, format=format),
         'controllerimageses': reverse('controllerimages-list-legacy', request=request, format=format),
@@ -607,7 +601,6 @@
         'deploymentroles': reverse('deploymentrole-list-legacy', request=request, format=format),
         'projects': reverse('project-list-legacy', request=request, format=format),
         'tenantrootprivileges': reverse('tenantrootprivilege-list-legacy', request=request, format=format),
-        'xoscomponentvolumecontainers': reverse('xoscomponentvolumecontainer-list-legacy', request=request, format=format),
         'slicecredentials': reverse('slicecredential-list-legacy', request=request, format=format),
         'slicetags': reverse('slicetag-list-legacy', request=request, format=format),
         'networktemplates': reverse('networktemplate-list-legacy', request=request, format=format),
@@ -621,7 +614,7 @@
 @api_view(['GET'])
 def api_root(request, format=None):
     return Response({
-        'servicecontrollerresources': reverse('servicecontrollerresource-list', request=request, format=format),
+        'xoscomponentvolumecontainers': reverse('xoscomponentvolumecontainer-list', request=request, format=format),
         'xosvolumes': reverse('xosvolume-list', request=request, format=format),
         'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
         'controllerimageses': reverse('controllerimages-list', request=request, format=format),
@@ -694,7 +687,6 @@
         'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
         'projects': reverse('project-list', request=request, format=format),
         'tenantrootprivileges': reverse('tenantrootprivilege-list', request=request, format=format),
-        'xoscomponentvolumecontainers': reverse('xoscomponentvolumecontainer-list', request=request, format=format),
         'slicecredentials': reverse('slicecredential-list', request=request, format=format),
         'slicetags': reverse('slicetag-list', request=request, format=format),
         'networktemplates': reverse('networktemplate-list', request=request, format=format),
@@ -762,7 +754,7 @@
 
 
 
-class ServiceControllerResourceSerializer(serializers.HyperlinkedModelSerializer):
+class XOSComponentVolumeContainerSerializer(serializers.HyperlinkedModelSerializer):
     id = IdField()
     
     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
@@ -775,10 +767,10 @@
         except:
             return None
     class Meta:
-        model = ServiceControllerResource
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_need_delete','backend_need_reap','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','loadable_module','name','subdirectory','kind','format','url',)
+        model = XOSComponentVolumeContainer
+        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_need_delete','backend_need_reap','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','component','name','container',)
 
-class ServiceControllerResourceIdSerializer(XOSModelSerializer):
+class XOSComponentVolumeContainerIdSerializer(XOSModelSerializer):
     id = IdField()
     
     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
@@ -791,8 +783,8 @@
         except:
             return None
     class Meta:
-        model = ServiceControllerResource
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_need_delete','backend_need_reap','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','loadable_module','name','subdirectory','kind','format','url',)
+        model = XOSComponentVolumeContainer
+        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_need_delete','backend_need_reap','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','component','name','container',)
 
 
 
@@ -3477,41 +3469,6 @@
 
 
 
-class XOSComponentVolumeContainerSerializer(serializers.HyperlinkedModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = XOSComponentVolumeContainer
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_need_delete','backend_need_reap','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','component','name','container',)
-
-class XOSComponentVolumeContainerIdSerializer(XOSModelSerializer):
-    id = IdField()
-    
-    humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
-    validators = serializers.SerializerMethodField("getValidators")
-    def getHumanReadableName(self, obj):
-        return str(obj)
-    def getValidators(self, obj):
-        try:
-            return obj.getValidators()
-        except:
-            return None
-    class Meta:
-        model = XOSComponentVolumeContainer
-        fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_need_delete','backend_need_reap','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','component','name','container',)
-
-
-
-
 class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
     id = IdField()
     
@@ -3775,7 +3732,7 @@
 
 serializerLookUp = {
 
-                 ServiceControllerResource: ServiceControllerResourceSerializer,
+                 XOSComponentVolumeContainer: XOSComponentVolumeContainerSerializer,
 
                  XOSVolume: XOSVolumeSerializer,
 
@@ -3921,8 +3878,6 @@
 
                  TenantRootPrivilege: TenantRootPrivilegeSerializer,
 
-                 XOSComponentVolumeContainer: XOSComponentVolumeContainerSerializer,
-
                  SliceCredential: SliceCredentialSerializer,
 
                  SliceTag: SliceTagSerializer,
@@ -3943,12 +3898,12 @@
 # Based on core/views/*.py
 
 
-class ServiceControllerResourceList(XOSListCreateAPIView):
-    queryset = ServiceControllerResource.objects.select_related().all()
-    serializer_class = ServiceControllerResourceSerializer
-    id_serializer_class = ServiceControllerResourceIdSerializer
+class XOSComponentVolumeContainerList(XOSListCreateAPIView):
+    queryset = XOSComponentVolumeContainer.objects.select_related().all()
+    serializer_class = XOSComponentVolumeContainerSerializer
+    id_serializer_class = XOSComponentVolumeContainerIdSerializer
     filter_backends = (filters.DjangoFilterBackend,)
-    filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_need_delete','backend_need_reap','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','loadable_module','name','subdirectory','kind','format','url',)
+    filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_need_delete','backend_need_reap','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','component','name','container',)
 
     def get_serializer_class(self):
         no_hyperlinks=False
@@ -3962,13 +3917,13 @@
     def get_queryset(self):
         if (not self.request.user.is_authenticated()):
             raise XOSNotAuthenticated()
-        return ServiceControllerResource.select_by_user(self.request.user)
+        return XOSComponentVolumeContainer.select_by_user(self.request.user)
 
 
-class ServiceControllerResourceDetail(XOSRetrieveUpdateDestroyAPIView):
-    queryset = ServiceControllerResource.objects.select_related().all()
-    serializer_class = ServiceControllerResourceSerializer
-    id_serializer_class = ServiceControllerResourceIdSerializer
+class XOSComponentVolumeContainerDetail(XOSRetrieveUpdateDestroyAPIView):
+    queryset = XOSComponentVolumeContainer.objects.select_related().all()
+    serializer_class = XOSComponentVolumeContainerSerializer
+    id_serializer_class = XOSComponentVolumeContainerIdSerializer
 
     def get_serializer_class(self):
         no_hyperlinks=False
@@ -3982,7 +3937,7 @@
     def get_queryset(self):
         if (not self.request.user.is_authenticated()):
             raise XOSNotAuthenticated()
-        return ServiceControllerResource.select_by_user(self.request.user)
+        return XOSComponentVolumeContainer.select_by_user(self.request.user)
 
     # update() is handled by XOSRetrieveUpdateDestroyAPIView
 
@@ -7374,53 +7329,6 @@
 
 
 
-class XOSComponentVolumeContainerList(XOSListCreateAPIView):
-    queryset = XOSComponentVolumeContainer.objects.select_related().all()
-    serializer_class = XOSComponentVolumeContainerSerializer
-    id_serializer_class = XOSComponentVolumeContainerIdSerializer
-    filter_backends = (filters.DjangoFilterBackend,)
-    filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_need_delete','backend_need_reap','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','component','name','container',)
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return XOSComponentVolumeContainer.select_by_user(self.request.user)
-
-
-class XOSComponentVolumeContainerDetail(XOSRetrieveUpdateDestroyAPIView):
-    queryset = XOSComponentVolumeContainer.objects.select_related().all()
-    serializer_class = XOSComponentVolumeContainerSerializer
-    id_serializer_class = XOSComponentVolumeContainerIdSerializer
-
-    def get_serializer_class(self):
-        no_hyperlinks=False
-        if hasattr(self.request,"query_params"):
-            no_hyperlinks = self.request.query_params.get('no_hyperlinks', False)
-        if (no_hyperlinks):
-            return self.id_serializer_class
-        else:
-            return self.serializer_class
-
-    def get_queryset(self):
-        if (not self.request.user.is_authenticated()):
-            raise XOSNotAuthenticated()
-        return XOSComponentVolumeContainer.select_by_user(self.request.user)
-
-    # update() is handled by XOSRetrieveUpdateDestroyAPIView
-
-    # destroy() is handled by XOSRetrieveUpdateDestroyAPIView
-
-
-
 class SliceCredentialList(XOSListCreateAPIView):
     queryset = SliceCredential.objects.select_related().all()
     serializer_class = SliceCredentialSerializer