summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorMate Lakat <mate.lakat@citrix.com>2012-09-11 16:53:05 +0100
committerMate Lakat <mate.lakat@citrix.com>2012-09-19 11:08:19 +0100
commitb8b46cbd6c06cb4979fa2f443892a2a1d60cc7bb (patch)
treeeb6f7c4068af2e160ad67d3016e35ec6e5298a40 /nova/compute
parentf1189f4774e469e39097e4d10159425a9ed40757 (diff)
xapi: fix create hypervisor pool
Fixes bug 1049099. Fixing problems with the rpc api when creating hypervisor pools with xenapi. Rpc calls were not using the compute_rpcapi approach, thus were not properly versioned. Apart from that, the slave parameters were not forwarded to the master. A new (2.2) version is introduced where the rpc calls have the slave_info payload. Added tests to cover the pool cases. Some trivial extract methods performed on pool, to decouple the pool functionality from its dependencies. Change-Id: Ie44a1c09ef204affc4a657c71557691e83b22c22
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/manager.py13
-rw-r--r--nova/compute/rpcapi.py22
2 files changed, 24 insertions, 11 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index cd756af65..2f977b26c 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -213,7 +213,7 @@ def _get_image_meta(context, image_ref):
class ComputeManager(manager.SchedulerDependentManager):
"""Manages the running instances from creation to destruction."""
- RPC_API_VERSION = '2.1'
+ RPC_API_VERSION = '2.2'
def __init__(self, compute_driver=None, *args, **kwargs):
"""Load configuration options and connect to the hypervisor."""
@@ -2812,11 +2812,12 @@ class ComputeManager(manager.SchedulerDependentManager):
self._set_instance_error_state(context, instance_uuid)
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
- def add_aggregate_host(self, context, aggregate_id, host):
+ def add_aggregate_host(self, context, aggregate_id, host, slave_info=None):
"""Notify hypervisor of change (for hypervisor pools)."""
aggregate = self.db.aggregate_get(context, aggregate_id)
try:
- self.driver.add_to_aggregate(context, aggregate, host)
+ self.driver.add_to_aggregate(context, aggregate, host,
+ slave_info=slave_info)
except exception.AggregateError:
with excutils.save_and_reraise_exception():
self.driver.undo_aggregate_operation(context,
@@ -2824,11 +2825,13 @@ class ComputeManager(manager.SchedulerDependentManager):
aggregate.id, host)
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
- def remove_aggregate_host(self, context, aggregate_id, host):
+ def remove_aggregate_host(self, context, aggregate_id,
+ host, slave_info=None):
"""Removes a host from a physical hypervisor pool."""
aggregate = self.db.aggregate_get(context, aggregate_id)
try:
- self.driver.remove_from_aggregate(context, aggregate, host)
+ self.driver.remove_from_aggregate(context, aggregate, host,
+ slave_info=slave_info)
except (exception.AggregateError,
exception.InvalidAggregateAction) as e:
with excutils.save_and_reraise_exception():
diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py
index b53cc1e7a..2e3873c19 100644
--- a/nova/compute/rpcapi.py
+++ b/nova/compute/rpcapi.py
@@ -128,6 +128,8 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
2.0 - Remove 1.x backwards compat
2.1 - Adds orig_sys_metadata to rebuild_instance()
+ 2.2 - Adds slave_info parameter to add_aggregate_host() and
+ remove_aggregate_host()
'''
#
@@ -145,7 +147,8 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
topic=FLAGS.compute_topic,
default_version=self.BASE_RPC_API_VERSION)
- def add_aggregate_host(self, ctxt, aggregate_id, host_param, host):
+ def add_aggregate_host(self, ctxt, aggregate_id, host_param, host,
+ slave_info=None):
'''Add aggregate host.
:param ctxt: request context
@@ -154,9 +157,12 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
parameter for the remote method.
:param host: This is the host to send the message to.
'''
+
self.cast(ctxt, self.make_msg('add_aggregate_host',
- aggregate_id=aggregate_id, host=host_param),
- topic=_compute_topic(self.topic, ctxt, host, None))
+ aggregate_id=aggregate_id, host=host_param,
+ slave_info=slave_info),
+ topic=_compute_topic(self.topic, ctxt, host, None),
+ version='2.2')
def add_fixed_ip_to_instance(self, ctxt, instance, network_id):
instance_p = jsonutils.to_primitive(instance)
@@ -355,7 +361,8 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
self.cast(ctxt, self.make_msg('refresh_provider_fw_rules'),
_compute_topic(self.topic, ctxt, host, None))
- def remove_aggregate_host(self, ctxt, aggregate_id, host_param, host):
+ def remove_aggregate_host(self, ctxt, aggregate_id, host_param, host,
+ slave_info=None):
'''Remove aggregate host.
:param ctxt: request context
@@ -364,9 +371,12 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
parameter for the remote method.
:param host: This is the host to send the message to.
'''
+
self.cast(ctxt, self.make_msg('remove_aggregate_host',
- aggregate_id=aggregate_id, host=host_param),
- topic=_compute_topic(self.topic, ctxt, host, None))
+ aggregate_id=aggregate_id, host=host_param,
+ slave_info=slave_info),
+ topic=_compute_topic(self.topic, ctxt, host, None),
+ version='2.2')
def remove_fixed_ip_from_instance(self, ctxt, instance, address):
instance_p = jsonutils.to_primitive(instance)