NSXP: complete port attach/detach methods
Add required attributes for trunk driver implementation to port attach/detach methods. Change-Id: Icb43cad26b899723ea7e606b7d4a67853496d9b9
This commit is contained in:
parent
eee5406118
commit
42d373bf54
|
@ -3959,6 +3959,59 @@ class TestPolicySegmentPort(NsxPolicyLibTestCase):
|
||||||
self.assert_called_with_def(api_call, expected_def)
|
self.assert_called_with_def(api_call, expected_def)
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
|
|
||||||
|
def test_attach(self):
|
||||||
|
segment_id = "segment"
|
||||||
|
port_id = "port"
|
||||||
|
attachment_type = "CHILD"
|
||||||
|
vif_id = "vif"
|
||||||
|
app_id = "app"
|
||||||
|
context_id = "context"
|
||||||
|
traffic_tag = 10
|
||||||
|
allocate_addresses = "BOTH"
|
||||||
|
tags = [{'scope': 'a', 'tag': 'b'}]
|
||||||
|
with mock.patch.object(self.policy_api,
|
||||||
|
"create_or_update") as api_call:
|
||||||
|
self.resourceApi.attach(
|
||||||
|
segment_id, port_id,
|
||||||
|
attachment_type=attachment_type, vif_id=vif_id, app_id=app_id,
|
||||||
|
context_id=context_id, traffic_tag=traffic_tag,
|
||||||
|
allocate_addresses=allocate_addresses, tags=tags,
|
||||||
|
tenant=TEST_TENANT)
|
||||||
|
|
||||||
|
expected_def = core_defs.SegmentPortDef(
|
||||||
|
segment_id=segment_id,
|
||||||
|
port_id=port_id,
|
||||||
|
attachment_type=attachment_type,
|
||||||
|
vif_id=vif_id,
|
||||||
|
app_id=app_id,
|
||||||
|
context_id=context_id,
|
||||||
|
traffic_tag=traffic_tag,
|
||||||
|
allocate_addresses=allocate_addresses,
|
||||||
|
tags=tags,
|
||||||
|
tenant=TEST_TENANT)
|
||||||
|
|
||||||
|
self.assert_called_with_def(api_call, expected_def)
|
||||||
|
|
||||||
|
def test_detach(self):
|
||||||
|
segment_id = "segment"
|
||||||
|
port_id = "port"
|
||||||
|
tags = [{'scope': 'a', 'tag': 'b'}]
|
||||||
|
with mock.patch.object(self.policy_api,
|
||||||
|
"create_or_update") as api_call:
|
||||||
|
self.resourceApi.detach(
|
||||||
|
segment_id, port_id, tags=tags,
|
||||||
|
tenant=TEST_TENANT)
|
||||||
|
|
||||||
|
expected_def = core_defs.SegmentPortDef(
|
||||||
|
segment_id=segment_id,
|
||||||
|
port_id=port_id,
|
||||||
|
attachment_type=None,
|
||||||
|
vif_id=None,
|
||||||
|
tags=tags,
|
||||||
|
tenant=TEST_TENANT)
|
||||||
|
|
||||||
|
self.assert_called_with_def(api_call, expected_def)
|
||||||
|
|
||||||
|
|
||||||
class TestPolicySegmentProfileBase(NsxPolicyLibTestCase):
|
class TestPolicySegmentProfileBase(NsxPolicyLibTestCase):
|
||||||
|
|
||||||
|
|
|
@ -1962,21 +1962,25 @@ class NsxPolicySegmentPortApi(NsxPolicyResourceBase):
|
||||||
tags=tags,
|
tags=tags,
|
||||||
tenant=tenant)
|
tenant=tenant)
|
||||||
|
|
||||||
def detach(self, segment_id, port_id,
|
def detach(self, segment_id, port_id, tags=IGNORE,
|
||||||
tenant=constants.POLICY_INFRA_TENANT):
|
tenant=constants.POLICY_INFRA_TENANT):
|
||||||
|
|
||||||
port_def = self.entry_def(segment_id=segment_id,
|
port_def = self.entry_def(segment_id=segment_id,
|
||||||
port_id=port_id,
|
port_id=port_id,
|
||||||
|
vif_id=None,
|
||||||
attachment_type=None,
|
attachment_type=None,
|
||||||
|
tags=tags,
|
||||||
tenant=tenant)
|
tenant=tenant)
|
||||||
self.policy_api.create_or_update(port_def)
|
self.policy_api.create_or_update(port_def)
|
||||||
|
|
||||||
def attach(self, segment_id, port_id,
|
def attach(self, segment_id, port_id,
|
||||||
attachment_type,
|
attachment_type,
|
||||||
vif_id,
|
vif_id,
|
||||||
allocate_addresses,
|
allocate_addresses=None,
|
||||||
app_id=None,
|
app_id=None,
|
||||||
context_id=None,
|
context_id=None,
|
||||||
|
traffic_tag=None,
|
||||||
|
tags=IGNORE,
|
||||||
tenant=constants.POLICY_INFRA_TENANT):
|
tenant=constants.POLICY_INFRA_TENANT):
|
||||||
|
|
||||||
port_def = self.entry_def(segment_id=segment_id,
|
port_def = self.entry_def(segment_id=segment_id,
|
||||||
|
@ -1986,6 +1990,8 @@ class NsxPolicySegmentPortApi(NsxPolicyResourceBase):
|
||||||
vif_id=vif_id,
|
vif_id=vif_id,
|
||||||
app_id=app_id,
|
app_id=app_id,
|
||||||
context_id=context_id,
|
context_id=context_id,
|
||||||
|
traffic_tag=traffic_tag,
|
||||||
|
tags=tags,
|
||||||
tenant=tenant)
|
tenant=tenant)
|
||||||
|
|
||||||
self.policy_api.create_or_update(port_def)
|
self.policy_api.create_or_update(port_def)
|
||||||
|
|
Loading…
Reference in New Issue