diff --git a/shade/openstackcloud.py b/shade/openstackcloud.py index 28ed2e543..670647353 100644 --- a/shade/openstackcloud.py +++ b/shade/openstackcloud.py @@ -8812,24 +8812,25 @@ class OpenStackCloud( def list_nics(self): msg = "Error fetching machine port list" - return self._baremetal_client.get("/ports", + data = self._baremetal_client.get("/ports", microversion="1.6", error_message=msg) + return data['ports'] def list_nics_for_machine(self, uuid): """Returns a list of ports present on the machine node. :param uuid: String representing machine UUID value in order to identify the machine. - :returns: A dictionary containing containing a list of ports, - associated with the label "ports". + :returns: A list of ports. """ msg = "Error fetching port list for node {node_id}".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", error_message=msg) + return data['ports'] def get_nic_by_mac(self, mac): try: diff --git a/shade/tests/unit/test_baremetal_ports.py b/shade/tests/unit/test_baremetal_ports.py index 63c5b40ba..75eb0d386 100644 --- a/shade/tests/unit/test_baremetal_ports.py +++ b/shade/tests/unit/test_baremetal_ports.py @@ -49,8 +49,8 @@ class TestBaremetalPort(base.IronicTestCase): ]) return_value = self.op_cloud.list_nics() - self.assertEqual(2, len(return_value['ports'])) - self.assertEqual(self.fake_baremetal_port, return_value['ports'][0]) + self.assertEqual(2, len(return_value)) + self.assertEqual(self.fake_baremetal_port, return_value[0]) self.assert_calls() def test_list_nics_failure(self): @@ -75,8 +75,8 @@ class TestBaremetalPort(base.IronicTestCase): return_value = self.op_cloud.list_nics_for_machine( self.fake_baremetal_node['uuid']) - self.assertEqual(2, len(return_value['ports'])) - self.assertEqual(self.fake_baremetal_port, return_value['ports'][0]) + self.assertEqual(2, len(return_value)) + self.assertEqual(self.fake_baremetal_port, return_value[0]) self.assert_calls() def test_list_nics_for_machine_failure(self):