blob: c25ac2c88e8a85f8daaf96155233b7551d66138b [file] [log] [blame]
Matthew Treinish9e26ca82016-02-23 11:43:20 -05001# Copyright 2013 IBM Corp
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from oslo_serialization import jsonutils as json
17
18from tempest.lib.api_schema.response.compute.v2_1 import fixed_ips as schema
19from tempest.lib.common import rest_client
Ghanshyamee9af302016-02-25 06:12:43 +090020from tempest.lib.services.compute import base_compute_client
Matthew Treinish9e26ca82016-02-23 11:43:20 -050021
22
Ghanshyamee9af302016-02-25 06:12:43 +090023class FixedIPsClient(base_compute_client.BaseComputeClient):
Matthew Treinish9e26ca82016-02-23 11:43:20 -050024
25 def show_fixed_ip(self, fixed_ip):
26 url = "os-fixed-ips/%s" % fixed_ip
27 resp, body = self.get(url)
28 body = json.loads(body)
29 self.validate_response(schema.get_fixed_ip, resp, body)
30 return rest_client.ResponseBody(resp, body)
31
32 def reserve_fixed_ip(self, fixed_ip, **kwargs):
33 """Reserve/Unreserve a fixed IP.
34
35 Available params: see http://developer.openstack.org/
36 api-ref-compute-v2.1.html#reserveIP
37 """
38 url = "os-fixed-ips/%s/action" % fixed_ip
39 resp, body = self.post(url, json.dumps(kwargs))
40 self.validate_response(schema.reserve_unreserve_fixed_ip, resp, body)
41 return rest_client.ResponseBody(resp, body)