Merge lp:~eday/nova/compute-abstraction-reboot into lp:~hudson-openstack/nova/trunk

Proposed by Eric Day
Status: Merged
Approved by: Jay Pipes
Approved revision: 429
Merged at revision: 448
Proposed branch: lp:~eday/nova/compute-abstraction-reboot
Merge into: lp:~hudson-openstack/nova/trunk
Prerequisite: lp:~eday/nova/compute-abstraction
Diff against target: 157 lines (+33/-66)
4 files modified
nova/api/cloud.py (+0/-58)
nova/api/ec2/cloud.py (+3/-4)
nova/api/openstack/servers.py (+3/-4)
nova/compute/api.py (+27/-0)
To merge this branch: bzr merge lp:~eday/nova/compute-abstraction-reboot
Reviewer Review Type Date Requested Status
Jay Pipes (community) Approve
Michael Gundlach (community) Approve
Review via email: mp+42528@code.launchpad.net

Description of the change

Moved the reboot/rescue methods into nova.compute.api.

To post a comment you must log in.
Revision history for this message
Michael Gundlach (gundlach) wrote :

yep

review: Approve
429. By Eric Day

Merged trunk.

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

rock on.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== removed file 'nova/api/cloud.py'
--- nova/api/cloud.py 2010-10-24 23:04:35 +0000
+++ nova/api/cloud.py 1970-01-01 00:00:00 +0000
@@ -1,58 +0,0 @@
1# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2010 United States Government as represented by the
4# Administrator of the National Aeronautics and Space Administration.
5# All Rights Reserved.
6#
7# Licensed under the Apache License, Version 2.0 (the "License"); you may
8# not use this file except in compliance with the License. You may obtain
9# a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16# License for the specific language governing permissions and limitations
17# under the License.
18
19"""
20Methods for API calls to control instances via AMQP.
21"""
22
23
24from nova import db
25from nova import flags
26from nova import rpc
27
28FLAGS = flags.FLAGS
29
30
31def reboot(instance_id, context=None):
32 """Reboot the given instance."""
33 instance_ref = db.instance_get_by_internal_id(context, instance_id)
34 host = instance_ref['host']
35 rpc.cast(context,
36 db.queue_get_for(context, FLAGS.compute_topic, host),
37 {"method": "reboot_instance",
38 "args": {"instance_id": instance_ref['id']}})
39
40
41def rescue(instance_id, context):
42 """Rescue the given instance."""
43 instance_ref = db.instance_get_by_internal_id(context, instance_id)
44 host = instance_ref['host']
45 rpc.cast(context,
46 db.queue_get_for(context, FLAGS.compute_topic, host),
47 {"method": "rescue_instance",
48 "args": {"instance_id": instance_ref['id']}})
49
50
51def unrescue(instance_id, context):
52 """Unrescue the given instance."""
53 instance_ref = db.instance_get_by_internal_id(context, instance_id)
54 host = instance_ref['host']
55 rpc.cast(context,
56 db.queue_get_for(context, FLAGS.compute_topic, host),
57 {"method": "unrescue_instance",
58 "args": {"instance_id": instance_ref['id']}})
590
=== modified file 'nova/api/ec2/cloud.py'
--- nova/api/ec2/cloud.py 2010-12-02 16:47:25 +0000
+++ nova/api/ec2/cloud.py 2010-12-03 17:43:19 +0000
@@ -41,7 +41,6 @@
41from nova import utils41from nova import utils
42from nova.compute import api as compute_api42from nova.compute import api as compute_api
43from nova.compute import instance_types43from nova.compute import instance_types
44from nova.api import cloud
45from nova.image.s3 import S3ImageService44from nova.image.s3 import S3ImageService
4645
4746
@@ -834,19 +833,19 @@
834 """instance_id is a list of instance ids"""833 """instance_id is a list of instance ids"""
835 for ec2_id in instance_id:834 for ec2_id in instance_id:
836 internal_id = ec2_id_to_internal_id(ec2_id)835 internal_id = ec2_id_to_internal_id(ec2_id)
837 cloud.reboot(internal_id, context=context)836 self.compute_api.reboot(context, internal_id)
838 return True837 return True
839838
840 def rescue_instance(self, context, instance_id, **kwargs):839 def rescue_instance(self, context, instance_id, **kwargs):
841 """This is an extension to the normal ec2_api"""840 """This is an extension to the normal ec2_api"""
842 internal_id = ec2_id_to_internal_id(instance_id)841 internal_id = ec2_id_to_internal_id(instance_id)
843 cloud.rescue(internal_id, context=context)842 self.compute_api.rescue(context, internal_id)
844 return True843 return True
845844
846 def unrescue_instance(self, context, instance_id, **kwargs):845 def unrescue_instance(self, context, instance_id, **kwargs):
847 """This is an extension to the normal ec2_api"""846 """This is an extension to the normal ec2_api"""
848 internal_id = ec2_id_to_internal_id(instance_id)847 internal_id = ec2_id_to_internal_id(instance_id)
849 cloud.unrescue(internal_id, context=context)848 self.compute_api.unrescue(context, internal_id)
850 return True849 return True
851850
852 def update_instance(self, context, ec2_id, **kwargs):851 def update_instance(self, context, ec2_id, **kwargs):
853852
=== modified file 'nova/api/openstack/servers.py'
--- nova/api/openstack/servers.py 2010-12-02 20:17:41 +0000
+++ nova/api/openstack/servers.py 2010-12-03 17:43:19 +0000
@@ -23,7 +23,6 @@
23from nova import utils23from nova import utils
24from nova import wsgi24from nova import wsgi
25from nova import context25from nova import context
26from nova.api import cloud
27from nova.api.openstack import faults26from nova.api.openstack import faults
28from nova.compute import api as compute_api27from nova.compute import api as compute_api
29from nova.compute import instance_types28from nova.compute import instance_types
@@ -183,9 +182,9 @@
183 inst_ref = self.db.instance_get_by_internal_id(ctxt, int(id))182 inst_ref = self.db.instance_get_by_internal_id(ctxt, int(id))
184 if not inst_ref or (inst_ref and not inst_ref.user_id == user_id):183 if not inst_ref or (inst_ref and not inst_ref.user_id == user_id):
185 return faults.Fault(exc.HTTPUnprocessableEntity())184 return faults.Fault(exc.HTTPUnprocessableEntity())
186 #TODO(gundlach): pass reboot_type, support soft reboot in185 # TODO(gundlach): pass reboot_type, support soft reboot in
187 #virt driver186 # virt driver
188 cloud.reboot(id)187 self.compute_api.reboot(ctxt, id)
189188
190 def _get_network_topic(self, context):189 def _get_network_topic(self, context):
191 """Retrieves the network host for a project"""190 """Retrieves the network host for a project"""
192191
=== modified file 'nova/compute/api.py'
--- nova/compute/api.py 2010-12-02 17:34:52 +0000
+++ nova/compute/api.py 2010-12-03 17:43:19 +0000
@@ -210,3 +210,30 @@
210210
211 """211 """
212 self.db.instance_update(context, instance_id, kwargs)212 self.db.instance_update(context, instance_id, kwargs)
213
214 def reboot(self, context, instance_id):
215 """Reboot the given instance."""
216 instance = self.db.instance_get_by_internal_id(context, instance_id)
217 host = instance['host']
218 rpc.cast(context,
219 self.db.queue_get_for(context, FLAGS.compute_topic, host),
220 {"method": "reboot_instance",
221 "args": {"instance_id": instance['id']}})
222
223 def rescue(self, context, instance_id):
224 """Rescue the given instance."""
225 instance = self.db.instance_get_by_internal_id(context, instance_id)
226 host = instance['host']
227 rpc.cast(context,
228 self.db.queue_get_for(context, FLAGS.compute_topic, host),
229 {"method": "rescue_instance",
230 "args": {"instance_id": instance['id']}})
231
232 def unrescue(self, context, instance_id):
233 """Unrescue the given instance."""
234 instance = self.db.instance_get_by_internal_id(context, instance_id)
235 host = instance['host']
236 rpc.cast(context,
237 self.db.queue_get_for(context, FLAGS.compute_topic, host),
238 {"method": "unrescue_instance",
239 "args": {"instance_id": instance['id']}})