Update Custom Field logic for Netbox v2.10.x
This commit is contained in:
parent
036f94a450
commit
5c9bea8b50
24 changed files with 168 additions and 268 deletions
|
@ -1,2 +1,3 @@
|
|||
from .load_yaml import load_yaml
|
||||
from .permissions import set_permissions
|
||||
from .custom_fields import set_custom_fields_values, pop_custom_fields
|
||||
|
|
15
startup_scripts/startup_script_utils/custom_fields.py
Normal file
15
startup_scripts/startup_script_utils/custom_fields.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
def set_custom_fields_values(entity, custom_field_data):
|
||||
if not custom_field_data:
|
||||
return
|
||||
|
||||
entity.custom_field_data = custom_field_data
|
||||
return entity.save()
|
||||
|
||||
def pop_custom_fields(params):
|
||||
if 'custom_field_data' in params:
|
||||
return params.pop('custom_field_data')
|
||||
elif 'custom_fields' in params:
|
||||
print("⚠️ Please rename 'custom_fields' to 'custom_field_data'!")
|
||||
return params.pop('custom_fields')
|
||||
|
||||
return None
|
|
@ -1,5 +1,6 @@
|
|||
from ruamel.yaml import YAML
|
||||
from pathlib import Path
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
|
||||
def load_yaml(yaml_file: str):
|
||||
yf = Path(yaml_file)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue