Baremetal NIC list should return a list
Since the list_nics* methods were changed to use raw HTTP client rather than the ironic client, they return a dict rather than a list. Instead of getting this: [{'address': '00:11:22:33:44:55', ...}, ...] We get this: {'ports': [{'address': '00:11:22:33:44:55', ...}, ...]} This change removes this outer dict and returns to the old behaviour of returning a list. This affects list_nics and list_nics_for_machine. Change-Id: I3cb9ef5d97cf911cb4897b00ab4cef77b76efaa4
This commit is contained in:

committed by
Monty Taylor

parent
baef9e52bc
commit
ff23cd0681
@@ -8833,24 +8833,25 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||||||
|
|
||||||
def list_nics(self):
|
def list_nics(self):
|
||||||
msg = "Error fetching machine port list"
|
msg = "Error fetching machine port list"
|
||||||
return self._baremetal_client.get("/ports",
|
data = self._baremetal_client.get("/ports",
|
||||||
microversion="1.6",
|
microversion="1.6",
|
||||||
error_message=msg)
|
error_message=msg)
|
||||||
|
return data['ports']
|
||||||
|
|
||||||
def list_nics_for_machine(self, uuid):
|
def list_nics_for_machine(self, uuid):
|
||||||
"""Returns a list of ports present on the machine node.
|
"""Returns a list of ports present on the machine node.
|
||||||
|
|
||||||
:param uuid: String representing machine UUID value in
|
:param uuid: String representing machine UUID value in
|
||||||
order to identify the machine.
|
order to identify the machine.
|
||||||
:returns: A dictionary containing containing a list of ports,
|
:returns: A list of ports.
|
||||||
associated with the label "ports".
|
|
||||||
"""
|
"""
|
||||||
msg = "Error fetching port list for node {node_id}".format(
|
msg = "Error fetching port list for node {node_id}".format(
|
||||||
node_id=uuid)
|
node_id=uuid)
|
||||||
url = "/nodes/{node_id}/ports".format(node_id=uuid)
|
url = "/nodes/{node_id}/ports".format(node_id=uuid)
|
||||||
return self._baremetal_client.get(url,
|
data = self._baremetal_client.get(url,
|
||||||
microversion="1.6",
|
microversion="1.6",
|
||||||
error_message=msg)
|
error_message=msg)
|
||||||
|
return data['ports']
|
||||||
|
|
||||||
def get_nic_by_mac(self, mac):
|
def get_nic_by_mac(self, mac):
|
||||||
try:
|
try:
|
||||||
|
@@ -49,8 +49,8 @@ class TestBaremetalPort(base.IronicTestCase):
|
|||||||
])
|
])
|
||||||
|
|
||||||
return_value = self.cloud.list_nics()
|
return_value = self.cloud.list_nics()
|
||||||
self.assertEqual(2, len(return_value['ports']))
|
self.assertEqual(2, len(return_value))
|
||||||
self.assertEqual(self.fake_baremetal_port, return_value['ports'][0])
|
self.assertEqual(self.fake_baremetal_port, return_value[0])
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
def test_list_nics_failure(self):
|
def test_list_nics_failure(self):
|
||||||
@@ -75,8 +75,8 @@ class TestBaremetalPort(base.IronicTestCase):
|
|||||||
|
|
||||||
return_value = self.cloud.list_nics_for_machine(
|
return_value = self.cloud.list_nics_for_machine(
|
||||||
self.fake_baremetal_node['uuid'])
|
self.fake_baremetal_node['uuid'])
|
||||||
self.assertEqual(2, len(return_value['ports']))
|
self.assertEqual(2, len(return_value))
|
||||||
self.assertEqual(self.fake_baremetal_port, return_value['ports'][0])
|
self.assertEqual(self.fake_baremetal_port, return_value[0])
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
def test_list_nics_for_machine_failure(self):
|
def test_list_nics_for_machine_failure(self):
|
||||||
|
Reference in New Issue
Block a user