Changes to support multiple vCPEs per VM
diff --git a/xos/observers/vcpe/steps/sync_vcpetenant.yaml b/xos/observers/vcpe/steps/sync_vcpetenant.yaml
index d924941..1ae4b09 100644
--- a/xos/observers/vcpe/steps/sync_vcpetenant.yaml
+++ b/xos/observers/vcpe/steps/sync_vcpetenant.yaml
@@ -31,6 +31,7 @@
private_ip: {{ private_ip }}
hpc_client_ip: {{ hpc_client_ip }}
wan_mac: {{ wan_mac }}
+ vcpe_name: vcpe-{{ vlan_ids[0] }}
tasks:
{% if full_setup %}
@@ -63,27 +64,30 @@
- name: Disable resolvconf updates (to avoid overwriting /etc/resolv.conf on host)
shell: service resolvconf disable-updates
-
- - name: vCPE upstart
- copy: src=/opt/xos/observers/vcpe/files/vcpe.conf dest=/etc/init/vcpe.conf
{% endif %}
+ - name: vCPE upstart
+ template: src=/opt/xos/observers/vcpe/files/vcpe.conf.j2 dest=/etc/init/{{ vcpe_name }}.conf
+
- name: vCPE startup script
- template: src=/opt/xos/observers/vcpe/templates/start-vcpe.sh.j2 dest=/usr/local/sbin/start-vcpe.sh mode=0755
+ template: src=/opt/xos/observers/vcpe/templates/start-vcpe.sh.j2 dest=/usr/local/sbin/start-{{ vcpe_name }}.sh mode=0755
notify:
# - restart vcpe
- stop vcpe
- remove container
- start vcpe
+ - name: create /etc/{{ vcpe_name }}/dnsmasq.d
+ file: path=/etc/{{ vcpe_name }}/dnsmasq.d state=directory owner=root group=root
+
- name: vCPE basic dnsmasq config
- copy: src=/opt/xos/observers/vcpe/files/vcpe.dnsmasq dest=/etc/dnsmasq.d/vcpe.conf owner=root group=root
+ copy: src=/opt/xos/observers/vcpe/files/vcpe.dnsmasq dest=/etc/{{ vcpe_name }}/dnsmasq.d/vcpe.conf owner=root group=root
notify:
- stop dnsmasq
- start dnsmasq
- name: dnsmasq config
- template: src=/opt/xos/observers/vcpe/templates/dnsmasq_servers.j2 dest=/etc/dnsmasq.d/servers.conf owner=root group=root
+ template: src=/opt/xos/observers/vcpe/templates/dnsmasq_servers.j2 dest=/etc/{{ vcpe_name }}/dnsmasq.d/servers.conf owner=root group=root
notify:
- stop dnsmasq
- start dnsmasq
@@ -96,24 +100,24 @@
# - name: firewall info
# template: src=/opt/xos/observers/vcpe/templates/firewall_sample.j2 dest=/etc/firewall_sample owner=root group=root
- - name: Make sure vCPE service is running
- service: name=vcpe state=started
+ - name: Make sure vCPE service is running
+ service: name={{ vcpe_name }} state=started
handlers:
- name: stop dnsmasq
- shell: docker exec vcpe /usr/bin/killall dnsmasq
+ shell: docker exec {{ vcpe_name }} /usr/bin/killall dnsmasq
- name: start dnsmasq
- shell: docker exec vcpe /usr/sbin/service dnsmasq start
+ shell: docker exec {{ vcpe_name }} /usr/sbin/service dnsmasq start
- name: restart vcpe
- shell: service vcpe stop; sleep 1; service vcpe start
+ shell: service {{ vcpe_name }} stop; sleep 1; service {{ vcpe_name }} start
- name: stop vcpe
- service: name=vcpe state=stopped
+ service: name={{ vcpe_name }} state=stopped
- name: remove container
- docker: name=vcpe state=absent image=docker-vcpe
+ docker: name={{ vcpe_name }} state=absent image=docker-vcpe
- name: start vcpe
- service: name=vcpe state=started
+ service: name={{ vcpe_name }} state=started
diff --git a/xos/observers/vcpe/templates/start-vcpe.sh.j2 b/xos/observers/vcpe/templates/start-vcpe.sh.j2
index 0f87e89..565adaf 100755
--- a/xos/observers/vcpe/templates/start-vcpe.sh.j2
+++ b/xos/observers/vcpe/templates/start-vcpe.sh.j2
@@ -3,25 +3,27 @@
iptables -L > /dev/null
ip6tables -L > /dev/null
-docker inspect vcpe > /dev/null 2>&1
+VCPE=vcpe-{{ vlan_ids[0] }}
+
+docker inspect $VCPE > /dev/null 2>&1
if [ "$?" == 1 ]
then
docker pull andybavier/docker-vcpe
- docker run -d --name=vcpe --privileged=true --net=none -v /etc/dnsmasq.d:/etc/dnsmasq.d andybavier/docker-vcpe
+ docker run -d --name=$VCPE --privileged=true --net=none -v /etc/$VCPE/dnsmasq.d:/etc/dnsmasq.d andybavier/docker-vcpe
else
- docker start vcpe
+ docker start $VCPE
fi
# Set up networking via pipework
-docker exec vcpe ifconfig eth0 >> /dev/null || pipework eth4 -i eth0 vcpe {{ wan_ip }}/17@192.168.128.1 {{ wan_mac }}
-docker exec vcpe ifconfig eth1 >> /dev/null || pipework eth3 -i eth1 vcpe 192.168.0.1/24 @{{ vlan_ids[0] }}
-docker exec vcpe ifconfig eth2 >> /dev/null || pipework eth0 -i eth2 vcpe {{ hpc_client_ip }}/24
+docker exec $VCPE ifconfig eth0 >> /dev/null || pipework eth4 -i eth0 $VCPE {{ wan_ip }}/17@192.168.128.1 {{ wan_mac }}
+docker exec $VCPE ifconfig eth1 >> /dev/null || pipework eth3 -i eth1 $VCPE 192.168.0.1/24 @{{ vlan_ids[0] }}
+docker exec $VCPE ifconfig eth2 >> /dev/null || pipework eth0 -i eth2 $VCPE {{ hpc_client_ip }}/24
# Make sure VM's eth0 (hpc_client) has no IP address
ifconfig eth0 0.0.0.0
# Now can start up dnsmasq
-docker exec vcpe service dnsmasq start
+docker exec $VCPE service dnsmasq start
# Attach to container
-docker start -a vcpe
+docker start -a $VCPE