add docker_image_name attribute to VSGService
Change-Id: I27cd9ffd4629823f0f9cfe17c70038c2122929fc
diff --git a/xos/admin.py b/xos/admin.py
index fe20519..b87ffdc 100644
--- a/xos/admin.py
+++ b/xos/admin.py
@@ -31,6 +31,8 @@
dns_servers = forms.CharField(required=False)
url_filter_kind = forms.ChoiceField(choices=VSGService.URL_FILTER_KIND_CHOICES, required=False)
node_label = forms.CharField(required=False)
+ docker_image_name = forms.CharField(required=False)
+ docker_insecure_registry = forms.BooleanField(required=False)
def __init__(self,*args,**kwargs):
super (VSGServiceForm,self ).__init__(*args,**kwargs)
@@ -43,6 +45,8 @@
self.fields['dns_servers'].initial = self.instance.dns_servers
self.fields['url_filter_kind']. initial = self.instance.url_filter_kind
self.fields['node_label'].initial = self.instance.node_label
+ self.fields['docker_image_name'].initial = self.instance.docker_image_name
+ self.fields['docker_insecure_registry'].initial = self.instance.docker_insecure_registry
def save(self, commit=True):
self.instance.bbs_api_hostname = self.cleaned_data.get("bbs_api_hostname")
@@ -53,6 +57,8 @@
self.instance.dns_servers = self.cleaned_data.get("dns_servers")
self.instance.url_filter_kind = self.cleaned_data.get("url_filter_kind")
self.instance.node_label = self.cleaned_data.get("node_label")
+ self.instance.docker_image_name = self.cleaned_data.get("docker_image_name")
+ self.instance.docker_insecure_registry = self.cleaned_data.get("docker_insecure_registry")
return super(VSGServiceForm, self).save(commit=commit)
class Meta:
@@ -69,7 +75,7 @@
'classes':['suit-tab suit-tab-general']}),
("backend config", {'fields': [ "backend_network_label", "url_filter_kind", "bbs_api_hostname", "bbs_api_port", "bbs_server", "bbs_slice"],
'classes':['suit-tab suit-tab-backend']}),
- ("vSG config", {'fields': ["dns_servers"],
+ ("vSG config", {'fields': ["dns_servers", "docker_image_name", "docker_insecure_registry"],
'classes':['suit-tab suit-tab-vsg']}) ]
readonly_fields = ('backend_status_text', "service_specific_attribute")
inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
diff --git a/xos/models.py b/xos/models.py
index ad25c98..96fb71a 100644
--- a/xos/models.py
+++ b/xos/models.py
@@ -36,7 +36,9 @@
("backend_network_label", "hpc_client"),
("dns_servers", "8.8.8.8"),
("url_filter_kind", None),
- ("node_label", None) )
+ ("node_label", None),
+ ("docker_image_name", "docker.io/xosproject/vsg"),
+ ("docker_insecure_registry", False) )
def __init__(self, *args, **kwargs):
super(VSGService, self).__init__(*args, **kwargs)
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
diff --git a/xos/tosca/resources/vcpeservice.py b/xos/tosca/resources/vcpeservice.py
index 2e3558f..1d8754c 100644
--- a/xos/tosca/resources/vcpeservice.py
+++ b/xos/tosca/resources/vcpeservice.py
@@ -6,5 +6,5 @@
xos_model = VSGService
copyin_props = ["view_url", "icon_url", "enabled", "published", "public_key",
"private_key_fn", "versionNumber", "backend_network_label",
- "dns_servers", "node_label"]
+ "dns_servers", "node_label", "docker_image_name", "docker_insecure_registry"]