Merge lp:~gundlach/nova/rsapi-reboot into lp:~cerberus/nova/servers_api

Proposed by Michael Gundlach
Status: Merged
Approved by: Matt Dietz
Approved revision: 299
Merge reported by: Matt Dietz
Merged at revision: not available
Proposed branch: lp:~gundlach/nova/rsapi-reboot
Merge into: lp:~cerberus/nova/servers_api
Diff against target: 124 lines (+54/-8)
5 files modified
nova/api/cloud.py (+42/-0)
nova/api/ec2/cloud.py (+2/-6)
nova/api/rackspace/servers.py (+8/-2)
nova/tests/api/rackspace/images.py (+1/-0)
nova/tests/api/rackspace/sharedipgroups.py (+1/-0)
To merge this branch: bzr merge lp:~gundlach/nova/rsapi-reboot
Reviewer Review Type Date Requested Status
Jay Pipes (community) Approve
Review via email: mp+37050@code.launchpad.net

Description of the change

Reboot functionality in servers Controller, and a couple of missing imports in unittests.

Note that I did this semi-blind, relying on _deserialize() and _instance_id_translator() to exist and work. You'll want to make sure it merges properly into your branch.

Also, you might need to pull from trunk in order for this merge to look small, as I've got the latest trunk in here.

To post a comment you must log in.
lp:~gundlach/nova/rsapi-reboot updated
299. By Michael Gundlach

Support reboot in api.rackspace by extracting reboot function from api.ec2 into api.cloud.

Revision history for this message
Jay Pipes (jaypipes) wrote :

nice.

review: Approve
Revision history for this message
Matt Dietz (cerberus) wrote :

Seems fine.

Only thing to note is that the other actions (Resize and Rebuild) will also multiplex through the action... action :-/ So we may want to raise "not implemented" if anything but a reboot is requested.

Revision history for this message
Matt Dietz (cerberus) wrote :

Disregard, I just realized it would do that no matter what.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'nova/api/cloud.py'
2--- nova/api/cloud.py 1970-01-01 00:00:00 +0000
3+++ nova/api/cloud.py 2010-09-29 19:55:55 +0000
4@@ -0,0 +1,42 @@
5+# vim: tabstop=4 shiftwidth=4 softtabstop=4
6+
7+# Copyright 2010 United States Government as represented by the
8+# Administrator of the National Aeronautics and Space Administration.
9+# All Rights Reserved.
10+#
11+# Licensed under the Apache License, Version 2.0 (the "License"); you may
12+# not use this file except in compliance with the License. You may obtain
13+# a copy of the License at
14+#
15+# http://www.apache.org/licenses/LICENSE-2.0
16+#
17+# Unless required by applicable law or agreed to in writing, software
18+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
19+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
20+# License for the specific language governing permissions and limitations
21+# under the License.
22+
23+"""
24+Methods for API calls to control instances via AMQP.
25+"""
26+
27+
28+from nova import db
29+from nova import flags
30+from nova import rpc
31+
32+FLAGS = flags.FLAGS
33+
34+
35+def reboot(instance_id, context=None):
36+ """Reboot the given instance.
37+
38+ #TODO(gundlach) not actually sure what context is used for by ec2 here
39+ -- I think we can just remove it and use None all the time.
40+ """
41+ instance_ref = db.instance_get_by_ec2_id(None, instance_id)
42+ host = instance_ref['host']
43+ rpc.cast(db.queue_get_for(context, FLAGS.compute_topic, host),
44+ {"method": "reboot_instance",
45+ "args": {"context": None,
46+ "instance_id": instance_ref['id']}})
47
48=== modified file 'nova/api/ec2/cloud.py'
49--- nova/api/ec2/cloud.py 2010-09-28 23:10:47 +0000
50+++ nova/api/ec2/cloud.py 2010-09-29 19:55:55 +0000
51@@ -36,6 +36,7 @@
52 from nova import rpc
53 from nova import utils
54 from nova.compute.instance_types import INSTANCE_TYPES
55+from nova.api import cloud
56 from nova.api.ec2 import images
57
58
59@@ -664,12 +665,7 @@
60 def reboot_instances(self, context, instance_id, **kwargs):
61 """instance_id is a list of instance ids"""
62 for id_str in instance_id:
63- instance_ref = db.instance_get_by_ec2_id(context, id_str)
64- host = instance_ref['host']
65- rpc.cast(db.queue_get_for(context, FLAGS.compute_topic, host),
66- {"method": "reboot_instance",
67- "args": {"context": None,
68- "instance_id": instance_ref['id']}})
69+ cloud.reboot(id_str, context=context)
70 return True
71
72 def delete_volume(self, context, volume_id, **kwargs):
73
74=== modified file 'nova/api/rackspace/servers.py'
75--- nova/api/rackspace/servers.py 2010-09-29 17:58:40 +0000
76+++ nova/api/rackspace/servers.py 2010-09-29 19:55:55 +0000
77@@ -24,6 +24,7 @@
78 from nova import rpc
79 from nova import utils
80 from nova import wsgi
81+from nova.api import cloud
82 from nova.api.rackspace import _id_translator
83 from nova.compute import power_state
84 from nova.wsgi import Serializer
85@@ -171,8 +172,13 @@
86 def action(self, req, id):
87 """ multi-purpose method used to reboot, rebuild, and
88 resize a server """
89- if not req.environ.has_key('inst_dict'):
90- return exc.HTTPUnprocessableEntity()
91+ input_dict = self._deserialize(req.body, req)
92+ try:
93+ reboot_type = input_dict['reboot']['type']
94+ except Exception:
95+ raise faults.Fault(webob.exc.HTTPNotImplemented())
96+ opaque_id = _instance_id_translator().from_rsapi_id(id)
97+ cloud.reboot(opaque_id)
98
99 def _build_server_instance(self, req):
100 """Build instance data structure and save it to the data store."""
101
102=== modified file 'nova/tests/api/rackspace/images.py'
103--- nova/tests/api/rackspace/images.py 2010-08-30 19:04:47 +0000
104+++ nova/tests/api/rackspace/images.py 2010-09-29 19:55:55 +0000
105@@ -15,6 +15,7 @@
106 # License for the specific language governing permissions and limitations
107 # under the License.
108
109+import stubout
110 import unittest
111
112 from nova.api.rackspace import images
113
114=== modified file 'nova/tests/api/rackspace/sharedipgroups.py'
115--- nova/tests/api/rackspace/sharedipgroups.py 2010-08-25 21:37:22 +0000
116+++ nova/tests/api/rackspace/sharedipgroups.py 2010-09-29 19:55:55 +0000
117@@ -15,6 +15,7 @@
118 # License for the specific language governing permissions and limitations
119 # under the License.
120
121+import stubout
122 import unittest
123
124 from nova.api.rackspace import sharedipgroups

Subscribers

People subscribed via source and target branches

to all changes: