refactor vBBU as a separate project

(1) Moved xos/xos/services/mcord/ to xos_services/vBBU
(2) Moved the location of tosca files
    from xos/xos/tosca/ to xos_services/vBBU/xos/tosca/
(3) Moved the location of synchronizer files
    from xos/xos/synchronizers to xos_services/vBBU/xos/synchronizers
(4) Added make_synchronizer_manifest.sh and manifest
(5) Added vBBU-onboard.yaml

Change-Id: I97c8c234d66ef3121403fb9dd109d7497efe4e2a
diff --git a/xos/synchronizer/__init__.py b/xos/synchronizer/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/xos/synchronizer/__init__.py
diff --git a/xos/synchronizer/manifest b/xos/synchronizer/manifest
new file mode 100644
index 0000000..1eb3bf5
--- /dev/null
+++ b/xos/synchronizer/manifest
@@ -0,0 +1,9 @@
+model-deps
+vbbu-synchronizer.py
+vbbu_config
+steps/sync_vbbu.py
+steps/sync_vbbu.yaml
+stop.sh
+manifest
+__init__.py
+run.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/synchronizer/run.sh b/xos/synchronizer/run.sh
new file mode 100644
index 0000000..27d4e24
--- /dev/null
+++ b/xos/synchronizer/run.sh
@@ -0,0 +1,3 @@
+# 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
new file mode 100644
index 0000000..09b1fe8
--- /dev/null
+++ b/xos/synchronizer/steps/sync_vbbu.py
@@ -0,0 +1,37 @@
+import os
+import sys
+from django.db.models import Q, F
+from services.mcord.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_vbbu.yaml b/xos/synchronizer/steps/sync_vbbu.yaml
new file mode 100644
index 0000000..1e1e258
--- /dev/null
+++ b/xos/synchronizer/steps/sync_vbbu.yaml
@@ -0,0 +1,19 @@
+---
+- hosts: {{ instance_name }}
+  gather_facts: False
+  connection: ssh
+  user: ubuntu
+  sudo: yes
+  tasks:
+
+  - name: write message
+    shell: echo "{{ display_message }}" > /var/tmp/index.html
+
+  - name: setup s1u interface config
+    shell: ./start_3gpp_int.sh eth1 {{ s1u_tag }} {{ s1u_ip }}/24 
+
+  - name: setup s1mme interface config
+    shell: ./start_3gpp_int.sh eth2 {{ s1mme_tag }} {{ s1mme_ip }}/24 
+
+  - name: setup rru interface config
+    shell: ./start_3gpp_int.sh eth3 {{ rru_tag }} {{ rru_ip }}/24 
diff --git a/xos/synchronizer/stop.sh b/xos/synchronizer/stop.sh
new file mode 100644
index 0000000..7ad7f4c
--- /dev/null
+++ b/xos/synchronizer/stop.sh
@@ -0,0 +1,2 @@
+# Kill the observer
+pkill -9 -f vbbu-synchronizer.py
diff --git a/xos/synchronizer/vbbu-synchronizer.py b/xos/synchronizer/vbbu-synchronizer.py
new file mode 100644
index 0000000..95f4081
--- /dev/null
+++ b/xos/synchronizer/vbbu-synchronizer.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+
+# This imports and runs ../../xos-observer.py
+# Runs the standard XOS observer
+
+import importlib
+import os
+import sys
+observer_path = os.path.join(os.path.dirname(
+    os.path.realpath(__file__)), "../../synchronizers/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
new file mode 100644
index 0000000..3713b67
--- /dev/null
+++ b/xos/synchronizer/vbbu_config
@@ -0,0 +1,40 @@
+# Required by XOS
+[db]
+name=xos
+user=postgres
+password=password
+host=localhost
+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