Skip to content

Commit 95a376a

Browse files
committed
network: Remove the workaround for SDK for advertise_host attribute
The patch removes the workaround for advertise_host attribute support. Related-Bug: #2144617 Change-Id: I7bff6a6c5382b386f58ad163d4115b962f80e6a5 Signed-off-by: Jakub Libosvar <libosvar@redhat.com>
1 parent 05249ce commit 95a376a

2 files changed

Lines changed: 9 additions & 22 deletions

File tree

openstackclient/network/v2/router.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -402,20 +402,11 @@ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
402402
def take_action(self, parsed_args: argparse.Namespace) -> None:
403403
client = self.app.client_manager.network
404404
subnet = client.find_subnet(parsed_args.subnet, ignore_missing=False)
405-
if parsed_args.advertise_host:
406-
# TODO(evpn): switch to client.add_interface_to_router() once
407-
# openstacksdk supports the advertise_host parameter.
408-
router = client.find_router(
409-
parsed_args.router, ignore_missing=False
410-
)
411-
router.add_interface(
412-
client, subnet_id=subnet.id, advertise_host=True
413-
)
414-
else:
415-
client.add_interface_to_router(
416-
client.find_router(parsed_args.router, ignore_missing=False),
417-
subnet=subnet.id,
418-
)
405+
client.add_interface_to_router(
406+
client.find_router(parsed_args.router, ignore_missing=False),
407+
subnet=subnet.id,
408+
advertise_host=parsed_args.advertise_host,
409+
)
419410

420411

421412
class AddExtraRoutesToRouter(command.ShowOne):

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def test_add_subnet_required_options(self):
108108

109109
result = self.cmd.take_action(parsed_args)
110110
self.network_client.add_interface_to_router.assert_called_with(
111-
self._router, subnet=self._router.subnet
111+
self._router, subnet=self._router.subnet, advertise_host=False
112112
)
113113

114114
self.assertIsNone(result)
@@ -127,12 +127,9 @@ def test_add_subnet_with_advertise_host(self):
127127
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
128128

129129
result = self.cmd.take_action(parsed_args)
130-
self._router.add_interface.assert_called_once_with(
131-
self.network_client,
132-
subnet_id=self._subnet.id,
133-
advertise_host=True,
130+
self.network_client.add_interface_to_router.assert_called_once_with(
131+
self._router, subnet=self._router.subnet, advertise_host=True
134132
)
135-
self.network_client.add_interface_to_router.assert_not_called()
136133

137134
self.assertIsNone(result)
138135

@@ -150,9 +147,8 @@ def test_add_subnet_without_advertise_host(self):
150147

151148
result = self.cmd.take_action(parsed_args)
152149
self.network_client.add_interface_to_router.assert_called_once_with(
153-
self._router, subnet=self._subnet.id
150+
self._router, subnet=self._subnet.id, advertise_host=False
154151
)
155-
self._router.add_interface.assert_not_called()
156152

157153
self.assertIsNone(result)
158154

0 commit comments

Comments
 (0)