Increase order prefix to 3 digits
This commit is contained in:
parent
7e6edd1bf5
commit
97477556e0
|
@ -15,7 +15,7 @@ with open('/opt/netbox/initializers/regions.yml', 'r') as stream:
|
|||
for assoc, details in optional_assocs.items():
|
||||
if assoc in params:
|
||||
model, field = details
|
||||
query = dict(field=params.pop(assoc))
|
||||
query = { field: params.pop(assoc) }
|
||||
|
||||
params[assoc] = model.objects.get(**query)
|
||||
|
|
@ -14,6 +14,7 @@ with open('/opt/netbox/initializers/sites.yml', 'r') as stream:
|
|||
|
||||
if sites is not None:
|
||||
for params in sites:
|
||||
custom_fields = params.pop('custom_fields', None)
|
||||
|
||||
for assoc, details in optional_assocs.items():
|
||||
if assoc in params:
|
||||
|
@ -30,7 +31,7 @@ with open('/opt/netbox/initializers/sites.yml', 'r') as stream:
|
|||
custom_field = CustomField.objects.get(name=cf_name)
|
||||
custom_field_value = CustomFieldValue.objects.create(
|
||||
field=custom_field,
|
||||
obj=device_type,
|
||||
obj=site,
|
||||
value=cf_value
|
||||
)
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
from dcim.models import DeviceType, Manufacturer
|
||||
from dcim.models import DeviceType, Manufacturer, Region
|
||||
from tenancy.models import Tenant
|
||||
from extras.models import CustomField, CustomFieldValue
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
|
@ -19,16 +20,16 @@ with open('/opt/netbox/initializers/device_types.yml', 'r') as stream:
|
|||
for params in device_types:
|
||||
custom_fields = params.pop('custom_fields', None)
|
||||
|
||||
for assoc, details in required.items():
|
||||
for assoc, details in required_assocs.items():
|
||||
model, field = details
|
||||
query = dict(field=params.pop(assoc))
|
||||
query = { field: params.pop(assoc) }
|
||||
|
||||
params[assoc] = model.objects.get(**query)
|
||||
|
||||
for assoc, details in optional_assocs.items():
|
||||
if assoc in params:
|
||||
model, field = details
|
||||
query = dict(field=params.pop(assoc))
|
||||
query = { field: params.pop(assoc) }
|
||||
|
||||
params[assoc] = model.objects.get(**query)
|
||||
|
|
@ -13,7 +13,7 @@ with open('/opt/netbox/initializers/rack_roles.yml', 'r') as stream:
|
|||
|
||||
for color_tpl in COLOR_CHOICES:
|
||||
if color in color_tpl:
|
||||
params['color'] = color_tpl[0]
|
||||
params['color'] = color_tpl[0]
|
||||
|
||||
rack_role, created = RackRole.objects.get_or_create(**params)
|
||||
|
|
@ -22,16 +22,16 @@ with open('/opt/netbox/initializers/racks.yml', 'r') as stream:
|
|||
for params in racks:
|
||||
custom_fields = params.pop('custom_fields', None)
|
||||
|
||||
for assoc, details in required.items():
|
||||
for assoc, details in required_assocs.items():
|
||||
model, field = details
|
||||
query = dict(field=params.pop(assoc))
|
||||
query = { field: params.pop(assoc) }
|
||||
|
||||
params[assoc] = model.objects.get(**query)
|
||||
|
||||
for assoc, details in optional_assocs.items():
|
||||
if assoc in params:
|
||||
model, field = details
|
||||
query = dict(field=params.pop(assoc))
|
||||
query = { field: params.pop(assoc) }
|
||||
|
||||
params[assoc] = model.objects.get(**query)
|
||||
|
||||
|
@ -51,7 +51,7 @@ with open('/opt/netbox/initializers/racks.yml', 'r') as stream:
|
|||
custom_field = CustomField.objects.get(name=cf_name)
|
||||
custom_field_value = CustomFieldValue.objects.create(
|
||||
field=custom_field,
|
||||
obj=device_type,
|
||||
obj=rack,
|
||||
value=cf_value
|
||||
)
|
||||
|
|
@ -21,7 +21,7 @@ with open('/opt/netbox/initializers/devices.yml', 'r') as stream:
|
|||
'platform': (Platform, 'name'),
|
||||
'rack': (Rack, 'name'),
|
||||
'cluster': (Cluster, 'name'),
|
||||
'primary_ip4': (IPAddress, 'address')
|
||||
'primary_ip4': (IPAddress, 'address'),
|
||||
'primary_ip6': (IPAddress, 'address')
|
||||
}
|
||||
|
||||
|
@ -29,16 +29,16 @@ with open('/opt/netbox/initializers/devices.yml', 'r') as stream:
|
|||
for params in devices:
|
||||
custom_fields = params.pop('custom_fields', None)
|
||||
|
||||
for assoc, details in required.items():
|
||||
for assoc, details in required_assocs.items():
|
||||
model, field = details
|
||||
query = dict(field=params.pop(assoc))
|
||||
query = { field: params.pop(assoc) }
|
||||
|
||||
params[assoc] = model.objects.get(**query)
|
||||
|
||||
for assoc, details in optional_assocs.items():
|
||||
if assoc in params:
|
||||
model, field = details
|
||||
query = dict(field=params.pop(assoc))
|
||||
query = { field: params.pop(assoc) }
|
||||
|
||||
params[assoc] = model.objects.get(**query)
|
||||
|
||||
|
@ -55,7 +55,7 @@ with open('/opt/netbox/initializers/devices.yml', 'r') as stream:
|
|||
custom_field = CustomField.objects.get(name=cf_name)
|
||||
custom_field_value = CustomFieldValue.objects.create(
|
||||
field=custom_field,
|
||||
obj=device_type,
|
||||
obj=device,
|
||||
value=cf_value
|
||||
)
|
||||
|
Loading…
Reference in New Issue