dhcp/rpc: retrieve network details with segments
When segment plugin is enabled, we should return segments details as they are part of network. Partial-Bug: #1956435 Partial-Bug: #1764738 Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@industrialdiscipline.com> Change-Id: I1dab155bc812f8764d22e78ebb7d80aaaad65515
This commit is contained in:
parent
7a1e253851
commit
7ceb935da8
|
@ -75,10 +75,12 @@ class DhcpRpcCallback(object):
|
||||||
# 1.7 - Add get_networks
|
# 1.7 - Add get_networks
|
||||||
# 1.8 - Add get_dhcp_port
|
# 1.8 - Add get_dhcp_port
|
||||||
# 1.9 - get_network_info returns info with only DHCP enabled subnets
|
# 1.9 - get_network_info returns info with only DHCP enabled subnets
|
||||||
|
# 1.10 - get_network_info returns segments details when plugin is
|
||||||
|
# enabled
|
||||||
|
|
||||||
target = oslo_messaging.Target(
|
target = oslo_messaging.Target(
|
||||||
namespace=constants.RPC_NAMESPACE_DHCP_PLUGIN,
|
namespace=constants.RPC_NAMESPACE_DHCP_PLUGIN,
|
||||||
version='1.9')
|
version='1.10')
|
||||||
|
|
||||||
def _get_active_networks(self, context, **kwargs):
|
def _get_active_networks(self, context, **kwargs):
|
||||||
"""Retrieve and return a list of the active networks."""
|
"""Retrieve and return a list of the active networks."""
|
||||||
|
@ -229,15 +231,27 @@ class DhcpRpcCallback(object):
|
||||||
# the order changes.
|
# the order changes.
|
||||||
# TODO(ralonsoh): in Z+, remove "tenant_id" parameter. DHCP agents
|
# TODO(ralonsoh): in Z+, remove "tenant_id" parameter. DHCP agents
|
||||||
# should read only "project_id".
|
# should read only "project_id".
|
||||||
return {'id': network.id,
|
ret = {'id': network.id,
|
||||||
'project_id': network.project_id,
|
'project_id': network.project_id,
|
||||||
'tenant_id': network.project_id,
|
'tenant_id': network.project_id,
|
||||||
'admin_state_up': network.admin_state_up,
|
'admin_state_up': network.admin_state_up,
|
||||||
'subnets': sorted(subnets, key=operator.itemgetter('id')),
|
'subnets': sorted(subnets, key=operator.itemgetter('id')),
|
||||||
'non_local_subnets': sorted(nonlocal_subnets,
|
'non_local_subnets': sorted(nonlocal_subnets,
|
||||||
key=operator.itemgetter('id')),
|
key=operator.itemgetter('id')),
|
||||||
'ports': ports,
|
'ports': ports,
|
||||||
'mtu': network.mtu}
|
'mtu': network.mtu}
|
||||||
|
if seg_plug:
|
||||||
|
ret['segments'] = [{
|
||||||
|
'id': segment.id,
|
||||||
|
'network_id': segment.network_id,
|
||||||
|
'name': segment.name,
|
||||||
|
'network_type': segment.network_type,
|
||||||
|
'physical_network': segment.physical_network,
|
||||||
|
'segmentation_id': segment.segmentation_id,
|
||||||
|
'is_dynamic': segment.is_dynamic,
|
||||||
|
'segment_index': segment.segment_index,
|
||||||
|
'hosts': segment.hosts} for segment in network.segments]
|
||||||
|
return ret
|
||||||
|
|
||||||
@db_api.retry_db_errors
|
@db_api.retry_db_errors
|
||||||
def release_dhcp_port(self, context, **kwargs):
|
def release_dhcp_port(self, context, **kwargs):
|
||||||
|
|
|
@ -206,15 +206,28 @@ class TestDhcpRpcCallback(base.BaseTestCase):
|
||||||
if subnet.get('segment_id') in segment_ids]
|
if subnet.get('segment_id') in segment_ids]
|
||||||
else:
|
else:
|
||||||
non_local_subnets = []
|
non_local_subnets = []
|
||||||
return {'id': network.id,
|
ret = {'id': network.id,
|
||||||
'project_id': network.project_id,
|
'project_id': network.project_id,
|
||||||
'tenant_id': network.project_id,
|
'tenant_id': network.project_id,
|
||||||
'admin_state_up': network.admin_state_up,
|
'admin_state_up': network.admin_state_up,
|
||||||
'ports': ports,
|
'ports': ports,
|
||||||
'subnets': sorted(subnets, key=operator.itemgetter('id')),
|
'subnets': sorted(subnets, key=operator.itemgetter('id')),
|
||||||
'non_local_subnets': sorted(non_local_subnets,
|
'non_local_subnets': sorted(non_local_subnets,
|
||||||
key=operator.itemgetter('id')),
|
key=operator.itemgetter('id')),
|
||||||
'mtu': network.mtu}
|
'mtu': network.mtu}
|
||||||
|
# Plugin segment is activated globally, the tests is asserting the
|
||||||
|
# return.
|
||||||
|
ret['segments'] = [{'id': segment.id,
|
||||||
|
'network_id': segment.network_id,
|
||||||
|
'name': segment.name,
|
||||||
|
'network_type': segment.network_type,
|
||||||
|
'physical_network': segment.physical_network,
|
||||||
|
'segmentation_id': segment.segmentation_id,
|
||||||
|
'is_dynamic': segment.is_dynamic,
|
||||||
|
'segment_index': segment.segment_index,
|
||||||
|
'hosts': segment.hosts
|
||||||
|
} for segment in network.segments]
|
||||||
|
return ret
|
||||||
|
|
||||||
def _make_subnet_dict(subnet):
|
def _make_subnet_dict(subnet):
|
||||||
ret = {'id': subnet.id}
|
ret = {'id': subnet.id}
|
||||||
|
@ -243,6 +256,8 @@ class TestDhcpRpcCallback(base.BaseTestCase):
|
||||||
if segmented_network:
|
if segmented_network:
|
||||||
network.segments = [mock.Mock(id='1', hosts=['host1']),
|
network.segments = [mock.Mock(id='1', hosts=['host1']),
|
||||||
mock.Mock(id='2', hosts=['host2'])]
|
mock.Mock(id='2', hosts=['host2'])]
|
||||||
|
else:
|
||||||
|
network.segments = []
|
||||||
|
|
||||||
_kwargs = {'network_id': 'a', 'host': 'host1'}
|
_kwargs = {'network_id': 'a', 'host': 'host1'}
|
||||||
if network_info:
|
if network_info:
|
||||||
|
|
Loading…
Reference in New Issue