blob: 2599d86e81eb04c02cc00e3b2c8bd24a23093b9f [file] [log] [blame]
YuikoTakadaac0879a2015-01-22 02:40:03 +00001# Copyright 2015 NEC Corporation. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from tempest.api.compute import base
16from tempest import config
17from tempest import test
18
19CONF = config.CONF
20
21
22class BaremetalNodesAdminTestJSON(base.BaseV2ComputeAdminTest):
23 """
24 Tests Baremetal API
25 """
26
27 @classmethod
28 def resource_setup(cls):
29 super(BaremetalNodesAdminTestJSON, cls).resource_setup()
30 if not CONF.service_available.ironic:
31 skip_msg = ('%s skipped as Ironic is not available' % cls.__name__)
32 raise cls.skipException(skip_msg)
33 cls.client = cls.os_adm.baremetal_nodes_client
Adam Gandelman118cd392015-03-09 14:41:36 -070034 cls.ironic_client = cls.os_adm.baremetal_client
YuikoTakadaac0879a2015-01-22 02:40:03 +000035
Sean Daguef0462a12015-04-27 11:03:59 -040036 @test.attr(type=['baremetal'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080037 @test.idempotent_id('e475aa6e-416d-4fa4-b3af-28d5e84250fb')
Adam Gandelman118cd392015-03-09 14:41:36 -070038 def test_list_get_baremetal_nodes(self):
39 # Create some test nodes in Ironic directly
40 test_nodes = []
41 for i in range(0, 3):
42 _, node = self.ironic_client.create_node()
43 test_nodes.append(node)
44 self.addCleanup(self.ironic_client.delete_node, node['uuid'])
YuikoTakadaac0879a2015-01-22 02:40:03 +000045
Adam Gandelman118cd392015-03-09 14:41:36 -070046 # List all baremetal nodes and ensure our created test nodes are
47 # listed
48 bm_node_ids = set([n['id'] for n in
ghanshyamf9a569b2015-08-04 15:29:06 +090049 self.client.list_baremetal_nodes()['nodes']])
Adam Gandelman118cd392015-03-09 14:41:36 -070050 test_node_ids = set([n['uuid'] for n in test_nodes])
51 self.assertTrue(test_node_ids.issubset(bm_node_ids))
52
53 # Test getting each individually
54 for node in test_nodes:
Ken'ichi Ohmichi3de6d982015-04-13 00:20:41 +000055 baremetal_node = self.client.show_baremetal_node(node['uuid'])
ghanshyamf9a569b2015-08-04 15:29:06 +090056 self.assertEqual(node['uuid'], baremetal_node['node']['id'])