Merge "Add network_id in segment check log"
This commit is contained in:
commit
c3b4ddaf7c
|
@ -27,6 +27,7 @@ LOG = logging.getLogger(__name__)
|
|||
NETWORK_TYPE = segments_model.NetworkSegment.network_type.name
|
||||
PHYSICAL_NETWORK = segments_model.NetworkSegment.physical_network.name
|
||||
SEGMENTATION_ID = segments_model.NetworkSegment.segmentation_id.name
|
||||
NETWORK_ID = segments_model.NetworkSegment.network_id.name
|
||||
|
||||
|
||||
def _make_segment_dict(obj):
|
||||
|
@ -34,7 +35,8 @@ def _make_segment_dict(obj):
|
|||
return {'id': obj.id,
|
||||
NETWORK_TYPE: obj.network_type,
|
||||
PHYSICAL_NETWORK: obj.physical_network,
|
||||
SEGMENTATION_ID: obj.segmentation_id}
|
||||
SEGMENTATION_ID: obj.segmentation_id,
|
||||
NETWORK_ID: obj.network_id}
|
||||
|
||||
|
||||
def add_network_segment(context, network_id, segment, segment_index=0,
|
||||
|
|
|
@ -27,6 +27,7 @@ NETWORK_TYPE = 'network_type'
|
|||
PHYSICAL_NETWORK = 'physical_network'
|
||||
SEGMENTATION_ID = 'segmentation_id'
|
||||
MTU = 'mtu'
|
||||
NETWORK_ID = 'network_id'
|
||||
|
||||
# The following keys are used in the binding level dictionaries
|
||||
# available via the binding_levels and original_binding_levels
|
||||
|
|
|
@ -233,10 +233,11 @@ class SimpleAgentMechanismDriverBase(AgentMechanismDriverBase):
|
|||
network_type = segment[api.NETWORK_TYPE]
|
||||
if network_type not in allowed_network_types:
|
||||
LOG.debug(
|
||||
'Segment %(id)s is of type %(network_type)s '
|
||||
'but agent %(agent)s or mechanism driver only '
|
||||
'support %(allowed_network_types)s.',
|
||||
{'id': segment['id'],
|
||||
'Network %(network_id)s with segment %(id)s is type '
|
||||
'of %(network_type)s but agent %(agent)s or mechanism driver '
|
||||
'only support %(allowed_network_types)s.',
|
||||
{'network_id': segment['network_id'],
|
||||
'id': segment['id'],
|
||||
'network_type': network_type,
|
||||
'agent': agent['host'],
|
||||
'allowed_network_types': allowed_network_types})
|
||||
|
@ -246,12 +247,13 @@ class SimpleAgentMechanismDriverBase(AgentMechanismDriverBase):
|
|||
physnet = segment[api.PHYSICAL_NETWORK]
|
||||
if not self.physnet_in_mappings(physnet, mappings):
|
||||
LOG.debug(
|
||||
'Segment %(id)s is connected to physical '
|
||||
'network %(physnet)s, but agent %(agent)s reported '
|
||||
'physical networks %(mappings)s. '
|
||||
'Network %(network_id)s with segment %(id)s is connected '
|
||||
'to physical network %(physnet)s, but agent %(agent)s '
|
||||
'reported physical networks %(mappings)s. '
|
||||
'The physical network must be configured on the '
|
||||
'agent if binding is to succeed.',
|
||||
{'id': segment['id'],
|
||||
{'network_id': segment['network_id'],
|
||||
'id': segment['id'],
|
||||
'physnet': physnet,
|
||||
'agent': agent['host'],
|
||||
'mappings': mappings})
|
||||
|
|
|
@ -191,7 +191,8 @@ class AgentMechanismBaseTestCase(base.BaseTestCase):
|
|||
|
||||
class AgentMechanismGenericTestCase(AgentMechanismBaseTestCase):
|
||||
UNKNOWN_TYPE_SEGMENTS = [{api.ID: 'unknown_segment_id',
|
||||
api.NETWORK_TYPE: 'no_such_type'}]
|
||||
api.NETWORK_TYPE: 'no_such_type',
|
||||
api.NETWORK_ID: 'fake_network_id'}]
|
||||
|
||||
def test_unknown_type(self):
|
||||
context = FakePortContext(self.AGENT_TYPE,
|
||||
|
@ -204,9 +205,11 @@ class AgentMechanismGenericTestCase(AgentMechanismBaseTestCase):
|
|||
|
||||
class AgentMechanismLocalTestCase(AgentMechanismBaseTestCase):
|
||||
LOCAL_SEGMENTS = [{api.ID: 'unknown_segment_id',
|
||||
api.NETWORK_TYPE: 'no_such_type'},
|
||||
api.NETWORK_TYPE: 'no_such_type',
|
||||
api.NETWORK_ID: 'fake_network_id'},
|
||||
{api.ID: 'local_segment_id',
|
||||
api.NETWORK_TYPE: 'local'}]
|
||||
api.NETWORK_TYPE: 'local',
|
||||
api.NETWORK_ID: 'fake_network_id'}]
|
||||
|
||||
def test_type_local(self):
|
||||
context = FakePortContext(self.AGENT_TYPE,
|
||||
|
@ -227,10 +230,12 @@ class AgentMechanismLocalTestCase(AgentMechanismBaseTestCase):
|
|||
|
||||
class AgentMechanismFlatTestCase(AgentMechanismBaseTestCase):
|
||||
FLAT_SEGMENTS = [{api.ID: 'unknown_segment_id',
|
||||
api.NETWORK_TYPE: 'no_such_type'},
|
||||
api.NETWORK_TYPE: 'no_such_type',
|
||||
api.NETWORK_ID: 'fake_network_id'},
|
||||
{api.ID: 'flat_segment_id',
|
||||
api.NETWORK_TYPE: 'flat',
|
||||
api.PHYSICAL_NETWORK: 'fake_physical_network'}]
|
||||
api.PHYSICAL_NETWORK: 'fake_physical_network',
|
||||
api.NETWORK_ID: 'fake_network_id'}]
|
||||
|
||||
def test_type_flat(self):
|
||||
context = FakePortContext(self.AGENT_TYPE,
|
||||
|
@ -251,11 +256,13 @@ class AgentMechanismFlatTestCase(AgentMechanismBaseTestCase):
|
|||
|
||||
class AgentMechanismVlanTestCase(AgentMechanismBaseTestCase):
|
||||
VLAN_SEGMENTS = [{api.ID: 'unknown_segment_id',
|
||||
api.NETWORK_TYPE: 'no_such_type'},
|
||||
api.NETWORK_TYPE: 'no_such_type',
|
||||
api.NETWORK_ID: 'fake_network_id'},
|
||||
{api.ID: 'vlan_segment_id',
|
||||
api.NETWORK_TYPE: 'vlan',
|
||||
api.PHYSICAL_NETWORK: 'fake_physical_network',
|
||||
api.SEGMENTATION_ID: 1234}]
|
||||
api.SEGMENTATION_ID: 1234,
|
||||
api.NETWORK_ID: 'fake_network_id'}]
|
||||
|
||||
def test_type_vlan(self):
|
||||
context = FakePortContext(self.AGENT_TYPE,
|
||||
|
@ -276,10 +283,12 @@ class AgentMechanismVlanTestCase(AgentMechanismBaseTestCase):
|
|||
|
||||
class AgentMechanismGreTestCase(AgentMechanismBaseTestCase):
|
||||
GRE_SEGMENTS = [{api.ID: 'unknown_segment_id',
|
||||
api.NETWORK_TYPE: 'no_such_type'},
|
||||
api.NETWORK_TYPE: 'no_such_type',
|
||||
api.NETWORK_ID: 'fake_network_id'},
|
||||
{api.ID: 'gre_segment_id',
|
||||
api.NETWORK_TYPE: 'gre',
|
||||
api.SEGMENTATION_ID: 1234}]
|
||||
api.SEGMENTATION_ID: 1234,
|
||||
api.NETWORK_ID: 'fake_network_id'}]
|
||||
|
||||
def test_type_gre(self):
|
||||
context = FakePortContext(self.AGENT_TYPE,
|
||||
|
|
|
@ -80,6 +80,7 @@ class Ml2DBTestCase(testlib_api.SqlTestCase):
|
|||
segments_db.add_network_segment(
|
||||
self.ctx, network_id, segment,
|
||||
is_dynamic=is_seg_dynamic)
|
||||
segment['network_id'] = network_id
|
||||
|
||||
net_segments = segments_db.get_network_segments(
|
||||
self.ctx, network_id,
|
||||
|
|
Loading…
Reference in New Issue