From 48a89e101efc041c7e61a0b3e06bc06938cd347e Mon Sep 17 00:00:00 2001 From: gardar Date: Mon, 14 Oct 2019 23:02:22 +0000 Subject: [PATCH] Update inventory.py Replace all special characters in slug with a dash rather than just spaces and dots --- netbox_agent/inventory.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/netbox_agent/inventory.py b/netbox_agent/inventory.py index a5561e2..dfe3aaf 100644 --- a/netbox_agent/inventory.py +++ b/netbox_agent/inventory.py @@ -1,5 +1,6 @@ import logging import pynetbox +import re from netbox_agent.config import netbox_instance as nb, config from netbox_agent.misc import is_tool, get_vendor @@ -75,7 +76,7 @@ class Inventory(): logging.info('Creating missing manufacturer {name}'.format(name=name)) manufacturer = nb.dcim.manufacturers.create( 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)) -- 2.47.0