Merge branch 'master' of github.com:open-cloud/xos
diff --git a/Dockerfile b/Dockerfile
index 45de0df..1d296fd 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -58,6 +58,7 @@
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python-setuptools
RUN easy_install django_evolution
RUN easy_install python_gflags
+RUN easy_install --upgrade httplib2
RUN easy_install google_api_python_client
# Install custom Ansible
@@ -116,6 +117,8 @@
# git clone uses cached copy, doesn't pick up latest
RUN git -C /opt/ansible pull
+RUN git -C /opt/ansible/lib/ansible/modules/core pull
+RUN git -C /opt/ansible/v2/ansible/modules/core pull
EXPOSE 8000
diff --git a/xos/observers/vcpe/files/vcpe.conf b/xos/observers/vcpe/files/vcpe.conf
new file mode 100644
index 0000000..752c57a
--- /dev/null
+++ b/xos/observers/vcpe/files/vcpe.conf
@@ -0,0 +1,10 @@
+# Upstart script for vCPE
+description "vCPE container"
+author "andy@onlab.us"
+start on filesystem and started docker
+stop on runlevel [!2345]
+respawn
+
+script
+ /usr/local/sbin/start-vcpe.sh
+end script
diff --git a/xos/observers/vcpe/steps/sync_vcpetenant.yaml b/xos/observers/vcpe/steps/sync_vcpetenant.yaml
index 92da2cc..91499af 100644
--- a/xos/observers/vcpe/steps/sync_vcpetenant.yaml
+++ b/xos/observers/vcpe/steps/sync_vcpetenant.yaml
@@ -46,12 +46,6 @@
dest=/usr/local/bin/pipework
mode=0755
- - name: bring up LAN interface
- shell: ifconfig eth2 up
-
- - name: bring up WAN interface
- shell: ifconfig eth3 up
-
- name: make sure /etc/dnsmasq.d exists
file: path=/etc/dnsmasq.d state=directory owner=root group=root
@@ -64,29 +58,14 @@
- name: firewall info
template: src=/opt/xos/observers/vcpe/templates/firewall_sample.j2 dest=/etc/firewall_sample owner=root group=root
- - name: Make sure iptables module loaded
- shell: "iptables -L > /dev/null"
-
- - name: Make sure ip6tables module loaded
- shell: "ip6tables -L > /dev/null"
-
- name: Disable resolvconf updates (to avoid overwriting /etc/resolv.conf on host)
shell: service resolvconf disable-updates
- - name: spin up container
- docker: name=vcpe
- image=andybavier/docker-vcpe
- net=none
- privileged=yes
+ - name: vCPE startup script
+ template: src=/opt/xos/observers/vcpe/templates/start-vcpe.sh.j2 dest=/usr/local/sbin/start-vcpe.sh mode=0755
- # This needs attention once ONOS is integrated
- - name: Connect container to WAN network
- shell: docker exec vcpe ifconfig eth0 >> /dev/null || pipework eth3 -i eth0 vcpe 10.1.2.3/24
+ - name: vCPE upstart
+ copy: src=/opt/xos/observers/vcpe/files/vcpe.conf dest=/etc/init/vcpe.conf
- # Only uses the first vlan_id
- - name: Connect container to LAN network, VLAN {{ vlan_ids[0] }}
- shell: docker exec vcpe ifconfig eth1 >> /dev/null || pipework eth2 -i eth1 vcpe 192.168.0.1/24 @{{ vlan_ids[0] }}
-
- - name: Start container services
- shell: docker exec vcpe service dnsmasq start
-
+ - name: Start vCPE service
+ service: name=vcpe state=started
diff --git a/xos/observers/vcpe/templates/start-vcpe.sh.j2 b/xos/observers/vcpe/templates/start-vcpe.sh.j2
new file mode 100755
index 0000000..a9a8e88
--- /dev/null
+++ b/xos/observers/vcpe/templates/start-vcpe.sh.j2
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+iptables -L > /dev/null
+ip6tables -L > /dev/null
+
+docker inspect vcpe > /dev/null 2>&1
+if [ "$?" == 1 ]
+then
+ docker run -d --name=vcpe --privileged=true --net=none andybavier/docker-vcpe
+else
+ docker start vcpe
+fi
+
+# Set up networking via pipework
+docker exec vcpe ifconfig eth0 >> /dev/null || pipework eth3 -i eth0 vcpe 10.1.2.99/24
+docker exec vcpe ifconfig eth1 >> /dev/null || pipework eth2 -i eth1 vcpe 192.168.0.1/24 @{{ vlan_ids[0] }}
+
+# Now can start up dnsmasq
+docker exec vcpe service dnsmasq start
+
+# Attach to container
+docker start -a vcpe