Skip to content

Commit ae01148

Browse files
Fixed pre-commit warnings
Signed-off-by: Ashutosh Agrawal <[email protected]>
1 parent c8dd2f4 commit ae01148

File tree

2 files changed

+58
-158
lines changed

2 files changed

+58
-158
lines changed

config/plugins/sonic-dhcpv4-relay_yang.py

+6-87
Original file line numberDiff line numberDiff line change
@@ -205,41 +205,6 @@ def clear_list_entry_validated(db, table, key, attr):
205205
update_entry_validated(db, table, key, {attr: None})
206206

207207

208-
209-
210-
211-
212-
213-
214-
215-
216-
217-
218-
219-
220-
221-
222-
223-
224-
225-
226-
227-
228-
229-
230-
231-
232-
233-
234-
235-
236-
237-
238-
239-
240-
241-
242-
243208
@click.group(name="dhcpv4-relay",
244209
cls=clicommon.AliasedGroup)
245210
def DHCPV4_RELAY():
@@ -248,24 +213,12 @@ def DHCPV4_RELAY():
248213
pass
249214

250215

251-
252-
253-
254-
255-
256-
257-
258-
259-
260-
261216
@DHCPV4_RELAY.command(name="add")
262-
263217
@click.argument(
264218
"name",
265219
nargs=1,
266220
required=True,
267221
)
268-
269222
@click.option(
270223
"--server-vrf",
271224
help="Server VRF",
@@ -299,7 +252,8 @@ def DHCPV4_RELAY():
299252
help="Server IPv4 address list",
300253
)
301254
@clicommon.pass_db
302-
def DHCPV4_RELAY_add(db, name, server_vrf, source_interface, link_selection, vrf_selection, server_id_override, agent_relay_mode, max_hop_count, dhcpv4_servers):
255+
def DHCPV4_RELAY_add(db, name, server_vrf, source_interface, link_selection, vrf_selection,
256+
server_id_override, agent_relay_mode, max_hop_count, dhcpv4_servers):
303257
""" Add object in DHCPV4_RELAY. """
304258

305259
table = "DHCPV4_RELAY"
@@ -329,13 +283,11 @@ def DHCPV4_RELAY_add(db, name, server_vrf, source_interface, link_selection, vrf
329283

330284

331285
@DHCPV4_RELAY.command(name="update")
332-
333286
@click.argument(
334287
"name",
335288
nargs=1,
336289
required=True,
337290
)
338-
339291
@click.option(
340292
"--server-vrf",
341293
help="Server VRF",
@@ -369,7 +321,8 @@ def DHCPV4_RELAY_add(db, name, server_vrf, source_interface, link_selection, vrf
369321
help="Server IPv4 address list",
370322
)
371323
@clicommon.pass_db
372-
def DHCPV4_RELAY_update(db, name, server_vrf, source_interface, link_selection, vrf_selection, server_id_override, agent_relay_mode, max_hop_count, dhcpv4_servers):
324+
def DHCPV4_RELAY_update(db, name, server_vrf, source_interface, link_selection, vrf_selection,
325+
server_id_override, agent_relay_mode, max_hop_count, dhcpv4_servers):
373326
""" Add object in DHCPV4_RELAY. """
374327

375328
table = "DHCPV4_RELAY"
@@ -399,7 +352,6 @@ def DHCPV4_RELAY_update(db, name, server_vrf, source_interface, link_selection,
399352

400353

401354
@DHCPV4_RELAY.command(name="delete")
402-
403355
@click.argument(
404356
"name",
405357
nargs=1,
@@ -416,36 +368,16 @@ def DHCPV4_RELAY_delete(db, name):
416368
except Exception as err:
417369
exit_with_error(f"Error: {err}", fg="red")
418370

419-
420-
421-
422-
423-
424-
425-
426-
427-
428-
429-
430-
431-
432-
433-
434-
435-
436-
437-
438371

439372
@DHCPV4_RELAY.group(name="dhcpv4-servers",
440-
cls=clicommon.AliasedGroup)
373+
cls=clicommon.AliasedGroup)
441374
def DHCPV4_RELAY_dhcpv4_servers():
442375
""" Add/Delete dhcpv4_servers in DHCPV4_RELAY """
443376

444377
pass
445378

446379

447380
@DHCPV4_RELAY_dhcpv4_servers.command(name="add")
448-
449381
@click.argument(
450382
"name",
451383
nargs=1,
@@ -474,9 +406,7 @@ def DHCPV4_RELAY_dhcpv4_servers_add(
474406
exit_with_error(f"Error: {err}", fg="red")
475407

476408

477-
478409
@DHCPV4_RELAY_dhcpv4_servers.command(name="delete")
479-
480410
@click.argument(
481411
"name",
482412
nargs=1,
@@ -505,9 +435,7 @@ def DHCPV4_RELAY_dhcpv4_servers_delete(
505435
exit_with_error(f"Error: {err}", fg="red")
506436

507437

508-
509438
@DHCPV4_RELAY_dhcpv4_servers.command(name="clear")
510-
511439
@click.argument(
512440
"name",
513441
nargs=1,
@@ -530,15 +458,6 @@ def DHCPV4_RELAY_dhcpv4_servers_clear(
530458
exit_with_error(f"Error: {err}", fg="red")
531459

532460

533-
534-
535-
536-
537-
538-
539-
540-
541-
542461
def register(cli):
543462
""" Register new CLI nodes in root CLI.
544463
@@ -551,4 +470,4 @@ def register(cli):
551470
cli_node = DHCPV4_RELAY
552471
if cli_node.name in cli.commands:
553472
raise Exception(f"{cli_node.name} already exists in CLI")
554-
cli.add_command(DHCPV4_RELAY)
473+
cli.add_command(DHCPV4_RELAY)
+52-71
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""
22
Auto-generated show CLI plugin.
3-
4-
53
"""
64

75
import click
@@ -10,9 +8,6 @@
108
import utilities_common.cli as clicommon
119

1210

13-
14-
15-
1611
def format_attr_value(entry, attr):
1712
""" Helper that formats attribute to be presented in the table output.
1813
@@ -47,24 +42,6 @@ def format_group_value(entry, attrs):
4742
return tabulate.tabulate(data, tablefmt="plain")
4843

4944

50-
51-
52-
53-
54-
55-
56-
57-
58-
59-
60-
61-
62-
63-
64-
65-
66-
67-
6845
@click.group(name="dhcpv4-relay",
6946
cls=clicommon.AliasedGroup,
7047
invoke_without_command=True)
@@ -73,18 +50,16 @@ def DHCPV4_RELAY(db):
7350
""" [Callable command group] """
7451

7552
header = [
76-
"NAME",
77-
78-
"SERVER VRF",
79-
"SOURCE INTERFACE",
80-
"LINK SELECTION",
81-
"VRF SELECTION",
82-
"SERVER ID OVERRIDE",
83-
"AGENT RELAY MODE",
84-
"MAX HOP COUNT",
85-
"DHCPV4 SERVERS",
86-
87-
]
53+
"NAME",
54+
"SERVER VRF",
55+
"SOURCE INTERFACE",
56+
"LINK SELECTION",
57+
"VRF SELECTION",
58+
"SERVER ID OVERRIDE",
59+
"AGENT RELAY MODE",
60+
"MAX HOP COUNT",
61+
"DHCPV4 SERVERS",
62+
]
8863

8964
body = []
9065

@@ -95,47 +70,53 @@ def DHCPV4_RELAY(db):
9570
key = (key,)
9671

9772
row = [*key] + [
98-
format_attr_value(
99-
entry,
100-
{'name': 'server_vrf', 'description': 'Server VRF', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''}
101-
),
102-
format_attr_value(
103-
entry,
104-
{'name': 'source_interface', 'description': 'Used to determine the source IP address of the relayed packet', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''}
105-
),
106-
format_attr_value(
107-
entry,
108-
{'name': 'link_selection', 'description': 'Enable link selection', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''}
109-
),
110-
format_attr_value(
111-
entry,
112-
{'name': 'vrf_selection', 'description': 'Enable VRF selection', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''}
113-
),
114-
format_attr_value(
115-
entry,
116-
{'name': 'server_id_override', 'description': 'Enable server id override', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''}
117-
),
118-
format_attr_value(
119-
entry,
120-
{'name': 'agent_relay_mode', 'description': 'How to forward packets that already have a relay option', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''}
121-
),
122-
format_attr_value(
123-
entry,
124-
{'name': 'max_hop_count', 'description': 'Maximum hop count for relayed packets', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''}
125-
),
126-
format_attr_value(
127-
entry,
128-
{'name': 'dhcpv4_servers', 'description': 'Server IPv4 address list', 'is-leaf-list': True, 'is-mandatory': False, 'group': ''}
129-
),
130-
]
73+
format_attr_value(
74+
entry,
75+
{'name': 'server_vrf', 'description': 'Server VRF', 'is-leaf-list': False,
76+
'is-mandatory': False, 'group': ''}
77+
),
78+
format_attr_value(
79+
entry,
80+
{'name': 'source_interface', 'description': 'Used to determine the source IP address of the \
81+
relayed packet', 'is-leaf-list': False, 'is-mandatory': False, 'group': ''}
82+
),
83+
format_attr_value(
84+
entry,
85+
{'name': 'link_selection', 'description': 'Enable link selection', 'is-leaf-list': False,
86+
'is-mandatory': False, 'group': ''}
87+
),
88+
format_attr_value(
89+
entry,
90+
{'name': 'vrf_selection', 'description': 'Enable VRF selection', 'is-leaf-list': False,
91+
'is-mandatory': False, 'group': ''}
92+
),
93+
format_attr_value(
94+
entry,
95+
{'name': 'server_id_override', 'description': 'Enable server id override', 'is-leaf-list': False,
96+
'is-mandatory': False, 'group': ''}
97+
),
98+
format_attr_value(
99+
entry,
100+
{'name': 'agent_relay_mode', 'description': 'How to forward packets that already have a relay option',
101+
'is-leaf-list': False, 'is-mandatory': False, 'group': ''}
102+
),
103+
format_attr_value(
104+
entry,
105+
{'name': 'max_hop_count', 'description': 'Maximum hop count for relayed packets', 'is-leaf-list': False,
106+
'is-mandatory': False, 'group': ''}
107+
),
108+
format_attr_value(
109+
entry,
110+
{'name': 'dhcpv4_servers', 'description': 'Server IPv4 address list', 'is-leaf-list': True,
111+
'is-mandatory': False, 'group': ''}
112+
),
113+
]
131114

132115
body.append(row)
133116

134117
click.echo(tabulate.tabulate(body, header))
135118

136119

137-
138-
139120
def register(cli):
140121
""" Register new CLI nodes in root CLI.
141122
@@ -148,4 +129,4 @@ def register(cli):
148129
cli_node = DHCPV4_RELAY
149130
if cli_node.name in cli.commands:
150131
raise Exception(f"{cli_node.name} already exists in CLI")
151-
cli.add_command(DHCPV4_RELAY)
132+
cli.add_command(DHCPV4_RELAY)

0 commit comments

Comments
 (0)