YuikoTakada | ac0879a | 2015-01-22 02:40:03 +0000 | [diff] [blame] | 1 | # 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 | |
Matthew Treinish | 2190551 | 2015-07-13 10:33:35 -0400 | [diff] [blame] | 15 | from oslo_serialization import jsonutils as json |
Matthew Treinish | 8912814 | 2015-04-23 10:44:30 -0400 | [diff] [blame] | 16 | from six.moves.urllib import parse as urllib |
YuikoTakada | ac0879a | 2015-01-22 02:40:03 +0000 | [diff] [blame] | 17 | |
ghanshyam | 59869d0 | 2015-04-22 17:23:08 +0900 | [diff] [blame] | 18 | from tempest.api_schema.response.compute.v2_1 import baremetal_nodes \ |
| 19 | as schema |
YuikoTakada | ac0879a | 2015-01-22 02:40:03 +0000 | [diff] [blame] | 20 | from tempest.common import service_client |
| 21 | |
| 22 | |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 23 | class BaremetalNodesClient(service_client.ServiceClient): |
YuikoTakada | ac0879a | 2015-01-22 02:40:03 +0000 | [diff] [blame] | 24 | """ |
| 25 | Tests Baremetal API |
| 26 | """ |
| 27 | |
Ken'ichi Ohmichi | 118776d | 2015-07-01 08:15:00 +0000 | [diff] [blame] | 28 | def list_baremetal_nodes(self, **params): |
YuikoTakada | ac0879a | 2015-01-22 02:40:03 +0000 | [diff] [blame] | 29 | """List all baremetal nodes.""" |
| 30 | url = 'os-baremetal-nodes' |
| 31 | if params: |
| 32 | url += '?%s' % urllib.urlencode(params) |
| 33 | resp, body = self.get(url) |
| 34 | body = json.loads(body) |
| 35 | self.validate_response(schema.list_baremetal_nodes, resp, body) |
ghanshyam | f9a569b | 2015-08-04 15:29:06 +0900 | [diff] [blame] | 36 | return service_client.ResponseBody(resp, body) |
YuikoTakada | ac0879a | 2015-01-22 02:40:03 +0000 | [diff] [blame] | 37 | |
Ken'ichi Ohmichi | 3de6d98 | 2015-04-13 00:20:41 +0000 | [diff] [blame] | 38 | def show_baremetal_node(self, baremetal_node_id): |
YuikoTakada | ac0879a | 2015-01-22 02:40:03 +0000 | [diff] [blame] | 39 | """Returns the details of a single baremetal node.""" |
| 40 | url = 'os-baremetal-nodes/%s' % baremetal_node_id |
| 41 | resp, body = self.get(url) |
| 42 | body = json.loads(body) |
| 43 | self.validate_response(schema.get_baremetal_node, resp, body) |
ghanshyam | f9a569b | 2015-08-04 15:29:06 +0900 | [diff] [blame] | 44 | return service_client.ResponseBody(resp, body) |