blob: cf9f534bcad31d647117f487aa1cbf8f80d74e20 [file] [log] [blame]
Andrea Frittolie258cd72014-07-17 04:47:26 +01001# Copyright 2012 OpenStack Foundation
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
16import json
17
Ken'ichi Ohmichi4771cbc2015-01-19 23:45:23 +000018from tempest.common import service_client
Andrea Frittolie258cd72014-07-17 04:47:26 +010019
20
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000021class NetworksClient(service_client.ServiceClient):
Andrea Frittolie258cd72014-07-17 04:47:26 +010022
Ken'ichi Ohmichi46f574e2015-06-15 04:53:55 +000023 def list_networks(self):
Andrea Frittolie258cd72014-07-17 04:47:26 +010024 resp, body = self.get("os-networks")
25 body = json.loads(body)
26 self.expected_success(200, resp.status)
Ken'ichi Ohmichi46f574e2015-06-15 04:53:55 +000027 return service_client.ResponseBodyList(resp, body['networks'])
Andrea Frittolie258cd72014-07-17 04:47:26 +010028
Ken'ichi Ohmichi46f574e2015-06-15 04:53:55 +000029 def show_network(self, network_id):
Ken'ichi Ohmichicd6e8992015-07-01 06:45:34 +000030 resp, body = self.get("os-networks/%s" % network_id)
Andrea Frittolie258cd72014-07-17 04:47:26 +010031 body = json.loads(body)
32 self.expected_success(200, resp.status)
David Kranzb2b0c182015-02-18 13:28:19 -050033 return service_client.ResponseBody(resp, body['network'])