TOX fixes
This commit is contained in:
parent
79a5f5e06d
commit
5fd9c7358b
8 changed files with 54 additions and 58 deletions
|
|
@ -64,7 +64,7 @@ network:
|
|||
# tags: server, blade, ,just a comma,delimited,list
|
||||
|
||||
#
|
||||
# Can use this to set the tenant
|
||||
# This sets the tenant
|
||||
#
|
||||
tenant:
|
||||
driver: "file:/tmp/tenant"
|
||||
|
|
|
|||
|
|
@ -1,15 +1,11 @@
|
|||
import re
|
||||
from shutil import which
|
||||
from pprint import pprint
|
||||
import subprocess
|
||||
|
||||
# Originally from https://github.com/opencoff/useful-scripts/blob/master/linktest.py
|
||||
|
||||
# 'Connector':'connector',
|
||||
# 'Transceiver type': 'transciever_type',
|
||||
|
||||
module_map = {
|
||||
'Identifier' : 'identifier',
|
||||
'Identifier': 'identifier',
|
||||
'Extended identifier': 'extended_identifier',
|
||||
'Vendor name': 'vendor',
|
||||
'Vendor PN': 'partnumber',
|
||||
|
|
@ -76,7 +72,9 @@ class Ethtool():
|
|||
return fields
|
||||
|
||||
def _parse_ethtool_info_output(self):
|
||||
status, output = subprocess.getstatusoutput('sudo /usr/sbin/ethtool -i {}'.format(self.interface))
|
||||
status, output = subprocess.getstatusoutput(
|
||||
'sudo /usr/sbin/ethtool -i {}'.format(self.interface)
|
||||
)
|
||||
|
||||
if status != 0:
|
||||
return {}
|
||||
|
|
@ -101,7 +99,10 @@ class Ethtool():
|
|||
ie, connector and type, plus dropping un needed information.
|
||||
"""
|
||||
|
||||
status, output = subprocess.getstatusoutput('sudo /usr/sbin/ethtool -m {}'.format(self.interface))
|
||||
status, output = subprocess.getstatusoutput(
|
||||
'sudo /usr/sbin/ethtool -m {}'.format(self.interface)
|
||||
)
|
||||
|
||||
if status != 0:
|
||||
return {}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from netbox_agent.ethtool import Ethtool
|
|||
INVENTORY_TAG = {
|
||||
'cpu': {'name': 'hw:cpu', 'slug': 'hw-cpu'},
|
||||
'disk': {'name': 'hw:disk', 'slug': 'hw-disk'},
|
||||
'gbic': {'name': 'hw:gbic', 'slug': 'hw-gbic' },
|
||||
'gbic': {'name': 'hw:gbic', 'slug': 'hw-gbic'},
|
||||
'interface': {'name': 'hw:interface', 'slug': 'hw-interface'},
|
||||
'memory': {'name': 'hw:memory', 'slug': 'hw-memory'},
|
||||
'motherboard': {'name': 'hw:motherboard', 'slug': 'hw-motherboard'},
|
||||
|
|
@ -177,10 +177,14 @@ class Inventory():
|
|||
manufacturer=manufacturer.id,
|
||||
discovered=True,
|
||||
tags=[INVENTORY_TAG['gbic']['name']],
|
||||
name="{}/GBIC in interface {}".format(info.get('identifier'),iface.get('name')),
|
||||
name="{}/GBIC in interface {}".format(info.get('identifier'), iface.get('name')),
|
||||
part_id="{}".format(info.get('partnumber')),
|
||||
serial='{}'.format(info.get('serialnumber')),
|
||||
description='{}/{} connector GBIC/{}'.format(info.get('transciever_type'), info.get('connector'), info.get('identifier'))
|
||||
description='{}/{} connector GBIC/{}'.format(
|
||||
info.get('transciever_type'),
|
||||
info.get('connector'),
|
||||
info.get('identifier')
|
||||
)
|
||||
)
|
||||
|
||||
def create_netbox_interface(self, iface):
|
||||
|
|
|
|||
|
|
@ -89,7 +89,8 @@ class LSHW():
|
|||
|
||||
elif "nvme" in obj["configuration"]["driver"]:
|
||||
nvme = json.loads(
|
||||
subprocess.check_output(["sudo", "/usr/sbin/nvme", '-list', '-o', 'json'],
|
||||
subprocess.check_output(
|
||||
["sudo", "/usr/sbin/nvme", '-list', '-o', 'json'],
|
||||
encoding='utf8')) # noqa: E128
|
||||
|
||||
d = {}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import re
|
|||
|
||||
from netaddr import IPAddress, IPNetwork
|
||||
import netifaces
|
||||
from pprint import pprint
|
||||
|
||||
from netbox_agent.config import netbox_instance as nb, config
|
||||
from netbox_agent.ethtool import Ethtool
|
||||
|
|
@ -124,11 +123,11 @@ class Network():
|
|||
}
|
||||
|
||||
if nic["vlan"] is None:
|
||||
if nic["ovs"] != None:
|
||||
if nic["ovs"] is not None:
|
||||
ovs_info = nic.get("ovs")
|
||||
nic["vlan"] = ovs_info.get("vlan")
|
||||
|
||||
if nic["ovs"] != None:
|
||||
if nic["ovs"] is not None:
|
||||
nic["description"] = "OVS internal interface"
|
||||
|
||||
self.nics.append(nic)
|
||||
|
|
|
|||
|
|
@ -1,19 +1,12 @@
|
|||
import subprocess
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from shutil import which
|
||||
from pprint import pprint
|
||||
|
||||
from netbox_agent.misc import is_tool
|
||||
|
||||
|
||||
class OVS():
|
||||
def __init__(self):
|
||||
|
||||
self.fields = {}
|
||||
field = ''
|
||||
|
||||
if which('ovs-vsctl') is None:
|
||||
print("could not find ovs-vsctl")
|
||||
|
|
@ -51,7 +44,6 @@ class OVS():
|
|||
if "ovs_version" in r[0]:
|
||||
self.fields["info"]["ovs_version"] = r[1]
|
||||
|
||||
|
||||
def get_info(self, interface):
|
||||
for iface in self.fields:
|
||||
if "interface" in self.fields[iface]:
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ class ServerBase():
|
|||
slug=tag
|
||||
)
|
||||
|
||||
|
||||
def get_tenant(self):
|
||||
tenant = Tenant()
|
||||
return tenant.get()
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue