add rack unit and rack location functions
This commit is contained in:
parent
cd47e01831
commit
de07a4ccf1
3 changed files with 28 additions and 1 deletions
|
|
@ -71,6 +71,12 @@ def get_config():
|
|||
p.add_argument('--rack_location.driver', help='Rack location driver, ie: cmd, file')
|
||||
p.add_argument('--rack_location.driver_file', help='Rack location custom driver file path')
|
||||
p.add_argument('--rack_location.regex', help='Rack location regex to extract Rack name')
|
||||
p.add_argument('--rack_unit.driver', help='Rack Unit driver, ie: cmd, file')
|
||||
p.add_argument('--rack_unit.driver_file', help='Rack Unit custom driver file path')
|
||||
p.add_argument('--rack_unit.regex', help='Rack Unit regex to extract Rack name')
|
||||
p.add_argument('--rack_face.driver', help='Rack Face driver, ie: cmd, file')
|
||||
p.add_argument('--rack_face.driver_file', help='Rack Face custom driver file path')
|
||||
p.add_argument('--rack_face.regex', help='Rack Face regex to extract Rack name')
|
||||
p.add_argument('--slot_location.driver', help='Slot location driver, ie: cmd, file')
|
||||
p.add_argument('--slot_location.driver_file', help='Slot location custom driver file path')
|
||||
p.add_argument('--slot_location.regex', help='Slot location regex to extract slot name')
|
||||
|
|
|
|||
|
|
@ -71,6 +71,25 @@ class Datacenter(LocationBase):
|
|||
regex = config.datacenter_location.regex
|
||||
super().__init__(driver, driver_value, driver_file, regex)
|
||||
|
||||
class Rack_Unit(LocationBase):
|
||||
def __init__(self):
|
||||
driver = config.rack_unit.driver.split(':')[0] if \
|
||||
config.rack_unit.driver else None
|
||||
driver_value = ':'.join(config.rack_unit.driver.split(':')[1:]) if \
|
||||
config.rack_unit.driver else None
|
||||
driver_file = config.rack_unit.driver_file
|
||||
regex = config.rack_unit.regex
|
||||
super().__init__(driver, driver_value, driver_file, regex)
|
||||
|
||||
class Rack_Face(LocationBase):
|
||||
def __init__(self):
|
||||
driver = config.rack_face.driver.split(':')[0] if \
|
||||
config.rack_face.driver else None
|
||||
driver_value = ':'.join(config.rack_face.driver.split(':')[1:]) if \
|
||||
config.rack_face.driver else None
|
||||
driver_file = config.rack_face.driver_file
|
||||
regex = config.rack_face.regex
|
||||
super().__init__(driver, driver_value, driver_file, regex)
|
||||
|
||||
class Rack(LocationBase):
|
||||
def __init__(self):
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import netbox_agent.dmidecode as dmidecode
|
|||
from netbox_agent.config import config
|
||||
from netbox_agent.config import netbox_instance as nb
|
||||
from netbox_agent.inventory import Inventory
|
||||
from netbox_agent.location import Datacenter, Rack, Tenant
|
||||
from netbox_agent.location import Datacenter, Rack, Tenant, Rack_Unit, Rack_Face
|
||||
from netbox_agent.misc import create_netbox_tags, get_device_role, get_device_type, get_device_platform
|
||||
from netbox_agent.network import ServerNetwork
|
||||
from netbox_agent.power import PowerSupply
|
||||
|
|
@ -102,6 +102,8 @@ class ServerBase():
|
|||
if nb_rack is None:
|
||||
server.face = None
|
||||
server.position = None
|
||||
server.position = Rack_Unit().get()
|
||||
server.face = Rack_Face().get()
|
||||
return update, server
|
||||
|
||||
def update_netbox_expansion_location(self, server, expansion):
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue