Skip to content

Commit 3bd761b

Browse files
Fixed ruff
1 parent d8408c6 commit 3bd761b

4 files changed

Lines changed: 17 additions & 33 deletions

File tree

lib/jnpr/junos/facts/get_jnu_satellites_information.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,14 @@ def provides_facts():
2222

2323
def _get_sat_dev(rsp, name):
2424
"""Return the <satellite-device> element matching *name*, or first found."""
25-
sat_dev = rsp.find(
26-
".//satellite-device[satellite-mgmt-ip='{}']".format(name)
27-
)
25+
sat_dev = rsp.find(".//satellite-device[satellite-mgmt-ip='{}']".format(name))
2826
return sat_dev if sat_dev is not None else rsp.find(".//satellite-device")
2927

3028

3129
def _collect_sw_facts(device, name, sat_facts):
3230
"""Populate software version facts from get_software_information."""
3331
try:
34-
rsp = device.rpc.get_software_information(
35-
device_list=name, normalize=True
36-
)
32+
rsp = device.rpc.get_software_information(device_list=name, normalize=True)
3733
if rsp is None or rsp is True:
3834
return
3935
sat_dev = _get_sat_dev(rsp, name)
@@ -53,9 +49,7 @@ def _collect_sw_facts(device, name, sat_facts):
5349
def _collect_re_facts(device, name, sat_facts):
5450
"""Populate RE facts from get_route_engine_information."""
5551
try:
56-
rsp = device.rpc.get_route_engine_information(
57-
device_list=name, normalize=True
58-
)
52+
rsp = device.rpc.get_route_engine_information(device_list=name, normalize=True)
5953
if rsp is None or rsp is True:
6054
return
6155
sat_dev = _get_sat_dev(rsp, name)
@@ -96,18 +90,15 @@ def _collect_re_facts(device, name, sat_facts):
9690
def _collect_chassis_facts(device, name, sat_facts):
9791
"""Populate chassis inventory facts from get_chassis_inventory."""
9892
try:
99-
rsp = device.rpc.get_chassis_inventory(
100-
device_list=name, normalize=True
101-
)
93+
rsp = device.rpc.get_chassis_inventory(device_list=name, normalize=True)
10294
if rsp is None or rsp is True:
10395
return
10496
sat_dev = _get_sat_dev(rsp, name)
10597
if sat_dev is None:
10698
return
107-
sat_facts["serialnumber"] = (
108-
sat_dev.findtext(".//chassis[1]/serial-number")
109-
or sat_dev.findtext('.//chassis-module[name="Midplane"]/serial-number')
110-
)
99+
sat_facts["serialnumber"] = sat_dev.findtext(
100+
".//chassis[1]/serial-number"
101+
) or sat_dev.findtext('.//chassis-module[name="Midplane"]/serial-number')
111102
except Exception:
112103
pass
113104

lib/jnpr/junos/ofacts/satellites.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
def _get_sat_dev(rsp, name):
22
"""Return the <satellite-device> element matching *name*, or first found."""
3-
sat_dev = rsp.find(
4-
".//satellite-device[satellite-mgmt-ip='{}']".format(name)
5-
)
3+
sat_dev = rsp.find(".//satellite-device[satellite-mgmt-ip='{}']".format(name))
64
return sat_dev if sat_dev is not None else rsp.find(".//satellite-device")
75

86

@@ -140,20 +138,17 @@ def facts_satellites(junos, facts):
140138
if inv_rsp is not None and inv_rsp is not True:
141139
sat_dev = _get_sat_dev(inv_rsp, name)
142140
if sat_dev is not None:
143-
sat_facts["serialnumber"] = (
144-
sat_dev.findtext(".//chassis[1]/serial-number")
145-
or sat_dev.findtext(
146-
'.//chassis-module[name="Midplane"]/serial-number'
147-
)
141+
sat_facts["serialnumber"] = sat_dev.findtext(
142+
".//chassis[1]/serial-number"
143+
) or sat_dev.findtext(
144+
'.//chassis-module[name="Midplane"]/serial-number'
148145
)
149146
except Exception:
150147
pass
151148

152149
# --- virtual chassis facts ---
153150
try:
154-
vc_rsp = junos.rpc.get_virtual_chassis_information(
155-
device_list=name
156-
)
151+
vc_rsp = junos.rpc.get_virtual_chassis_information(device_list=name)
157152
if vc_rsp is not None and vc_rsp is not True:
158153
sat_dev = _get_sat_dev(vc_rsp, name)
159154
if sat_dev is not None and sat_dev.find(".//rpc-error") is None:

lib/jnpr/junos/utils/sw.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ def _install_on_satellites(
207207
v_ok = True
208208
else:
209209
overall_ok = False
210-
overall_msg += (
211-
"\nSatellite %s: validation raised error: %s"
212-
% (sat_name, str(e))
210+
overall_msg += "\nSatellite %s: validation raised error: %s" % (
211+
sat_name,
212+
str(e),
213213
)
214214
continue
215215
if v_ok is not True:

tests/unit/facts/test_get_jnu_satellites_information.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ def _mock_satellites_down(self, *args, **kwargs):
7272
if not args:
7373
return None
7474
if args[0].tag == "get-jnu-satellites-information":
75-
return self._read_file(
76-
"satellites_down_get-jnu-satellites-information.xml"
77-
)
75+
return self._read_file("satellites_down_get-jnu-satellites-information.xml")
7876
return None
7977

8078
def _mock_satellites_rpc_error(self, *args, **kwargs):

0 commit comments

Comments
 (0)