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