Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 1 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 | # not use this file except in compliance with the License. You may obtain |
| 3 | # a copy of the License at |
| 4 | # |
| 5 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | # |
| 7 | # Unless required by applicable law or agreed to in writing, software |
| 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | # License for the specific language governing permissions and limitations |
| 11 | # under the License. |
| 12 | |
| 13 | from tempest.lib.services.network import base |
| 14 | |
| 15 | |
| 16 | class SubnetsClient(base.BaseNetworkClient): |
| 17 | |
| 18 | def create_subnet(self, **kwargs): |
Lv Fumei | fbfe20f | 2016-07-06 13:42:27 +0800 | [diff] [blame] | 19 | """Creates a subnet on a network. |
| 20 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 21 | For a full list of available parameters, please refer to the official |
| 22 | API reference: |
| 23 | http://developer.openstack.org/api-ref/networking/v2/index.html#create-subnet |
Lv Fumei | fbfe20f | 2016-07-06 13:42:27 +0800 | [diff] [blame] | 24 | """ |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 25 | uri = '/subnets' |
| 26 | post_data = {'subnet': kwargs} |
| 27 | return self.create_resource(uri, post_data) |
| 28 | |
| 29 | def update_subnet(self, subnet_id, **kwargs): |
Lv Fumei | fbfe20f | 2016-07-06 13:42:27 +0800 | [diff] [blame] | 30 | """Updates a subnet. |
| 31 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 32 | For a full list of available parameters, please refer to the official |
| 33 | API reference: |
| 34 | http://developer.openstack.org/api-ref/networking/v2/index.html#update-subnet |
Lv Fumei | fbfe20f | 2016-07-06 13:42:27 +0800 | [diff] [blame] | 35 | """ |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 36 | uri = '/subnets/%s' % subnet_id |
| 37 | post_data = {'subnet': kwargs} |
| 38 | return self.update_resource(uri, post_data) |
| 39 | |
| 40 | def show_subnet(self, subnet_id, **fields): |
Lv Fumei | 8efac68 | 2016-07-08 16:49:52 +0800 | [diff] [blame] | 41 | """Shows details for a subnet. |
| 42 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 43 | For a full list of available parameters, please refer to the official |
| 44 | API reference: |
| 45 | http://developer.openstack.org/api-ref/networking/v2/index.html#show-subnet-details |
Lv Fumei | 8efac68 | 2016-07-08 16:49:52 +0800 | [diff] [blame] | 46 | """ |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 47 | uri = '/subnets/%s' % subnet_id |
| 48 | return self.show_resource(uri, **fields) |
| 49 | |
| 50 | def delete_subnet(self, subnet_id): |
| 51 | uri = '/subnets/%s' % subnet_id |
| 52 | return self.delete_resource(uri) |
| 53 | |
| 54 | def list_subnets(self, **filters): |
Lv Fumei | 8efac68 | 2016-07-08 16:49:52 +0800 | [diff] [blame] | 55 | """Lists subnets to which the tenant has access. |
| 56 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 57 | For a full list of available parameters, please refer to the official |
| 58 | API reference: |
| 59 | http://developer.openstack.org/api-ref/networking/v2/index.html#list-subnets |
Lv Fumei | 8efac68 | 2016-07-08 16:49:52 +0800 | [diff] [blame] | 60 | """ |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 61 | uri = '/subnets' |
| 62 | return self.list_resources(uri, **filters) |
| 63 | |
| 64 | def create_bulk_subnets(self, **kwargs): |
| 65 | """Create multiple subnets in a single request. |
| 66 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 67 | For a full list of available parameters, please refer to the official |
| 68 | API reference: |
| 69 | http://developer.openstack.org/api-ref/networking/v2/index.html#bulk-create-subnet |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 70 | """ |
| 71 | uri = '/subnets' |
| 72 | return self.create_resource(uri, kwargs) |