summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrey Morris <trey.morris@rackspace.com>2011-02-14 12:32:33 -0600
committerTrey Morris <trey.morris@rackspace.com>2011-02-14 12:32:33 -0600
commit3f96e6dbf12533355aa6722eeb498814df076aea (patch)
treee02bdbc03996bb26143542cc33b3ee2bf0c34fac
parent9c0862b5f84cdb09b7ab0aafca669d30f261a666 (diff)
downloadnova-3f96e6dbf12533355aa6722eeb498814df076aea.tar.gz
nova-3f96e6dbf12533355aa6722eeb498814df076aea.tar.xz
nova-3f96e6dbf12533355aa6722eeb498814df076aea.zip
added call to reset_network from openstack api down to vmops
-rw-r--r--nova/api/openstack/servers.py14
-rw-r--r--nova/compute/api.py9
-rw-r--r--nova/compute/manager.py12
-rw-r--r--nova/virt/xenapi_conn.py4
4 files changed, 38 insertions, 1 deletions
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 8cbcebed2..c604bd215 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -242,6 +242,20 @@ class Controller(wsgi.Controller):
return faults.Fault(exc.HTTPUnprocessableEntity())
return exc.HTTPAccepted()
+ def reset_network(self, req, id):
+ """
+ admin only operation which resets networking on an instance
+
+ """
+ context = req.environ['nova.context']
+ try:
+ self.compute_api.reset_network(context, id)
+ except:
+ readable = traceback.format_exc()
+ LOG.exception(_("Compute.api::reset_network %s"), readable)
+ return faults.Fault(exc.HTTPUnprocessableEntity())
+ return exc.HTTPAccepted()
+
def pause(self, req, id):
""" Permit Admins to Pause the server. """
ctxt = req.environ['nova.context']
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 6a3fe08b6..43332ed27 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -1,4 +1,4 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
+# vim: tabstop=5 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
@@ -463,6 +463,13 @@ class API(base.Base):
instance = self.get(context, instance_id)
return instance['locked']
+ def reset_network(self, context, instance_id):
+ """
+ resets networking on the instance
+
+ """
+ self._cast_compute_message('reset_network', context, instance_id)
+
def attach_volume(self, context, instance_id, volume_id, device):
if not re.match("^/dev/[a-z]d[a-z]+$", device):
raise exception.ApiError(_("Invalid device specified: %s. "
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 6f09ce674..b03f58693 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -494,6 +494,18 @@ class ComputeManager(manager.Manager):
instance_ref = self.db.instance_get(context, instance_id)
return instance_ref['locked']
+ @checks_instance_lock
+ def reset_network(self, context, instance_id):
+ """
+ resets the networking on the instance
+
+ """
+ context = context.elevated()
+ instance_ref = self.db.instance_get(context, instance_id)
+ LOG.debug(_('instance %s: reset network'), instance_id,
+ context=context)
+ self.driver.reset_network(instance_ref)
+
@exception.wrap_exception
def get_console_output(self, context, instance_id):
"""Send the console output for an instance."""
diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py
index 927f5905b..4e5442aa6 100644
--- a/nova/virt/xenapi_conn.py
+++ b/nova/virt/xenapi_conn.py
@@ -188,6 +188,10 @@ class XenAPIConnection(object):
"""resume the specified instance"""
self._vmops.resume(instance, callback)
+ def reset_network(self, instance):
+ """reset networking for specified instance"""
+ self._vmops.reset_network(instance)
+
def get_info(self, instance_id):
"""Return data about VM instance"""
return self._vmops.get_info(instance_id)