Merge ~ack/maas:1884075-2.8 into maas:2.7

Proposed by Alberto Donato
Status: Merged
Approved by: Alberto Donato
Approved revision: dcce2a51b600d9da81431db6bb328d6c38dc3884
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ack/maas:1884075-2.8
Merge into: maas:2.7
Diff against target: 144 lines (+84/-25)
3 files modified
src/machine-resources/src/machine-resources/Gopkg.lock (+1/-1)
src/metadataserver/builtin_scripts/hooks.py (+32/-24)
src/metadataserver/builtin_scripts/tests/test_hooks.py (+51/-0)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Björn Tillenius Approve
Review via email: mp+386243@code.launchpad.net

Commit message

LP:1884075 - look up NIC ports also under the "vfs" section (for SRIOV cards)

To post a comment you must log in.
Revision history for this message
Björn Tillenius (bjornt) wrote :

+1

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b 1884075-2.8 lp:~ack/maas/+git/maas into -b 2.7 lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/7774/console
COMMIT: 9cf30b30ac504f0eb05f9584da6867e1fa92e152

review: Needs Fixing
Revision history for this message
MAAS Lander (maas-lander) wrote :
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b 1884075-2.8 lp:~ack/maas/+git/maas into -b 2.7 lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: dcce2a51b600d9da81431db6bb328d6c38dc3884

review: Approve

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/machine-resources/src/machine-resources/Gopkg.lock b/src/machine-resources/src/machine-resources/Gopkg.lock
2index 3006552..afd1fb4 100644
3--- a/src/machine-resources/src/machine-resources/Gopkg.lock
4+++ b/src/machine-resources/src/machine-resources/Gopkg.lock
5@@ -28,7 +28,7 @@
6 branch = "master"
7 name = "github.com/lxc/lxd"
8 packages = ["lxd/resources","shared","shared/api","shared/cancel","shared/ioprogress","shared/logger","shared/osarch","shared/units","shared/usbid","shared/version"]
9- revision = "7516f0a2968b025efd1ea5066e78b16d6646b1c8"
10+ revision = "6c2d0d039346d2e2b524e1b9bd207be182abe0a6"
11
12 [[projects]]
13 name = "github.com/mitchellh/go-homedir"
14diff --git a/src/metadataserver/builtin_scripts/hooks.py b/src/metadataserver/builtin_scripts/hooks.py
15index c0d3b2a..5706221 100644
16--- a/src/metadataserver/builtin_scripts/hooks.py
17+++ b/src/metadataserver/builtin_scripts/hooks.py
18@@ -114,32 +114,40 @@ def _parse_interfaces(node, data):
19 assert isinstance(script_result.output, bytes)
20
21 ip_addr_info = parse_ip_addr(script_result.output)
22+
23+ def process_port(card, port):
24+ mac = port.get("address")
25+ if mac in (None, SWITCH_OPENBMC_MAC):
26+ # Ignore loopback (with no MAC) and OpenBMC interfaces on switches
27+ # which all share the same, hard-coded OpenBMC MAC address.
28+ return
29+
30+ interface = {
31+ "name": port.get("id"),
32+ "link_connected": port.get("link_detected"),
33+ "interface_speed": _parse_interface_speed(port),
34+ "link_speed": port.get("link_speed", 0),
35+ "numa_node": card.get("numa_node", 0),
36+ "vendor": card.get("vendor"),
37+ "product": card.get("product"),
38+ "firmware_version": card.get("firmware_version"),
39+ "sriov_max_vf": card.get("sriov", {}).get("maximum_vfs", 0),
40+ }
41+ # Assign the IP addresses to this interface
42+ link = ip_addr_info.get(interface["name"], {})
43+ interface["ips"] = link.get("inet", []) + link.get("inet6", [])
44+ interfaces[mac] = interface
45+
46 network_cards = data.get("network", {}).get("cards", {})
47 for card in network_cards:
48- for port in card.get("ports", {}):
49- mac = port.get("address")
50- if mac in (None, SWITCH_OPENBMC_MAC):
51- # Ignore loopback (with no MAC) and OpenBMC interfaces on
52- # switches which all share the same, hard-coded OpenBMC MAC
53- # address.
54- continue
55-
56- interface = {
57- "name": port.get("id"),
58- "link_connected": port.get("link_detected"),
59- "interface_speed": _parse_interface_speed(port),
60- "link_speed": port.get("link_speed", 0),
61- "numa_node": card.get("numa_node", 0),
62- "vendor": card.get("vendor"),
63- "product": card.get("product"),
64- "firmware_version": card.get("firmware_version"),
65- "sriov_max_vf": card.get("sriov", {}).get("maximum_vfs", 0),
66- }
67- # Assign the IP addresses to this interface
68- link = ip_addr_info[interface["name"]]
69- interface["ips"] = link.get("inet", []) + link.get("inet6", [])
70-
71- interfaces[mac] = interface
72+ for port in card.get("ports", []):
73+ process_port(card, port)
74+
75+ # entry can be present but None
76+ vfs = card.get("sriov", {}).get("vfs") or {}
77+ for vf in vfs:
78+ for vf_port in vf.get("ports", []):
79+ process_port(vf, vf_port)
80
81 return interfaces
82
83diff --git a/src/metadataserver/builtin_scripts/tests/test_hooks.py b/src/metadataserver/builtin_scripts/tests/test_hooks.py
84index 423e0e4..9375497 100644
85--- a/src/metadataserver/builtin_scripts/tests/test_hooks.py
86+++ b/src/metadataserver/builtin_scripts/tests/test_hooks.py
87@@ -2407,6 +2407,57 @@ class TestUpdateNodeNetworkInformation(MAASServerTestCase):
88 self.assertEqual(nic2.tags, [])
89 self.assertEqual(nic3.tags, [])
90
91+ def test_adds_ifaces_under_sriov(self):
92+ node = factory.make_Node()
93+ create_IPADDR_OUTPUT_NAME_script(node, IP_ADDR_OUTPUT)
94+
95+ # Delete all Interfaces created by factory attached to this node.
96+ Interface.objects.filter(node_id=node.id).delete()
97+
98+ resources = deepcopy(SAMPLE_LXD_JSON)
99+ resources["network"]["cards"].append(
100+ {
101+ "driver": "thunder-nic",
102+ "driver_version": "1.0",
103+ "sriov": {
104+ "current_vfs": 30,
105+ "maximum_vfs": 128,
106+ "vfs": [
107+ {
108+ "driver": "thunder-nicvf",
109+ "driver_version": "1.0",
110+ "ports": [
111+ {
112+ "id": "enP2p1s0f1",
113+ "address": "01:01:01:01:01:01",
114+ "port": 0,
115+ "protocol": "ethernet",
116+ "auto_negotiation": False,
117+ "link_detected": False,
118+ }
119+ ],
120+ "numa_node": 0,
121+ "vendor": "Cavium, Inc.",
122+ "vendor_id": "177d",
123+ "product": "THUNDERX Network Interface Controller virtual function",
124+ "product_id": "a034",
125+ }
126+ ],
127+ },
128+ "numa_node": 0,
129+ "pci_address": "0002:01:00.0",
130+ "vendor": "Cavium, Inc.",
131+ "vendor_id": "177d",
132+ "product": "THUNDERX Network Interface Controller",
133+ "product_id": "a01e",
134+ }
135+ )
136+ update_node_network_information(
137+ node, resources, create_numa_nodes(node)
138+ )
139+ nic = Interface.objects.get(mac_address="01:01:01:01:01:01")
140+ self.assertEqual(nic.vendor, "Cavium, Inc.")
141+
142 def test_ignores_missing_vendor_data(self):
143 """Test a node that has no previously known interfaces gets info from
144 lshw added.

Subscribers

People subscribed via source and target branches