CORD-2476 Migrate rcord profile to dynamic load

Change-Id: Iba149ccfb433d0be8918b617caca57e6e9a3f329
diff --git a/rcord.yml b/rcord.yml
index 6893e22..b4b6e78 100644
--- a/rcord.yml
+++ b/rcord.yml
@@ -54,6 +54,8 @@
 
 # paths defined in manifest/default.xml
 xos_services:
+  - name: rcord
+    path: orchestration/profiles/rcord
   - name: volt
     path: orchestration/xos_services/olt-service
     keypair: volt_rsa
@@ -89,8 +91,6 @@
 # service graph gui constraints
 xos_gui_service_graph_constraints: '[[null, "rcord"], [null, "volt"], ["addressmanager", "vsg"], [null, "vrouter"]]'
 
-profile_library: "rcord"
-
 # VTN network configuration
 management_network_cidr: 172.27.0.0/24
 management_network_ip: 172.27.0.1/24
diff --git a/xos/admin.py b/xos/admin.py
deleted file mode 100644
index 526fe61..0000000
--- a/xos/admin.py
+++ /dev/null
@@ -1,85 +0,0 @@
-
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-from django.contrib import admin
-
-#from services.volt.models import *
-from services.rcord.models import *
-from django import forms
-from django.utils.safestring import mark_safe
-from django.contrib.auth.admin import UserAdmin
-from django.contrib.admin.widgets import FilteredSelectMultiple
-from django.contrib.auth.forms import ReadOnlyPasswordHashField
-from django.contrib.auth.signals import user_logged_in
-from django.utils import timezone
-from django.contrib.contenttypes import generic
-from suit.widgets import LinkedSelect
-from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline, ServicePrivilegeInline
-from core.middleware import get_request
-
-from functools import update_wrapper
-from django.contrib.admin.views.main import ChangeList
-from django.core.urlresolvers import reverse
-from django.contrib.admin.utils import quote
-
-#class VOLTTenantInline(XOSTabularInline):
-#    model = VOLTTenant
-#    fields = ['provider_service', 'subscriber_root', 'service_specific_id']
-#    readonly_fields = ['provider_service', 'subscriber_root', 'service_specific_id']
-#    extra = 0
-#    max_num = 0
-#    suit_classes = 'suit-tab suit-tab-volttenants'
-#    fk_name = 'subscriber_root'
-#    verbose_name = 'subscribed tenant'
-#    verbose_name_plural = 'subscribed tenants'
-#
-#    @property
-#    def selflink_reverse_path(self):
-#        return "admin:cord_volttenant_change"
-
-class CordSubscriberRootForm(forms.ModelForm):
-    def __init__(self,*args,**kwargs):
-        super (CordSubscriberRootForm,self ).__init__(*args,**kwargs)
-        self.fields['kind'].widget.attrs['readonly'] = True
-        if (not self.instance) or (not self.instance.pk):
-            # default fields for an 'add' form
-            self.fields['kind'].initial = CORD_SUBSCRIBER_KIND
-
-    def save(self, commit=True):
-        return super(CordSubscriberRootForm, self).save(commit=commit)
-
-    class Meta:
-        model = CordSubscriberRoot
-        fields = '__all__'
-
-class CordSubscriberRootAdmin(ReadOnlyAwareAdmin):
-    list_display = ('backend_status_icon', 'id',  'name', )
-    list_display_links = ('backend_status_icon', 'id', 'name', )
-    fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'name', 'service_specific_id', # 'service_specific_attribute',
-                                     'url_filter_level', "uplink_speed", "downlink_speed", "status", "enable_uverse", "cdn_enable"],
-                          'classes':['suit-tab suit-tab-general']})]
-    readonly_fields = ('backend_status_text', 'service_specific_attribute',)
-    form = CordSubscriberRootForm
-
-    suit_form_tabs =(('general', 'Cord Subscriber Root Details'),
-#        ('volttenants','VOLT Tenancy'),
-#        ('tenantrootprivileges','Privileges')
-    )
-
-    def get_queryset(self, request):
-        return CordSubscriberRoot.get_tenant_objects_by_user(request.user)
-
-admin.site.register(CordSubscriberRoot, CordSubscriberRootAdmin)
diff --git a/xos/header.py b/xos/header.py
deleted file mode 120000
index 721b5c0..0000000
--- a/xos/header.py
+++ /dev/null
@@ -1 +0,0 @@
-attic/header.py
\ No newline at end of file
diff --git a/xos/rcord-onboard.yaml b/xos/rcord-onboard.yaml
index d71b90e..e4d8384 100644
--- a/xos/rcord-onboard.yaml
+++ b/xos/rcord-onboard.yaml
@@ -29,5 +29,3 @@
           base_url: file:///opt/cord/orchestration/profiles/rcord/xos/
           # The following will concatenate with base_url automatically, if
           # base_url is non-null.
-          xproto: ./
-          admin: admin.py
diff --git a/xos/synchronizer/Dockerfile.synchronizer b/xos/synchronizer/Dockerfile.synchronizer
index c89c468..fb7438d 100644
--- a/xos/synchronizer/Dockerfile.synchronizer
+++ b/xos/synchronizer/Dockerfile.synchronizer
@@ -52,4 +52,4 @@
       org.opencord.component.xos.vcs-url=$org_opencord_component_xos_vcs_url \
       org.opencord.component.xos.vcs-ref=$org_opencord_component_xos_vcs_ref
 
-CMD bash -c "sleep 86400"
+CMD bash -c "cd /opt/xos/synchronizers/rcord; ./run-from-api.sh"
diff --git a/xos/synchronizer/model-deps b/xos/synchronizer/model-deps
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/xos/synchronizer/model-deps
@@ -0,0 +1 @@
+{}
diff --git a/xos/attic/cordsubscriberroot_bottom.py b/xos/synchronizer/models/attic/cordsubscriberroot_bottom.py
similarity index 100%
rename from xos/attic/cordsubscriberroot_bottom.py
rename to xos/synchronizer/models/attic/cordsubscriberroot_bottom.py
diff --git a/xos/attic/cordsubscriberroot_model.py b/xos/synchronizer/models/attic/cordsubscriberroot_model.py
similarity index 100%
rename from xos/attic/cordsubscriberroot_model.py
rename to xos/synchronizer/models/attic/cordsubscriberroot_model.py
diff --git a/xos/attic/header.py b/xos/synchronizer/models/attic/header.py
similarity index 100%
rename from xos/attic/header.py
rename to xos/synchronizer/models/attic/header.py
diff --git a/xos/rcord.xproto b/xos/synchronizer/models/rcord.xproto
similarity index 100%
rename from xos/rcord.xproto
rename to xos/synchronizer/models/rcord.xproto
diff --git a/xos/synchronizer/rcord-synchronizer.py b/xos/synchronizer/rcord-synchronizer.py
new file mode 100644
index 0000000..4e11e6d
--- /dev/null
+++ b/xos/synchronizer/rcord-synchronizer.py
@@ -0,0 +1,32 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+#!/usr/bin/env python
+
+# This imports and runs ../../xos-observer.py
+
+import importlib
+import os
+import sys
+from xosconfig import Config
+
+config_file = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + '/rcord_config.yaml')
+Config.init(config_file, 'synchronizer-config-schema.yaml')
+
+observer_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),"../../synchronizers/new_base")
+sys.path.append(observer_path)
+mod = importlib.import_module("xos-synchronizer")
+mod.main()
diff --git a/xos/synchronizer/run-from-api.sh b/xos/synchronizer/run-from-api.sh
new file mode 100755
index 0000000..1d936f7
--- /dev/null
+++ b/xos/synchronizer/run-from-api.sh
@@ -0,0 +1,17 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+python rcord-synchronizer.py