- # first loop through and read details for all devices
- # request machine readable format, with numeric IDs
- dev = {}
- dev_lines = check_output(["lspci", "-Dvmmn"]).splitlines()
- for dev_line in dev_lines:
- if len(dev_line) == 0:
- if dev["Class"][0:2] == NETWORK_BASE_CLASS:
- # convert device and vendor ids to numbers, then add to global
- dev["Vendor"] = int(dev["Vendor"], 16)
- dev["Device"] = int(dev["Device"], 16)
- # use dict to make copy of dev
- devices[dev["Slot"]] = dict(dev)
- else:
- name, value = dev_line.decode().split("\t", 1)
- dev[name.rstrip(":")] = value
-
- # check what is the interface if any for an ssh connection if
- # any to this host, so we can mark it later.
- ssh_if = []
- route = check_output(["ip", "-o", "route"])
- # filter out all lines for 169.254 routes
- route = "\n".join(filter(lambda ln: not ln.startswith("169.254"),
- route.decode().splitlines()))
- rt_info = route.split()
- for i in range(len(rt_info) - 1):
- if rt_info[i] == "dev":
- ssh_if.append(rt_info[i+1])
-
- # based on the basic info, get extended text details
- for d in devices.keys():
- # get additional info and add it to existing data
- devices[d] = devices[d].copy()
- devices[d].update(get_pci_device_details(d).items())
-
- for _if in ssh_if:
- if _if in devices[d]["Interface"].split(","):
- devices[d]["Ssh_if"] = True
- devices[d]["Active"] = "*Active*"
- break
-
- # add igb_uio to list of supporting modules if needed
- if "Module_str" in devices[d]:
- for driver in dpdk_drivers:
- if driver not in devices[d]["Module_str"]:
- devices[d]["Module_str"] = \
- devices[d]["Module_str"] + ",%s" % driver
- else:
- devices[d]["Module_str"] = ",".join(dpdk_drivers)