refactor vBBU cord-3.0

Change-Id: I843cd7954862a38d05c918de101fb8635d15829c
diff --git a/xos/admin.py b/xos/admin.py
deleted file mode 100644
index 3a02eeb..0000000
--- a/xos/admin.py
+++ /dev/null
@@ -1,144 +0,0 @@
-
-from core.admin import ReadOnlyAwareAdmin, SliceInline
-from core.middleware import get_request
-# from core.models import User
-from django import forms
-from django.contrib import admin
-# from services.vbbu.models import *
-from synchronizers.new_base.modelaccessor import *
-
-# The class to provide an admin interface on the web for the service.
-# We do only configuration here and don't change any logic because the logic
-# is taken care of for us by ReadOnlyAwareAdmin
-class VBBUServiceAdmin(ReadOnlyAwareAdmin):
-    # We must set the model so that the admin knows what fields to use
-    model = VBBUService
-    verbose_name = "VBBU Service"
-    verbose_name_plural = "VBBU Services"
-
-    # Setting list_display creates columns on the admin page, each value here
-    # is a column, the column is populated for every instance of the model.
-    list_display = ("backend_status_icon", "name", "enabled")
-
-    # Used to indicate which values in the columns of the admin form are links.
-    list_display_links = ('backend_status_icon', 'name', )
-
-    # Denotes the sections of the form, the fields in the section, and the
-    # CSS classes used to style them. We represent this as a set of tuples, each
-    # tuple as a name (or None) and a set of fields and classes.
-    # Here the first section does not have a name so we use none. That first
-    # section has several fields indicated in the 'fields' attribute, and styled
-    # by the classes indicated in the 'classes' attribute. The classes given
-    # here are important for rendering the tabs on the form. To give the tabs
-    # we must assign the classes suit-tab and suit-tab-<name> where
-    # where <name> will be used later.
-    fieldsets = [(None, {'fields': ['backend_status_text', 'name', 'enabled',
-                                    'versionNumber', 'description', "view_url"],
-                         'classes':['suit-tab suit-tab-general']})]
-
-    # Denotes the fields that are readonly and cannot be changed.
-    readonly_fields = ('backend_status_text', )
-
-    # Inlines are used to denote other models that can be edited on the same
-    # form as this one. In this case the service form also allows changes
-    # to slices.
-    inlines = [SliceInline]
-
-    extracontext_registered_admins = True
-
-    # Denotes the fields that can be changed by an admin but not be all users
-    user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
-
-    # Associates fieldsets from this form and from the inlines.
-    # The format here are tuples, of (<name>, tab title). <name> comes from the
-    # <name> in the fieldsets.
-    suit_form_tabs = (('general', 'MCORD Service Details'),
-                      ('administration', 'Components'),
-                      ('slices', 'Slices'),)
-
-    # Used to include a template for a tab. Here we include the
-    # helloworldserviceadmin template in the top position for the administration
-    # tab.
-    suit_form_includes = (('admin.html',
-                           'top',
-                           'administration'),)
-
-    # Used to get the objects for this model that are associated with the
-    # requesting user.
-    def queryset(self, request):
-        return VBBUService.get_service_objects_by_user(request.user)
-
-# Class to represent the form to add and edit tenants.
-# We need to define this instead of just using an admin like we did for the
-# service because tenants vary more than services and there isn't a common form.
-# This allows us to change the python behavior for the admin form to save extra
-# fields and control defaults.
-class VBBUTenantForm(forms.ModelForm):
-    # Defines a field for the creator of this service. It is a dropdown which
-    # is populated with all of the users.
-    creator = forms.ModelChoiceField(queryset=User.objects.all())
-    # Defines a text field for the display message, it is not required.
-    display_message = forms.CharField(required=False)
-
-    def __init__(self, *args, **kwargs):
-        super(VBBUTenantForm, self).__init__(*args, **kwargs)
-        # Set the kind field to readonly
-        self.fields['kind'].widget.attrs['readonly'] = True
-        # Define the logic for obtaining the objects for the provider_service
-        # dropdown of the tenant form.
-        self.fields[
-            'provider_service'].queryset = VBBUService.get_service_objects().all()
-        # Set the initial kind to HELLO_WORLD_KIND for this tenant.
-        self.fields['kind'].initial = MCORD_KIND
-        # If there is an instance of this model then we can set the initial
-        # form values to the existing values.
-        if self.instance:
-            self.fields['creator'].initial = self.instance.creator
-            self.fields[
-                'display_message'].initial = self.instance.display_message
-
-        # If there is not an instance then we need to set initial values.
-        if (not self.instance) or (not self.instance.pk):
-            self.fields['creator'].initial = get_request().user
-            if VBBUService.get_service_objects().exists():
-                self.fields["provider_service"].initial = VBBUService.get_service_objects().all()[0]
-
-    # This function describes what happens when the save button is pressed on
-    # the tenant form. In this case we set the values for the instance that were
-    # entered.
-    def save(self, commit=True):
-        self.instance.creator = self.cleaned_data.get("creator")
-        self.instance.display_message = self.cleaned_data.get(
-            "display_message")
-        return super(VBBUTenantForm, self).save(commit=commit)
-
-    class Meta:
-        model = VBBUTenant
-        fields = '__all__'
-
-
-# Define the admin form for the tenant. This uses a similar structure as the
-# service but uses HelloWorldTenantCompleteForm to change the python behavior.
-
-class VBBUTenantAdmin(ReadOnlyAwareAdmin):
-    verbose_name = "vBBU Component"
-    verbose_name_plural = "vBBU Components"
-    list_display = ('id', 'backend_status_icon', 'instance', 'display_message')
-    list_display_links = ('backend_status_icon', 'instance', 'display_message',
-                          'id')
-    fieldsets = [(None, {'fields': ['backend_status_text', 'kind',
-                                    'provider_service', 'instance', 'creator',
-                                    'display_message'],
-                         'classes': ['suit-tab suit-tab-general']})]
-    readonly_fields = ('backend_status_text', 'instance',)
-    form = VBBUTenantForm
-
-    suit_form_tabs = (('general', 'Details'),)
-
-    def queryset(self, request):
-        return VBBUTenant.get_tenant_objects_by_user(request.user)
-
-
-# Associate the admin forms with the models.
-admin.site.register(VBBUService, VBBUServiceAdmin)
-admin.site.register(VBBUTenant, VBBUTenantAdmin)
diff --git a/xos/header.py b/xos/header.py
deleted file mode 100644
index 20a9153..0000000
--- a/xos/header.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from core.models import Service, TenantWithContainer
-from django.db import transaction
-from django.db.models import *
diff --git a/xos/models.py b/xos/models.py
index 3169185..e49bfad 100644
--- a/xos/models.py
+++ b/xos/models.py
@@ -2,6 +2,10 @@
 from models_decl import VBBUService_decl
 from models_decl import VBBUTenant_decl
 
+from core.models import Service, TenantWithContainer
+from django.db import transaction
+from django.db.models import *
+
 class VBBUService(VBBUService_decl):
    class Meta:
         proxy = True 
diff --git a/xos/synchronizer/__init__.py b/xos/synchronizer/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/xos/synchronizer/__init__.py
+++ /dev/null
diff --git a/xos/synchronizer/steps/vbbutenant_playbook.yaml b/xos/synchronizer/steps/vbbutenant_playbook.yaml
index e268dfb..de19598 100644
--- a/xos/synchronizer/steps/vbbutenant_playbook.yaml
+++ b/xos/synchronizer/steps/vbbutenant_playbook.yaml
@@ -4,4 +4,5 @@
   connection: ssh
   user: ubuntu
   become: yes
-  tasks:
+  vars:
+    - tenant_message: "{{ tenant_message }}"
diff --git a/xos/synchronizer/vbbu-synchronizer.py b/xos/synchronizer/vbbu-synchronizer.py
old mode 100644
new mode 100755
diff --git a/xos/templates/mcordadmin.html b/xos/templates/mcordadmin.html
deleted file mode 100644
index 6ef0d37..0000000
--- a/xos/templates/mcordadmin.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!-- Template used to for the button leading to the HelloWorldTenantComplete form. -->
-<div class = "left-nav">
-  <ul>
-    <li>
-      <a href="/admin/mcordservice/vbbutenant/">
-        MCORD Service Components
-      </a>
-    </li>
-  </ul>
-</div>
diff --git a/xos/tosca/custom_types/vbbu.m4 b/xos/tosca/custom_types/vbbu.m4
index 9e455aa..fe5065f 100644
--- a/xos/tosca/custom_types/vbbu.m4
+++ b/xos/tosca/custom_types/vbbu.m4
@@ -15,9 +15,6 @@
         properties:
             xos_base_props
             xos_base_service_props
-            service_message:
-                type: string
-                required: false
             
     tosca.nodes.VBBUTenant:
         derived_from: tosca.nodes.Root
diff --git a/xos/tosca/custom_types/vbbu.yaml b/xos/tosca/custom_types/vbbu.yaml
index 7dc507d..b272a5f 100644
--- a/xos/tosca/custom_types/vbbu.yaml
+++ b/xos/tosca/custom_types/vbbu.yaml
@@ -78,9 +78,6 @@
                 type: string
                 required: false
                 description: Version number of Service.
-            service_message:
-                type: string
-                required: false
             
     tosca.nodes.VBBUTenant:
         derived_from: tosca.nodes.Root
diff --git a/xos/tosca/resources/vbbuservice.py b/xos/tosca/resources/vbbuservice.py
index 55bb167..8723a3e 100644
--- a/xos/tosca/resources/vbbuservice.py
+++ b/xos/tosca/resources/vbbuservice.py
@@ -1,11 +1,8 @@
-# from services.vbbu.models import MCORDService
-from synchronizers.new_base.modelaccessor import *
 from service import XOSService
+from services.vbbu.models import VBBUService
 
 class XOSMVBBUService(XOSService):
     provides = "tosca.nodes.VBBUService"
     xos_model = VBBUService
-    copyin_props = ["view_url", "icon_url", "enabled", "published", "public_key",
-                    "private_key_fn", "versionNumber",
-                    ]
+    copyin_props = ["view_url", "icon_url", "enabled", "published", "public_key", "private_key_fn", "versionNumber"]
 
diff --git a/xos/tosca/resources/vbbutenant.py b/xos/tosca/resources/vbbutenant.py
index b93c023..d8cf10d 100644
--- a/xos/tosca/resources/vbbutenant.py
+++ b/xos/tosca/resources/vbbutenant.py
@@ -1,19 +1,19 @@
-# from services.vbbu.models import *
-from synchronizers.new_base.modelaccessor import *
 from xosresource import XOSResource
+from core.models import Tenant, Service
+from services.vbbu.models import VBBUTenant
 
 class XOSVBBUTenant(XOSResource):
     provides = "tosca.nodes.VBBUTenant"
     xos_model = VBBUTenant
-    copyin_props = ["s1u_tag", "s1mme_tag", "rru_tag", "display_message"]
+    copyin_props = ("tenant_message",)
     name_field = None
 
     def get_xos_args(self, throw_exception=True):
         args = super(XOSVBBUTenant, self).get_xos_args()
 
-        provider_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception)
+        provider_name = self.get_requirement("tosca.relationships.TenantOfService", throw_exception=throw_exception)
         if provider_name:
-            args["provider_service"] = self.get_xos_object(MCORDService, throw_exception=throw_exception, name=provider_name)
+            args["provider_service"] = self.get_xos_object(Service, throw_exception=throw_exception, name=provider_name)
 
         return args
 
diff --git a/xos/vbbu-onboard.yaml b/xos/vbbu-onboard.yaml
index df9d947..1fbeb9e 100644
--- a/xos/vbbu-onboard.yaml
+++ b/xos/vbbu-onboard.yaml
@@ -15,11 +15,9 @@
           # base_url is non-null.
           # models: models.py
           xproto: ./
-          admin: admin.py
-          admin_template: templates/mcordadmin.html
           synchronizer: synchronizer/manifest
           synchronizer_run: vbbu-synchronizer.py
           tosca_custom_types: tosca/custom_types/vbbu.yaml
           tosca_resource: tosca/resources/vbbutenant.py, tosca/resources/vbbuservice.py
           private_key: file:///opt/xos/key_import/mcord_rsa
-          public_key: file:///opt/xos/key_import/mcord_rsa.pub
\ No newline at end of file
+          public_key: file:///opt/xos/key_import/mcord_rsa.pub
diff --git a/xos/vbbu.xproto b/xos/vbbu.xproto
index 2a30222..07b24f3 100644
--- a/xos/vbbu.xproto
+++ b/xos/vbbu.xproto
@@ -1,15 +1,16 @@
-option name = "vbbu";
+option name = "vBBU";
+option verbose_name = "Virtual Broadband Base Unit";
 option app_label = "vbbu";
-option verbose_name = "vBBU Service";
 option kind = "vRAN";
 option legacy = "True";
 
 message VBBUService (Service){
-    required string service_message = 1 [help_text = "Service Message to Display", max_length = 254, null = False, db_index = False, blank = False];
+    option name = "VBBUService";
+    option verbose_name = "Virtual Broadband Base Unit Service";
 }
 
 message VBBUTenant (TenantWithContainer){
-     option name = "vbbutenant";
-     option verbose_name = "vBBU Tenant";
+     option name = "VBBUTenant";
+     option verbose_name = "Virtual Broadband Base Unit Tenant";
      required string tenant_message = 1 [help_text = "Tenant Message to Display", max_length = 254, null = False, db_index = False, blank = False];
 }