mirror of
https://github.com/netbox-community/Device-Type-Library-Import.git
synced 2025-06-06 18:06:37 +02:00
add: script timer + devicetype library repo url to .env
This commit is contained in:
parent
f8a078220c
commit
ef4c0fa515
@ -1,2 +1,3 @@
|
||||
NETBOX_URL=
|
||||
NETBOX_TOKEN=
|
||||
REPO_URL=https://github.com/netbox-community/devicetype-library.git
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
from git import Repo, exc, RemoteProgress
|
||||
from collections import Counter
|
||||
from datetime import datetime
|
||||
import yaml
|
||||
import pynetbox
|
||||
import glob
|
||||
@ -8,7 +9,7 @@ import argparse
|
||||
import os
|
||||
import settings
|
||||
|
||||
REPO_URL = 'https://github.com/netbox-community/devicetype-library.git'
|
||||
REPO_URL = settings.REPO_URL
|
||||
parser = argparse.ArgumentParser(description='Import Netbox Device Types')
|
||||
parser.add_argument('--vendor', nargs='+',
|
||||
help="List of vendors to import eg. apc cisco")
|
||||
@ -20,6 +21,7 @@ cwd = os.getcwd()
|
||||
counter = Counter(added=0, updated=0, manufacturer=0)
|
||||
nbUrl = settings.NETBOX_URL
|
||||
nbToken = settings.NETBOX_TOKEN
|
||||
startTime = datetime.now()
|
||||
|
||||
|
||||
def update_package(path: str):
|
||||
@ -358,6 +360,8 @@ else:
|
||||
createDeviceTypes(deviceTypes, nb)
|
||||
|
||||
print('---')
|
||||
print('Script took {} to run'.format(datetime.now() - startTime))
|
||||
print('{} devices created'.format(counter['added']))
|
||||
print('{} interfaces/ports updated'.format(counter['updated']))
|
||||
print('{} manufacturers created'.format(counter['manufacturer']))
|
||||
|
||||
|
@ -2,10 +2,11 @@ import os
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
REPO_URL = str(os.getenv("REPO_URL"))
|
||||
NETBOX_URL = str(os.getenv("NETBOX_URL"))
|
||||
NETBOX_TOKEN = str(os.getenv("NETBOX_TOKEN"))
|
||||
|
||||
MANDATORY_ENV_VARS = ["NETBOX_URL", "NETBOX_TOKEN"]
|
||||
MANDATORY_ENV_VARS = ["REPO_URL", "NETBOX_URL", "NETBOX_TOKEN"]
|
||||
|
||||
for var in MANDATORY_ENV_VARS:
|
||||
if var not in os.environ:
|
||||
|
Loading…
x
Reference in New Issue
Block a user