Merge "ML2: Driver API changes for hierarchical port binding"
This commit is contained in:
@@ -92,13 +92,13 @@ class APICMechanismDriver(api.MechanismDriver):
|
||||
tenant_id = self.name_mapper.tenant(context, tenant_id)
|
||||
|
||||
# Get segmentation id
|
||||
if not context.bound_segment:
|
||||
segment = context.top_bound_segment
|
||||
if not segment:
|
||||
LOG.debug("Port %s is not bound to a segment", port)
|
||||
return
|
||||
seg = None
|
||||
if (context.bound_segment.get(api.NETWORK_TYPE)
|
||||
in [constants.TYPE_VLAN]):
|
||||
seg = context.bound_segment.get(api.SEGMENTATION_ID)
|
||||
if (segment.get(api.NETWORK_TYPE) in [constants.TYPE_VLAN]):
|
||||
seg = segment.get(api.SEGMENTATION_ID)
|
||||
# hosts on which this vlan is provisioned
|
||||
host = context.host
|
||||
# Create a static path attachment for the host/epg/switchport combo
|
||||
|
||||
@@ -177,7 +177,8 @@ class CiscoNexusMechanismDriver(api.MechanismDriver):
|
||||
vlan_already_removed.append(switch_ip)
|
||||
|
||||
def _is_vm_migration(self, context):
|
||||
if not context.bound_segment and context.original_bound_segment:
|
||||
if (not context.bottom_bound_segment and
|
||||
context.original_bottom_bound_segment):
|
||||
return context.host != context.original_host
|
||||
|
||||
def _port_action(self, port, segment, func):
|
||||
@@ -201,13 +202,13 @@ class CiscoNexusMechanismDriver(api.MechanismDriver):
|
||||
# else process update event.
|
||||
if self._is_vm_migration(context):
|
||||
self._port_action(context.original,
|
||||
context.original_bound_segment,
|
||||
context.original_bottom_bound_segment,
|
||||
self._delete_nxos_db)
|
||||
else:
|
||||
if (self._is_deviceowner_compute(context.current) and
|
||||
self._is_status_active(context.current)):
|
||||
self._port_action(context.current,
|
||||
context.bound_segment,
|
||||
context.bottom_bound_segment,
|
||||
self._configure_nxos_db)
|
||||
|
||||
def update_port_postcommit(self, context):
|
||||
@@ -217,25 +218,25 @@ class CiscoNexusMechanismDriver(api.MechanismDriver):
|
||||
# else process update event.
|
||||
if self._is_vm_migration(context):
|
||||
self._port_action(context.original,
|
||||
context.original_bound_segment,
|
||||
context.original_bottom_bound_segment,
|
||||
self._delete_switch_entry)
|
||||
else:
|
||||
if (self._is_deviceowner_compute(context.current) and
|
||||
self._is_status_active(context.current)):
|
||||
self._port_action(context.current,
|
||||
context.bound_segment,
|
||||
context.bottom_bound_segment,
|
||||
self._configure_switch_entry)
|
||||
|
||||
def delete_port_precommit(self, context):
|
||||
"""Delete port pre-database commit event."""
|
||||
if self._is_deviceowner_compute(context.current):
|
||||
self._port_action(context.current,
|
||||
context.bound_segment,
|
||||
context.bottom_bound_segment,
|
||||
self._delete_nxos_db)
|
||||
|
||||
def delete_port_postcommit(self, context):
|
||||
"""Delete port non-database commit event."""
|
||||
if self._is_deviceowner_compute(context.current):
|
||||
self._port_action(context.current,
|
||||
context.bound_segment,
|
||||
context.bottom_bound_segment,
|
||||
self._delete_switch_entry)
|
||||
|
||||
@@ -321,7 +321,7 @@ class FakePortContext(object):
|
||||
return self._network
|
||||
|
||||
@property
|
||||
def bound_segment(self):
|
||||
def top_bound_segment(self):
|
||||
return self._bound_segment
|
||||
|
||||
def set_binding(self, segment_id, vif_type, cap_port_filter):
|
||||
|
||||
@@ -96,13 +96,13 @@ class CiscoML2MechanismTestCase(test_ml2_plugin.Ml2PluginV2TestCase):
|
||||
# Mock port context values for bound_segments and 'status'.
|
||||
self.mock_bound_segment = mock.patch.object(
|
||||
driver_context.PortContext,
|
||||
'bound_segment',
|
||||
'bottom_bound_segment',
|
||||
new_callable=mock.PropertyMock).start()
|
||||
self.mock_bound_segment.return_value = BOUND_SEGMENT1
|
||||
|
||||
self.mock_original_bound_segment = mock.patch.object(
|
||||
driver_context.PortContext,
|
||||
'original_bound_segment',
|
||||
'original_bottom_bound_segment',
|
||||
new_callable=mock.PropertyMock).start()
|
||||
self.mock_original_bound_segment.return_value = None
|
||||
|
||||
@@ -559,16 +559,16 @@ class TestCiscoPortsV2(CiscoML2MechanismTestCase,
|
||||
The first one should only change the current host_id and remove the
|
||||
binding resulting in the mechanism drivers receiving:
|
||||
PortContext.original['binding:host_id']: previous value
|
||||
PortContext.original_bound_segment: previous value
|
||||
PortContext.original_bottom_bound_segment: previous value
|
||||
PortContext.current['binding:host_id']: current (new) value
|
||||
PortContext.bound_segment: None
|
||||
PortContext.bottom_bound_segment: None
|
||||
|
||||
The second one binds the new host resulting in the mechanism
|
||||
drivers receiving:
|
||||
PortContext.original['binding:host_id']: previous value
|
||||
PortContext.original_bound_segment: None
|
||||
PortContext.original_bottom_bound_segment: None
|
||||
PortContext.current['binding:host_id']: previous value
|
||||
PortContext.bound_segment: new value
|
||||
PortContext.bottom_bound_segment: new value
|
||||
"""
|
||||
|
||||
# Create network, subnet and port.
|
||||
|
||||
@@ -93,7 +93,7 @@ class FakePortContext(object):
|
||||
return self._network
|
||||
|
||||
@property
|
||||
def bound_segment(self):
|
||||
def bottom_bound_segment(self):
|
||||
return self._segment
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user