Replace all special characters in slug with a dash rather than just spaces and dots #89
1 changed files with 2 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
import pynetbox
|
import pynetbox
|
||||||
|
import re
|
||||||
|
|
||||||
from netbox_agent.config import netbox_instance as nb, config
|
from netbox_agent.config import netbox_instance as nb, config
|
||||||
from netbox_agent.misc import is_tool, get_vendor
|
from netbox_agent.misc import is_tool, get_vendor
|
||||||
|
@ -75,7 +76,7 @@ class Inventory():
|
||||||
logging.info('Creating missing manufacturer {name}'.format(name=name))
|
logging.info('Creating missing manufacturer {name}'.format(name=name))
|
||||||
manufacturer = nb.dcim.manufacturers.create(
|
manufacturer = nb.dcim.manufacturers.create(
|
||||||
name=name,
|
name=name,
|
||||||
slug=name.replace(' ', '-').replace('.', '').lower(),
|
slug=re.sub('[^A-Za-z0-9]+', '-', name).lower(),
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.info('Creating missing manufacturer {name}'.format(name=name))
|
logging.info('Creating missing manufacturer {name}'.format(name=name))
|
||||||
|
|
Loading…
Reference in a new issue