From 360dbeebadb76b3628b2cfbd8b3c41e77581b24c Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Tue, 23 Aug 2011 17:31:19 -0400 Subject: rebuilds are functional again --- nova/api/openstack/servers.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 553357404..fa499b192 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -604,8 +604,10 @@ class ControllerV10(Controller): LOG.debug(msg) raise exc.HTTPBadRequest(explanation=msg) + password = utils.generate_password(16) + try: - self.compute_api.rebuild(context, instance_id, image_id) + self.compute_api.rebuild(context, instance_id, image_id, password) except exception.BuildInProgress: msg = _("Instance %s is currently being rebuilt.") % instance_id LOG.debug(msg) @@ -741,15 +743,19 @@ class ControllerV11(Controller): self._validate_metadata(metadata) self._decode_personalities(personalities) + password = info["rebuild"].get("adminPass", + utils.generate_password(16)) + try: - self.compute_api.rebuild(context, instance_id, image_href, name, - metadata, personalities) + self.compute_api.rebuild(context, instance_id, image_href, + password, name=name, metadata=metadata, + files_to_inject=personalities) except exception.BuildInProgress: msg = _("Instance %s is currently being rebuilt.") % instance_id LOG.debug(msg) raise exc.HTTPConflict(explanation=msg) - return webob.Response(status_int=202) + return webob.Response(status_int=202, headers={'x-nova-password':password}) @common.check_snapshots_enabled def _action_create_image(self, input_dict, req, instance_id): -- cgit From 309a264db6c952081f2e85db21efc719596240a6 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Tue, 23 Aug 2011 20:59:24 -0400 Subject: updating tests --- nova/api/openstack/servers.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'nova/api') diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index fa499b192..fc74b8288 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -755,7 +755,11 @@ class ControllerV11(Controller): LOG.debug(msg) raise exc.HTTPConflict(explanation=msg) - return webob.Response(status_int=202, headers={'x-nova-password':password}) + instance = self.compute_api.routing_get(context, instance_id) + view = self._build_view(request, instance, is_detail=True) + view['server']['adminPass'] = password + + return view @common.check_snapshots_enabled def _action_create_image(self, input_dict, req, instance_id): @@ -822,6 +826,9 @@ class HeadersSerializer(wsgi.ResponseHeadersSerializer): def delete(self, response, data): response.status_int = 204 + def action(self, response, data): + response.status_int = 202 + class ServerXMLSerializer(wsgi.XMLDictSerializer): -- cgit From 3d4d3d7f422c7327346b5731ad3c620f279411f2 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Wed, 24 Aug 2011 10:37:59 -0400 Subject: adding xml serialization and handling instance not found --- nova/api/openstack/servers.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'nova/api') diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index fc74b8288..27c67e79e 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -754,6 +754,9 @@ class ControllerV11(Controller): msg = _("Instance %s is currently being rebuilt.") % instance_id LOG.debug(msg) raise exc.HTTPConflict(explanation=msg) + except exception.InstanceNotFound: + msg = _("Instance %s could not be found") % instance_id + raise exc.HTTPNotFound(explanation=msg) instance = self.compute_api.routing_get(context, instance_id) view = self._build_view(request, instance, is_detail=True) @@ -950,6 +953,11 @@ class ServerXMLSerializer(wsgi.XMLDictSerializer): node.setAttribute('adminPass', server_dict['server']['adminPass']) return self.to_xml_string(node, True) + def action(self, server_dict): + #NOTE(bcwaldon): We need a way to serialize actions individually. This + # assumes all actions return a server entity + return self.create(server_dict) + def update(self, server_dict): xml_doc = minidom.Document() node = self._server_to_xml_detailed(xml_doc, -- cgit