[NIC Card Auto-Detect] NIC Card Auto-Detect
This patch is an addition to this patchset: https://review.opendev.org/c/airship/drydock/+/850579 It adds more debug messages. Change-Id: I01061934f5584276e461ef7a7f4c7a87c30755af
This commit is contained in:
parent
afdfa33099
commit
b431f7a2cf
@ -256,44 +256,58 @@ class BaremetalNode(drydock_provisioner.objects.hostprofile.HostProfile):
|
|||||||
:param address: String value that is used to find the logicalname. It can be PCI address
|
:param address: String value that is used to find the logicalname. It can be PCI address
|
||||||
to identify a vendor or a regexp to match multiple vendors. The regexp
|
to identify a vendor or a regexp to match multiple vendors. The regexp
|
||||||
has to start from regexp: prefix - for example:
|
has to start from regexp: prefix - for example:
|
||||||
regex:0000\\:(19|01)\\:00\\.[0-9].
|
regexp:0000\\:(19|01)\\:00\\.[0-9].
|
||||||
:return: String value of the logicalname or the alias_name if logicalname is not found.
|
:return: String value of the logicalname or the alias_name if logicalname is not found.
|
||||||
"""
|
"""
|
||||||
if address.find("regex:") != -1:
|
if "regexp:" in address:
|
||||||
address_regex = address.replace("regex:", "")
|
self.logger.info(
|
||||||
|
"Regexp: prefix has been detected in address: %s" %
|
||||||
|
(address))
|
||||||
|
address_regexp = address.replace("regexp:", "")
|
||||||
nodes = xml_root.findall(".//node")
|
nodes = xml_root.findall(".//node")
|
||||||
counter = 0
|
|
||||||
logicalnames = []
|
logicalnames = []
|
||||||
addresses = []
|
addresses = []
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
if 'class' in node.attrib:
|
if 'class' in node.attrib:
|
||||||
if node.get('class') == "network":
|
if node.get('class') == "network":
|
||||||
address = node.find('businfo').text.replace("pci@", "")
|
address = node.find('businfo').text.replace("pci@", "")
|
||||||
addresses.append(address)
|
self.logger.debug(
|
||||||
if re.match(address_regex, address):
|
"A network device PCI address found. Address=%s. Checking for regexp %s match..." %
|
||||||
counter += 1
|
(address, address_regexp))
|
||||||
|
if re.match(address_regexp, address):
|
||||||
logicalnames.append(node.find('logicalname').text)
|
logicalnames.append(node.find('logicalname').text)
|
||||||
|
addresses.append(address)
|
||||||
|
self.logger.debug(
|
||||||
|
"PCI address=%s is matching the regex %s." %
|
||||||
|
(address, address_regexp))
|
||||||
|
else:
|
||||||
|
self.logger.debug(
|
||||||
|
"A network device with PCI address=%s does not match the regex %s." %
|
||||||
|
(address, address_regexp))
|
||||||
|
if len(logicalnames) >= 1 and logicalnames[0]:
|
||||||
if len(logicalnames) > 1:
|
if len(logicalnames) > 1:
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"Multiple nodes found for businfo=%s@%s" %
|
"Multiple nodes found for businfo=%s@%s" %
|
||||||
(bus_type, address_regex))
|
(bus_type, address_regexp))
|
||||||
if logicalnames[0]:
|
for logicalname in reversed(logicalnames[0].split("/")):
|
||||||
logicalname = logicalnames[0]
|
|
||||||
address = addresses[0]
|
address = addresses[0]
|
||||||
self.logger.debug(
|
self.logger.info(
|
||||||
"Logicalname build dict: node_name = %s, alias_name = %s, "
|
"Logicalname build dict: node_name = %s, alias_name = %s, "
|
||||||
"bus_type = %s, address = %s, to logicalname = %s" %
|
"bus_type = %s, address = %s, to logicalname = %s" %
|
||||||
(self.get_name(), alias_name, bus_type, address,
|
(self.get_name(), alias_name, bus_type, address,
|
||||||
logicalname))
|
logicalname))
|
||||||
return logicalname
|
return logicalname
|
||||||
else:
|
else:
|
||||||
|
self.logger.info(
|
||||||
|
"No prefix has been detected in address: %s" %
|
||||||
|
(address))
|
||||||
nodes = xml_root.findall(".//node[businfo='" + bus_type + "@" + address + "'].logicalname")
|
nodes = xml_root.findall(".//node[businfo='" + bus_type + "@" + address + "'].logicalname")
|
||||||
if len(nodes) >= 1 and nodes[0].text:
|
if len(nodes) >= 1 and nodes[0].text:
|
||||||
if (len(nodes) > 1):
|
if (len(nodes) > 1):
|
||||||
self.logger.info("Multiple nodes found for businfo=%s@%s" %
|
self.logger.info("Multiple nodes found for businfo=%s@%s" %
|
||||||
(bus_type, address))
|
(bus_type, address))
|
||||||
for logicalname in reversed(nodes[0].text.split("/")):
|
for logicalname in reversed(nodes[0].text.split("/")):
|
||||||
self.logger.debug(
|
self.logger.info(
|
||||||
"Logicalname build dict: node_name = %s, alias_name = %s, "
|
"Logicalname build dict: node_name = %s, alias_name = %s, "
|
||||||
"bus_type = %s, address = %s, to logicalname = %s" %
|
"bus_type = %s, address = %s, to logicalname = %s" %
|
||||||
(self.get_name(), alias_name, bus_type, address,
|
(self.get_name(), alias_name, bus_type, address,
|
||||||
|
@ -411,7 +411,7 @@ data:
|
|||||||
pxe_interface: 0
|
pxe_interface: 0
|
||||||
device_aliases:
|
device_aliases:
|
||||||
prim_nic01:
|
prim_nic01:
|
||||||
address: 'regex:0000\:(19|01)\:00\.[0-9]'
|
address: 'regexp:0000:(19|01):00\.0'
|
||||||
# address: '0000:19:00.0'
|
# address: '0000:19:00.0'
|
||||||
dev_type: 'NetXtreme BCM5720 Gigabit Ethernet Controller or I350 Gigabit Ethernet Controller'
|
dev_type: 'NetXtreme BCM5720 Gigabit Ethernet Controller or I350 Gigabit Ethernet Controller'
|
||||||
bus_type: 'pci'
|
bus_type: 'pci'
|
||||||
|
Loading…
Reference in New Issue
Block a user