add docker_image_name attribute to VSGService
Change-Id: I27cd9ffd4629823f0f9cfe17c70038c2122929fc
diff --git a/xos/synchronizer/manifest b/xos/synchronizer/manifest
index d13ee05..d15f0d8 100644
--- a/xos/synchronizer/manifest
+++ b/xos/synchronizer/manifest
@@ -3,6 +3,7 @@
templates/before.rules.j2
templates/start-vcpe.sh.j2
templates/dnsmasq_safe_servers.j2
+templates/docker.j2
templates/firewall_sample.j2
templates/rc.local.j2
templates/vcpe.conf.j2
diff --git a/xos/synchronizer/steps/sync_vcpetenant.py b/xos/synchronizer/steps/sync_vcpetenant.py
index adabf85..e8670d6 100644
--- a/xos/synchronizer/steps/sync_vcpetenant.py
+++ b/xos/synchronizer/steps/sync_vcpetenant.py
@@ -156,8 +156,17 @@
if mac:
safe_macs.append(mac)
+
+ docker_opts = []
+ if vcpe_service.docker_insecure_registry:
+ reg_name = vcpe_service.docker_image_name.split("/",1)[0]
+ docker_opts.append("--insecure-registry " + reg_name)
+
fields = {"s_tags": s_tags,
"c_tags": c_tags,
+ "docker_remote_image_name": vcpe_service.docker_image_name,
+ "docker_local_image_name": vcpe_service.docker_image_name, # vcpe_service.docker_image_name.split("/",1)[1].split(":",1)[0],
+ "docker_opts": " ".join(docker_opts),
"dnsdemux_ip": dnsdemux_ip,
"cdn_prefixes": cdn_prefixes,
"bbs_addrs": bbs_addrs,
diff --git a/xos/synchronizer/steps/sync_vcpetenant_vtn.yaml b/xos/synchronizer/steps/sync_vcpetenant_vtn.yaml
index 0226354..7e32bd0 100644
--- a/xos/synchronizer/steps/sync_vcpetenant_vtn.yaml
+++ b/xos/synchronizer/steps/sync_vcpetenant_vtn.yaml
@@ -10,6 +10,9 @@
dnsdemux_ip: {{ dnsdemux_ip }}
firewall_enable: {{ firewall_enable }}
url_filter_enable: {{ url_filter_enable }}
+ docker_remote_image_name: {{ docker_remote_image_name }}
+ docker_local_image_name: {{ docker_local_image_name }}
+ docker_opts: {{ docker_opts }}
c_tags:
{% for c_tag in c_tags %}
- {{ c_tag }}
@@ -143,6 +146,11 @@
# when: cron_job_pids_count.stdout == "0"
{% endif %}
+ - name: Set docker options
+ template: src=/opt/xos/synchronizers/vsg/templates/docker.j2 dest=/etc/default/docker
+ notify:
+ - restart docker
+
- name: vCPE upstart
template: src=/opt/xos/synchronizers/vsg/templates/vcpe.conf.j2 dest=/etc/init/{{ container_name }}.conf
@@ -242,3 +250,6 @@
- name: restart vcpe
shell: service {{ container_name }} stop; sleep 1; service {{ container_name }} start
+
+ - name: restart docker
+ shell: service docker restart
diff --git a/xos/synchronizer/templates/docker.j2 b/xos/synchronizer/templates/docker.j2
new file mode 100644
index 0000000..48f5c5c
--- /dev/null
+++ b/xos/synchronizer/templates/docker.j2
@@ -0,0 +1,17 @@
+# Docker Upstart and SysVinit configuration file
+
+# Customize location of Docker binary (especially for development testing).
+#DOCKER="/usr/local/bin/docker"
+
+# Use DOCKER_OPTS to modify the daemon startup options.
+#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
+
+DOCKER_OPTS="{{ docker_opts }}"
+
+#"--insecure-registry 10.1.0.1:5000"
+
+# If you need Docker to use an HTTP proxy, it can also be specified here.
+#export http_proxy="http://127.0.0.1:3128/"
+
+# This is also a handy place to tweak where Docker's temporary files go.
+#export TMPDIR="/mnt/bigdrive/docker-tmp"
diff --git a/xos/synchronizer/templates/start-vcpe-vtn.sh.j2 b/xos/synchronizer/templates/start-vcpe-vtn.sh.j2
index dfdce0a..a309ae0 100644
--- a/xos/synchronizer/templates/start-vcpe-vtn.sh.j2
+++ b/xos/synchronizer/templates/start-vcpe-vtn.sh.j2
@@ -15,13 +15,13 @@
docker inspect $VCPE > /dev/null 2>&1
if [ "$?" == 1 ]
then
- docker pull andybavier/docker-vcpe
+ docker pull {{ docker_remote_image_name }}
docker run -d --name=$VCPE --privileged=true --net=none \
-v /var/container_volumes/$VCPE/mount:/mount:ro \
-v /var/container_volumes/$VCPE/etc/dnsmasq.d:/etc/dnsmasq.d:ro \
-v /var/container_volumes/$VCPE/etc/service/message:/etc/service/message \
-v /var/container_volumes/$VCPE/usr/local/sbin:/usr/local/sbin:ro \
- andybavier/docker-vcpe
+ {{ docker_local_image_name }}
else
docker start $VCPE
fi