no need to look up flavor and image by name. Just pass the id to servers.create()
diff --git a/plstackapi/core/api/slivers.py b/plstackapi/core/api/slivers.py
index c41ffba..a1589d2 100644
--- a/plstackapi/core/api/slivers.py
+++ b/plstackapi/core/api/slivers.py
@@ -42,16 +42,15 @@
if deployment_networks: fields['deploymentNetwork'] = deployment_networks[0]
nodes = _get_nodes(fields.get('node'))
if nodes: fields['node'] = nodes[0]
-
sliver = Sliver(**fields)
# create quantum sliver
- sliver = driver.spawn_instance(name=sliver.name,
+ instance = driver.spawn_instance(name=sliver.name,
key_name = sliver.key.name,
- flavor=sliver.flavor.name,
- image = sliver.image.name,
- hostname = sliver.node.hostname )
+ flavor_id = sliver.flavor.flavor_id,
+ image_id = sliver.image.image_id,
+ hostname = sliver.node.name )
- sliver.instance_id=sliver.id
+ sliver.instance_id=instance.id
sliver.save()
return sliver
diff --git a/plstackapi/openstack/driver.py b/plstackapi/openstack/driver.py
index fe93fbc..03d4ed6 100644
--- a/plstackapi/openstack/driver.py
+++ b/plstackapi/openstack/driver.py
@@ -170,26 +170,22 @@
for key in keys:
self.shell.nova.keypairs.delete(key)
- def spawn_instance(self, name, key_name=None, hostname=None, flavor=None, image=None, security_group=None, pubkeys=[]):
- if not flavor:
- flavor = self.config.nova_default_flavor
- if not image:
- image = self.config.nova_default_imave
+ def spawn_instance(self, name, key_name=None, hostname=None, flavor_id=None, image_id=None, security_group=None, pubkeys=[]):
+ #if not flavor_id:
+ # flavor = self.config.nova_default_flavor
+ #if not image:
+ # image = self.config.nova_default_imave
if not security_group:
security_group = self.config.nova_default_security_group
authorized_keys = "\n".join(pubkeys)
files = {'/root/.ssh/authorized_keys': authorized_keys}
- flavor_id = self.shell.nova.flavors.find(name=flavor)
- images = self.shell.glance.get_images(name=image)
- if not images:
- raise Exception, "Image not found: " + image
- image_id = images[0]['id']
hints = {}
if hostname:
#hints['force_hosts']= hostname
- hints['availability-zone'] = 'nova:%s' % hostname
+ #hints['availability-zone'] = 'nova:%s' % hostname
+ pass
server = self.shell.nova.servers.create(
name=name,
key_name = key_name,