support for external_hostname / external_container
diff --git a/xos/core/models/service.py b/xos/core/models/service.py
index b5ba737..1a1b6ef 100644
--- a/xos/core/models/service.py
+++ b/xos/core/models/service.py
@@ -554,6 +554,22 @@
self.set_attribute("instance_id", value)
@property
+ def external_hostname(self):
+ return self.get_attribute("external_hostname", "")
+
+ @external_hostname.setter
+ def external_hostname(self, value):
+ self.set_attribute("external_hostname", value)
+
+ @property
+ def external_container(self):
+ return self.get_attribute("external_container", "")
+
+ @external_container.setter
+ def external_container(self, value):
+ self.set_attribute("external_container", value)
+
+ @property
def creator(self):
from core.models import User
if getattr(self, "cached_creator", None):
diff --git a/xos/synchronizers/base/SyncInstanceUsingAnsible.py b/xos/synchronizers/base/SyncInstanceUsingAnsible.py
index 335932f..9e1db50 100644
--- a/xos/synchronizers/base/SyncInstanceUsingAnsible.py
+++ b/xos/synchronizers/base/SyncInstanceUsingAnsible.py
@@ -44,6 +44,14 @@
return o.instance
+ def get_external_sync(self, o):
+ hostname = getattr(o, "external_hostname", None)
+ container = getattr(o, "external_container", None)
+ if hostname and container:
+ return (hostname, container)
+ else:
+ return None
+
def run_playbook(self, o, fields, template_name=None):
if not template_name:
template_name = self.template_name
@@ -142,18 +150,28 @@
self.prepare_record(o)
- instance = self.get_instance(o)
-
- if isinstance(instance, basestring):
+ if self.get_external_sync(o):
# sync to some external host
- # XXX - this probably needs more work...
+ # UNTESTED
- fields = { "hostname": instance,
- "instance_id": "ubuntu", # this is the username to log into
- "private_key": service.key,
+ (hostname, container_name) = self.get_external_sync(o)
+ fields = { "hostname": hostname,
+ "baremetal_ssh": True,
+ "instance_name": "rootcontext",
+ "username": "root",
+ "container_name": container_name
}
+ key_name = self.get_node_key(node)
+ if not os.path.exists(key_name):
+ raise Exception("Node key %s does not exist" % key_name)
+
+ key = file(key_name).read()
+
+ fields["private_key"] = key
+ # TO DO: Ceilometer stuff
else:
+ instance = self.get_instance(o)
# sync to an XOS instance
if not instance:
self.defer_sync(o, "waiting on instance")
@@ -165,7 +183,7 @@
fields = self.get_ansible_fields(instance)
- fields["ansible_tag"] = o.__class__.__name__ + "_" + str(o.id)
+ fields["ansible_tag"] = o.__class__.__name__ + "_" + str(o.id)
# If 'o' defines a 'sync_attributes' list, then we'll copy those
# attributes into the Ansible recipe's field list automatically.
diff --git a/xos/synchronizers/onos/steps/sync_onosservice.py b/xos/synchronizers/onos/steps/sync_onosservice.py
index e70be0c..3e47a71 100644
--- a/xos/synchronizers/onos/steps/sync_onosservice.py
+++ b/xos/synchronizers/onos/steps/sync_onosservice.py
@@ -43,9 +43,6 @@
serv = o
- if serv.use_external_host:
- return serv.use_external_host
-
if serv.slices.exists():
slice = serv.slices.all()[0]
if slice.instances.exists():
@@ -66,6 +63,9 @@
super(SyncONOSService, self).sync_fields(o, fields)
def run_playbook(self, o, fields):
+ if o.no_container:
+ # If no_container is selected, then we have nothing to do
+ return
instance = self.get_instance(o)
if (instance.isolation=="container"):
# If the instance is already a container, then we don't need to