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
1=== removed file 'nova/api/cloud.py'
2--- nova/api/cloud.py 2010-10-24 23:04:35 +0000
3+++ nova/api/cloud.py 1970-01-01 00:00:00 +0000
4@@ -1,58 +0,0 @@
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- instance_ref = db.instance_get_by_internal_id(context, instance_id)
38- host = instance_ref['host']
39- rpc.cast(context,
40- db.queue_get_for(context, FLAGS.compute_topic, host),
41- {"method": "reboot_instance",
42- "args": {"instance_id": instance_ref['id']}})
43-
44-
45-def rescue(instance_id, context):
46- """Rescue the given instance."""
47- instance_ref = db.instance_get_by_internal_id(context, instance_id)
48- host = instance_ref['host']
49- rpc.cast(context,
50- db.queue_get_for(context, FLAGS.compute_topic, host),
51- {"method": "rescue_instance",
52- "args": {"instance_id": instance_ref['id']}})
53-
54-
55-def unrescue(instance_id, context):
56- """Unrescue the given instance."""
57- instance_ref = db.instance_get_by_internal_id(context, instance_id)
58- host = instance_ref['host']
59- rpc.cast(context,
60- db.queue_get_for(context, FLAGS.compute_topic, host),
61- {"method": "unrescue_instance",
62- "args": {"instance_id": instance_ref['id']}})
63
64=== modified file 'nova/api/ec2/cloud.py'
65--- nova/api/ec2/cloud.py 2010-12-02 16:47:25 +0000
66+++ nova/api/ec2/cloud.py 2010-12-03 17:43:19 +0000
67@@ -41,7 +41,6 @@
68 from nova import utils
69 from nova.compute import api as compute_api
70 from nova.compute import instance_types
71-from nova.api import cloud
72 from nova.image.s3 import S3ImageService
73
74
75@@ -834,19 +833,19 @@
76 """instance_id is a list of instance ids"""
77 for ec2_id in instance_id:
78 internal_id = ec2_id_to_internal_id(ec2_id)
79- cloud.reboot(internal_id, context=context)
80+ self.compute_api.reboot(context, internal_id)
81 return True
82
83 def rescue_instance(self, context, instance_id, **kwargs):
84 """This is an extension to the normal ec2_api"""
85 internal_id = ec2_id_to_internal_id(instance_id)
86- cloud.rescue(internal_id, context=context)
87+ self.compute_api.rescue(context, internal_id)
88 return True
89
90 def unrescue_instance(self, context, instance_id, **kwargs):
91 """This is an extension to the normal ec2_api"""
92 internal_id = ec2_id_to_internal_id(instance_id)
93- cloud.unrescue(internal_id, context=context)
94+ self.compute_api.unrescue(context, internal_id)
95 return True
96
97 def update_instance(self, context, ec2_id, **kwargs):
98
99=== modified file 'nova/api/openstack/servers.py'
100--- nova/api/openstack/servers.py 2010-12-02 20:17:41 +0000
101+++ nova/api/openstack/servers.py 2010-12-03 17:43:19 +0000
102@@ -23,7 +23,6 @@
103 from nova import utils
104 from nova import wsgi
105 from nova import context
106-from nova.api import cloud
107 from nova.api.openstack import faults
108 from nova.compute import api as compute_api
109 from nova.compute import instance_types
110@@ -183,9 +182,9 @@
111 inst_ref = self.db.instance_get_by_internal_id(ctxt, int(id))
112 if not inst_ref or (inst_ref and not inst_ref.user_id == user_id):
113 return faults.Fault(exc.HTTPUnprocessableEntity())
114- #TODO(gundlach): pass reboot_type, support soft reboot in
115- #virt driver
116- cloud.reboot(id)
117+ # TODO(gundlach): pass reboot_type, support soft reboot in
118+ # virt driver
119+ self.compute_api.reboot(ctxt, id)
120
121 def _get_network_topic(self, context):
122 """Retrieves the network host for a project"""
123
124=== modified file 'nova/compute/api.py'
125--- nova/compute/api.py 2010-12-02 17:34:52 +0000
126+++ nova/compute/api.py 2010-12-03 17:43:19 +0000
127@@ -210,3 +210,30 @@
128
129 """
130 self.db.instance_update(context, instance_id, kwargs)
131+
132+ def reboot(self, context, instance_id):
133+ """Reboot the given instance."""
134+ instance = self.db.instance_get_by_internal_id(context, instance_id)
135+ host = instance['host']
136+ rpc.cast(context,
137+ self.db.queue_get_for(context, FLAGS.compute_topic, host),
138+ {"method": "reboot_instance",
139+ "args": {"instance_id": instance['id']}})
140+
141+ def rescue(self, context, instance_id):
142+ """Rescue the given instance."""
143+ instance = self.db.instance_get_by_internal_id(context, instance_id)
144+ host = instance['host']
145+ rpc.cast(context,
146+ self.db.queue_get_for(context, FLAGS.compute_topic, host),
147+ {"method": "rescue_instance",
148+ "args": {"instance_id": instance['id']}})
149+
150+ def unrescue(self, context, instance_id):
151+ """Unrescue the given instance."""
152+ instance = self.db.instance_get_by_internal_id(context, instance_id)
153+ host = instance['host']
154+ rpc.cast(context,
155+ self.db.queue_get_for(context, FLAGS.compute_topic, host),
156+ {"method": "unrescue_instance",
157+ "args": {"instance_id": instance['id']}})