Kurt Taylor | 6a6f5be | 2013-04-02 18:53:47 -0400 | [diff] [blame] | 1 | # Copyright 2013 IBM Corp. |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 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 | |
Matthew Treinish | 2190551 | 2015-07-13 10:33:35 -0400 | [diff] [blame] | 16 | from oslo_serialization import jsonutils as json |
Matthew Treinish | 8912814 | 2015-04-23 10:44:30 -0400 | [diff] [blame] | 17 | from six.moves.urllib import parse as urllib |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 18 | |
| 19 | from tempest.common import glance_http |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 20 | from tempest.lib.common import rest_client |
Andrea Frittoli (andreaf) | db9672e | 2016-02-23 14:07:24 -0500 | [diff] [blame] | 21 | from tempest.lib import exceptions as lib_exc |
Matthew Treinish | 684d899 | 2014-01-30 16:27:40 +0000 | [diff] [blame] | 22 | |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 23 | |
Yaroslav Lobankov | 2fea405 | 2016-04-19 15:05:57 +0300 | [diff] [blame^] | 24 | class ImagesClient(rest_client.RestClient): |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 25 | |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 26 | def __init__(self, auth_provider, catalog_type, region, **kwargs): |
Yaroslav Lobankov | 2fea405 | 2016-04-19 15:05:57 +0300 | [diff] [blame^] | 27 | super(ImagesClient, self).__init__( |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 28 | auth_provider, catalog_type, region, **kwargs) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 29 | self._http = None |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 30 | self.dscv = kwargs.get("disable_ssl_certificate_validation") |
| 31 | self.ca_certs = kwargs.get("ca_certs") |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 32 | |
| 33 | def _get_http(self): |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 34 | return glance_http.HTTPClient(auth_provider=self.auth_provider, |
| 35 | filters=self.filters, |
Masayuki Igawa | bc7e189 | 2015-03-03 11:46:48 +0900 | [diff] [blame] | 36 | insecure=self.dscv, |
| 37 | ca_certs=self.ca_certs) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 38 | |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 39 | @property |
| 40 | def http(self): |
| 41 | if self._http is None: |
Masayuki Igawa | bc7e189 | 2015-03-03 11:46:48 +0900 | [diff] [blame] | 42 | self._http = self._get_http() |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 43 | return self._http |
| 44 | |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 45 | def update_image(self, image_id, patch): |
Ken'ichi Ohmichi | 25b3016 | 2015-11-30 11:27:13 +0000 | [diff] [blame] | 46 | """Update an image. |
| 47 | |
| 48 | Available params: see http://developer.openstack.org/ |
| 49 | api-ref-image-v2.html#updateImage-v2 |
| 50 | """ |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 51 | data = json.dumps(patch) |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 52 | headers = {"Content-Type": "application/openstack-images-v2.0" |
| 53 | "-json-patch"} |
| 54 | resp, body = self.patch('v2/images/%s' % image_id, data, headers) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 55 | self.expected_success(200, resp.status) |
ghanshyam | 08a73f9 | 2015-08-31 17:32:49 +0900 | [diff] [blame] | 56 | body = json.loads(body) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 57 | return rest_client.ResponseBody(resp, body) |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 58 | |
Ken'ichi Ohmichi | 25b3016 | 2015-11-30 11:27:13 +0000 | [diff] [blame] | 59 | def create_image(self, **kwargs): |
| 60 | """Create an image. |
Matthew Treinish | ce3ef92 | 2013-03-11 14:02:46 -0400 | [diff] [blame] | 61 | |
Ken'ichi Ohmichi | 25b3016 | 2015-11-30 11:27:13 +0000 | [diff] [blame] | 62 | Available params: see http://developer.openstack.org/ |
| 63 | api-ref-image-v2.html#createImage-v2 |
| 64 | """ |
| 65 | data = json.dumps(kwargs) |
Valeriy Ponomaryov | 88686d8 | 2014-02-16 12:24:51 +0200 | [diff] [blame] | 66 | resp, body = self.post('v2/images', data) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 67 | self.expected_success(201, resp.status) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 68 | body = json.loads(body) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 69 | return rest_client.ResponseBody(resp, body) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 70 | |
bkopilov | 81aaae7 | 2015-05-15 23:46:25 +0300 | [diff] [blame] | 71 | def deactivate_image(self, image_id): |
| 72 | url = 'v2/images/%s/actions/deactivate' % image_id |
| 73 | resp, body = self.post(url, None) |
| 74 | self.expected_success(204, resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 75 | return rest_client.ResponseBody(resp, body) |
bkopilov | 81aaae7 | 2015-05-15 23:46:25 +0300 | [diff] [blame] | 76 | |
| 77 | def reactivate_image(self, image_id): |
| 78 | url = 'v2/images/%s/actions/reactivate' % image_id |
| 79 | resp, body = self.post(url, None) |
| 80 | self.expected_success(204, resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 81 | return rest_client.ResponseBody(resp, body) |
bkopilov | 81aaae7 | 2015-05-15 23:46:25 +0300 | [diff] [blame] | 82 | |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 83 | def delete_image(self, image_id): |
| 84 | url = 'v2/images/%s' % image_id |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 85 | resp, _ = self.delete(url) |
| 86 | self.expected_success(204, resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 87 | return rest_client.ResponseBody(resp) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 88 | |
Ken'ichi Ohmichi | e3acc12 | 2015-05-22 00:32:54 +0000 | [diff] [blame] | 89 | def list_images(self, params=None): |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 90 | url = 'v2/images' |
| 91 | |
| 92 | if params: |
| 93 | url += '?%s' % urllib.urlencode(params) |
| 94 | |
| 95 | resp, body = self.get(url) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 96 | self.expected_success(200, resp.status) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 97 | body = json.loads(body) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 98 | return rest_client.ResponseBody(resp, body) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 99 | |
Ken'ichi Ohmichi | 5d41076 | 2015-05-22 01:10:03 +0000 | [diff] [blame] | 100 | def show_image(self, image_id): |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 101 | url = 'v2/images/%s' % image_id |
| 102 | resp, body = self.get(url) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 103 | self.expected_success(200, resp.status) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 104 | body = json.loads(body) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 105 | return rest_client.ResponseBody(resp, body) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 106 | |
| 107 | def is_resource_deleted(self, id): |
| 108 | try: |
Ken'ichi Ohmichi | 5d41076 | 2015-05-22 01:10:03 +0000 | [diff] [blame] | 109 | self.show_image(id) |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 110 | except lib_exc.NotFound: |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 111 | return True |
| 112 | return False |
| 113 | |
Matt Riedemann | d2b9651 | 2014-10-13 10:18:16 -0700 | [diff] [blame] | 114 | @property |
| 115 | def resource_type(self): |
| 116 | """Returns the primary type of resource this client works with.""" |
| 117 | return 'image' |
| 118 | |
Ken'ichi Ohmichi | 66494e9 | 2015-06-08 04:28:10 +0000 | [diff] [blame] | 119 | def store_image_file(self, image_id, data): |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 120 | url = 'v2/images/%s/file' % image_id |
| 121 | headers = {'Content-Type': 'application/octet-stream'} |
| 122 | resp, body = self.http.raw_request('PUT', url, headers=headers, |
| 123 | body=data) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 124 | self.expected_success(204, resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 125 | return rest_client.ResponseBody(resp, body) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 126 | |
Ken'ichi Ohmichi | 6bd6f20 | 2015-11-20 05:29:38 +0000 | [diff] [blame] | 127 | def show_image_file(self, image_id): |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 128 | url = 'v2/images/%s/file' % image_id |
| 129 | resp, body = self.get(url) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 130 | self.expected_success(200, resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 131 | return rest_client.ResponseBodyData(resp, body) |
Anju Tiwari | c495298 | 2013-10-20 07:10:02 +0530 | [diff] [blame] | 132 | |
| 133 | def add_image_tag(self, image_id, tag): |
| 134 | url = 'v2/images/%s/tags/%s' % (image_id, tag) |
Valeriy Ponomaryov | 88686d8 | 2014-02-16 12:24:51 +0200 | [diff] [blame] | 135 | resp, body = self.put(url, body=None) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 136 | self.expected_success(204, resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 137 | return rest_client.ResponseBody(resp, body) |
Anju Tiwari | c495298 | 2013-10-20 07:10:02 +0530 | [diff] [blame] | 138 | |
| 139 | def delete_image_tag(self, image_id, tag): |
| 140 | url = 'v2/images/%s/tags/%s' % (image_id, tag) |
| 141 | resp, _ = self.delete(url) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 142 | self.expected_success(204, resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 143 | return rest_client.ResponseBody(resp) |
Attila Fazekas | 689e265 | 2013-10-07 18:06:57 +0200 | [diff] [blame] | 144 | |
Ken'ichi Ohmichi | f0df53c | 2015-05-22 01:16:50 +0000 | [diff] [blame] | 145 | def list_image_members(self, image_id): |
Attila Fazekas | 689e265 | 2013-10-07 18:06:57 +0200 | [diff] [blame] | 146 | url = 'v2/images/%s/members' % image_id |
| 147 | resp, body = self.get(url) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 148 | self.expected_success(200, resp.status) |
Attila Fazekas | 689e265 | 2013-10-07 18:06:57 +0200 | [diff] [blame] | 149 | body = json.loads(body) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 150 | return rest_client.ResponseBody(resp, body) |
Attila Fazekas | 689e265 | 2013-10-07 18:06:57 +0200 | [diff] [blame] | 151 | |
Ken'ichi Ohmichi | 9dacbe0 | 2015-11-30 12:01:39 +0000 | [diff] [blame] | 152 | def create_image_member(self, image_id, **kwargs): |
| 153 | """Create an image member. |
| 154 | |
| 155 | Available params: see http://developer.openstack.org/ |
| 156 | api-ref-image-v2.html#createImageMember-v2 |
| 157 | """ |
Attila Fazekas | 689e265 | 2013-10-07 18:06:57 +0200 | [diff] [blame] | 158 | url = 'v2/images/%s/members' % image_id |
Ken'ichi Ohmichi | 2f8f6c2 | 2015-11-24 02:28:52 +0000 | [diff] [blame] | 159 | data = json.dumps(kwargs) |
Valeriy Ponomaryov | 88686d8 | 2014-02-16 12:24:51 +0200 | [diff] [blame] | 160 | resp, body = self.post(url, data) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 161 | self.expected_success(200, resp.status) |
Attila Fazekas | 689e265 | 2013-10-07 18:06:57 +0200 | [diff] [blame] | 162 | body = json.loads(body) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 163 | return rest_client.ResponseBody(resp, body) |
Attila Fazekas | 689e265 | 2013-10-07 18:06:57 +0200 | [diff] [blame] | 164 | |
Ken'ichi Ohmichi | 2f8f6c2 | 2015-11-24 02:28:52 +0000 | [diff] [blame] | 165 | def update_image_member(self, image_id, member_id, **kwargs): |
Ken'ichi Ohmichi | 5a1c934 | 2015-11-30 12:12:19 +0000 | [diff] [blame] | 166 | """Update an image member. |
| 167 | |
| 168 | Available params: see http://developer.openstack.org/ |
| 169 | api-ref-image-v2.html#updateImageMember-v2 |
| 170 | """ |
Attila Fazekas | 689e265 | 2013-10-07 18:06:57 +0200 | [diff] [blame] | 171 | url = 'v2/images/%s/members/%s' % (image_id, member_id) |
Ken'ichi Ohmichi | 2f8f6c2 | 2015-11-24 02:28:52 +0000 | [diff] [blame] | 172 | data = json.dumps(kwargs) |
Valeriy Ponomaryov | 88686d8 | 2014-02-16 12:24:51 +0200 | [diff] [blame] | 173 | resp, body = self.put(url, data) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 174 | self.expected_success(200, resp.status) |
Attila Fazekas | 689e265 | 2013-10-07 18:06:57 +0200 | [diff] [blame] | 175 | body = json.loads(body) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 176 | return rest_client.ResponseBody(resp, body) |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 177 | |
Ken'ichi Ohmichi | c3728c6 | 2015-06-08 04:01:45 +0000 | [diff] [blame] | 178 | def show_image_member(self, image_id, member_id): |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 179 | url = 'v2/images/%s/members/%s' % (image_id, member_id) |
| 180 | resp, body = self.get(url) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 181 | self.expected_success(200, resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 182 | return rest_client.ResponseBody(resp, json.loads(body)) |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 183 | |
Ken'ichi Ohmichi | b8461cb | 2015-11-20 08:10:51 +0000 | [diff] [blame] | 184 | def delete_image_member(self, image_id, member_id): |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 185 | url = 'v2/images/%s/members/%s' % (image_id, member_id) |
| 186 | resp, _ = self.delete(url) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 187 | self.expected_success(204, resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 188 | return rest_client.ResponseBody(resp) |
raiesmh08 | a1ce354 | 2014-03-04 11:58:29 +0530 | [diff] [blame] | 189 | |
Ken'ichi Ohmichi | 66494e9 | 2015-06-08 04:28:10 +0000 | [diff] [blame] | 190 | def show_schema(self, schema): |
raiesmh08 | a1ce354 | 2014-03-04 11:58:29 +0530 | [diff] [blame] | 191 | url = 'v2/schemas/%s' % schema |
| 192 | resp, body = self.get(url) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 193 | self.expected_success(200, resp.status) |
raiesmh08 | a1ce354 | 2014-03-04 11:58:29 +0530 | [diff] [blame] | 194 | body = json.loads(body) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 195 | return rest_client.ResponseBody(resp, body) |
piyush110786 | 5f829d7 | 2015-09-11 11:46:35 +0530 | [diff] [blame] | 196 | |
| 197 | def list_resource_types(self): |
| 198 | url = '/v2/metadefs/resource_types' |
| 199 | resp, body = self.get(url) |
| 200 | self.expected_success(200, resp.status) |
| 201 | body = json.loads(body) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 202 | return rest_client.ResponseBody(resp, body) |
piyush110786 | 5f829d7 | 2015-09-11 11:46:35 +0530 | [diff] [blame] | 203 | |
Ken'ichi Ohmichi | 2f8f6c2 | 2015-11-24 02:28:52 +0000 | [diff] [blame] | 204 | def create_namespace(self, **kwargs): |
| 205 | """Create a namespace. |
piyush110786 | 5f829d7 | 2015-09-11 11:46:35 +0530 | [diff] [blame] | 206 | |
Ken'ichi Ohmichi | 2f8f6c2 | 2015-11-24 02:28:52 +0000 | [diff] [blame] | 207 | Available params: see http://developer.openstack.org/ |
| 208 | api-ref-image-v2.html#createNamespace-v2 |
| 209 | """ |
| 210 | data = json.dumps(kwargs) |
piyush110786 | 5f829d7 | 2015-09-11 11:46:35 +0530 | [diff] [blame] | 211 | resp, body = self.post('/v2/metadefs/namespaces', data) |
| 212 | self.expected_success(201, resp.status) |
| 213 | body = json.loads(body) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 214 | return rest_client.ResponseBody(resp, body) |
piyush110786 | 5f829d7 | 2015-09-11 11:46:35 +0530 | [diff] [blame] | 215 | |
Ken'ichi Ohmichi | 1951563 | 2015-11-24 02:08:24 +0000 | [diff] [blame] | 216 | def show_namespace(self, namespace): |
piyush110786 | 5f829d7 | 2015-09-11 11:46:35 +0530 | [diff] [blame] | 217 | url = '/v2/metadefs/namespaces/%s' % namespace |
| 218 | resp, body = self.get(url) |
| 219 | self.expected_success(200, resp.status) |
| 220 | body = json.loads(body) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 221 | return rest_client.ResponseBody(resp, body) |
piyush110786 | 5f829d7 | 2015-09-11 11:46:35 +0530 | [diff] [blame] | 222 | |
Ken'ichi Ohmichi | 2f8f6c2 | 2015-11-24 02:28:52 +0000 | [diff] [blame] | 223 | def update_namespace(self, namespace, **kwargs): |
| 224 | """Update a namespace. |
piyush110786 | 5f829d7 | 2015-09-11 11:46:35 +0530 | [diff] [blame] | 225 | |
Ken'ichi Ohmichi | 2f8f6c2 | 2015-11-24 02:28:52 +0000 | [diff] [blame] | 226 | Available params: see http://developer.openstack.org/ |
| 227 | api-ref-image-v2.html#updateNamespace-v2 |
| 228 | """ |
| 229 | # NOTE: On Glance API, we need to pass namespace on both URI |
| 230 | # and a request body. |
| 231 | params = {'namespace': namespace} |
| 232 | params.update(kwargs) |
piyush110786 | 5f829d7 | 2015-09-11 11:46:35 +0530 | [diff] [blame] | 233 | data = json.dumps(params) |
piyush110786 | 5f829d7 | 2015-09-11 11:46:35 +0530 | [diff] [blame] | 234 | url = '/v2/metadefs/namespaces/%s' % namespace |
| 235 | resp, body = self.put(url, body=data) |
| 236 | self.expected_success(200, resp.status) |
| 237 | body = json.loads(body) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 238 | return rest_client.ResponseBody(resp, body) |
piyush110786 | 5f829d7 | 2015-09-11 11:46:35 +0530 | [diff] [blame] | 239 | |
Ken'ichi Ohmichi | 1951563 | 2015-11-24 02:08:24 +0000 | [diff] [blame] | 240 | def delete_namespace(self, namespace): |
piyush110786 | 5f829d7 | 2015-09-11 11:46:35 +0530 | [diff] [blame] | 241 | url = '/v2/metadefs/namespaces/%s' % namespace |
| 242 | resp, _ = self.delete(url) |
| 243 | self.expected_success(204, resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 244 | return rest_client.ResponseBody(resp) |