summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Day <eday@oddments.org>2010-12-08 17:19:43 +0000
committerTarmac <>2010-12-08 17:19:43 +0000
commit3bb38e64ed5144db00d77488243b6b70023a3c44 (patch)
tree5b327045d201b124f9696d44a140dce8241b8e5e
parentc56ef6aa6162d96c1b4225a06e51c706e9ae38e9 (diff)
parentb2062735781b9e189e2dfa395a6976be9e04e1ee (diff)
Moved the reboot/rescue methods into nova.compute.api.
-rw-r--r--nova/api/cloud.py58
-rw-r--r--nova/api/ec2/cloud.py7
-rw-r--r--nova/api/openstack/servers.py7
-rw-r--r--nova/compute/api.py27
4 files changed, 33 insertions, 66 deletions
diff --git a/nova/api/cloud.py b/nova/api/cloud.py
deleted file mode 100644
index b8f15019f..000000000
--- a/nova/api/cloud.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 United States Government as represented by the
-# Administrator of the National Aeronautics and Space Administration.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-"""
-Methods for API calls to control instances via AMQP.
-"""
-
-
-from nova import db
-from nova import flags
-from nova import rpc
-
-FLAGS = flags.FLAGS
-
-
-def reboot(instance_id, context=None):
- """Reboot the given instance."""
- instance_ref = db.instance_get_by_internal_id(context, instance_id)
- host = instance_ref['host']
- rpc.cast(context,
- db.queue_get_for(context, FLAGS.compute_topic, host),
- {"method": "reboot_instance",
- "args": {"instance_id": instance_ref['id']}})
-
-
-def rescue(instance_id, context):
- """Rescue the given instance."""
- instance_ref = db.instance_get_by_internal_id(context, instance_id)
- host = instance_ref['host']
- rpc.cast(context,
- db.queue_get_for(context, FLAGS.compute_topic, host),
- {"method": "rescue_instance",
- "args": {"instance_id": instance_ref['id']}})
-
-
-def unrescue(instance_id, context):
- """Unrescue the given instance."""
- instance_ref = db.instance_get_by_internal_id(context, instance_id)
- host = instance_ref['host']
- rpc.cast(context,
- db.queue_get_for(context, FLAGS.compute_topic, host),
- {"method": "unrescue_instance",
- "args": {"instance_id": instance_ref['id']}})
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index e50906ae1..161d2d038 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -41,7 +41,6 @@ from nova import rpc
from nova import utils
from nova.compute import api as compute_api
from nova.compute import instance_types
-from nova.api import cloud
from nova.image.s3 import S3ImageService
@@ -834,19 +833,19 @@ class CloudController(object):
"""instance_id is a list of instance ids"""
for ec2_id in instance_id:
internal_id = ec2_id_to_internal_id(ec2_id)
- cloud.reboot(internal_id, context=context)
+ self.compute_api.reboot(context, internal_id)
return True
def rescue_instance(self, context, instance_id, **kwargs):
"""This is an extension to the normal ec2_api"""
internal_id = ec2_id_to_internal_id(instance_id)
- cloud.rescue(internal_id, context=context)
+ self.compute_api.rescue(context, internal_id)
return True
def unrescue_instance(self, context, instance_id, **kwargs):
"""This is an extension to the normal ec2_api"""
internal_id = ec2_id_to_internal_id(instance_id)
- cloud.unrescue(internal_id, context=context)
+ self.compute_api.unrescue(context, internal_id)
return True
def update_instance(self, context, ec2_id, **kwargs):
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index e7f765c02..519250e60 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -23,7 +23,6 @@ from nova import rpc
from nova import utils
from nova import wsgi
from nova import context
-from nova.api import cloud
from nova.api.openstack import faults
from nova.compute import api as compute_api
from nova.compute import instance_types
@@ -183,9 +182,9 @@ class Controller(wsgi.Controller):
inst_ref = self.db.instance_get_by_internal_id(ctxt, int(id))
if not inst_ref or (inst_ref and not inst_ref.user_id == user_id):
return faults.Fault(exc.HTTPUnprocessableEntity())
- #TODO(gundlach): pass reboot_type, support soft reboot in
- #virt driver
- cloud.reboot(id)
+ # TODO(gundlach): pass reboot_type, support soft reboot in
+ # virt driver
+ self.compute_api.reboot(ctxt, id)
def _get_network_topic(self, context):
"""Retrieves the network host for a project"""
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 929342a1e..da01ca61a 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -210,3 +210,30 @@ class ComputeAPI(base.Base):
"""
self.db.instance_update(context, instance_id, kwargs)
+
+ def reboot(self, context, instance_id):
+ """Reboot the given instance."""
+ instance = self.db.instance_get_by_internal_id(context, instance_id)
+ host = instance['host']
+ rpc.cast(context,
+ self.db.queue_get_for(context, FLAGS.compute_topic, host),
+ {"method": "reboot_instance",
+ "args": {"instance_id": instance['id']}})
+
+ def rescue(self, context, instance_id):
+ """Rescue the given instance."""
+ instance = self.db.instance_get_by_internal_id(context, instance_id)
+ host = instance['host']
+ rpc.cast(context,
+ self.db.queue_get_for(context, FLAGS.compute_topic, host),
+ {"method": "rescue_instance",
+ "args": {"instance_id": instance['id']}})
+
+ def unrescue(self, context, instance_id):
+ """Unrescue the given instance."""
+ instance = self.db.instance_get_by_internal_id(context, instance_id)
+ host = instance['host']
+ rpc.cast(context,
+ self.db.queue_get_for(context, FLAGS.compute_topic, host),
+ {"method": "unrescue_instance",
+ "args": {"instance_id": instance['id']}})