diff --git a/initializers/manufacturers.yml b/initializers/manufacturers.yml new file mode 100644 index 0000000..18aef10 --- /dev/null +++ b/initializers/manufacturers.yml @@ -0,0 +1,6 @@ +# - name: Cisco +# slug: cisco +# - name: Intel +# slug: intel +# - name: NoName +# slug: noname diff --git a/startup_scripts/42_manufacturers.py b/startup_scripts/42_manufacturers.py new file mode 100644 index 0000000..49714bd --- /dev/null +++ b/startup_scripts/42_manufacturers.py @@ -0,0 +1,14 @@ +from dcim.models import Manufacturer +from ruamel.yaml import YAML + +with open('/opt/netbox/initializers/manufacturers.yml', 'r') as stream: + yaml = YAML(typ='safe') + manufacturers = yaml.load(stream) + + if manufacturers is not None: + for manufacturer_params in manufacturers: + manufacturer, created = Manufacturer.objects.get_or_create(**manufacturer_params) + + if created: + print("Created Manufacturer", manufacturer.name) +