summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Prince <dan.prince@rackspace.com>2011-07-26 17:23:21 +0000
committerTarmac <>2011-07-26 17:23:21 +0000
commitb45fa225f9477f4bae11cd379288db459d4b3c02 (patch)
tree6803f310cf9b71c58d732c984f8b3a99e55e5c6a
parentb1e72bbe231d29ddf62fb2942ab055b5c92f1a0a (diff)
parentd4803039c19a01087964c499c7e9ef9abfa82f74 (diff)
downloadnova-b45fa225f9477f4bae11cd379288db459d4b3c02.tar.gz
nova-b45fa225f9477f4bae11cd379288db459d4b3c02.tar.xz
nova-b45fa225f9477f4bae11cd379288db459d4b3c02.zip
Updates to the compute API and manager so that rebuild, reboot, snapshots, and password resets work with the most recent versions of novaclient.
-rw-r--r--nova/api/openstack/servers.py6
-rw-r--r--nova/compute/api.py6
-rw-r--r--nova/compute/manager.py5
-rw-r--r--nova/tests/api/openstack/test_servers.py10
4 files changed, 22 insertions, 5 deletions
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 7bef1d9b2..d7cabb067 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -447,7 +447,6 @@ class ControllerV10(Controller):
def _action_rebuild(self, info, request, instance_id):
context = request.environ['nova.context']
- instance_id = int(instance_id)
try:
image_id = info["rebuild"]["imageId"]
@@ -459,7 +458,7 @@ class ControllerV10(Controller):
try:
self.compute_api.rebuild(context, instance_id, image_id)
except exception.BuildInProgress:
- msg = _("Instance %d is currently being rebuilt.") % instance_id
+ msg = _("Instance %s is currently being rebuilt.") % instance_id
LOG.debug(msg)
raise exc.HTTPConflict(explanation=msg)
@@ -560,7 +559,6 @@ class ControllerV11(Controller):
def _action_rebuild(self, info, request, instance_id):
context = request.environ['nova.context']
- instance_id = int(instance_id)
try:
image_href = info["rebuild"]["imageRef"]
@@ -581,7 +579,7 @@ class ControllerV11(Controller):
self.compute_api.rebuild(context, instance_id, image_href, name,
metadata, personalities)
except exception.BuildInProgress:
- msg = _("Instance %d is currently being rebuilt.") % instance_id
+ msg = _("Instance %s is currently being rebuilt.") % instance_id
LOG.debug(msg)
raise exc.HTTPConflict(explanation=msg)
diff --git a/nova/compute/api.py b/nova/compute/api.py
index c49c0d95c..d1e5647d2 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -561,6 +561,7 @@ class API(base.Base):
self.db.queue_get_for(context, FLAGS.compute_topic, host),
{'method': 'refresh_provider_fw_rules', 'args': {}})
+ @scheduler_api.reroute_compute("update")
def update(self, context, instance_id, **kwargs):
"""Updates the instance in the datastore.
@@ -776,6 +777,7 @@ class API(base.Base):
raise exception.Error(_("Unable to find host for Instance %s")
% instance_id)
+ @scheduler_api.reroute_compute("backup")
def backup(self, context, instance_id, name, backup_type, rotation,
extra_properties=None):
"""Backup the given instance
@@ -792,6 +794,7 @@ class API(base.Base):
extra_properties=extra_properties)
return recv_meta
+ @scheduler_api.reroute_compute("snapshot")
def snapshot(self, context, instance_id, name, extra_properties=None):
"""Snapshot the given instance.
@@ -834,10 +837,12 @@ class API(base.Base):
params=params)
return recv_meta
+ @scheduler_api.reroute_compute("reboot")
def reboot(self, context, instance_id):
"""Reboot the given instance."""
self._cast_compute_message('reboot_instance', context, instance_id)
+ @scheduler_api.reroute_compute("rebuild")
def rebuild(self, context, instance_id, image_href, name=None,
metadata=None, files_to_inject=None):
"""Rebuild the given instance with the provided metadata."""
@@ -1024,6 +1029,7 @@ class API(base.Base):
"""Unrescue the given instance."""
self._cast_compute_message('unrescue_instance', context, instance_id)
+ @scheduler_api.reroute_compute("set_admin_password")
def set_admin_password(self, context, instance_id, password=None):
"""Set the root/admin password for the given instance."""
host = self._find_host(context, instance_id)
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 31627fe3b..c79abd696 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -430,7 +430,10 @@ class ComputeManager(manager.SchedulerDependentManager):
image_ref = kwargs.get('image_ref')
instance_ref.image_ref = image_ref
instance_ref.injected_files = kwargs.get('injected_files', [])
- self.driver.spawn(instance_ref, network_info)
+ network_info = self.network_api.get_instance_nw_info(context,
+ instance_ref)
+ bd_mapping = self._setup_block_device_mapping(context, instance_id)
+ self.driver.spawn(instance_ref, network_info, bd_mapping)
self._update_image_ref(context, instance_id, image_ref)
self._update_launched_at(context, instance_id)
diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py
index e6895086a..4ca79434f 100644
--- a/nova/tests/api/openstack/test_servers.py
+++ b/nova/tests/api/openstack/test_servers.py
@@ -97,6 +97,12 @@ def return_server_with_power_state(power_state):
return _return_server
+def return_server_with_uuid_and_power_state(power_state):
+ def _return_server(context, id):
+ return stub_instance(id, uuid=FAKE_UUID, power_state=power_state)
+ return _return_server
+
+
def return_servers(context, user_id=1):
return [stub_instance(i, user_id) for i in xrange(5)]
@@ -1854,6 +1860,8 @@ class ServersTest(test.TestCase):
state = power_state.BUILDING
new_return_server = return_server_with_power_state(state)
self.stubs.Set(nova.db.api, 'instance_get', new_return_server)
+ self.stubs.Set(nova.db, 'instance_get_by_uuid',
+ return_server_with_uuid_and_power_state(state))
req = webob.Request.blank('/v1.0/servers/1/action')
req.method = 'POST'
@@ -1902,6 +1910,8 @@ class ServersTest(test.TestCase):
state = power_state.BUILDING
new_return_server = return_server_with_power_state(state)
self.stubs.Set(nova.db.api, 'instance_get', new_return_server)
+ self.stubs.Set(nova.db, 'instance_get_by_uuid',
+ return_server_with_uuid_and_power_state(state))
req = webob.Request.blank('/v1.1/servers/1/action')
req.method = 'POST'