Return NetConnectionID instead of Name

Change get_network_adapters in the Windows osutils to return
NetConnectionID from the Win32_NetworkAdapter WMI query in
place of Name.

Different Windows API use different naming to identify the name and
description of a network adapter.
In the case of Win32_NetworkAdapter, NetConnectionID is the actual
name (e.g. Ethernet1) while Name is the description (e.g. Microsoft
Hyper-V Network Adapter).

Partially-Implements: blueprint json-network-config
Change-Id: I3e690a9e0b763e9829a3eddd91a47454d3eb1df8
This commit is contained in:
Alessandro Pilotti 2018-08-23 23:56:51 +03:00
parent 0dc65eb712
commit 01a501ff1d
2 changed files with 4 additions and 3 deletions

View File

@ -700,7 +700,7 @@ class WindowsUtils(base.BaseOSUtils):
wql += ' AND PhysicalAdapter = True'
q = conn.query(wql)
return [(r.Name, r.MACAddress) for r in q]
return [(r.NetConnectionID, r.MACAddress) for r in q]
def get_dhcp_hosts_in_use(self):
dhcp_hosts = []

View File

@ -576,8 +576,9 @@ class TestWindowsUtils(testutils.CloudbaseInitTestBase):
response = self._winutils.get_network_adapters()
conn.return_value.query.assert_called_with(wql)
self.assertEqual([(mock_response.Name, mock_response.MACAddress)],
response)
self.assertEqual(
[(mock_response.NetConnectionID, mock_response.MACAddress)],
response)
def test_get_network_adapters(self):
self._test_get_network_adapters(False)