Merge branch 'master' into configure_refactored_containers
diff --git a/xos/configurations/common/Makefile.cloudlab b/xos/configurations/common/Makefile.cloudlab
index 4646fd6..2cf9fcb 100644
--- a/xos/configurations/common/Makefile.cloudlab
+++ b/xos/configurations/common/Makefile.cloudlab
@@ -3,36 +3,39 @@
 $(error MYFLATLANIF is empty)
 endif
 MYFLATLANIP:=$(shell ifconfig $(MYFLATLANIF) | grep "inet addr" | awk -F: '{print $$2}' | awk '{print $$1}' )
+SETUPDIR:=./setup
 
-all: prereqs admin-openrc flat_name nodes_yaml public_key private_key ceilometer_url node_key
+all: prereqs admin-openrc flat_name nodes_yaml public_key private_key ceilometer_url other_keys
 
 prereqs:
 	make -f Makefile.prereqs
+	mkdir -p $(SETUPDIR)
 
 admin-openrc:
-	sudo cat /root/setup/admin-openrc.sh > admin-openrc.sh
-	sudo cat /root/setup/settings > controller_settings
-	echo 'CONTROLLER_FLAT_LAN_IP=$(MYFLATLANIP)' >> controller_settings
+	sudo cat /root/setup/admin-openrc.sh > $(SETUPDIR)/admin-openrc.sh
+	sudo cat /root/setup/settings > $(SETUPDIR)/controller_settings
+	echo 'CONTROLLER_FLAT_LAN_IP=$(MYFLATLANIP)' >> $(SETUPDIR)/controller_settings
 
 flat_name:
-	sudo bash -c "source /root/setup/admin-openrc.sh ; neutron net-list" |grep flat|awk '{printf "%s",$$4}' > flat_net_name
-	[ -s flat_net_name ] # throw error if flat_net_name is empty
+	bash -c "source $(SETUPDIR)/admin-openrc.sh ; neutron net-list" |grep flat|awk '{printf "%s",$$4}' > $(SETUPDIR)/flat_net_name
+	[ -s $(SETUPDIR)/flat_net_name ] # throw error if flat_net_name is empty
 
 nodes_yaml:
-	bash ./make-nodes-yaml.sh
+	bash ./make-nodes-yaml.sh > $(SETUPDIR)/nodes.yaml
 
 ceilometer_url:
-	echo http://`hostname -i`/xosmetering/ > ceilometer_url
+	echo http://`hostname -i`/xosmetering/ > $(SETUPDIR)/ceilometer_url
 
 public_key: ~/.ssh/id_rsa.pub
-	cp ~/.ssh/id_rsa.pub .
+	cp ~/.ssh/id_rsa.pub $(SETUPDIR)
 
 private_key: ~/.ssh/id_rsa
-	cp ~/.ssh/id_rsa .
+	cp ~/.ssh/id_rsa $(SETUPDIR)
 
 ~/.ssh/id_rsa.pub:
 	cat /dev/zero | ssh-keygen -q -N ""
 
-node_key:
-	sudo cat /root/setup/id_rsa > node_key
-	sudo cat /root/setup/id_rsa.pub > node_key.pub
+other_keys: public_key private_key
+	sudo cat /root/setup/id_rsa > $(SETUPDIR)/node_key
+	sudo cat /root/setup/id_rsa.pub > $(SETUPDIR)/node_key.pub
+	sudo cat /root/setup/id_rsa.pub > $(SETUPDIR)/padmin_public_key
diff --git a/xos/configurations/common/Makefile.devstack b/xos/configurations/common/Makefile.devstack
index f969b3d..3ba71ae 100644
--- a/xos/configurations/common/Makefile.devstack
+++ b/xos/configurations/common/Makefile.devstack
@@ -1,38 +1,40 @@
 # This shouldn't be hardcoded
 DEVSTACK_ROOT:=~/devstack
+SETUPDIR:=./setup
 
 all: prereqs admin-openrc flat_name nodes_yaml public_key private_key ceilometer_url node_key net_fix
 
 prereqs:
 	make -f Makefile.prereqs
 	sudo pip install httpie --upgrade
+	mkdir -p $(SETUPDIR)
 
 admin-openrc:
-	bash ./devstack-creds.sh $(DEVSTACK_ROOT) > admin-openrc.sh
-	touch controller_settings
+	bash ./devstack-creds.sh $(DEVSTACK_ROOT) > $(SETUPDIR)/admin-openrc.sh
+	touch $(SETUPDIR)/controller_settings
 
 flat_name:
-	echo private|tr -d '\n' > flat_net_name
+	echo private|tr -d '\n' > $(SETUPDIR)/flat_net_name
 	bash -c "source admin-openrc.sh; openstack network set --share private"
 
 nodes_yaml:
-	bash ./make-nodes-yaml.sh
+	bash ./make-nodes-yaml.sh > $(SETUPDIR)/nodes.yaml
 
 ceilometer_url:
-	echo http://`hostname -i`/xosmetering/ > ceilometer_url
+	echo http://`hostname -i`/xosmetering/ > $(SETUPDIR)/ceilometer_url
 
 public_key: ~/.ssh/id_rsa.pub
-	cp ~/.ssh/id_rsa.pub .
+	cp ~/.ssh/id_rsa.pub $(SETUPDIR)
 
 private_key: ~/.ssh/id_rsa
-	cp ~/.ssh/id_rsa .
+	cp ~/.ssh/id_rsa $(SETUPDIR)
 
 ~/.ssh/id_rsa.pub:
 	cat /dev/zero | ssh-keygen -q -N ""
 
 node_key:
-	sudo cat ~/.ssh/id_rsa > node_key
-	sudo cat ~/.ssh/id_rsa.pub > node_key.pub
+	sudo cat ~/.ssh/id_rsa > $(SETUPDIR)/node_key
+	sudo cat ~/.ssh/id_rsa.pub > $(SETUPDIR)/node_key.pub
 
 net_fix:
 	sudo devstack/net-fix.sh
diff --git a/xos/configurations/common/Makefile.opencloud b/xos/configurations/common/Makefile.opencloud
index 8bc5b93..f1ed944 100644
--- a/xos/configurations/common/Makefile.opencloud
+++ b/xos/configurations/common/Makefile.opencloud
@@ -1,36 +1,40 @@
-MYFLATLANIP:=$(shell hostname -i)
+MYFLATLANIF:=$(shell netstat -i |grep "flat"|awk '{print $$1}' )
+MYFLATLANIP:=$(shell ifconfig $(MYFLATLANIF) | grep "inet addr" | awk -F: '{print $$2}' | awk '{print $$1}' )
+SETUPDIR:=./setup
 
-all: prereqs admin-openrc flat_name nodes_yaml public_key private_key ceilometer_url node_key images
+all: prereqs admin-openrc flat_name nodes_yaml public_key private_key ceilometer_url node_key
 
 prereqs:
 	make -f Makefile.prereqs
+	mkdir -p $(SETUPDIR)
 
 admin-openrc:
-	sudo cat /root/setup/admin-openrc.sh > admin-openrc.sh
-	sudo cat /root/setup/settings > controller_settings
-	echo 'CONTROLLER_FLAT_LAN_IP=$(MYFLATLANIP)' >> controller_settings
+	sudo cat /root/setup/admin-openrc.sh > $(SETUPDIR)/admin-openrc.sh
+	sudo cat /root/setup/settings > $(SETUPDIR)/controller_settings
+	echo 'CONTROLLER_FLAT_LAN_IP=$(MYFLATLANIP)' >> $(SETUPDIR)/controller_settings
 
 flat_name:
-	echo nat-net|tr -d '\n' > flat_net_name
+	sudo bash -c "source /root/setup/admin-openrc.sh ; neutron net-list" |grep flat|awk '{printf "%s",$$4}' > $(SETUPDIR)/flat_net_name
+	[ -s $(SETUPDIR)/flat_net_name ] # throw error if flat_net_name is empty
 
 nodes_yaml:
-	bash ./make-nodes-yaml.sh
+	bash ./make-nodes-yaml.sh > $(SETUPDIR)/nodes.yaml
 
 ceilometer_url:
-	echo http://`hostname -i`/xosmetering/ > ceilometer_url
+	echo http://`hostname -i`/xosmetering/ > $(SETUPDIR)/ceilometer_url
 
 public_key: ~/.ssh/id_rsa.pub
-	cp ~/.ssh/id_rsa.pub .
+	cp ~/.ssh/id_rsa.pub $(SETUPDIR)
 
 private_key: ~/.ssh/id_rsa
-	cp ~/.ssh/id_rsa .
+	cp ~/.ssh/id_rsa $(SETUPDIR)
 
 ~/.ssh/id_rsa.pub:
 	cat /dev/zero | ssh-keygen -q -N ""
 
 node_key:
-	sudo cat /root/setup/id_rsa > node_key
-	sudo cat /root/setup/id_rsa.pub > node_key.pub
+	sudo cat /root/setup/id_rsa > $(SETUPDIR)/node_key
+	sudo cat /root/setup/id_rsa.pub > $(SETUPDIR)/node_key.pub
 
 images:
 	source admin-openrc.sh; glance image-show trusty-server-multi-nic || glance image-create --name trusty-server-multi-nic --disk-format qcow2 --file /proj/xos-PG0/acb/images/trusty-server-multi-nic.img --container-format bare
diff --git a/xos/configurations/common/Makefile.prereqs b/xos/configurations/common/Makefile.prereqs
index 0325224..fce51be 100644
--- a/xos/configurations/common/Makefile.prereqs
+++ b/xos/configurations/common/Makefile.prereqs
@@ -3,11 +3,14 @@
 ifeq ($(UBUNTU),0)
 
 # ******************* apt-based distros ***************************
-prereqs: /usr/bin/http docker
+prereqs: /usr/bin/http docker /usr/bin/curl /usr/local/bin/docker-compose
 
-/usr/bin/http: 
+/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)
@@ -18,11 +21,11 @@
 
 # (untested / work-in-progress)
 
-prereqs: /usr/bin/pip /usr/bin/http docker
+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     
+	sudo python ./get-pip.py
 
 docker:
 	which docker > /dev/null || wget -qO- https://get.docker.com/ | sh
@@ -32,3 +35,7 @@
 	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
diff --git a/xos/configurations/common/make-nodes-yaml.sh b/xos/configurations/common/make-nodes-yaml.sh
index eafab4a..ef84c68 100644
--- a/xos/configurations/common/make-nodes-yaml.sh
+++ b/xos/configurations/common/make-nodes-yaml.sh
@@ -1,8 +1,6 @@
-FN=nodes.yaml
+#!/bin/sh
 
-rm -f $FN
-
-cat >> $FN <<EOF
+cat <<EOF
 tosca_definitions_version: tosca_simple_yaml_1_0
 
 imports:
@@ -18,11 +16,11 @@
         type: tosca.nodes.Site
 EOF
 
-NODES=$( bash -c "source ./admin-openrc.sh ; nova hypervisor-list" |grep enabled|awk '{print $4}' )
+NODES=$( bash -c "source ./setup/admin-openrc.sh ; nova hypervisor-list" |grep enabled|awk '{print $4}' )
 I=0
 for NODE in $NODES; do
-    echo $NODE
-    cat >> $FN <<EOF
+    # echo $NODE
+    cat <<EOF
     $NODE:
       type: tosca.nodes.Node
       requirements:
diff --git a/xos/configurations/devel/Dockerfile.devel b/xos/configurations/devel/Dockerfile.devel
deleted file mode 100644
index 85b661d..0000000
--- a/xos/configurations/devel/Dockerfile.devel
+++ /dev/null
@@ -1,14 +0,0 @@
-RUN mkdir -p /root/setup
-ADD xos/configurations/common/admin-openrc.sh /root/setup/
-ADD xos/configurations/common/controller_settings /root/setup/
-ADD xos/configurations/common/flat_net_name /root/setup/
-ADD xos/configurations/common/nodes.yaml /opt/xos/configurations/commmon/
-ADD xos/configurations/common/id_rsa.pub /root/setup/padmin_public_key
-ADD xos/configurations/common/id_rsa /opt/xos/observers/helloworldservice_complete/helloworldservice_private_key
-ADD xos/configurations/common/node_key.pub /root/setup/node_key.pub
-ADD xos/configurations/common/node_key /root/setup/node_key
-ADD xos/configurations/common/ceilometer_url /root/setup/ceilometer_url
-
-CMD /usr/bin/make -C /opt/xos/configurations/devel -f Makefile.inside; /bin/bash
-
-#CMD ["/bin/bash"]
diff --git a/xos/configurations/devel/Makefile b/xos/configurations/devel/Makefile
index f33479f..db78402 100644
--- a/xos/configurations/devel/Makefile
+++ b/xos/configurations/devel/Makefile
@@ -1,21 +1,14 @@
 MYIP:=$(shell hostname -i)
-RUNNING_CONTAINER:=$(shell sudo docker ps|grep "xos"|awk '{print $$NF}')
-LAST_CONTAINER=$(shell sudo docker ps -l -q)
 
 cloudlab: common_cloudlab xos
 
-devstack: common_devstack xos
-
-opencloud: common_opencloud xos
+devstack: upgrade_pkgs common_devstack devstack_net_fix xos
 
 xos:
-	rm ../../xos_configuration/*
-	cp ../common/xos_common_config ../../xos_configuration/
-	echo "# Autogenerated -- do not edit" > Dockerfile
-	cat ../common/Dockerfile.common Dockerfile.devel >> Dockerfile
-	cd ../../..; sudo docker build -t xosproject/xos-devel -f xos/configurations/devel/Dockerfile .
-	sudo docker run -d --add-host="ctl:$(MYIP)" -p 9999:8000 xosproject/xos-devel
+	sudo MYIP=$(MYIP) docker-compose up -d
 	bash ../common/wait_for_xos.sh
+	sudo MYIP=$(MYIP) docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/common/base.yaml
+	sudo MYIP=$(MYIP) docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /root/setup/nodes.yaml
 
 common_cloudlab:
 	make -C ../common -f Makefile.cloudlab
@@ -23,14 +16,15 @@
 common_devstack:
 	make -C ../common -f Makefile.devstack
 
-common_opencloud:
-	make -C ../common -f Makefile.opencloud
-
 stop:
-	sudo docker stop $(RUNNING_CONTAINER)
+	sudo MYIP=$(MYIP) docker-compose stop
 
 showlogs:
-	sudo docker logs $(LAST_CONTAINER)
+	sudo MYIP=$(MYIP) docker-compose logs
 
-enter:
-	sudo docker exec -t -i $(RUNNING_CONTAINER) bash
+devstack_net_fix:
+	sudo ../devstack/net-fix.sh
+	sudo bash -c "source ../common/admin-openrc.sh; neutron subnet-update private-subnet --dns-nameservers list=true 8.8.8.8 8.8.4.4"
+
+upgrade_pkgs:
+	sudo pip install httpie --upgrade
diff --git a/xos/configurations/devel/Makefile.inside b/xos/configurations/devel/Makefile.inside
deleted file mode 100644
index fb9433c..0000000
--- a/xos/configurations/devel/Makefile.inside
+++ /dev/null
@@ -1,9 +0,0 @@
-all: setup_xos run_develserver
-
-setup_xos:
-	bash /opt/xos/scripts/docker_setup_xos
-	python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/common/base.yaml
-	python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/common/nodes.yaml
-
-run_develserver:
-	cd /opt/xos; python manage.py runserver 0.0.0.0:8000 --insecure
diff --git a/xos/configurations/devel/README.md b/xos/configurations/devel/README.md
index d877a39..dd4c12a 100644
--- a/xos/configurations/devel/README.md
+++ b/xos/configurations/devel/README.md
@@ -1,8 +1,8 @@
 # XOS development environment
 
 This configuration can be used to do basic end-to-end development of XOS.  It launches
-an XOS container, runs the XOS develserver, and configures XOS to talk to an OpenStack
-backend.  
+XOS in three Docker containers (development GUI, Synchronizer, database) and configures XOS
+to talk to an OpenStack backend.  
 
 ## How to run it
 
diff --git a/xos/configurations/devel/docker-compose.yml b/xos/configurations/devel/docker-compose.yml
new file mode 100644
index 0000000..03f7aaf
--- /dev/null
+++ b/xos/configurations/devel/docker-compose.yml
@@ -0,0 +1,32 @@
+xos_db:
+    image: xosproject/xos-postgres
+    expose:
+        - "5432"
+
+xos_synchronizer_openstack:
+    image: xosproject/xos-synchronizer-openstack
+    labels:
+        org.xosproject.kind: synchronizer
+        org.xosproject.target: openstack
+    links:
+        - xos_db
+    extra_hosts:
+      - ctl:${MYIP}
+
+# FUTURE
+#xos_swarm_synchronizer:
+#    image: xosproject/xos-swarm-synchronizer
+#    labels:
+#        org.xosproject.kind: synchronizer
+#        org.xosproject.target: swarm
+
+xos:
+    image: xosproject/xos
+    command: python /opt/xos/manage.py runserver 0.0.0.0:8000 --insecure --makemigrations
+    ports:
+        - "9999:8000"
+    links:
+        - xos_db
+    volumes:
+      - ../common/setup:/root/setup:ro
+      - ../common/xos_common_config:/opt/xos/xos_configuration/xos_common_config:ro