Skip to content

Commit 9ac5bb2

Browse files
committed
[wcmp]: Fix static code analysis errors.
Signed-off-by: Nazarii Hnydyn <[email protected]>
1 parent 192a55b commit 9ac5bb2

File tree

6 files changed

+37
-17
lines changed

6 files changed

+37
-17
lines changed

config/bgp_cli.py

+15
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
log = logger.Logger(SYSLOG_IDENTIFIER)
1414
log.set_min_log_priority_info()
1515

16+
1617
#
1718
# BGP DB interface ----------------------------------------------------------------------------------------------------
1819
#
1920

21+
2022
def update_entry_validated(db, table, key, data, create_if_not_exists=False):
2123
""" Update entry in table and validate configuration.
2224
If attribute value in data is None, the attribute is deleted.
@@ -61,10 +63,12 @@ def update_entry_validated(db, table, key, data, create_if_not_exists=False):
6163

6264
db.set_entry(table, key, cfg[table][key])
6365

66+
6467
#
6568
# BGP handlers --------------------------------------------------------------------------------------------------------
6669
#
6770

71+
6872
def tsa_handler(ctx, db, state):
6973
""" Handle config updates for Traffic-Shift-Away (TSA) feature """
7074

@@ -81,6 +85,7 @@ def tsa_handler(ctx, db, state):
8185
log.log_error("Failed to configure TSA state: {}".format(str(e)))
8286
ctx.fail(str(e))
8387

88+
8489
def wcmp_handler(ctx, db, state):
8590
""" Handle config updates for Weighted-Cost Multi-Path (W-ECMP) feature """
8691

@@ -97,10 +102,12 @@ def wcmp_handler(ctx, db, state):
97102
log.log_error("Failed to configure W-ECMP state: {}".format(str(e)))
98103
ctx.fail(str(e))
99104

105+
100106
#
101107
# BGP device-global ---------------------------------------------------------------------------------------------------
102108
#
103109

110+
104111
@click.group(
105112
name="device-global",
106113
cls=clicommon.AliasedGroup
@@ -110,10 +117,12 @@ def DEVICE_GLOBAL():
110117

111118
pass
112119

120+
113121
#
114122
# BGP device-global tsa -----------------------------------------------------------------------------------------------
115123
#
116124

125+
117126
@DEVICE_GLOBAL.group(
118127
name="tsa",
119128
cls=clicommon.AliasedGroup
@@ -123,6 +132,7 @@ def DEVICE_GLOBAL_TSA():
123132

124133
pass
125134

135+
126136
@DEVICE_GLOBAL_TSA.command(
127137
name="enabled"
128138
)
@@ -133,6 +143,7 @@ def DEVICE_GLOBAL_TSA_ENABLED(ctx, db):
133143

134144
tsa_handler(ctx, db, "true")
135145

146+
136147
@DEVICE_GLOBAL_TSA.command(
137148
name="disabled"
138149
)
@@ -143,10 +154,12 @@ def DEVICE_GLOBAL_TSA_DISABLED(ctx, db):
143154

144155
tsa_handler(ctx, db, "false")
145156

157+
146158
#
147159
# BGP device-global w-ecmp --------------------------------------------------------------------------------------------
148160
#
149161

162+
150163
@DEVICE_GLOBAL.group(
151164
name="w-ecmp",
152165
cls=clicommon.AliasedGroup
@@ -156,6 +169,7 @@ def DEVICE_GLOBAL_WCMP():
156169

157170
pass
158171

172+
159173
@DEVICE_GLOBAL_WCMP.command(
160174
name="enabled"
161175
)
@@ -166,6 +180,7 @@ def DEVICE_GLOBAL_WCMP_ENABLED(ctx, db):
166180

167181
wcmp_handler(ctx, db, "true")
168182

183+
169184
@DEVICE_GLOBAL_WCMP.command(
170185
name="disabled"
171186
)

config/main.py

+1
Original file line numberDiff line numberDiff line change
@@ -4048,6 +4048,7 @@ def bgp():
40484048
"""BGP-related configuration tasks"""
40494049
pass
40504050

4051+
40514052
# BGP module extensions
40524053
config.commands['bgp'].add_command(bgp_cli.DEVICE_GLOBAL)
40534054

show/bgp_cli.py

+6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
to_str,
1010
)
1111

12+
1213
#
1314
# BGP helpers ---------------------------------------------------------------------------------------------------------
1415
#
1516

17+
1618
def format_attr_value(entry, attr):
1719
""" Helper that formats attribute to be presented in the table output.
1820
@@ -29,10 +31,12 @@ def format_attr_value(entry, attr):
2931
return "\n".join(value) if value else "N/A"
3032
return entry.get(attr["name"], "N/A")
3133

34+
3235
#
3336
# BGP CLI -------------------------------------------------------------------------------------------------------------
3437
#
3538

39+
3640
@click.group(
3741
name="bgp",
3842
cls=clicommon.AliasedGroup
@@ -42,10 +46,12 @@ def BGP():
4246

4347
pass
4448

49+
4550
#
4651
# BGP device-global ---------------------------------------------------------------------------------------------------
4752
#
4853

54+
4955
@BGP.command(
5056
name="device-global"
5157
)

tests/bgp_input/assert_show_output.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,52 @@
22
Module holding the correct values for show CLI command outputs for the bgp_test.py
33
"""
44

5-
show_device_global_empty="""\
5+
show_device_global_empty = """\
66
No configuration is present in CONFIG DB
77
"""
88

9-
show_device_global_all_disabled="""\
9+
show_device_global_all_disabled = """\
1010
TSA W-ECMP
1111
-------- --------
1212
disabled disabled
1313
"""
14-
show_device_global_all_disabled_json="""\
14+
show_device_global_all_disabled_json = """\
1515
{
1616
"tsa": "disabled",
1717
"w-ecmp": "disabled"
1818
}
1919
"""
2020

21-
show_device_global_all_enabled="""\
21+
show_device_global_all_enabled = """\
2222
TSA W-ECMP
2323
------- --------
2424
enabled enabled
2525
"""
26-
show_device_global_all_enabled_json="""\
26+
show_device_global_all_enabled_json = """\
2727
{
2828
"tsa": "enabled",
2929
"w-ecmp": "enabled"
3030
}
3131
"""
3232

33-
show_device_global_tsa_enabled="""\
33+
show_device_global_tsa_enabled = """\
3434
TSA W-ECMP
3535
------- --------
3636
enabled disabled
3737
"""
38-
show_device_global_tsa_enabled_json="""\
38+
show_device_global_tsa_enabled_json = """\
3939
{
4040
"tsa": "enabled",
4141
"w-ecmp": "disabled"
4242
}
4343
"""
4444

45-
show_device_global_wcmp_enabled="""\
45+
show_device_global_wcmp_enabled = """\
4646
TSA W-ECMP
4747
-------- --------
4848
disabled enabled
4949
"""
50-
show_device_global_wcmp_enabled_json="""\
50+
show_device_global_wcmp_enabled_json = """\
5151
{
5252
"tsa": "disabled",
5353
"w-ecmp": "enabled"

tests/bgp_test.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@ def teardown_class(cls):
3232
os.environ['UTILITIES_UNIT_TESTING'] = "0"
3333
dbconnector.dedicated_dbs.clear()
3434

35-
36-
########## CONFIG BGP ##########
37-
35+
# ---------- CONFIG BGP ---------- #
3836

3937
@pytest.mark.parametrize(
4038
"feature", [
4139
"tsa",
42-
"wcmp"
40+
"w-ecmp"
4341
]
4442
)
4543
@pytest.mark.parametrize(
@@ -62,9 +60,7 @@ def test_config_device_global(self, feature, state):
6260

6361
assert result.exit_code == SUCCESS
6462

65-
66-
########## SHOW BGP ##########
67-
63+
# ---------- SHOW BGP ---------- #
6864

6965
@pytest.mark.parametrize(
7066
"cfgdb,output", [

utilities_common/bgp.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from swsscommon.swsscommon import CFG_BGP_DEVICE_GLOBAL_TABLE_NAME as CFG_BGP_DEVICE_GLOBAL
1+
from swsscommon.swsscommon import CFG_BGP_DEVICE_GLOBAL_TABLE_NAME as CFG_BGP_DEVICE_GLOBAL # noqa
22

33
#
44
# BGP constants -------------------------------------------------------------------------------------------------------
@@ -8,10 +8,12 @@
88

99
SYSLOG_IDENTIFIER = "bgp-cli"
1010

11+
1112
#
1213
# BGP helpers ---------------------------------------------------------------------------------------------------------
1314
#
1415

16+
1517
def to_str(state):
1618
""" Convert boolean to string representation """
1719
if state == "true":

0 commit comments

Comments
 (0)