Port all rpcapi modules to oslo.messaging interface
Add a temporary nova.rpcclient.RPCClient helper class which translates oslo.messaging.rpc.RPCClient compatible calls into calls on a RpcProxy object. Use this new class to port all of the rpcapi modules over to the new RPCClient so that the final port of Nova over to oslo.messaging will be smaller and easier to review. This patch contains no functional changes at all, except that all client side RPCs go through this temporary helper class. blueprint: oslo-messaging Change-Id: Iee86c36bcc474a604993618b8a2255af8c3d2f48
This commit is contained in:
@@ -21,7 +21,7 @@ Client side of the scheduler manager RPC API.
|
|||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from nova.openstack.common import jsonutils
|
from nova.openstack.common import jsonutils
|
||||||
import nova.openstack.common.rpc.proxy
|
from nova import rpcclient
|
||||||
|
|
||||||
rpcapi_opts = [
|
rpcapi_opts = [
|
||||||
cfg.StrOpt('scheduler_topic',
|
cfg.StrOpt('scheduler_topic',
|
||||||
@@ -37,7 +37,7 @@ rpcapi_cap_opt = cfg.StrOpt('scheduler',
|
|||||||
CONF.register_opt(rpcapi_cap_opt, 'upgrade_levels')
|
CONF.register_opt(rpcapi_cap_opt, 'upgrade_levels')
|
||||||
|
|
||||||
|
|
||||||
class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
class SchedulerAPI(rpcclient.RpcProxy):
|
||||||
'''Client side of the scheduler rpc API.
|
'''Client side of the scheduler rpc API.
|
||||||
|
|
||||||
API version history:
|
API version history:
|
||||||
@@ -94,11 +94,12 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
|||||||
super(SchedulerAPI, self).__init__(topic=CONF.scheduler_topic,
|
super(SchedulerAPI, self).__init__(topic=CONF.scheduler_topic,
|
||||||
default_version=self.BASE_RPC_API_VERSION,
|
default_version=self.BASE_RPC_API_VERSION,
|
||||||
version_cap=version_cap)
|
version_cap=version_cap)
|
||||||
|
self.client = self.get_client()
|
||||||
|
|
||||||
def select_destinations(self, ctxt, request_spec, filter_properties):
|
def select_destinations(self, ctxt, request_spec, filter_properties):
|
||||||
return self.call(ctxt, self.make_msg('select_destinations',
|
cctxt = self.client.prepare(version='2.7')
|
||||||
request_spec=request_spec, filter_properties=filter_properties),
|
return cctxt.call(ctxt, 'select_destinations',
|
||||||
version='2.7')
|
request_spec=request_spec, filter_properties=filter_properties)
|
||||||
|
|
||||||
def run_instance(self, ctxt, request_spec, admin_password,
|
def run_instance(self, ctxt, request_spec, admin_password,
|
||||||
injected_files, requested_networks, is_first_time,
|
injected_files, requested_networks, is_first_time,
|
||||||
@@ -110,11 +111,11 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
|||||||
'requested_networks': requested_networks,
|
'requested_networks': requested_networks,
|
||||||
'is_first_time': is_first_time,
|
'is_first_time': is_first_time,
|
||||||
'filter_properties': filter_properties}
|
'filter_properties': filter_properties}
|
||||||
if self.can_send_version('2.9'):
|
if self.client.can_send_version('2.9'):
|
||||||
version = '2.9'
|
version = '2.9'
|
||||||
msg_kwargs['legacy_bdm_in_spec'] = legacy_bdm_in_spec
|
msg_kwargs['legacy_bdm_in_spec'] = legacy_bdm_in_spec
|
||||||
return self.cast(ctxt, self.make_msg('run_instance', **msg_kwargs),
|
cctxt = self.client.prepare(version=version)
|
||||||
version=version)
|
return cctxt.cast(ctxt, 'run_instance', **msg_kwargs)
|
||||||
|
|
||||||
def prep_resize(self, ctxt, instance, instance_type, image,
|
def prep_resize(self, ctxt, instance, instance_type, image,
|
||||||
request_spec, filter_properties, reservations):
|
request_spec, filter_properties, reservations):
|
||||||
@@ -122,24 +123,24 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
|||||||
instance_type_p = jsonutils.to_primitive(instance_type)
|
instance_type_p = jsonutils.to_primitive(instance_type)
|
||||||
reservations_p = jsonutils.to_primitive(reservations)
|
reservations_p = jsonutils.to_primitive(reservations)
|
||||||
image_p = jsonutils.to_primitive(image)
|
image_p = jsonutils.to_primitive(image)
|
||||||
self.cast(ctxt, self.make_msg('prep_resize',
|
self.client.cast(ctxt, 'prep_resize',
|
||||||
instance=instance_p, instance_type=instance_type_p,
|
instance=instance_p, instance_type=instance_type_p,
|
||||||
image=image_p, request_spec=request_spec,
|
image=image_p, request_spec=request_spec,
|
||||||
filter_properties=filter_properties,
|
filter_properties=filter_properties,
|
||||||
reservations=reservations_p))
|
reservations=reservations_p)
|
||||||
|
|
||||||
def update_service_capabilities(self, ctxt, service_name, host,
|
def update_service_capabilities(self, ctxt, service_name, host,
|
||||||
capabilities):
|
capabilities):
|
||||||
#NOTE(jogo) This is deprecated, but is used by the deprecated
|
#NOTE(jogo) This is deprecated, but is used by the deprecated
|
||||||
# publish_service_capabilities call. So this can begin its removal
|
# publish_service_capabilities call. So this can begin its removal
|
||||||
# process once publish_service_capabilities is removed.
|
# process once publish_service_capabilities is removed.
|
||||||
self.fanout_cast(ctxt, self.make_msg('update_service_capabilities',
|
cctxt = self.client.prepare(fanout=True, version='2.4')
|
||||||
service_name=service_name, host=host,
|
cctxt.cast(ctxt, 'update_service_capabilities',
|
||||||
capabilities=capabilities),
|
service_name=service_name, host=host,
|
||||||
version='2.4')
|
capabilities=capabilities)
|
||||||
|
|
||||||
def select_hosts(self, ctxt, request_spec, filter_properties):
|
def select_hosts(self, ctxt, request_spec, filter_properties):
|
||||||
return self.call(ctxt, self.make_msg('select_hosts',
|
cctxt = self.client.prepare(version='2.6')
|
||||||
request_spec=request_spec,
|
return cctxt.call(ctxt, 'select_hosts',
|
||||||
filter_properties=filter_properties),
|
request_spec=request_spec,
|
||||||
version='2.6')
|
filter_properties=filter_properties)
|
||||||
|
|||||||
Reference in New Issue
Block a user