reorg to use common/tosca/ directory for shared TOSCA files, update of opencloud service-profile
unified config into common/Makedefs, included common/Makefile
strip last path component to get directory
clarify container target names, dependency fixes on service dir
fix test-standalone
converted other configs, added .DEFAULT_GOAL's
immediately set paths, run docker under sudo
port and cleanup fixes
fixes after testing cord-pod
follow log files, fix typo metronetwork/xos.yaml

Change-Id: I3e28d10ffd37a22c4a2927288924db453ed6ec44
diff --git a/common/Makedefs b/common/Makedefs
index 36602f9..6cc85ab 100644
--- a/common/Makedefs
+++ b/common/Makedefs
@@ -1,10 +1,28 @@
 # service-profile/common/Makedefs
 
-SERVICE_DIR ?= ../../xos_services
-XOS_DIR ?= ../../xos
+COMMON_DIR           ?= $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
+CONFIG_DIR           ?= $(COMMON_DIR)
 
+HOME_DIR             ?= $(shell echo ~)
+MYIP                 ?= $(shell hostname -i)
+
+XOS_DIR              ?= $(HOME_DIR)/xos
+SERVICE_DIR          ?= $(HOME_DIR)/xos_services
+
+XOS_BOOTSTRAP_PORT   ?= 81
+XOS_UI_PORT          ?= 80
+
+DOCKER_PROJECT       ?= unknown
+BOOTSTRAP_PROJECT    ?= $(DOCKER_PROJECT)bs
+
+ADMIN_USERNAME       ?= padmin@vicci.org
+ADMIN_PASSWORD       ?= letmein
+
+BOOTSTRAP_YML        ?= $(CONFIG_DIR)/docker-compose-bootstrap.yml
+DOCKER_COMPOSE_YML   ?= $(CONFIG_DIR)/onboarding-docker-compose/docker-compose.yml
+
+# git repos
 CORD_BASE_GIT_URL ?= https://gerrit.opencord.org/p
-
 DEFAULT_BRANCH ?= master
 
 XOS_BRANCH ?= $(DEFAULT_BRANCH)
@@ -45,3 +63,4 @@
 
 OPENSTACK_BRANCH ?= $(DEFAULT_BRANCH)
 OPENSTACK_GIT_URL ?= $(CORD_BASE_GIT_URL)/openstack.git
+
diff --git a/common/Makefile b/common/Makefile
new file mode 100644
index 0000000..de6ffa0
--- /dev/null
+++ b/common/Makefile
@@ -0,0 +1,207 @@
+include $(COMMON_DIR)/Makedefs
+
+# prerequisite software
+prereqs: apt-prereqs /usr/bin/http /usr/bin/docker /usr/bin/curl /usr/local/bin/docker-compose
+
+apt-prereqs:
+	sudo apt-get update
+	sudo apt-get -y install apt-transport-https ca-certificates python-pip
+
+/usr/bin/http:
+	sudo apt-get -y install httpie
+
+/usr/bin/curl:
+	sudo apt-get -y install curl
+
+/usr/bin/docker:
+	sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
+	echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" > /tmp/docker.list
+	sudo mv /tmp/docker.list /etc/apt/sources.list.d/docker.list
+	sudo apt-get update
+	sudo apt-get -y install docker-engine
+	sudo usermod -aG docker $(shell whoami)
+
+/usr/local/bin/docker-compose:
+	sudo pip install docker-compose
+
+
+# configuration
+config_dirs:
+	mkdir -p $(CONFIG_DIR)/key_import
+	mkdir -p $(CONFIG_DIR)/onboarding-docker-compose
+	mkdir -p $(CONFIG_DIR)/images
+
+nodes.yaml:
+	export SETUPDIR=$(CONFIG_DIR); bash $(COMMON_DIR)/make-nodes-yaml.sh
+
+clean_nodes:
+	rm -f $(CONFIG_DIR)/nodes.yaml
+
+images.yaml:
+	export SETUPDIR=$(CONFIG_DIR); bash $(COMMON_DIR)/make-images-yaml.sh
+
+
+# download/clone xos and service repos
+GITOPTS ?= -c advice.detachedHead=false
+
+xos_download: $(XOS_DIR)
+
+$(XOS_DIR):
+	git -C $(HOME_DIR) $(GITOPTS) clone -b $(XOS_BRANCH) $(XOS_GIT_URL)
+
+update_xos:
+	git -C $(XOS_DIR) pull
+
+cord_services: $(SERVICE_DIR) \
+	$(SERVICE_DIR)/exampleservice \
+	$(SERVICE_DIR)/fabric \
+	$(SERVICE_DIR)/hypercache \
+	$(SERVICE_DIR)/olt \
+	$(SERVICE_DIR)/onos-service \
+	$(SERVICE_DIR)/openstack \
+	$(SERVICE_DIR)/vrouter \
+	$(SERVICE_DIR)/vsg \
+	$(SERVICE_DIR)/vtn \
+	$(SERVICE_DIR)/vtr \
+	$(SERVICE_DIR)/metro-net
+
+$(SERVICE_DIR):
+	mkdir -p $(SERVICE_DIR)
+
+$(SERVICE_DIR)/exampleservice:
+	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(EXAMPLESERVICE_BRANCH) $(EXAMPLESERVICE_GIT_URL)
+
+$(SERVICE_DIR)/olt:
+	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(OLT_BRANCH) $(OLT_GIT_URL)
+
+$(SERVICE_DIR)/vsg:
+	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VSG_BRANCH) $(VSG_GIT_URL)
+
+$(SERVICE_DIR)/vtn:
+	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VTN_BRANCH) $(VTN_GIT_URL)
+
+$(SERVICE_DIR)/vrouter:
+	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VROUTER_BRANCH) $(VROUTER_GIT_URL)
+
+$(SERVICE_DIR)/vtr:
+	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VTR_BRANCH) $(VTR_GIT_URL)
+
+$(SERVICE_DIR)/onos-service:
+	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(ONOS_BRANCH) $(ONOS_GIT_URL)
+
+$(SERVICE_DIR)/fabric:
+	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(FABRIC_BRANCH) $(FABRIC_GIT_URL)
+
+$(SERVICE_DIR)/monitoring:
+	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(MONITORING_BRANCH) $(MONITORING_GIT_URL)
+
+$(SERVICE_DIR)/hypercache:
+	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(HYPERCACHE_BRANCH) $(HYPERCACHE_GIT_URL)
+
+$(SERVICE_DIR)/metro-net:
+	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(METRONETWORK_BRANCH) $(METRONETWORK_GIT_URL)
+
+$(SERVICE_DIR)/openstack:
+	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(OPENSTACK_BRANCH) $(OPENSTACK_GIT_URL)
+
+update_services:
+	git -C $(SERVICE_DIR)/exampleservice pull
+	git -C $(SERVICE_DIR)/olt pull
+	git -C $(SERVICE_DIR)/vsg pull
+	git -C $(SERVICE_DIR)/vtn pull
+	git -C $(SERVICE_DIR)/vrouter pull
+	git -C $(SERVICE_DIR)/vtr pull
+	git -C $(SERVICE_DIR)/onos-service pull
+	git -C $(SERVICE_DIR)/fabric pull
+	git -C $(SERVICE_DIR)/hypercache pull
+	git -C $(SERVICE_DIR)/metro-net pull
+	git -C $(SERVICE_DIR)/openstack pull
+
+# bootstrap the containers
+
+RUN_TOSCA_BOOTSTRAP ?= python $(COMMON_DIR)/run_tosca.py $(XOS_BOOTSTRAP_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD)
+RUN_TOSCA ?= python $(COMMON_DIR)/run_tosca.py $(XOS_UI_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD)
+
+bootstrap: $(BOOTSTRAP_YML) $(CONFIG_DIR)/xos.yaml
+	@echo "[BOOTSTRAP]"
+	@echo "XOS Image Build Date: `sudo docker inspect -f '{{ .Created }}' xosproject/xos`"
+	@echo "XOS Image Commit Hash: `sudo docker inspect -f '{{ .Config.Labels.XOS_GIT_COMMIT_HASH }}' xosproject/xos`"
+	@echo "XOS Image Commit Date: `sudo docker inspect -f '{{ .Config.Labels.XOS_GIT_COMMIT_DATE }}' xosproject/xos`"
+	sudo rm -f $(DOCKER_COMPOSE_YML)
+	sudo CONFIG_DIR=$(CONFIG_DIR) docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) up -d
+	bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_BOOTSTRAP_PORT)
+	sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py none - < $(COMMON_DIR)/tosca/fixtures.yaml
+	sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py none - < $(COMMON_DIR)/tosca/mydeployment.yaml
+	$(RUN_TOSCA_BOOTSTRAP) $(CONFIG_DIR)/xos.yaml
+
+
+# container creation targets
+
+local_containers: prereqs xos_download update_certs xos_base_c xos_devel_c synchronizer_c onboarding_synchronizer_c
+
+update_certs:
+	echo "" > $(XOS_DIR)/containers/xos/local_certs.crt
+	for CRT in $$(ls /usr/local/share/ca-certificates/*) ; do \
+	        echo Adding Certificate: $$CRT ;\
+	        cat $$CRT >> $(XOS_DIR)/containers/xos/local_certs.crt ;\
+	        echo "" >> $(XOS_DIR)/containers/xos/local_certs.crt ;\
+	done
+
+xos_base_c:
+	cd $(XOS_DIR)/containers/xos; make base
+
+xos_devel_c:
+	cd $(XOS_DIR)/containers/xos; make devel
+
+xos_test_c:
+	cd $(XOS_DIR)/containers/xos; make test
+
+synchronizer_c:
+	cd $(XOS_DIR)/containers/synchronizer; make
+
+onboarding_synchronizer_c:
+	cd $(XOS_DIR)/containers/onboarding_synchronizer; make
+
+
+# utilties/convenience targets
+cleanup: stop rm
+	$(CONFIG_DIR)/cleanup.sh
+	bash -c "source ./admin-openrc.sh; nova list --all-tenants; neutron net-list"
+
+cleanup_services: $(SERVICE_DIR)
+	rm -rf $(SERVICE_DIR)/*
+
+rebuild:
+	bash $(COMMON_DIR)/rebuild.sh $(XOS_BOOTSTRAP_PORT)
+	bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
+
+stop:
+	test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) stop
+	sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) stop
+
+rm: stop
+	test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) rm -f
+	sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) rm -f
+	[ -n "$(shell docker images -f \"dangling=true\" -q)" ] && docker rmi $(shell docker images -f "dangling=true" -q) || true
+
+ps:
+	sudo docker ps
+
+showlogs_bootstrap:
+	sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) logs -f
+
+showlogs:
+	sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) logs -f
+
+enter-ui:
+	sudo docker exec -ti $(DOCKER_PROJECT)_xos_ui_1 bash
+
+enter-bootstrap-ui:
+	sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_bootstrap_ui_1 bash
+
+enter-db:
+	sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_db_1 bash
+
+django-restart:
+	sudo docker exec $(DOCKER_PROJECT)_xos_ui_1 touch /opt/xos/xos/settings.py
+
diff --git a/common/Makefile.containers b/common/Makefile.containers
deleted file mode 100644
index 0db49d6..0000000
--- a/common/Makefile.containers
+++ /dev/null
@@ -1,26 +0,0 @@
-include ../common/Makedefs
-
-local_containers: xos_devel synchronizer onboarding_synchronizer
-
-xos_devel:
-	cd $(XOS_DIR)/containers/xos; make devel
-
-xos_base:
-	cd $(XOS_DIR)/containers/xos; make base
-
-xos_test:
-	cd $(XOS_DIR)/containers/xos; make test
-
-synchronizer:
-	cd $(XOS_DIR)/containers/synchronizer; make
-
-onboarding_synchronizer:
-	cd $(XOS_DIR)/containers/onboarding_synchronizer; make
-
-update_certs:
-	echo "" > $(XOS_DIR)/containers/xos/local_certs.crt
-	for CRT in $$(ls /usr/local/share/ca-certificates/*) ; do \
-	        echo Adding Certificate: $$CRT ;\
-	        cat $$CRT >> $(XOS_DIR)/containers/xos/local_certs.crt ;\
-	        echo "" >> $(XOS_DIR)/containers/xos/local_certs.crt ;\
-	done
diff --git a/common/Makefile.prereqs b/common/Makefile.prereqs
deleted file mode 100644
index cbe047b..0000000
--- a/common/Makefile.prereqs
+++ /dev/null
@@ -1,56 +0,0 @@
-UBUNTU:=$(shell which apt > /dev/null 2>&1; echo $$?)
-
-ifeq ($(UBUNTU),0)
-
-# ******************* apt-based distros ***************************
-prereqs: /usr/bin/http docker /usr/bin/curl /usr/local/bin/docker-compose
-
-/usr/bin/http:
-	sudo apt-get -y install httpie
-
-/usr/bin/curl:
-	sudo apt-get -y install curl
-
-docker:
-	which docker > /dev/null || wget -qO- https://get.docker.com/ | sh
-	sudo usermod -aG docker $(shell whoami)
-
-else
-
-# ****************** RPM-based distros ******************
-
-# (untested / work-in-progress)
-
-prereqs: /usr/bin/pip /usr/bin/http docker /usr/local/bin/docker-compose
-
-/usr/bin/pip:
-	curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
-	sudo python ./get-pip.py
-
-docker:
-	which docker > /dev/null || wget -qO- https://get.docker.com/ | sh
-	sudo usermod -aG docker $(shell whoami)
-
-/usr/bin/http:
-	sudo pip install httpie
-
-endif
-
-/usr/local/bin/docker-compose:
-	sudo bash -c "curl -L https://github.com/docker/compose/releases/download/1.5.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose"
-	sudo chmod +x /usr/local/bin/docker-compose
-
-rebuild_docker:
-	stat docker_build || git clone https://github.com/dotcloud/docker.git docker_build
-	sudo make -C docker_build build
-	sudo make -C docker_build binary
-	sudo service docker stop
-	sudo mv /usr/bin/docker /usr/bin/docker-old
-	sudo cp docker_build/bundles/latest/binary-client/docker /usr/bin/
-	sudo cp docker_build/bundles/latest/binary-daemon/dockerd /usr/bin/
-	sudo cp docker_build/bundles/latest/binary-daemon/docker-containerd /usr/bin/
-	sudo cp docker_build/bundles/latest/binary-daemon/docker-containerd-shim /usr/bin/
-	sudo cp docker_build/bundles/latest/binary-daemon/docker-containerd-ctr /usr/bin/
-	sudo cp docker_build/bundles/latest/binary-daemon/docker-runc /usr/bin/
-	sudo cp docker_build/bundles/latest/binary-daemon/docker-proxy /usr/bin/
-	sudo service docker start
diff --git a/common/Makefile.services b/common/Makefile.services
deleted file mode 100644
index 89f7631..0000000
--- a/common/Makefile.services
+++ /dev/null
@@ -1,81 +0,0 @@
-include ../common/Makedefs
-
-GITOPTS=-c advice.detachedHead=false
-
-services: $(SERVICE_DIR) \
-          $(SERVICE_DIR)/exampleservice \
-          $(SERVICE_DIR)/olt \
-          $(SERVICE_DIR)/vsg \
-          $(SERVICE_DIR)/vtn \
-          $(SERVICE_DIR)/vrouter \
-          $(SERVICE_DIR)/vtr \
-          $(SERVICE_DIR)/onos-service \
-          $(SERVICE_DIR)/fabric \
-          $(SERVICE_DIR)/hypercache \
-          $(SERVICE_DIR)/metro-net \
-          $(SERVICE_DIR)/openstack
-
-monitoring_services: $(SERVICE_DIR)/monitoring
-
-xos_core: $(XOS_DIR)
-
-$(XOS_DIR):
-	git -C ../.. $(GITOPTS) clone -b $(XOS_BRANCH) $(XOS_GIT_URL)
-
-update_xos:
-	git -C $(XOS_DIR) pull
-
-$(SERVICE_DIR):
-	mkdir -p $(SERVICE_DIR)
-
-$(SERVICE_DIR)/exampleservice:
-	git -C $(SERVICE_DIR) $(GITOPTS) clone  -b $(EXAMPLESERVICE_BRANCH) $(EXAMPLESERVICE_GIT_URL)
-
-$(SERVICE_DIR)/olt:
-	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(OLT_BRANCH) $(OLT_GIT_URL)
-
-$(SERVICE_DIR)/vsg:
-	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VSG_BRANCH) $(VSG_GIT_URL)
-
-$(SERVICE_DIR)/vtn:
-	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VTN_BRANCH) $(VTN_GIT_URL)
-
-$(SERVICE_DIR)/vrouter:
-	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VROUTER_BRANCH) $(VROUTER_GIT_URL)
-
-$(SERVICE_DIR)/vtr:
-	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VTR_BRANCH) $(VTR_GIT_URL)
-
-$(SERVICE_DIR)/onos-service:
-	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(ONOS_BRANCH) $(ONOS_GIT_URL)
-
-$(SERVICE_DIR)/fabric:
-	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(FABRIC_BRANCH) $(FABRIC_GIT_URL)
-
-$(SERVICE_DIR)/monitoring:
-	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(MONITORING_BRANCH) $(MONITORING_GIT_URL)
-
-$(SERVICE_DIR)/hypercache:
-	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(HYPERCACHE_BRANCH) $(HYPERCACHE_GIT_URL)
-
-$(SERVICE_DIR)/metro-net:
-	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(METRONETWORK_BRANCH) $(METRONETWORK_GIT_URL)
-
-$(SERVICE_DIR)/openstack:
-	git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(OPENSTACK_BRANCH) $(OPENSTACK_GIT_URL)
-
-cleanup:
-	rm -rf $(SERVICE_DIR)/*
-
-update:
-	git -C $(SERVICE_DIR)/exampleservice pull
-	git -C $(SERVICE_DIR)/olt pull
-	git -C $(SERVICE_DIR)/vsg pull
-	git -C $(SERVICE_DIR)/vtn pull
-	git -C $(SERVICE_DIR)/vrouter pull
-	git -C $(SERVICE_DIR)/vtr pull
-	git -C $(SERVICE_DIR)/onos-service pull
-	git -C $(SERVICE_DIR)/fabric pull
-	git -C $(SERVICE_DIR)/hypercache pull
-	git -C $(SERVICE_DIR)/metro-net pull
-	git -C $(SERVICE_DIR)/openstack pull
diff --git a/common/base.yaml b/common/tosca/base.yaml
similarity index 100%
rename from common/base.yaml
rename to common/tosca/base.yaml
diff --git a/common/cloudlab-openstack.yaml b/common/tosca/cloudlab-openstack.yaml
similarity index 100%
rename from common/cloudlab-openstack.yaml
rename to common/tosca/cloudlab-openstack.yaml
diff --git a/common/tosca/cord-volt-devices.yaml b/common/tosca/cord-volt-devices.yaml
new file mode 100644
index 0000000..8b41623
--- /dev/null
+++ b/common/tosca/cord-volt-devices.yaml
@@ -0,0 +1,47 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Just enough Tosca to get the vSG slice running on the CORD POD
+
+imports:
+   - custom_types/xos.yaml
+
+topology_template:
+  node_templates:
+    service#volt:
+      type: tosca.nodes.VOLTService
+      properties:
+          no-create: True
+          no-delete: True
+          no-update: True
+
+    voltdev-1:
+      type: tosca.nodes.VOLTDevice
+      properties:
+            driver: pmc-olt
+            openflow_id: of:1000000000000001
+            access_devices: >
+              2 222,
+              3 223,
+              4 224
+      requirements:
+          - volt_service:
+              node: service#volt
+              relationship: tosca.relationships.MemberOfService
+          - access_agent:
+              node: agent-1
+              relationship: tosca.relationships.UsesAgent
+
+    agent-1:
+      type: tosca.nodes.AccessAgent
+      properties:
+          mac: AA:BB:CC:DD:EE:FF
+          port_mappings: >
+            of:0000000000000002/2 DE:AD:BE:EF:BA:11,
+            of:0000000000000002/3 BE:EF:DE:AD:BE:EF
+      requirements:
+          - volt_service:
+              node: service#volt
+              relationship: tosca.relationships.MemberOfService
+
+
+
diff --git a/common/disable-onboarding.yaml b/common/tosca/disable-onboarding.yaml
similarity index 100%
rename from common/disable-onboarding.yaml
rename to common/tosca/disable-onboarding.yaml
diff --git a/common/enable-onboarding.yaml b/common/tosca/enable-onboarding.yaml
similarity index 100%
rename from common/enable-onboarding.yaml
rename to common/tosca/enable-onboarding.yaml
diff --git a/common/fixtures.yaml b/common/tosca/fixtures.yaml
similarity index 100%
rename from common/fixtures.yaml
rename to common/tosca/fixtures.yaml
diff --git a/common/tosca/mgmt-net.yaml b/common/tosca/mgmt-net.yaml
new file mode 100644
index 0000000..b45f0d5
--- /dev/null
+++ b/common/tosca/mgmt-net.yaml
@@ -0,0 +1,64 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Set up management network for CORD POD
+imports:
+   - custom_types/xos.yaml
+
+topology_template:
+  node_templates:
+
+    management_template:
+      type: tosca.nodes.NetworkTemplate
+      properties:
+          visibility: private
+          translation: none
+          vtn_kind: MANAGEMENT_LOCAL
+
+    management:
+      type: tosca.nodes.network.Network
+      properties:
+          ip_version: 4
+          cidr: 172.27.0.0/24
+      requirements:
+          - network_template:
+              node: management_template
+              relationship: tosca.relationships.UsesNetworkTemplate
+          - owner:
+              node: mysite_management
+              relationship: tosca.relationships.MemberOfSlice
+
+    management_hosts_template:
+      type: tosca.nodes.NetworkTemplate
+      properties:
+          visibility: private
+          translation: none
+          vtn_kind: MANAGEMENT_HOST
+
+#    management_hosts:
+#      type: tosca.nodes.network.Network
+#      properties:
+#          ip_version: 4
+#          cidr: 10.1.0.0/24
+#          start_ip: 10.1.0.128
+#          end_ip: 10.1.0.254
+#      requirements:
+#          - network_template:
+#              node: management_hosts_template
+#              relationship: tosca.relationships.UsesNetworkTemplate
+#          - owner:
+#              node: mysite_management
+#              relationship: tosca.relationships.MemberOfSlice
+
+    mysite:
+      type: tosca.nodes.Site
+
+    mysite_management:
+      description: This slice exists solely to own the management network
+      type: tosca.nodes.Slice
+      properties:
+          network: noauto
+      requirements:
+          - site:
+              node: mysite
+              relationship: tosca.relationships.MemberOfSite
+
diff --git a/common/mydeployment.yaml b/common/tosca/mydeployment.yaml
similarity index 100%
rename from common/mydeployment.yaml
rename to common/tosca/mydeployment.yaml
diff --git a/common/tosca/setup.yaml b/common/tosca/setup.yaml
new file mode 100644
index 0000000..20b1b12
--- /dev/null
+++ b/common/tosca/setup.yaml
@@ -0,0 +1,60 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: >
+    * Adds OpenCloud Sites, Deployments, and Controllers.
+
+imports:
+   - custom_types/xos.yaml
+
+topology_template:
+  node_templates:
+
+    MyDeployment:
+      type: tosca.nodes.Deployment
+      properties:
+          flavors: m1.large, m1.medium, m1.small
+
+    MyOpenStack:
+      type: tosca.nodes.Controller
+      requirements:
+          - deployment:
+              node: MyDeployment
+              relationship: tosca.relationships.ControllerDeployment
+      properties:
+          backend_type: OpenStack
+          version: Kilo
+          auth_url: { get_script_env: [ SELF, adminrc, OS_AUTH_URL, LOCAL_FILE] }
+          admin_user: { get_script_env: [ SELF, adminrc, OS_USERNAME, LOCAL_FILE] }
+          admin_password: { get_script_env: [ SELF, adminrc, OS_PASSWORD, LOCAL_FILE] }
+          admin_tenant: { get_script_env: [ SELF, adminrc, OS_TENANT_NAME, LOCAL_FILE] }
+          domain: Default
+      artifacts:
+          adminrc: /root/setup/admin-openrc.sh
+
+    mysite:
+      type: tosca.nodes.Site
+      properties:
+          display_name: MySite
+          site_url: http://xosproject.org/
+      requirements:
+          - deployment:
+               node: MyDeployment
+               relationship: tosca.relationships.MemberOfDeployment
+          - controller:
+               node: MyOpenStack
+               relationship: tosca.relationships.UsesController
+
+    # This user already exists in XOS with this password
+    # It's an example of how to create new users
+    padmin@vicci.org:
+      type: tosca.nodes.User
+      requirements:
+          - site:
+              node: mysite
+              relationship: tosca.relationships.MemberOfSite
+      properties:
+          is_admin: true
+          is_active: true
+          firstname: XOS
+          lastname: admin
+          password: letmein
diff --git a/common/wait_for_xos.sh b/common/wait_for_xos.sh
deleted file mode 100644
index afffb86..0000000
--- a/common/wait_for_xos.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#! /bin/bash
-echo "Waiting for XOS to come up"
-until http 0.0.0.0:9999 &> /dev/null
-do
-    sleep 1
-    echo -ne "."
-    RUNNING_CONTAINER=`sudo docker ps|grep "xos"|awk '{print $$NF}'`
-    if [[ $RUNNING_CONTAINER == "" ]]; then
-        echo Container may have failed. check with \"make showlogs\'
-        exit 1
-    fi
-done
-echo "XOS is ready"