Skip to content

Commit 81fd78a

Browse files
committed
Fix for 35 and update missing default parameters in readme
1 parent ddccf8c commit 81fd78a

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ The plugin behavior can be controlled with the following list of settings
3333
- `create_device_type_if_missing` boolean (default True), If True, a new device type object will be created if the model discovered by Napalm do not match an existing device type.
3434
- `create_manufacturer_if_missing` boolean (default True), If True, a new manufacturer object will be created if the manufacturer discovered by Napalm is do not match an existing manufacturer, this option is only valid if `create_device_type_if_missing` is True as well.
3535
- `create_device_role_if_missing` boolean (default True), If True, a new device role object will be created if the device role provided was not provided as part of the onboarding and if the `default_device_role` do not already exist.
36-
- `default_device_role` string (default "network")
36+
- `default_device_role` string (default "network")
37+
- `default_device_role_color` string (default FF0000) color assigned to the device role if it needs to be created.
38+
- `default_management_interface` string (default "PLACEHOLDER"), name of the management interface that will be created, if one can't be identified on the device.
39+
- `default_management_prefix_length` integer ( default 0), length of the prefix that will be used for the management IP address, if the IP can't be found.
3740

3841
## Usage
3942
### Preparation

netbox_onboarding/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class OnboardingConfig(PluginConfig):
3333
"create_device_type_if_missing": True,
3434
"create_device_role_if_missing": True,
3535
"default_device_role": "network",
36+
"default_device_role_color": "FF0000",
3637
"default_management_interface": "PLACEHOLDER",
3738
"default_management_prefix_length": 0,
3839
}

netbox_onboarding/onboard.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,14 @@ def ensure_device_role(
386386
self,
387387
create_device_role=PLUGIN_SETTINGS["create_device_role_if_missing"],
388388
default_device_role=PLUGIN_SETTINGS["default_device_role"],
389+
default_device_role_color=PLUGIN_SETTINGS["default_device_role_color"],
389390
):
390391
"""Ensure that the device role is defined / exist in NetBox or create it if it doesn't exist.
391392
392393
Args:
393394
create_device_role (bool) :Flag to indicate if we need to create the device_role, if not already present
394395
default_device_role (str): Default value for the device_role, if we need to create it
396+
default_device_role_color (str): Default color to assign to the device_role, if we need to create it
395397
Raises:
396398
OnboardException('fail-config'):
397399
When the device role value does not exist
@@ -408,7 +410,12 @@ def ensure_device_role(
408410
reason="fail-config", message=f"ERROR device role not found: {default_device_role}"
409411
)
410412

411-
device_role = DeviceRole.objects.create(name=default_device_role, slug=slugify(default_device_role))
413+
device_role = DeviceRole.objects.create(
414+
name=default_device_role,
415+
slug=slugify(default_device_role),
416+
color=default_device_role_color,
417+
vm_role=False,
418+
)
412419
device_role.save()
413420

414421
self.netdev.ot.role = device_role

0 commit comments

Comments
 (0)