add inventory configuration variable to enable the feature

This commit is contained in:
Solvik Blum 2019-08-22 11:06:45 +02:00
parent 856e9094fc
commit 397cc7a648
No known key found for this signature in database
GPG key ID: CC12B3DC262B6C47
5 changed files with 20 additions and 10 deletions

View file

@ -2,7 +2,7 @@ import logging
import subprocess
import re
from netbox_agent.config import netbox_instance as nb
from netbox_agent.config import netbox_instance as nb, INVENTORY_ENABLED
from netbox_agent.misc import is_tool
from netbox_agent.raid.hp import HPRaid
from netbox_agent.raid.storcli import StorcliRaid
@ -43,6 +43,10 @@ class Inventory():
* get netbox item
* create netbox item
* update netbox item
Known issues:
- no scan of non-raid devices
- no scan of NVMe devices
"""
def __init__(self, server):
@ -306,13 +310,19 @@ class Inventory():
self.create_netbox_memory(memory)
def create(self):
if not INVENTORY_ENABLED:
return False
self.create_netbox_cpus()
self.create_netbox_memory()
self.create_netbox_raid_cards()
self.create_netbox_disks()
return True
def update(self):
if not INVENTORY_ENABLED:
return False
self.update_netbox_cpus()
self.update_netbox_memory()
self.update_netbox_raid_cards()
self.update_netbox_disks()
return True