Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b7d3ef1
Removed multiple imports of settings.py
danner26 Mar 4, 2023
12cfb56
stating to abstract the netbox api calls to their own class
danner26 Mar 4, 2023
edeec26
Abstracted away determine features from main script, implemented as p…
danner26 Mar 4, 2023
f1e8d30
added helper functions to get repos relative & absolute path
danner26 Mar 5, 2023
64ab88b
renaming gitcmd to repo
danner26 Mar 5, 2023
49c16d8
starting to abstract away the get_files
danner26 Mar 5, 2023
b0b3248
fixed issue where spaces and commas in vendor list with/without space…
danner26 Mar 5, 2023
26245e4
Added prelim fix for slugs if same issue vendors arg was facing exist…
danner26 Mar 5, 2023
2402a02
Finished abstracting the get_files function. Reduced fors and ifs to …
danner26 Mar 5, 2023
6ada56f
abstracted getFiles to repo class. Fixed slug issue not matching beca…
danner26 Mar 5, 2023
1e06e68
utilized new logging class throughout script to reduce excess logging
danner26 Mar 5, 2023
a4abea8
Abstracted and optimized create manufacturers
danner26 Mar 5, 2023
180bb24
Abstracted the create interfaces for devices to the netbox api class
danner26 Mar 5, 2023
3002a97
Fixed regression where check manufactuerers did not have the latest list
danner26 Mar 7, 2023
909726d
Fixed regression caused by externally calling script. Discovered from…
danner26 Mar 7, 2023
2767cb9
abstracted all device interfaces to the devicetype class. optimized f…
danner26 Mar 9, 2023
bd1fbbe
Ran against all devices and passed with flying colors
danner26 Mar 9, 2023
51ecb92
formatting settings.py
danner26 Mar 9, 2023
260558d
formatting repo.py
danner26 Mar 9, 2023
b998453
formatting main file
danner26 Mar 9, 2023
a1da6a1
formatting log_handler.py
danner26 Mar 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions exception_handler.py

This file was deleted.

46 changes: 0 additions & 46 deletions gitcmd.py

This file was deleted.

44 changes: 44 additions & 0 deletions log_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from sys import exit as system_exit


class LogHandler:
def __new__(cls, *args, **kwargs):
return super().__new__(cls)

def __init__(self, args):
self.args = args

def exception(self, exception_type, exception, stack_trace=None):
exception_dict = {
"EnvironmentError": f'Environment variable "{exception}" is not set.',
"SSLError": f'SSL verification failed. IGNORE_SSL_ERRORS is {exception}. Set IGNORE_SSL_ERRORS to True if you want to ignore this error. EXITING.',
"GitCommandError": f'The repo "{exception}" is not a valid git repo.',
"GitInvalidRepositoryError": f'The repo "{exception}" is not a valid git repo.',
"Exception": f'An unknown error occurred: "{exception}"'
}

if self.args.verbose and stack_trace:
print(stack_trace)
print(exception_dict[exception_type])
system_exit(1)

def verbose_log(self, message):
if self.args.verbose:
print(message)

def log(self, message):
print(message)

def log_device_ports_created(self, created_ports: list = [], port_type: str = "port"):
for port in created_ports:
self.verbose_log(f'{port_type} Template Created: {port.name} - '
+ f'{port.type if hasattr(port, "type") else ""} - {port.device_type.id} - '
+ f'{port.id}')
return len(created_ports)

def log_module_ports_created(self, created_ports: list = [], port_type: str = "port"):
for port in created_ports:
self.verbose_log(f'{port_type} Template Created: {port.name} - '
+ f'{port.type if hasattr(port, "type") else ""} - {port.module_type.id} - '
+ f'{port.id}')
return len(created_ports)
Loading