Skip to content

Commit 136344d

Browse files
danner26jbemmel
andauthored
Release v2.0.2 (#102)
* Fix image upload v2 (#91) * Add upload_image functionality to new beta script * Updated for new location of files with Boolean flag for front/rear image * fixing the requests verify missing issue #95 (#96) * Bumping deps. Closes PR#99 and PR#98 (#100) * Added ability for IGNORE_SSL_ERRORS to dictate if the images upload verifys the request (#101) --------- Co-authored-by: J vanBemmel <[email protected]>
1 parent 8ad3ed7 commit 136344d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

netbox_api.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ def __init__(self, settings):
2727
self.connect_api()
2828
self.verify_compatibility()
2929
self.existing_manufacturers = self.get_manufacturers()
30-
self.device_types = DeviceTypes(self.netbox, self.handle, self.counter)
30+
self.device_types = DeviceTypes(self.netbox, self.handle, self.counter, self.ignore_ssl)
3131

3232
def connect_api(self):
3333
try:
3434
self.netbox = pynetbox.api(self.url, token=self.token)
3535
if self.ignore_ssl:
3636
self.handle.verbose_log("IGNORE_SSL_ERRORS is True, catching exception and disabling SSL verification.")
37-
requests.packages.urllib3.disable_warnings()
37+
#requests.packages.urllib3.disable_warnings()
3838
self.netbox.http_session.verify = False
3939
except Exception as e:
4040
self.handle.exception("Exception", 'NetBox API Error', e)
@@ -183,11 +183,12 @@ class DeviceTypes:
183183
def __new__(cls, *args, **kwargs):
184184
return super().__new__(cls)
185185

186-
def __init__(self, netbox, handle, counter):
186+
def __init__(self, netbox, handle, counter, ignore_ssl):
187187
self.netbox = netbox
188188
self.handle = handle
189189
self.counter = counter
190190
self.existing_device_types = self.get_device_types()
191+
self.ignore_ssl = ignore_ssl
191192

192193
def get_device_types(self):
193194
return {str(item): item for item in self.netbox.dcim.device_types.all()}
@@ -478,7 +479,7 @@ def upload_images(self,baseurl,token,images,device_type):
478479
headers = { "Authorization": f"Token {token}" }
479480

480481
files = { i: (os.path.basename(f), open(f,"rb") ) for i,f in images.items() }
481-
response = requests.patch(url, headers=headers, files=files, verify=False)
482+
response = requests.patch(url, headers=headers, files=files, verify=(not self.ignore_ssl))
482483

483484
self.handle.log( f'Images {images} updated at {url}: {response}' )
484485
self.counter["images"] += len(images)

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
GitPython==3.1.31
1+
GitPython==3.1.32
22
pynetbox==7.0.1
33
python-dotenv==1.0.0
4-
PyYAML==6.0
4+
PyYAML==6.0.1

0 commit comments

Comments
 (0)