diff --git a/vmware_nsxlib/tests/unit/v3/policy/test_resources.py b/vmware_nsxlib/tests/unit/v3/policy/test_resources.py index d197ce4b..db61ee95 100644 --- a/vmware_nsxlib/tests/unit/v3/policy/test_resources.py +++ b/vmware_nsxlib/tests/unit/v3/policy/test_resources.py @@ -5764,6 +5764,26 @@ class TestPolicySegmentPort(NsxPolicyLibTestCase): lp_update.assert_called_once_with( mock.ANY, False, admin_state=True) + def test_update(self): + segment_id = '111' + port_id = '222' + name = 'new name' + # admin_state = False + with self.mock_get(segment_id, port_id), \ + self.mock_create_update() as update_call: + + self.resourceApi.update(segment_id, + port_id, + name=name, + init_state=None) + expected_def = core_defs.SegmentPortDef( + nsx_version=nsxlib_testcase.LATEST_VERSION, + segment_id=segment_id, + port_id=port_id, + name=name, + init_state=None) + self.assert_called_with_def(update_call, expected_def) + class TestPolicySegmentProfileBase(NsxPolicyLibTestCase): diff --git a/vmware_nsxlib/v3/nsx_constants.py b/vmware_nsxlib/v3/nsx_constants.py index 69a3ad2d..ffe3580a 100644 --- a/vmware_nsxlib/v3/nsx_constants.py +++ b/vmware_nsxlib/v3/nsx_constants.py @@ -36,6 +36,7 @@ ALLOCATE_ADDRESS_NONE = "None" # SegmentPort init_state types INIT_STATE_UNBLOCKED_VLAN = 'UNBLOCKED_VLAN' INIT_STATE_RESTORE_VIF = 'RESTORE_VIF' +INIT_STATE_NONE = None # NSXv3 L2 Gateway constants BRIDGE_ENDPOINT = "BRIDGEENDPOINT" diff --git a/vmware_nsxlib/v3/policy/core_defs.py b/vmware_nsxlib/v3/policy/core_defs.py index 7b6a2c89..7224e41b 100644 --- a/vmware_nsxlib/v3/policy/core_defs.py +++ b/vmware_nsxlib/v3/policy/core_defs.py @@ -1356,7 +1356,8 @@ class SegmentPortDef(ResourceDef): if (self.has_attr('init_state') and self._version_dependant_attr_supported('init_state')): valid_list = [nsx_constants.INIT_STATE_UNBLOCKED_VLAN, - nsx_constants.INIT_STATE_RESTORE_VIF] + nsx_constants.INIT_STATE_RESTORE_VIF, + nsx_constants.INIT_STATE_NONE] init_state = self.get_attr('init_state') if init_state not in valid_list: raise exceptions.InvalidInput( diff --git a/vmware_nsxlib/v3/policy/core_resources.py b/vmware_nsxlib/v3/policy/core_resources.py index c5f0e531..8002fd91 100644 --- a/vmware_nsxlib/v3/policy/core_resources.py +++ b/vmware_nsxlib/v3/policy/core_resources.py @@ -2606,6 +2606,7 @@ class NsxPolicySegmentPortApi(NsxPolicyResourceBase): address_bindings=IGNORE, hyperbus_mode=IGNORE, admin_state=IGNORE, + init_state=IGNORE, extra_configs=IGNORE, tags=IGNORE, tenant=constants.POLICY_INFRA_TENANT): @@ -2617,6 +2618,7 @@ class NsxPolicySegmentPortApi(NsxPolicyResourceBase): address_bindings=address_bindings, hyperbus_mode=hyperbus_mode, admin_state=admin_state, + init_state=init_state, extra_configs=extra_configs, tags=tags, tenant=tenant)