Merge "Add RPC method to get networks for L3 and DHCP agents"
This commit is contained in:
commit
1421c63f4b
|
@ -717,6 +717,7 @@ class DhcpPluginApi(object):
|
|||
1.1 - Added get_active_networks_info, create_dhcp_port,
|
||||
and update_dhcp_port methods.
|
||||
1.5 - Added dhcp_ready_on_ports
|
||||
1.7 - Added get_networks
|
||||
|
||||
"""
|
||||
|
||||
|
@ -781,6 +782,20 @@ class DhcpPluginApi(object):
|
|||
return cctxt.call(self.context, 'dhcp_ready_on_ports',
|
||||
port_ids=port_ids)
|
||||
|
||||
def get_networks(self, filters=None, fields=None):
|
||||
"""Get networks.
|
||||
|
||||
:param filters: The filters to apply.
|
||||
E.g {"id" : ["<uuid of a network>", ...]}
|
||||
:param fields: A list of fields to collect, e.g ["id", "subnets"].
|
||||
:return: A list of NetModel where each object represent a network.
|
||||
"""
|
||||
|
||||
cctxt = self.client.prepare(version='1.7')
|
||||
nets = cctxt.call(self.context, 'get_networks', filters=filters,
|
||||
fields=fields)
|
||||
return [dhcp.NetModel(net) for net in nets]
|
||||
|
||||
|
||||
class NetworkCache(object):
|
||||
"""Agent cache of the current network state."""
|
||||
|
|
|
@ -112,6 +112,7 @@ class L3PluginApi(object):
|
|||
1.9 - Added get_router_ids
|
||||
1.10 Added update_all_ha_network_port_statuses
|
||||
1.11 Added get_host_ha_router_count
|
||||
1.12 Added get_networks
|
||||
"""
|
||||
|
||||
def __init__(self, topic, host):
|
||||
|
@ -204,6 +205,20 @@ class L3PluginApi(object):
|
|||
cctxt = self.client.prepare(version='1.11')
|
||||
return cctxt.call(context, 'get_host_ha_router_count', host=self.host)
|
||||
|
||||
def get_networks(self, context, filters=None, fields=None):
|
||||
"""Get networks.
|
||||
|
||||
:param context: Security context
|
||||
:param filters: The filters to apply.
|
||||
E.g {"id" : ["<uuid of a network>", ...]}
|
||||
:param fields: A list of fields to collect, e.g ["id", "subnets"].
|
||||
:return: A list of dicts where each dict represent a network object.
|
||||
"""
|
||||
|
||||
cctxt = self.client.prepare(version='1.12')
|
||||
return cctxt.call(
|
||||
context, 'get_networks', filters=filters, fields=fields)
|
||||
|
||||
|
||||
class RouterFactory(object):
|
||||
|
||||
|
|
|
@ -70,10 +70,11 @@ class DhcpRpcCallback(object):
|
|||
# 1.6 - Removed get_active_networks. It's not used by reference
|
||||
# DHCP agent since Havana, so similar rationale for not bumping
|
||||
# the major version as above applies here too.
|
||||
# 1.7 - Add get_networks
|
||||
|
||||
target = oslo_messaging.Target(
|
||||
namespace=constants.RPC_NAMESPACE_DHCP_PLUGIN,
|
||||
version='1.6')
|
||||
version='1.7')
|
||||
|
||||
def _get_active_networks(self, context, **kwargs):
|
||||
"""Retrieve and return a list of the active networks."""
|
||||
|
@ -318,3 +319,12 @@ class DhcpRpcCallback(object):
|
|||
provisioning_blocks.provisioning_complete(
|
||||
context, port_id, resources.PORT,
|
||||
provisioning_blocks.DHCP_ENTITY)
|
||||
|
||||
def get_networks(self, context, filters=None, fields=None):
|
||||
"""Retrieve and return a list of networks."""
|
||||
# NOTE(adrianc): This RPC is being used by out of tree interface
|
||||
# drivers, MultiInterfaceDriver and IPoIBInterfaceDriver, located in
|
||||
# networking-mlnx.
|
||||
plugin = directory.get_plugin()
|
||||
return plugin.get_networks(
|
||||
context, filters=filters, fields=fields)
|
||||
|
|
|
@ -46,7 +46,8 @@ class L3RpcCallback(object):
|
|||
# 1.9 Added get_router_ids
|
||||
# 1.10 Added update_all_ha_network_port_statuses
|
||||
# 1.11 Added get_host_ha_router_count
|
||||
target = oslo_messaging.Target(version='1.11')
|
||||
# 1.12 Added get_networks
|
||||
target = oslo_messaging.Target(version='1.12')
|
||||
|
||||
@property
|
||||
def plugin(self):
|
||||
|
@ -348,3 +349,11 @@ class L3RpcCallback(object):
|
|||
admin_ctx = neutron_context.get_admin_context()
|
||||
self.l3plugin.delete_floatingip_agent_gateway_port(
|
||||
admin_ctx, host, network_id)
|
||||
|
||||
def get_networks(self, context, filters=None, fields=None):
|
||||
"""Retrieve and return a list of networks."""
|
||||
# NOTE(adrianc): This RPC is being used by out of tree interface
|
||||
# drivers, MultiInterfaceDriver and IPoIBInterfaceDriver, located in
|
||||
# networking-mlnx.
|
||||
return self.plugin.get_networks(
|
||||
context, filters=filters, fields=fields)
|
||||
|
|
Loading…
Reference in New Issue