@@ -29,7 +29,8 @@ def check_out_asset(snipeit_api, asset_id):
29
29
print (f"Error checking out asset { asset_id } " )
30
30
print (f"Response data: { data } " )
31
31
exit (
32
- f"Exiting to avoid conflict. Check who is working on this device and contact them first."
32
+ f"Exiting to avoid conflict. Check who is working on this device"
33
+ f" and contact them first."
33
34
)
34
35
35
36
return already_checked_out
@@ -93,7 +94,8 @@ def list_my_assets(snipeit_api, args):
93
94
94
95
Args:
95
96
snipeit_api: The API client used to interact with the Snipe-IT API.
96
- args: Command-line arguments object which contains the following attributes:
97
+ args: Command-line arguments object which contains the following
98
+ attributes:
97
99
- json: A boolean indicating to output the list as json.
98
100
Returns:
99
101
Boolean: False if no assets were assigned to the user, True otherwise
@@ -119,7 +121,8 @@ def check_in_my(snipeit_api, args):
119
121
120
122
Args:
121
123
snipeit_api: The API client used to interact with the Snipe-IT API.
122
- args: Command-line arguments object which contains the following attributes:
124
+ args: Command-line arguments object which contains the following
125
+ attributes:
123
126
- yes: A boolean indicating to skip the confirmation prompt.
124
127
Returns:
125
128
None
@@ -200,7 +203,8 @@ def list_for_zabbix(snipeit_api, args):
200
203
# Print asset details including custom fields
201
204
def print_asset_details (asset ):
202
205
print (
203
- f'Asset Tag: { asset ["asset_tag" ]} , Asset ID: { asset ["id" ]} , Name: { asset ["name" ]} , Serial: { asset ["serial" ]} '
206
+ f'Asset Tag: { asset ["asset_tag" ]} , Asset ID: { asset ["id" ]} ,'
207
+ f'Name: { asset ["name" ]} , Serial: { asset ["serial" ]} '
204
208
)
205
209
206
210
if asset ["assigned_to" ]:
@@ -265,7 +269,8 @@ def power_on(rte, args):
265
269
if state != rte .PSU_STATE_ON :
266
270
print (f"Power supply state: { state } !" )
267
271
print (
268
- 'If you wanted to power on the DUT, you need to enable power supply first ("pwr psu on"), pushing the power button is not enough!'
272
+ "If you wanted to power on the DUT, you need to enable power suppl"
273
+ 'y first ("pwr psu on"), pushing the power button is not enough!'
269
274
)
270
275
print (f"Powering on..." )
271
276
rte .power_on (args .time )
@@ -507,12 +512,14 @@ def update_zabbix_assets(snipeit_api):
507
512
== snipeit_assets [snipeit_assets_keys [j ]]
508
513
):
509
514
print (
510
- f"{ snipeit_assets_keys [i ]} has the same IP as { snipeit_assets_keys [j ]} !"
515
+ f"{ snipeit_assets_keys [i ]} has the same IP as "
516
+ f"{ snipeit_assets_keys [j ]} !"
511
517
)
512
518
snipeit_configuration_error = True
513
519
if snipeit_assets_keys [i ] == snipeit_assets_keys [j ]:
514
520
print (
515
- f"There are at least 2 assets with name { snipeit_assets_keys [i ]} present!"
521
+ f"There are at least 2 assets with name "
522
+ f"{ snipeit_assets_keys [i ]} present!"
516
523
)
517
524
snipeit_configuration_error = True
518
525
@@ -521,7 +528,8 @@ def update_zabbix_assets(snipeit_api):
521
528
symbol in snipeit_assets_keys [i ] for symbol in forbidden_symbols
522
529
):
523
530
print (
524
- f"{ snipeit_assets_keys [i ]} contains forbidden symbols! They are going to be changed to '_'."
531
+ f"{ snipeit_assets_keys [i ]} contains forbidden symbols! They "
532
+ f"are going to be changed to '_'."
525
533
)
526
534
new_key = copy (snipeit_assets_keys [i ])
527
535
for s in forbidden_symbols :
@@ -533,7 +541,8 @@ def update_zabbix_assets(snipeit_api):
533
541
534
542
if snipeit_configuration_error :
535
543
print (
536
- "\n SnipeIT configuration errors have been detected! Fix them and then continue."
544
+ "\n SnipeIT configuration errors have been detected! "
545
+ "Fix them and then continue."
537
546
)
538
547
return
539
548
@@ -561,7 +570,8 @@ def update_zabbix_assets(snipeit_api):
561
570
562
571
if keys_not_present_in_snipeit .__len__ () > 0 :
563
572
print (
564
- "\n Assets present in Zabbix but not in SnipeIT (these will be removed):"
573
+ "\n Assets present in Zabbix but not in SnipeIT "
574
+ "(these will be removed):"
565
575
)
566
576
print ("\n " .join (keys_not_present_in_snipeit ))
567
577
@@ -570,7 +580,8 @@ def update_zabbix_assets(snipeit_api):
570
580
for key in common_keys :
571
581
if snipeit_assets [key ] != current_zabbix_assets [key ]:
572
582
print (
573
- f"{ key } has wrong IP! (Zabbix one will be updated from { current_zabbix_assets [key ]} to { snipeit_assets [key ]} )"
583
+ f"{ key } has wrong IP! (Zabbix one will be updated from "
584
+ f"{ current_zabbix_assets [key ]} to { snipeit_assets [key ]} )"
574
585
)
575
586
keys_for_ip_change .append (key )
576
587
@@ -750,8 +761,10 @@ def main():
750
761
rte_parser .add_argument (
751
762
"--skip-snipeit" ,
752
763
action = "store_true" ,
753
- help = "Skips Snipe-IT related actions like checkout and check-in. \
754
- Useful for OSFV homelab." ,
764
+ help = (
765
+ f"Skips Snipe-IT related actions like checkout and check-in. "
766
+ f"Useful for OSFV homelab."
767
+ ),
755
768
)
756
769
rte_subparsers = rte_parser .add_subparsers (
757
770
title = "subcommands" , dest = "rte_cmd" , help = "RTE subcommands"
@@ -983,7 +996,8 @@ def main():
983
996
)
984
997
else :
985
998
exit (
986
- f"failed to retrieve model name from snipe-it. check again arguments, or try providing model manually."
999
+ f"failed to retrieve model name from snipe-it. check "
1000
+ f"again arguments, or try providing model manually."
987
1001
)
988
1002
else :
989
1003
exit (f"model name not present. check again arguments." )
@@ -992,7 +1006,8 @@ def main():
992
1006
993
1007
if not args .skip_snipeit :
994
1008
print (
995
- f"Using rte command is invasive action, checking first if the device is not used..."
1009
+ f"Using rte command is invasive action, checking first if the "
1010
+ f"device is not used..."
996
1011
)
997
1012
already_checked_out = check_out_asset (snipeit_api , asset_id )
998
1013
@@ -1053,16 +1068,16 @@ def main():
1053
1068
if not args .skip_snipeit :
1054
1069
if already_checked_out :
1055
1070
print (
1056
- f"Since the asset { asset_id } has been checkout manually \
1057
- by you prior running this script, it will NOT be checked \
1058
- in automatically. Please return the device when work is \
1059
- finished."
1071
+ f"Since the asset { asset_id } has been checkout manually "
1072
+ f" by you prior running this script, it will NOT be checked "
1073
+ f" in automatically. Please return the device when work is "
1074
+ f" finished."
1060
1075
)
1061
1076
else :
1062
1077
print (
1063
- f"Since the asset { asset_id } has been checkout \
1064
- automatically by this script, it is automatically checked \
1065
- in as well."
1078
+ f"Since the asset { asset_id } has been checkout "
1079
+ f" automatically by this script, it is automatically "
1080
+ f"checked in as well."
1066
1081
)
1067
1082
check_in_asset (snipeit_api , asset_id )
1068
1083
elif args .command == "sonoff" :
@@ -1080,7 +1095,8 @@ def main():
1080
1095
print (f"No asset found with RTE IP: { args .rte_ip } " )
1081
1096
1082
1097
print (
1083
- f"Using rte command is invasive action, checking first if the device is not used..."
1098
+ f"Using rte command is invasive action, checking first if the "
1099
+ f"device is not used..."
1084
1100
)
1085
1101
already_checked_out = check_out_asset (snipeit_api , asset_id )
1086
1102
@@ -1097,11 +1113,15 @@ def main():
1097
1113
1098
1114
if already_checked_out :
1099
1115
print (
1100
- f"Since the asset { asset_id } has been checkout manually by you prior running this script, it will NOT be checked in automatically. Please return the device when work is finished."
1116
+ f"Since the asset { asset_id } has been checkout manually by "
1117
+ f"you prior running this script, it will NOT be checked in "
1118
+ f"automatically. Please return the device when work is "
1119
+ f"finished."
1101
1120
)
1102
1121
else :
1103
1122
print (
1104
- f"Since the asset { asset_id } has been checkout automatically by this script, it is automatically checked in as well."
1123
+ f"Since the asset { asset_id } has been checkout automatically "
1124
+ f"by this script, it is automatically checked in as well."
1105
1125
)
1106
1126
check_in_asset (snipeit_api , asset_id )
1107
1127
elif args .command == "list_models" :
0 commit comments