userdata support for instance creation
diff --git a/planetstack/core/models/sliver.py b/planetstack/core/models/sliver.py
index 98e59d7..6351bd1 100644
--- a/planetstack/core/models/sliver.py
+++ b/planetstack/core/models/sliver.py
@@ -25,6 +25,7 @@
deploymentNetwork = models.ForeignKey(Deployment, verbose_name='deployment', related_name='sliver_deploymentNetwork')
numberCores = models.IntegerField(verbose_name="Number of Cores", help_text="Number of cores for sliver", default=0)
tags = generic.GenericRelation(Tag)
+ userData = models.TextField(blank=True, null=True, help_text="user_data passed to instance during creation")
def __unicode__(self):
if self.instance_name:
diff --git a/planetstack/observer/steps/sync_slivers.py b/planetstack/observer/steps/sync_slivers.py
index a794ccf..3b81766 100644
--- a/planetstack/observer/steps/sync_slivers.py
+++ b/planetstack/observer/steps/sync_slivers.py
@@ -57,8 +57,6 @@
if net['name'] in network_templates:
nics.append({'net-id': net['id']})
- file("/tmp/scott-manager","a").write("slice: %s\nreq: %s\n" % (str(sliver.slice.name), str(nics)))
-
# look up image id
deployment_driver = self.driver.admin_driver(deployment=sliver.deploymentNetwork.name)
image_id = None
@@ -75,14 +73,15 @@
sliver.slice.name
key_fields = {'name': keyname,
'public_key': sliver.creator.public_key}
- driver.create_keypair(**key_fields)
-
+ driver.create_keypair(**key_fields)
+
instance = driver.spawn_instance(name=sliver.name,
key_name = keyname,
image_id = image_id,
hostname = sliver.node.name,
pubkeys = pubkeys,
- nics = nics )
+ nics = nics,
+ userdata = sliver.userData )
sliver.instance_id = instance.id
sliver.instance_name = getattr(instance, 'OS-EXT-SRV-ATTR:instance_name')
sliver.save()
diff --git a/planetstack/openstack/driver.py b/planetstack/openstack/driver.py
index 91807f1..8ebea68 100644
--- a/planetstack/openstack/driver.py
+++ b/planetstack/openstack/driver.py
@@ -413,7 +413,7 @@
return (subnet_id, subnet)
- def spawn_instance(self, name, key_name=None, hostname=None, image_id=None, security_group=None, pubkeys=[], nics=None, metadata=None):
+ def spawn_instance(self, name, key_name=None, hostname=None, image_id=None, security_group=None, pubkeys=[], nics=None, metadata=None, userdata=None):
flavor_name = self.config.nova_default_flavor
flavor = self.shell.nova.flavors.find(name=flavor_name)
#if not image:
@@ -439,7 +439,8 @@
availability_zone=availability_zone,
nics=nics,
networks=nics,
- meta=metadata)
+ meta=metadata,
+ userdata=userdata)
return server
def destroy_instance(self, id):