add extra_hosts to xos model

Change-Id: I909e32e1a4737065e56302aedfb6c75e900b292f
diff --git a/xos/core/models/xosmodel.py b/xos/core/models/xosmodel.py
index 1d0a20b..73c44e4 100644
--- a/xos/core/models/xosmodel.py
+++ b/xos/core/models/xosmodel.py
@@ -17,6 +17,7 @@
     enable_build = models.BooleanField(help_text="True if Onboarding Synchronizer should build XOS as necessary", default=True)
     frontend_only = models.BooleanField(help_text="If True, XOS will not start synchronizer containers", default=False)
     source_ui_image = StrippedCharField(max_length=200, default="xosproject/xos")
+    extra_hosts = StrippedCharField(max_length=1024, help_text="list of hostname mappings that will be passed to docker-compose", null=True, blank=True)
 
     def __unicode__(self):  return u'%s' % (self.name)
 
diff --git a/xos/synchronizers/onboarding/templates/docker-compose.yml.j2 b/xos/synchronizers/onboarding/templates/docker-compose.yml.j2
index faa9d02..0479160 100644
--- a/xos/synchronizers/onboarding/templates/docker-compose.yml.j2
+++ b/xos/synchronizers/onboarding/templates/docker-compose.yml.j2
@@ -40,6 +40,12 @@
     - "{{ expose }}"
 {%- endfor %}
 {%- endif %}
+{%- if container.extra_hosts %}
+  extra_hosts:
+{%- for host in container.extra_hosts %}
+    - "{{ host }}"
+{%- endfor %}
+{%- endif %}
   log_driver: "json-file"
   log_opt:

     max-size: "100k"

diff --git a/xos/synchronizers/onboarding/xosbuilder.py b/xos/synchronizers/onboarding/xosbuilder.py
index be3960e..78ee3d0 100644
--- a/xos/synchronizers/onboarding/xosbuilder.py
+++ b/xos/synchronizers/onboarding/xosbuilder.py
@@ -308,6 +308,11 @@
                                  "container_path": volume.container_path,
                                  "read_only": volume.read_only})
 
+         if xos.extra_hosts:
+             extra_hosts = [x.strip() for x in xos.extra_hosts.split(",")]
+         else:
+             extra_hosts = []
+
          containers = {}
 
 #         containers["xos_db"] = \
@@ -320,6 +325,7 @@
                              "ports": {"%d"%xos.ui_port : "%d"%xos.ui_port},
                              #"links": ["xos_db"],
                              "external_links": ["%s:%s" % (xos.db_container_name, "xos_db")],
+                             "extra_hosts": extra_hosts,
                              "volumes": volume_list}
 
 #         containers["xos_bootstrap_ui"] = {"image": "xosproject/xos",
@@ -345,7 +351,7 @@
                                     {"image": "xosproject/xos-synchronizer-%s" % c.name,
                                      "command": command,
                                      "external_links": ["%s:%s" % (xos.db_container_name, "xos_db")],
-                                     #"links": ["xos_db"],
+                                     "extra_hosts": extra_hosts,
                                      "volumes": volume_list}
 
          vars = { "containers": containers }
diff --git a/xos/tosca/custom_types/xos.m4 b/xos/tosca/custom_types/xos.m4
index 3faedcc..4105e05 100644
--- a/xos/tosca/custom_types/xos.m4
+++ b/xos/tosca/custom_types/xos.m4
@@ -39,6 +39,10 @@
                 type: boolean
                 required: false
                 description: True if XOS should not start synchronizer containers
+            extra_hosts:
+                type: string
+                required: false
+                description: List of extra_hosts to pass to docker compose
 
 
     tosca.nodes.XOSVolume:
diff --git a/xos/tosca/custom_types/xos.yaml b/xos/tosca/custom_types/xos.yaml
index 501b164..a643959 100644
--- a/xos/tosca/custom_types/xos.yaml
+++ b/xos/tosca/custom_types/xos.yaml
@@ -69,6 +69,10 @@
                 type: boolean
                 required: false
                 description: True if XOS should not start synchronizer containers
+            extra_hosts:
+                type: string
+                required: false
+                description: List of extra_hosts to pass to docker compose
 
 
     tosca.nodes.XOSVolume:
diff --git a/xos/tosca/resources/xosmodel.py b/xos/tosca/resources/xosmodel.py
index 9470c6b..c500d7e 100644
--- a/xos/tosca/resources/xosmodel.py
+++ b/xos/tosca/resources/xosmodel.py
@@ -12,7 +12,7 @@
 class XOSXOS(XOSResource):
     provides = "tosca.nodes.XOS"
     xos_model = XOS
-    copyin_props = ["ui_port", "bootstrap_ui_port", "docker_project_name", "db_container_name", "enable_build", "frontend_only", "source_ui_image"]
+    copyin_props = ["ui_port", "bootstrap_ui_port", "docker_project_name", "db_container_name", "enable_build", "frontend_only", "source_ui_image", "extra_hosts"]
 
 class XOSVolume(XOSResource):
     provides = "tosca.nodes.XOSVolume"