Skip to content

Commit f462933

Browse files
committed
Allow unset port's host_id
It is supported by Neutron and needs to be done like that when e.g. admin wants to unbound port from the host. Task: #44043 Story: #2009705 Change-Id: I08f1bb40f4dc72cfa7c62feeb5f513455de0ca45
1 parent 8b394e5 commit f462933

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

openstackclient/network/v2/port.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,12 @@ def get_parser(self, prog_name):
969969
action='store_true',
970970
help=_("Clear existing NUMA affinity policy")
971971
)
972+
parser.add_argument(
973+
'--host',
974+
action='store_true',
975+
default=False,
976+
help=_("Clear host binding for the port.")
977+
)
972978

973979
_tag.add_tag_option_to_parser_for_unset(parser, _('port'))
974980

@@ -1026,6 +1032,8 @@ def take_action(self, parsed_args):
10261032
attrs['data_plane_status'] = None
10271033
if parsed_args.numa_policy:
10281034
attrs['numa_affinity_policy'] = None
1035+
if parsed_args.host:
1036+
attrs['binding:host_id'] = None
10291037

10301038
attrs.update(
10311039
self._parse_extra_properties(parsed_args.extra_properties))

openstackclient/tests/unit/network/v2/test_port.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1923,6 +1923,7 @@ def test_unset_port_parameters(self):
19231923
'subnet=042eb10a-3a18-4658-ab-cf47c8d03152,ip-address=1.0.0.0',
19241924
'--binding-profile', 'Superman',
19251925
'--qos-policy',
1926+
'--host',
19261927
self._testport.name,
19271928
]
19281929
verifylist = [
@@ -1931,6 +1932,7 @@ def test_unset_port_parameters(self):
19311932
'ip-address': '1.0.0.0'}]),
19321933
('binding_profile', ['Superman']),
19331934
('qos_policy', True),
1935+
('host', True)
19341936
]
19351937

19361938
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -1941,7 +1943,8 @@ def test_unset_port_parameters(self):
19411943
'subnet_id': '042eb10a-3a18-4658-ab-cf47c8d03152',
19421944
'ip_address': '0.0.0.1'}],
19431945
'binding:profile': {'batman': 'Joker'},
1944-
'qos_policy_id': None
1946+
'qos_policy_id': None,
1947+
'binding:host_id': None
19451948
}
19461949
self.network.update_port.assert_called_once_with(
19471950
self._testport, **attrs)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
features:
3+
- |
4+
Add possibility to unbind Neutron's port from the host by unsetting its
5+
host_id.

0 commit comments

Comments
 (0)