summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSandy Walsh <sandy.walsh@rackspace.com>2011-06-01 12:39:31 -0700
committerSandy Walsh <sandy.walsh@rackspace.com>2011-06-01 12:39:31 -0700
commitb05dcdc69387ecd54e40063e66355961d39b4430 (patch)
tree03b03357502cb878e2ee31b253588cd1d9801c7f
parent3bf3255f91aab28aa6915a2836dad77f17312e03 (diff)
downloadnova-b05dcdc69387ecd54e40063e66355961d39b4430.tar.gz
nova-b05dcdc69387ecd54e40063e66355961d39b4430.tar.xz
nova-b05dcdc69387ecd54e40063e66355961d39b4430.zip
reservation id's properly forwarded to child zones on create
-rw-r--r--nova/api/openstack/create_instance_controller.py30
-rw-r--r--nova/scheduler/zone_aware_scheduler.py6
2 files changed, 34 insertions, 2 deletions
diff --git a/nova/api/openstack/create_instance_controller.py b/nova/api/openstack/create_instance_controller.py
index c79638bd9..786d74e37 100644
--- a/nova/api/openstack/create_instance_controller.py
+++ b/nova/api/openstack/create_instance_controller.py
@@ -116,6 +116,8 @@ class OpenstackCreateInstanceController(common.OpenstackController):
zone_blob = env['server'].get('blob')
reservation_id = env['server'].get('reservation_id')
+ LOG.exception("******* CREATE_INSTANCE RES_ID=%s of %s" % (reservation_id, env))
+
inst_type = instance_types.get_instance_type_by_flavor_id(flavor_id)
extra_values = {
'instance_type': inst_type,
@@ -221,6 +223,34 @@ class OpenstackCreateInstanceController(common.OpenstackController):
raise exception.RamdiskNotFoundForImage(image_id=image_id)
return kernel_id, ramdisk_id
+
+ def _get_injected_files(self, personality):
+ """
+ Create a list of injected files from the personality attribute
+
+ At this time, injected_files must be formatted as a list of
+ (file_path, file_content) pairs for compatibility with the
+ underlying compute service.
+ """
+ injected_files = []
+
+ for item in personality:
+ try:
+ path = item['path']
+ contents = item['contents']
+ except KeyError as key:
+ expl = _('Bad personality format: missing %s') % key
+ raise exc.HTTPBadRequest(explanation=expl)
+ except TypeError:
+ expl = _('Bad personality format')
+ raise exc.HTTPBadRequest(explanation=expl)
+ try:
+ contents = base64.b64decode(contents)
+ except TypeError:
+ expl = _('Personality content for %s cannot be decoded') % path
+ raise exc.HTTPBadRequest(explanation=expl)
+ injected_files.append((path, contents))
+ return injected_files
class ServerCreateRequestXMLDeserializer(object):
diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py
index 35ffdbde1..4b96f9877 100644
--- a/nova/scheduler/zone_aware_scheduler.py
+++ b/nova/scheduler/zone_aware_scheduler.py
@@ -90,6 +90,7 @@ class ZoneAwareScheduler(driver.Scheduler):
image_id = instance_properties['image_id']
meta = instance_properties['metadata']
flavor_id = instance_type['flavorid']
+ reservation_id = instance_properties['reservation_id']
files = kwargs['injected_files']
ipgroup = None # Not supported in OS API ... yet
@@ -98,7 +99,8 @@ class ZoneAwareScheduler(driver.Scheduler):
child_blob = zone_info['child_blob']
zone = db.zone_get(context, child_zone)
url = zone.api_url
- LOG.debug(_("Forwarding instance create call to child zone %(url)s")
+ LOG.debug(_("Forwarding instance create call to child zone %(url)s"
+ ". ReservationID=%(reservation_id)s")
% locals())
nova = None
try:
@@ -109,7 +111,7 @@ class ZoneAwareScheduler(driver.Scheduler):
"to talk to zone at %(url)s.") % locals())
nova.servers.create(name, image_id, flavor_id, ipgroup, meta, files,
- child_blob)
+ child_blob, reservation_id=reservation_id)
def _provision_resource_from_blob(self, context, item, instance_id,
request_spec, kwargs):