blob: b7644836b5d6c44e00d0e3d1553147b0cbdf55c4 [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):
Ken'ichi Ohmichi9e3dac02015-11-19 07:01:07 +000023 """Tests Baremetal API"""
YuikoTakadaac0879a2015-01-22 02:40:03 +000024
25 @classmethod
26 def resource_setup(cls):
27 super(BaremetalNodesAdminTestJSON, cls).resource_setup()
28 if not CONF.service_available.ironic:
29 skip_msg = ('%s skipped as Ironic is not available' % cls.__name__)
30 raise cls.skipException(skip_msg)
31 cls.client = cls.os_adm.baremetal_nodes_client
Adam Gandelman118cd392015-03-09 14:41:36 -070032 cls.ironic_client = cls.os_adm.baremetal_client
YuikoTakadaac0879a2015-01-22 02:40:03 +000033
Sean Daguef0462a12015-04-27 11:03:59 -040034 @test.attr(type=['baremetal'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080035 @test.idempotent_id('e475aa6e-416d-4fa4-b3af-28d5e84250fb')
Adam Gandelman118cd392015-03-09 14:41:36 -070036 def test_list_get_baremetal_nodes(self):
37 # Create some test nodes in Ironic directly
38 test_nodes = []
39 for i in range(0, 3):
40 _, node = self.ironic_client.create_node()
41 test_nodes.append(node)
42 self.addCleanup(self.ironic_client.delete_node, node['uuid'])
YuikoTakadaac0879a2015-01-22 02:40:03 +000043
Adam Gandelman118cd392015-03-09 14:41:36 -070044 # List all baremetal nodes and ensure our created test nodes are
45 # listed
46 bm_node_ids = set([n['id'] for n in
ghanshyamf9a569b2015-08-04 15:29:06 +090047 self.client.list_baremetal_nodes()['nodes']])
Adam Gandelman118cd392015-03-09 14:41:36 -070048 test_node_ids = set([n['uuid'] for n in test_nodes])
49 self.assertTrue(test_node_ids.issubset(bm_node_ids))
50
51 # Test getting each individually
52 for node in test_nodes:
Ken'ichi Ohmichi3de6d982015-04-13 00:20:41 +000053 baremetal_node = self.client.show_baremetal_node(node['uuid'])
ghanshyamf9a569b2015-08-04 15:29:06 +090054 self.assertEqual(node['uuid'], baremetal_node['node']['id'])