@@ -478,26 +478,36 @@ def group_extractors(self):
478
478
# Locations were added in 2.11 replacing rack-groups.
479
479
if self .api_version >= version .parse ("2.11" ):
480
480
extractors .update (
481
- {"location" : self .extract_location ,}
481
+ {
482
+ "location" : self .extract_location ,
483
+ }
482
484
)
483
485
else :
484
486
extractors .update (
485
- {"rack_group" : self .extract_rack_group ,}
487
+ {
488
+ "rack_group" : self .extract_rack_group ,
489
+ }
486
490
)
487
491
488
492
if self .services :
489
493
extractors .update (
490
- {"services" : self .extract_services ,}
494
+ {
495
+ "services" : self .extract_services ,
496
+ }
491
497
)
492
498
493
499
if self .interfaces :
494
500
extractors .update (
495
- {"interfaces" : self .extract_interfaces ,}
501
+ {
502
+ "interfaces" : self .extract_interfaces ,
503
+ }
496
504
)
497
505
498
506
if self .interfaces or self .dns_name or self .ansible_host_dns_name :
499
507
extractors .update (
500
- {"dns_name" : self .extract_dns_name ,}
508
+ {
509
+ "dns_name" : self .extract_dns_name ,
510
+ }
501
511
)
502
512
503
513
return extractors
@@ -1288,7 +1298,7 @@ def fetch_api_docs(self):
1288
1298
try :
1289
1299
status = self ._fetch_information (self .api_endpoint + "/api/status" )
1290
1300
netbox_api_version = "." .join (status ["netbox-version" ].split ("." )[:2 ])
1291
- except :
1301
+ except Exception :
1292
1302
netbox_api_version = 0
1293
1303
1294
1304
tmp_dir = os .path .split (DEFAULT_LOCAL_TMP )[0 ]
@@ -1297,7 +1307,7 @@ def fetch_api_docs(self):
1297
1307
try :
1298
1308
with open (tmp_file ) as file :
1299
1309
openapi = json .load (file )
1300
- except :
1310
+ except Exception :
1301
1311
openapi = {}
1302
1312
1303
1313
cached_api_version = openapi .get ("info" , {}).get ("version" )
@@ -1725,7 +1735,8 @@ def main(self):
1725
1735
elif getattr (self , "site_group_names" , None ) and host .get ("site" ):
1726
1736
# Add host to site group when host is NOT assigned to a location
1727
1737
self .inventory .add_host (
1728
- group = self .site_group_names [host ["site" ]["id" ]], host = hostname ,
1738
+ group = self .site_group_names [host ["site" ]["id" ]],
1739
+ host = hostname ,
1729
1740
)
1730
1741
1731
1742
def parse (self , inventory , loader , path , cache = True ):
@@ -1753,7 +1764,7 @@ def parse(self, inventory, loader, path, cache=True):
1753
1764
self .fetch_all = self .get_option ("fetch_all" )
1754
1765
self .headers = {
1755
1766
"User-Agent" : "ansible %s Python %s"
1756
- % (ansible_version , python_version .split (" " )[0 ]),
1767
+ % (ansible_version , python_version .split (" " , maxsplit = 1 )[0 ]),
1757
1768
"Content-type" : "application/json" ,
1758
1769
}
1759
1770
self .cert = self .get_option ("cert" )
0 commit comments