Refactor vBBU from 2.0 to 3.0, not for master

Change-Id: Ib2d68852ad4065d8c34599dca731123ed6297e84
diff --git a/xos/admin.py b/xos/admin.py
index 5b8071c..ef7503f 100644
--- a/xos/admin.py
+++ b/xos/admin.py
@@ -1,10 +1,11 @@
 
 from core.admin import ReadOnlyAwareAdmin, SliceInline
 from core.middleware import get_request
-from core.models import User
+# from core.models import User
 from django import forms
 from django.contrib import admin
-from services.vbbu.models import MCORDService, VBBUComponent, MCORD_KIND
+# 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
@@ -72,7 +73,7 @@
 # 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 VBBUComponentForm(forms.ModelForm):
+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())
@@ -80,7 +81,7 @@
     display_message = forms.CharField(required=False)
 
     def __init__(self, *args, **kwargs):
-        super(VBBUComponentForm, self).__init__(*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
@@ -109,17 +110,17 @@
         self.instance.creator = self.cleaned_data.get("creator")
         self.instance.display_message = self.cleaned_data.get(
             "display_message")
-        return super(VBBUComponentForm, self).save(commit=commit)
+        return super(VBBUTenantForm, self).save(commit=commit)
 
     class Meta:
-        model = VBBUComponent
+        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 VBBUComponentAdmin(ReadOnlyAwareAdmin):
+class VBBUTenantAdmin(ReadOnlyAwareAdmin):
     verbose_name = "vBBU Component"
     verbose_name_plural = "vBBU Components"
     list_display = ('id', 'backend_status_icon', 'instance', 'display_message')
@@ -130,14 +131,14 @@
                                     'display_message'],
                          'classes': ['suit-tab suit-tab-general']})]
     readonly_fields = ('backend_status_text', 'instance',)
-    form = VBBUComponentForm
+    form = VBBUTenantForm
 
     suit_form_tabs = (('general', 'Details'),)
 
     def queryset(self, request):
-        return VBBUComponent.get_tenant_objects_by_user(request.user)
+        return VBBUTenant.get_tenant_objects_by_user(request.user)
 
 
 # Associate the admin forms with the models.
 admin.site.register(MCORDService, MCORDServiceAdmin)
-admin.site.register(VBBUComponent, VBBUComponentAdmin)
+admin.site.register(VBBUTenant, VBBUTenantAdmin)
diff --git a/xos/attic/header.py b/xos/attic/header.py
new file mode 100644
index 0000000..3bde40f
--- /dev/null
+++ b/xos/attic/header.py
@@ -0,0 +1,11 @@
+# models.py -  ExampleService Models
+
+from core.models import Service, TenantWithContainer
+from django.db import transaction
+from django.db.models import *
+
+SERVICE_NAME = 'vbbuservice'
+SERVICE_NAME_VERBOSE = 'vBBU Service'
+SERVICE_NAME_VERBOSE_PLURAL = 'vBBU Services'
+TENANT_NAME_VERBOSE = 'vBBU Tenant'
+TENANT_NAME_VERBOSE_PLURAL = 'vBBU Tenants'
diff --git a/xos/header.py b/xos/header.py
new file mode 100644
index 0000000..5a7f4bc
--- /dev/null
+++ b/xos/header.py
@@ -0,0 +1,11 @@
+# models.py -  vBBU Models
+
+from core.models import Service, TenantWithContainer
+from django.db import transaction
+from django.db.models import *
+
+SERVICE_NAME = 'vbbuservice'
+SERVICE_NAME_VERBOSE = 'vBBU Service'
+SERVICE_NAME_VERBOSE_PLURAL = 'vBBU Services'
+TENANT_NAME_VERBOSE = 'vBBU Tenant'
+TENANT_NAME_VERBOSE_PLURAL = 'vBBU Tenants'
diff --git a/xos/migrations/0001_initial.py b/xos/migrations/0001_initial.py
index a11fe30..7ead827 100644
--- a/xos/migrations/0001_initial.py
+++ b/xos/migrations/0001_initial.py
@@ -22,7 +22,7 @@
             bases=('core.service',),
         ),
         migrations.CreateModel(
-            name='VBBUComponent',
+            name='VBBUTenant',
             fields=[
             ],
             options={
diff --git a/xos/models.py b/xos/models.py
deleted file mode 100644
index cc52bc6..0000000
--- a/xos/models.py
+++ /dev/null
@@ -1,285 +0,0 @@
-from django.db import models
-from core.models import Service, XOSBase, Slice, Instance, Tenant, TenantWithContainer, Node, Image, User, Flavor, Subscriber, NetworkParameter, NetworkParameterType, AddressPool, Port
-from core.models.xosbase import StrippedCharField
-import os
-from django.db import models, transaction
-from django.forms.models import model_to_dict
-from django.db.models import Q
-from operator import itemgetter, attrgetter, methodcaller
-from core.models import Tag
-from core.models.service import LeastLoadedNodeScheduler
-import traceback
-from xos.exceptions import *
-from core.models import SlicePrivilege, SitePrivilege
-from sets import Set
-from xos.config import Config
-
-MCORD_KIND = "RAN" # This should be changed later I did it fo demo
-MCORD_USE_VTN = getattr(Config(), "networking_use_vtn", False)
-VBBU_KIND = "RAN"
-VSGW_KIND = "vSGW"
-VPGWC_KIND = "RAN"
-vbbu_net_types = ("s1u", "s1mme", "rru")
-vpgwc_net_types = ("s5s8")
-# The class to represent the service. Most of the service logic is given for us
-# in the Service class but, we have some configuration that is specific for
-# this example.
-class MCORDService(Service):
-    KIND = MCORD_KIND
-
-    class Meta:
-        # When the proxy field is set to True the model is represented as
-        # it's superclass in the database, but we can still change the python
-        # behavior. In this case HelloWorldServiceComplete is a Service in the
-        # database.
-        proxy = True
-        # The name used to find this service, all directories are named this
-        app_label = "vbbu"
-        verbose_name = "MCORD Service"
-
-# This is the class to represent the tenant. Most of the logic is given to use
-# in TenantWithContainer, however there is some configuration and logic that
-# we need to define for this example.
-class VBBUComponent(TenantWithContainer):
-
-    class Meta:
-        # Same as a above, HelloWorldTenantComplete is represented as a
-        # TenantWithContainer, but we change the python behavior.
-        proxy = True
-        verbose_name = "VBBU MCORD Service Component"
-
-    # The kind of the service is used on forms to differentiate this service
-    # from the other services.
-    KIND = VBBU_KIND
-
-    # Ansible requires that the sync_attributes field contain nat_ip and nat_mac
-    # these will be used to determine where to SSH to for ansible.
-    # Getters must be defined for every attribute specified here.
-    sync_attributes = ("s1u_ip", "s1u_mac",
-                       "s1mme_ip", "s1mme_mac",
-                       "rru_ip", "rru_mac")
-    # default_attributes is used cleanly indicate what the default values for
-    # the fields are.
-    default_attributes = {"display_message": "New vBBU Component", "s1u_tag": "901", "s1mme_tag": "900", "rru_tag": "999"}
-    def __init__(self, *args, **kwargs):
-        mcord_services = MCORDService.get_service_objects().all()
-        # When the tenant is created the default service in the form is set
-        # to be the first created HelloWorldServiceComplete
-        if mcord_services:
-            self._meta.get_field(
-                "provider_service").default = mcord_services[0].id
-        super(VBBUComponent, self).__init__(*args, **kwargs)
-
-    def can_update(self, user):
-        #Allow creation of this model instances for non-admin users also
-        return True
-
-    def save(self, *args, **kwargs):
-        if not self.creator:
-            if not getattr(self, "caller", None):
-                # caller must be set when creating a monitoring channel since it creates a slice
-                raise XOSProgrammingError("ServiceComponents's self.caller was not set")
-            self.creator = self.caller
-            if not self.creator:
-                raise XOSProgrammingError("ServiceComponents's self.creator was not set")
-
-        super(VBBUComponent, self).save(*args, **kwargs)
-        # This call needs to happen so that an instance is created for this
-        # tenant is created in the slice. One instance is created per tenant.
-        model_policy_mcord_servicecomponent(self.pk)
-
-    def save_instance(self, instance):
-        with transaction.atomic():
-            super(VBBUComponent, self).save_instance(instance)
-            if instance.isolation in ["vm"]:
-                for ntype in vbbu_net_types:
-                    lan_network = self.get_lan_network(instance, ntype)
-                    port = self.find_or_make_port(instance,lan_network)
-                    if (ntype == "s1u"):
-                        port.set_parameter("s_tag", self.s1u_tag)
-                        port.set_parameter("neutron_port_name", "stag-%s" % self.s1u_tag)
-                        port.save()
-                    elif (ntype == "s1mme"):
-                        port.set_parameter("s_tag", self.s1mme_tag)
-                        port.set_parameter("neutron_port_name", "stag-%s" % self.s1mme_tag)
-                        port.save()
-                    elif (ntype == "rru"):
-                        port.set_parameter("s_tag", self.rru_tag)
-                        port.set_parameter("neutron_port_name", "stag-%s" % self.rru_tag)
-                        port.save()
-    
-    def delete(self, *args, **kwargs):
-        # Delete the instance that was created for this tenant
-        self.cleanup_container()
-        super(VBBUComponent, self).delete(*args, **kwargs)
-
-    def find_or_make_port(self, instance, network, **kwargs):
-        port = Port.objects.filter(instance=instance, network=network)
-        if port:
-            port = port[0]
-            print "port already exist", port[0]
-        else:
-            port = Port(instance=instance, network=network, **kwargs)
-            print "NETWORK", network, "MAKE_PORT", port 
-            port.save()
-        return port
-
-    def get_lan_network(self, instance, ntype):
-        slice = self.provider_service.slices.all()[0]
-        lan_networks = [x for x in slice.networks.all() if ntype in x.name]
-        if not lan_networks:
-            raise XOSProgrammingError("No lan_network")
-        return lan_networks[0]
-
-    def manage_container(self):
-        from core.models import Instance, Flavor
-
-        if self.deleted:
-            return
-
-        # For container or container_vm isolation, use what TenantWithCotnainer
-        # provides us
-        slice = self.get_slice()
-        if slice.default_isolation in ["container_vm", "container"]:
-            super(VBBUComponent,self).manage_container()
-            return
-
-        if not self.s1u_tag:
-            raise XOSConfigurationError("S1U_TAG is missed")
-
-        if not self.s1mme_tag:
-            raise XOSConfigurationError("S1U_TAG is missed")
-
-        if not self.rru_tag:
-            raise XOSConfigurationError("S1U_TAG is missed")
-
-        if self.instance:
-            # We're good.
-            return
-
-        instance = self.make_instance()
-        self.instance = instance
-        super(TenantWithContainer, self).save()
-
-    def get_slice(self):
-        if not self.provider_service.slices.count():
-            raise XOSConfigurationError("The service has no slices")
-        slice = self.provider_service.slices.all()[0]
-        return slice
-
-    def make_instance(self):
-        slice = self.provider_service.slices.all()[0]            
-        flavors = Flavor.objects.filter(name=slice.default_flavor)
-#        flavors = Flavor.objects.filter(name="m1.xlarge")
-        if not flavors:
-            raise XOSConfigurationError("No default flavor")
-        default_flavor = slice.default_flavor
-        slice = self.provider_service.slices.all()[0]
-        if slice.default_isolation == "container_vm":
-            (node, parent) = ContainerVmScheduler(slice).pick()
-        else:
-            (node, parent) = LeastLoadedNodeScheduler(slice).pick()
-        instance = Instance(slice = slice,
-                        node = node,
-                        image = self.image,
-                        creator = self.creator,
-                        deployment = node.site_deployment.deployment,
-                        flavor = flavors[0],
-                        isolation = slice.default_isolation,
-                        parent = parent)
-        self.save_instance(instance)
-        return instance
-
-    def ip_to_mac(self, ip):
-        (a, b, c, d) = ip.split('.')
-        return "02:42:%02x:%02x:%02x:%02x" % (int(a), int(b), int(c), int(d))
-
-    # Getter for the message that will appear on the webpage
-    # By default it is "Hello World!"
-    @property
-    def display_message(self):
-        return self.get_attribute(
-            "display_message",
-            self.default_attributes['display_message'])
-
-    @display_message.setter
-    def display_message(self, value):
-        self.set_attribute("display_message", value)
-
-    @property
-    def s1u_tag(self):
-        return self.get_attribute(
-            "s1u_tag",
-            self.default_attributes['s1u_tag'])
-
-    @s1u_tag.setter
-    def s1u_tag(self, value):
-        self.set_attribute("s1u_tag", value)
-
-    @property
-    def s1mme_tag(self):
-        return self.get_attribute(
-            "s1mme_tag",
-            self.default_attributes['s1mme_tag'])
-
-    @s1mme_tag.setter
-    def s1mme_tag(self, value):
-        self.set_attribute("s1mme_tag", value)
-
-    @property
-    def rru_tag(self):
-        return self.get_attribute(
-            "rru_tag",
-            self.default_attributes['rru_tag'])
-
-    @rru_tag.setter
-    def rru_tag(self, value):
-        self.set_attribute("rru_tag", value)
-
-
-    @property
-    def addresses(self):
-        if (not self.id) or (not self.instance):
-            return {}
-
-        addresses = {}
-        for ns in self.instance.ports.all():
-            if "s1u" in ns.network.name.lower():
-                addresses["s1u"] = (ns.ip, ns.mac)
-            elif "s1mme" in ns.network.name.lower():
-                addresses["s1mme"] = (ns.ip, ns.mac)
-            elif "rru" in ns.network.name.lower():
-                addresses["rru"] = (ns.ip, ns.mac)
-        return addresses
-
-
-    @property
-    def s1u_ip(self):
-        return self.addresses.get("s1u", (None, None))[0]
-    @property
-    def s1u_mac(self):
-        return self.addresses.get("s1u", (None, None))[1]
-    @property
-    def s1mme_ip(self):
-        return self.addresses.get("s1mme", (None, None))[0]
-    @property
-    def s1mme_mac(self):
-        return self.addresses.get("s1mme", (None, None))[1]
-    @property
-    def rru_ip(self):
-        return self.addresses.get("rru", (None, None))[0]
-    @property
-    def rru_mac(self):
-        return self.addresses.get("rru", (None, None))[1]
-
-
-def model_policy_mcord_servicecomponent(pk):
-    # This section of code is atomic to prevent race conditions
-    with transaction.atomic():
-        # We find all of the tenants that are waiting to update
-        component = VBBUComponent.objects.select_for_update().filter(pk=pk)
-        if not component:
-            return
-        # Since this code is atomic it is safe to always use the first tenant
-        component = component[0]
-        component.manage_container()
diff --git a/xos/synchronizer/Dockerfile.synchronizer b/xos/synchronizer/Dockerfile.synchronizer
new file mode 100644
index 0000000..b31583e
--- /dev/null
+++ b/xos/synchronizer/Dockerfile.synchronizer
@@ -0,0 +1,39 @@
+# xosproject/vbbu-synchronizer
+FROM xosproject/xos-synchronizer-base:candidate
+
+COPY . /opt/xos/synchronizers/vbbu
+
+ENTRYPOINT []
+
+WORKDIR "/opt/xos/synchronizers/vbbu"
+
+# Label image
+ARG org_label_schema_schema_version=1.0
+ARG org_label_schema_name=vbbu-synchronizer
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+ARG org_opencord_component_chameleon_version=unknown
+ARG org_opencord_component_chameleon_vcs_url=unknown
+ARG org_opencord_component_chameleon_vcs_ref=unknown
+ARG org_opencord_component_xos_version=unknown
+ARG org_opencord_component_xos_vcs_url=unknown
+ARG org_opencord_component_xos_vcs_ref=unknown
+
+LABEL org.label-schema.schema-version=$org_label_schema_schema_version \
+      org.label-schema.name=$org_label_schema_name \
+      org.label-schema.version=$org_label_schema_version \
+      org.label-schema.vcs-url=$org_label_schema_vcs_url \
+      org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
+      org.label-schema.build-date=$org_label_schema_build_date \
+      org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date \
+      org.opencord.component.chameleon.version=$org_opencord_component_chameleon_version \
+      org.opencord.component.chameleon.vcs-url=$org_opencord_component_chameleon_vcs_url \
+      org.opencord.component.chameleon.vcs-ref=$org_opencord_component_chameleon_vcs_ref \
+      org.opencord.component.xos.version=$org_opencord_component_xos_version \
+      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 "cd /opt/xos/synchronizers/vbbu; ./run-from-api.sh"
\ No newline at end of file
diff --git a/xos/synchronizer/manifest b/xos/synchronizer/manifest
index 1eb3bf5..5fca47e 100644
--- a/xos/synchronizer/manifest
+++ b/xos/synchronizer/manifest
@@ -1,8 +1,8 @@
 model-deps
 vbbu-synchronizer.py
 vbbu_config
-steps/sync_vbbu.py
-steps/sync_vbbu.yaml
+steps/sync_vbbutenant.py
+steps/vbbutenant_playbook.yaml
 stop.sh
 manifest
 __init__.py
diff --git a/xos/synchronizer/run-from-api.sh b/xos/synchronizer/run-from-api.sh
new file mode 100755
index 0000000..b81baea
--- /dev/null
+++ b/xos/synchronizer/run-from-api.sh
@@ -0,0 +1,2 @@
+export XOS_DIR=/opt/xos
+python vbbu-synchronizer.py  -C $XOS_DIR/synchronizers/vbbu/vbbu_from_api_config
\ No newline at end of file
diff --git a/xos/synchronizer/run.sh b/xos/synchronizer/run.sh
deleted file mode 100644
index 27d4e24..0000000
--- a/xos/synchronizer/run.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-# Runs the XOS observer using helloworldservice_config
-export XOS_DIR=/opt/xos
-python vbbu-synchronizer.py  -C $XOS_DIR/synchronizers/vbbu/vbbu_config
diff --git a/xos/synchronizer/steps/sync_vbbu.py b/xos/synchronizer/steps/sync_vbbu.py
deleted file mode 100644
index a000230..0000000
--- a/xos/synchronizer/steps/sync_vbbu.py
+++ /dev/null
@@ -1,37 +0,0 @@
-import os
-import sys
-from django.db.models import Q, F
-from services.vbbu.models import MCORDService, VBBUComponent
-from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
-
-parentdir = os.path.join(os.path.dirname(__file__), "..")
-sys.path.insert(0, parentdir)
-
-class SyncVBBUComponent(SyncInstanceUsingAnsible):
-
-    provides = [VBBUComponent]
-
-    observes = VBBUComponent
-
-    requested_interval = 0
-
-    template_name = "sync_vbbu.yaml"
-
-    service_key_name = "/opt/xos/configurations/mcord/mcord_private_key"
-
-    def __init__(self, *args, **kwargs):
-        super(SyncVBBUComponent, self).__init__(*args, **kwargs)
-
-    def fetch_pending(self, deleted):
-
-        if (not deleted):
-            objs = VBBUComponent.get_tenant_objects().filter(
-                Q(enacted__lt=F('updated')) | Q(enacted=None), Q(lazy_blocked=False))
-        else:
-
-            objs = VBBUComponent.get_deleted_tenant_objects()
-
-        return objs
-
-    def get_extra_attributes(self, o):
-        return {"display_message": o.display_message, "s1u_tag": o.s1u_tag, "s1mme_tag": o.s1mme_tag, "rru_tag": o.rru_tag}
diff --git a/xos/synchronizer/steps/sync_vbbutenant.py b/xos/synchronizer/steps/sync_vbbutenant.py
new file mode 100644
index 0000000..1ec4528
--- /dev/null
+++ b/xos/synchronizer/steps/sync_vbbutenant.py
@@ -0,0 +1,39 @@
+import os
+import sys
+from django.db.models import Q, F
+# from services.vbbu.models import MCORDService, VBBUTenant
+from synchronizers.new_base.modelaccessor import *
+from synchronizers.new_base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
+
+parentdir = os.path.join(os.path.dirname(__file__), "..")
+sys.path.insert(0, parentdir)
+
+class SyncVBBUTenant(SyncInstanceUsingAnsible):
+
+
+    provides = [VBBUTenant]
+
+    observes = VBBUTenant
+
+    requested_interval = 0
+
+    template_name = "vbbutenant_playbook.yaml"
+
+    service_key_name = "/opt/xos/configurations/mcord/mcord_private_key"
+
+    def __init__(self, *args, **kwargs):
+        super(SyncVBBUTenant, self).__init__(*args, **kwargs)
+
+    def fetch_pending(self, deleted):
+
+        if (not deleted):
+            objs = VBBUTenant.get_tenant_objects().filter(
+                Q(enacted__lt=F('updated')) | Q(enacted=None), Q(lazy_blocked=False))
+        else:
+
+            objs = VBBUTenant.get_deleted_tenant_objects()
+
+        return objs
+
+    def get_extra_attributes(self, o):
+        return {"display_message": o.display_message, "s1u_tag": o.s1u_tag, "s1mme_tag": o.s1mme_tag, "rru_tag": o.rru_tag}
diff --git a/xos/synchronizer/steps/sync_vbbu.yaml b/xos/synchronizer/steps/vbbutenant_playbook.yaml
similarity index 100%
rename from xos/synchronizer/steps/sync_vbbu.yaml
rename to xos/synchronizer/steps/vbbutenant_playbook.yaml
diff --git a/xos/synchronizer/vbbu-synchronizer.py b/xos/synchronizer/vbbu-synchronizer.py
index 95f4081..0fb2fcb 100644
--- a/xos/synchronizer/vbbu-synchronizer.py
+++ b/xos/synchronizer/vbbu-synchronizer.py
@@ -7,7 +7,7 @@
 import os
 import sys
 observer_path = os.path.join(os.path.dirname(
-    os.path.realpath(__file__)), "../../synchronizers/base")
+    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/vbbu_config b/xos/synchronizer/vbbu_config
deleted file mode 100644
index f85ecb3..0000000
--- a/xos/synchronizer/vbbu_config
+++ /dev/null
@@ -1,40 +0,0 @@
-# Required by XOS
-[db]
-name=xos
-user=postgres
-password=password
-host=xos_db
-port=5432
-
-# Required by XOS
-[api]
-nova_enabled=True
-
-# Sets options for the observer
-[observer]
-# Optional name
-name=vbbu
-# This is the location to the dependency graph you generate
-dependency_graph=/opt/xos/synchronizers/vbbu/model-deps
-# The location of your SyncSteps
-steps_dir=/opt/xos/synchronizers/vbbu/steps
-# A temporary directory that will be used by ansible
-sys_dir=/opt/xos/synchronizers/vbbu/sys
-# Location of the file to save logging messages to the backend log is often used
-logfile=/var/log/xos_backend.log
-# If this option is true, then nothing will change, we simply pretend to run
-pretend=False
-# If this is False then XOS will use an exponential backoff when the observer
-# fails, since we will be waiting for an instance, we don't want this.
-backoff_disabled=True
-# We want the output from ansible to be logged
-save_ansible_output=True
-# This determines how we SSH to a client, if this is set to True then we try
-# to ssh using the instance name as a proxy, if this is disabled we ssh using
-# the NAT IP of the instance. On CloudLab the first option will fail so we must
-# set this to False
-proxy_ssh=True
-proxy_ssh_key=/root/setup/id_rsa
-proxy_ssh_user=root
-[networking]
-use_vtn=True
diff --git a/xos/synchronizer/vbbu_from_api_config b/xos/synchronizer/vbbu_from_api_config
new file mode 100644
index 0000000..34a07ee
--- /dev/null
+++ b/xos/synchronizer/vbbu_from_api_config
@@ -0,0 +1,20 @@
+# Sets options for the synchronizer
+[observer]
+name=vbbu
+dependency_graph=/opt/xos/synchronizers/vbbu/model-deps
+steps_dir=/opt/xos/synchronizers/vbbu/steps
+sys_dir=/opt/xos/synchronizers/vbbu/sys
+#logfile=/var/log/xos_backend.log
+log_file=console
+log_level=debug
+pretend=False
+backoff_disabled=True
+save_ansible_output=True
+proxy_ssh=True
+proxy_ssh_key=/opt/cord_profile/node_key
+proxy_ssh_user=root
+accessor_kind=api
+accessor_password=@/opt/xos/services/vbbu/credentials/xosadmin@opencord.org
+
+[networking]
+use_vtn=True
diff --git a/xos/templates/mcordadmin.html b/xos/templates/mcordadmin.html
index 4a69dcc..6ef0d37 100644
--- a/xos/templates/mcordadmin.html
+++ b/xos/templates/mcordadmin.html
@@ -2,7 +2,7 @@
 <div class = "left-nav">
   <ul>
     <li>
-      <a href="/admin/mcordservice/vbbucomponent/">
+      <a href="/admin/mcordservice/vbbutenant/">
         MCORD Service Components
       </a>
     </li>
diff --git a/xos/tosca/resources/mcordservice.py b/xos/tosca/resources/mcordservice.py
deleted file mode 100644
index 491b204..0000000
--- a/xos/tosca/resources/mcordservice.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from services.vbbu.models import MCORDService
-from service import XOSService
-
-class XOSMCORDService(XOSService):
-    provides = "tosca.nodes.MCORDService"
-    xos_model = MCORDService
-    copyin_props = ["view_url", "icon_url", "enabled", "published", "public_key",
-                    "private_key_fn", "versionNumber",
-                    ]
-
diff --git a/xos/tosca/resources/vbbuservice.py b/xos/tosca/resources/vbbuservice.py
new file mode 100644
index 0000000..bbe344e
--- /dev/null
+++ b/xos/tosca/resources/vbbuservice.py
@@ -0,0 +1,11 @@
+# from services.vbbu.models import MCORDService
+from synchronizers.new_base.modelaccessor import *
+from service import XOSService
+
+class XOSMVBBUService(XOSService):
+    provides = "tosca.nodes.VBBUervice"
+    xos_model = VBBUService
+    copyin_props = ["view_url", "icon_url", "enabled", "published", "public_key",
+                    "private_key_fn", "versionNumber",
+                    ]
+
diff --git a/xos/tosca/resources/vbbucomponent.py b/xos/tosca/resources/vbbutenant.py
similarity index 72%
rename from xos/tosca/resources/vbbucomponent.py
rename to xos/tosca/resources/vbbutenant.py
index 3782b5b..b93c023 100644
--- a/xos/tosca/resources/vbbucomponent.py
+++ b/xos/tosca/resources/vbbutenant.py
@@ -1,14 +1,15 @@
-from services.vbbu.models import VBBUComponent, MCORDService
+# from services.vbbu.models import *
+from synchronizers.new_base.modelaccessor import *
 from xosresource import XOSResource
 
-class XOSVBBUComponent(XOSResource):
-    provides = "tosca.nodes.VBBUComponent"
-    xos_model = VBBUComponent
+class XOSVBBUTenant(XOSResource):
+    provides = "tosca.nodes.VBBUTenant"
+    xos_model = VBBUTenant
     copyin_props = ["s1u_tag", "s1mme_tag", "rru_tag", "display_message"]
     name_field = None
 
     def get_xos_args(self, throw_exception=True):
-        args = super(XOSVBBUComponent, self).get_xos_args()
+        args = super(XOSVBBUTenant, self).get_xos_args()
 
         provider_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception)
         if provider_name:
@@ -27,5 +28,5 @@
         pass
 
     def can_delete(self, obj):
-        return super(XOSVBBUComponent, self).can_delete(obj)
+        return super(XOSVBBUTenant, self).can_delete(obj)
 
diff --git a/xos/vBBU-onboard.yaml b/xos/vbbu-onboard.yaml
similarity index 69%
rename from xos/vBBU-onboard.yaml
rename to xos/vbbu-onboard.yaml
index 16ea78e..86b0454 100644
--- a/xos/vBBU-onboard.yaml
+++ b/xos/vbbu-onboard.yaml
@@ -10,18 +10,18 @@
     servicecontroller#vbbu:
       type: tosca.nodes.ServiceController
       properties:
-          base_url: file:///opt/xos_services/vBBU/xos/
+          base_url: file:///opt/xos_services/vbbu/xos/
           # The following will concatenate with base_url automatically, if
           # base_url is non-null.
-          models: models.py
+          # models: models.py
+          xproto: ./
           admin: admin.py
           admin_template: templates/mcordadmin.html
           synchronizer: synchronizer/manifest
           synchronizer_run: vbbu-synchronizer.py
           #tosca_custom_types: exampleservice.yaml
-          tosca_resource: tosca/resources/vbbucomponent.py, tosca/resources/mcordservice.py
+          tosca_resource: tosca/resources/vbbutenant.py, tosca/resources/vbbuservice.py
           #rest_service: subdirectory:vsg api/service/vsg/vsgservice.py
           #rest_tenant: subdirectory:cord api/tenant/cord/vsg.py
-          private_key: file:///opt/xos/key_import/vBBU_rsa
-          public_key: file:///opt/xos/key_import/vBBU_rsa.pub
-
+          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
diff --git a/xos/vbbu.xproto b/xos/vbbu.xproto
new file mode 100644
index 0000000..33b8e8e
--- /dev/null
+++ b/xos/vbbu.xproto
@@ -0,0 +1,14 @@
+option name = "vbbu";
+option app_label = "vbbu";
+option verbose_name = "vBBU Service";
+
+message VBBUService (Service){
+    required string service_message = 1 [help_text = "Service Message to Display", max_length = 254, null = False, db_index = False, blank = False];
+}
+
+
+message VBBUTenant (TenantWithContainer){
+     option name = "vbbutenant";
+     option verbose_name = "vBBU Tenant";
+     required string tenant_message = 1 [help_text = "Tenant Message to Display", max_length = 254, null = False, db_index = False, blank = False];
+}
diff --git a/xos/view.py b/xos/view.py
index dc5f06a..b2aa10f 100644
--- a/xos/view.py
+++ b/xos/view.py
@@ -1,7 +1,8 @@
 from django.http import HttpResponse
 from django.views.generic import TemplateView, View
 from django import template
-from core.models import *
+# from core.models import *
+from synchronizers.new_base.modelaccessor import *
 import json
 import os
 import time