Skip to content

Commit 28bd0af

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Add --ha-chassis-priority to "network agent add router""
2 parents c1a43ec + 3a91a00 commit 28bd0af

3 files changed

Lines changed: 46 additions & 2 deletions

File tree

openstackclient/network/v2/network_agent.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
118118
parser.add_argument(
119119
'--l3', action='store_true', help=_('Add router to an L3 agent')
120120
)
121+
parser.add_argument(
122+
'--ha-chassis-priority',
123+
metavar='<ha-chassis-priority>',
124+
type=int,
125+
help=_(
126+
"HA Chassis priority, ranging from [0, 32767]. "
127+
"Only used with --l3 and for ML2/OVN L3 agents"
128+
),
129+
)
121130
parser.add_argument(
122131
'agent_id',
123132
metavar='<agent-id>',
@@ -136,7 +145,11 @@ def take_action(self, parsed_args: argparse.Namespace) -> None:
136145
agent = client.get_agent(parsed_args.agent_id)
137146
router = client.find_router(parsed_args.router, ignore_missing=False)
138147
if parsed_args.l3:
139-
client.add_router_to_agent(agent, router)
148+
client.add_router_to_agent(
149+
agent,
150+
router,
151+
ha_chassis_priority=parsed_args.ha_chassis_priority,
152+
)
140153

141154

142155
class DeleteNetworkAgent(command.Command):

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,32 @@ def test_add_router_required_options(self):
109109
result = self.cmd.take_action(parsed_args)
110110

111111
self.network_client.add_router_to_agent.assert_called_with(
112-
self._agent, self._router
112+
self._agent, self._router, ha_chassis_priority=None
113+
)
114+
self.assertIsNone(result)
115+
116+
def test_add_router_with_ha_chassis_priority(self):
117+
arglist = [
118+
self._agent.id,
119+
self._router.id,
120+
'--l3',
121+
'--ha-chassis-priority',
122+
'100',
123+
]
124+
verifylist = [
125+
('l3', True),
126+
('agent_id', self._agent.id),
127+
('router', self._router.id),
128+
('ha_chassis_priority', 100),
129+
]
130+
131+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
132+
result = self.cmd.take_action(parsed_args)
133+
134+
self.network_client.add_router_to_agent.assert_called_with(
135+
self._agent,
136+
self._router,
137+
ha_chassis_priority=100,
113138
)
114139
self.assertIsNone(result)
115140

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
features:
3+
- |
4+
Add a new option ``--ha-chassis-priority`` to the
5+
``network agent add router`` command. This allows setting
6+
the HA Chassis priority when adding a router to an L3 agent.

0 commit comments

Comments
 (0)