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 | |
Jordan Pittier | 9a573d9 | 2016-04-29 17:04:39 +0200 | [diff] [blame] | 16 | import functools |
songwenping | 99d6e00 | 2021-01-05 03:07:46 +0000 | [diff] [blame] | 17 | from urllib import parse as urllib |
Jordan Pittier | 9a573d9 | 2016-04-29 17:04:39 +0200 | [diff] [blame] | 18 | |
Matthew Treinish | 2190551 | 2015-07-13 10:33:35 -0400 | [diff] [blame] | 19 | from oslo_serialization import jsonutils as json |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 20 | |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 21 | from tempest.lib.common import rest_client |
Andrea Frittoli (andreaf) | db9672e | 2016-02-23 14:07:24 -0500 | [diff] [blame] | 22 | from tempest.lib import exceptions as lib_exc |
Matthew Treinish | 684d899 | 2014-01-30 16:27:40 +0000 | [diff] [blame] | 23 | |
Jordan Pittier | 9a573d9 | 2016-04-29 17:04:39 +0200 | [diff] [blame] | 24 | CHUNKSIZE = 1024 * 64 # 64kB |
| 25 | |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 26 | |
Yaroslav Lobankov | 2fea405 | 2016-04-19 15:05:57 +0300 | [diff] [blame] | 27 | class ImagesClient(rest_client.RestClient): |
Andrea Frittoli | cf40a86 | 2016-06-07 14:45:32 +0900 | [diff] [blame] | 28 | api_version = "v2" |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 29 | |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 30 | def update_image(self, image_id, patch): |
Ken'ichi Ohmichi | 25b3016 | 2015-11-30 11:27:13 +0000 | [diff] [blame] | 31 | """Update an image. |
| 32 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 33 | For a full list of available parameters, please refer to the official |
| 34 | API reference: |
Andreas Jaeger | bf30ae7 | 2019-07-22 19:22:57 +0200 | [diff] [blame] | 35 | https://docs.openstack.org/api-ref/image/v2/#update-image |
Ken'ichi Ohmichi | 25b3016 | 2015-11-30 11:27:13 +0000 | [diff] [blame] | 36 | """ |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 37 | data = json.dumps(patch) |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 38 | headers = {"Content-Type": "application/openstack-images-v2.0" |
| 39 | "-json-patch"} |
Andrea Frittoli | cf40a86 | 2016-06-07 14:45:32 +0900 | [diff] [blame] | 40 | resp, body = self.patch('images/%s' % image_id, data, headers) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 41 | self.expected_success(200, resp.status) |
ghanshyam | 08a73f9 | 2015-08-31 17:32:49 +0900 | [diff] [blame] | 42 | body = json.loads(body) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 43 | return rest_client.ResponseBody(resp, body) |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 44 | |
Ken'ichi Ohmichi | 25b3016 | 2015-11-30 11:27:13 +0000 | [diff] [blame] | 45 | def create_image(self, **kwargs): |
| 46 | """Create an image. |
Matthew Treinish | ce3ef92 | 2013-03-11 14:02:46 -0400 | [diff] [blame] | 47 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 48 | For a full list of available parameters, please refer to the official |
| 49 | API reference: |
Andreas Jaeger | bf30ae7 | 2019-07-22 19:22:57 +0200 | [diff] [blame] | 50 | https://docs.openstack.org/api-ref/image/v2/#create-image |
Ken'ichi Ohmichi | 25b3016 | 2015-11-30 11:27:13 +0000 | [diff] [blame] | 51 | """ |
| 52 | data = json.dumps(kwargs) |
Andrea Frittoli | cf40a86 | 2016-06-07 14:45:32 +0900 | [diff] [blame] | 53 | resp, body = self.post('images', data) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 54 | self.expected_success(201, resp.status) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 55 | body = json.loads(body) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 56 | return rest_client.ResponseBody(resp, body) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 57 | |
bkopilov | 81aaae7 | 2015-05-15 23:46:25 +0300 | [diff] [blame] | 58 | def deactivate_image(self, image_id): |
Anthony Washington | 4dcd002 | 2016-06-30 18:24:46 +0000 | [diff] [blame] | 59 | """Deactivate image. |
| 60 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 61 | For a full list of available parameters, please refer to the official |
| 62 | API reference: |
Andreas Jaeger | bf30ae7 | 2019-07-22 19:22:57 +0200 | [diff] [blame] | 63 | https://docs.openstack.org/api-ref/image/v2/#deactivate-image |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 64 | """ |
Andrea Frittoli | cf40a86 | 2016-06-07 14:45:32 +0900 | [diff] [blame] | 65 | url = 'images/%s/actions/deactivate' % image_id |
bkopilov | 81aaae7 | 2015-05-15 23:46:25 +0300 | [diff] [blame] | 66 | resp, body = self.post(url, None) |
| 67 | self.expected_success(204, resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 68 | return rest_client.ResponseBody(resp, body) |
bkopilov | 81aaae7 | 2015-05-15 23:46:25 +0300 | [diff] [blame] | 69 | |
| 70 | def reactivate_image(self, image_id): |
Anthony Washington | 4dcd002 | 2016-06-30 18:24:46 +0000 | [diff] [blame] | 71 | """Reactivate image. |
| 72 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 73 | For a full list of available parameters, please refer to the official |
| 74 | API reference: |
Andreas Jaeger | bf30ae7 | 2019-07-22 19:22:57 +0200 | [diff] [blame] | 75 | https://docs.openstack.org/api-ref/image/v2/#reactivate-image |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 76 | """ |
Andrea Frittoli | cf40a86 | 2016-06-07 14:45:32 +0900 | [diff] [blame] | 77 | url = 'images/%s/actions/reactivate' % image_id |
bkopilov | 81aaae7 | 2015-05-15 23:46:25 +0300 | [diff] [blame] | 78 | resp, body = self.post(url, None) |
| 79 | self.expected_success(204, resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 80 | return rest_client.ResponseBody(resp, body) |
bkopilov | 81aaae7 | 2015-05-15 23:46:25 +0300 | [diff] [blame] | 81 | |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 82 | def delete_image(self, image_id): |
Anthony Washington | 4dcd002 | 2016-06-30 18:24:46 +0000 | [diff] [blame] | 83 | """Delete image. |
| 84 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 85 | For a full list of available parameters, please refer to the official |
| 86 | API reference: |
Andreas Jaeger | bf30ae7 | 2019-07-22 19:22:57 +0200 | [diff] [blame] | 87 | https://docs.openstack.org/api-ref/image/v2/#delete-image |
Anthony Washington | 4dcd002 | 2016-06-30 18:24:46 +0000 | [diff] [blame] | 88 | """ |
Andrea Frittoli | cf40a86 | 2016-06-07 14:45:32 +0900 | [diff] [blame] | 89 | url = 'images/%s' % image_id |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 90 | resp, _ = self.delete(url) |
| 91 | self.expected_success(204, resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 92 | return rest_client.ResponseBody(resp) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 93 | |
Ken'ichi Ohmichi | e3acc12 | 2015-05-22 00:32:54 +0000 | [diff] [blame] | 94 | def list_images(self, params=None): |
Anthony Washington | 4dcd002 | 2016-06-30 18:24:46 +0000 | [diff] [blame] | 95 | """List images. |
| 96 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 97 | For a full list of available parameters, please refer to the official |
| 98 | API reference: |
Andreas Jaeger | bf30ae7 | 2019-07-22 19:22:57 +0200 | [diff] [blame] | 99 | https://docs.openstack.org/api-ref/image/v2/#list-images |
Anthony Washington | 4dcd002 | 2016-06-30 18:24:46 +0000 | [diff] [blame] | 100 | """ |
Andrea Frittoli | cf40a86 | 2016-06-07 14:45:32 +0900 | [diff] [blame] | 101 | url = 'images' |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 102 | |
| 103 | if params: |
| 104 | url += '?%s' % urllib.urlencode(params) |
| 105 | |
| 106 | resp, body = self.get(url) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 107 | self.expected_success(200, resp.status) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 108 | body = json.loads(body) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 109 | return rest_client.ResponseBody(resp, body) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 110 | |
Ken'ichi Ohmichi | 5d41076 | 2015-05-22 01:10:03 +0000 | [diff] [blame] | 111 | def show_image(self, image_id): |
Anthony Washington | 4dcd002 | 2016-06-30 18:24:46 +0000 | [diff] [blame] | 112 | """Show image details. |
| 113 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 114 | For a full list of available parameters, please refer to the official |
| 115 | API reference: |
Andreas Jaeger | bf30ae7 | 2019-07-22 19:22:57 +0200 | [diff] [blame] | 116 | https://docs.openstack.org/api-ref/image/v2/#show-image |
Anthony Washington | 4dcd002 | 2016-06-30 18:24:46 +0000 | [diff] [blame] | 117 | """ |
Andrea Frittoli | cf40a86 | 2016-06-07 14:45:32 +0900 | [diff] [blame] | 118 | url = 'images/%s' % image_id |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 119 | resp, body = self.get(url) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 120 | self.expected_success(200, resp.status) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 121 | body = json.loads(body) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 122 | return rest_client.ResponseBody(resp, body) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 123 | |
Dan Smith | 7bde7bf | 2021-02-15 08:44:47 -0800 | [diff] [blame] | 124 | def show_image_tasks(self, image_id): |
| 125 | """Show image tasks.""" |
| 126 | url = 'images/%s/tasks' % image_id |
| 127 | resp, body = self.get(url) |
| 128 | self.expected_success(200, resp.status) |
| 129 | body = json.loads(body) |
| 130 | return rest_client.ResponseBody(resp, body) |
| 131 | |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 132 | def is_resource_deleted(self, id): |
| 133 | try: |
Ken'ichi Ohmichi | 5d41076 | 2015-05-22 01:10:03 +0000 | [diff] [blame] | 134 | self.show_image(id) |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 135 | except lib_exc.NotFound: |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 136 | return True |
| 137 | return False |
| 138 | |
Abhishek Kekane | 7cff130 | 2020-07-16 10:30:13 +0000 | [diff] [blame] | 139 | def is_resource_active(self, id): |
| 140 | try: |
| 141 | image = self.show_image(id) |
| 142 | if image['status'] != 'active': |
| 143 | return False |
| 144 | except lib_exc.NotFound: |
| 145 | return False |
| 146 | return True |
| 147 | |
Matt Riedemann | d2b9651 | 2014-10-13 10:18:16 -0700 | [diff] [blame] | 148 | @property |
| 149 | def resource_type(self): |
| 150 | """Returns the primary type of resource this client works with.""" |
| 151 | return 'image' |
| 152 | |
Ken'ichi Ohmichi | 66494e9 | 2015-06-08 04:28:10 +0000 | [diff] [blame] | 153 | def store_image_file(self, image_id, data): |
Anthony Washington | 4dcd002 | 2016-06-30 18:24:46 +0000 | [diff] [blame] | 154 | """Upload binary image data. |
| 155 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 156 | For a full list of available parameters, please refer to the official |
| 157 | API reference: |
Andreas Jaeger | bf30ae7 | 2019-07-22 19:22:57 +0200 | [diff] [blame] | 158 | https://docs.openstack.org/api-ref/image/v2/#upload-binary-image-data |
Anthony Washington | 4dcd002 | 2016-06-30 18:24:46 +0000 | [diff] [blame] | 159 | """ |
Andrea Frittoli | cf40a86 | 2016-06-07 14:45:32 +0900 | [diff] [blame] | 160 | url = 'images/%s/file' % image_id |
Jordan Pittier | 9a573d9 | 2016-04-29 17:04:39 +0200 | [diff] [blame] | 161 | |
| 162 | # We are going to do chunked transfert, so split the input data |
| 163 | # info fixed-sized chunks. |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 164 | headers = {'Content-Type': 'application/octet-stream'} |
Jordan Pittier | 9a573d9 | 2016-04-29 17:04:39 +0200 | [diff] [blame] | 165 | data = iter(functools.partial(data.read, CHUNKSIZE), b'') |
| 166 | |
| 167 | resp, body = self.request('PUT', url, headers=headers, |
| 168 | body=data, chunked=True) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 169 | self.expected_success(204, resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 170 | return rest_client.ResponseBody(resp, body) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 171 | |
Abhishek Kekane | 7cff130 | 2020-07-16 10:30:13 +0000 | [diff] [blame] | 172 | def stage_image_file(self, image_id, data): |
| 173 | """Upload binary image data to staging area. |
| 174 | |
| 175 | For a full list of available parameters, please refer to the official |
| 176 | API reference (stage API: |
| 177 | https://docs.openstack.org/api-ref/image/v2/#interoperable-image-import |
| 178 | """ |
| 179 | url = 'images/%s/stage' % image_id |
| 180 | |
| 181 | # We are going to do chunked transfer, so split the input data |
| 182 | # info fixed-sized chunks. |
| 183 | headers = {'Content-Type': 'application/octet-stream'} |
| 184 | data = iter(functools.partial(data.read, CHUNKSIZE), b'') |
| 185 | |
| 186 | resp, body = self.request('PUT', url, headers=headers, |
| 187 | body=data, chunked=True) |
| 188 | self.expected_success(204, resp.status) |
| 189 | return rest_client.ResponseBody(resp, body) |
| 190 | |
| 191 | def info_import(self): |
| 192 | """Return information about server-supported import methods.""" |
| 193 | url = 'info/import' |
| 194 | resp, body = self.get(url) |
| 195 | |
| 196 | self.expected_success(200, resp.status) |
| 197 | body = json.loads(body) |
| 198 | return rest_client.ResponseBody(resp, body) |
| 199 | |
| 200 | def info_stores(self): |
| 201 | """Return information about server-supported stores.""" |
| 202 | url = 'info/stores' |
| 203 | resp, body = self.get(url) |
| 204 | body = json.loads(body) |
| 205 | return rest_client.ResponseBody(resp, body) |
| 206 | |
| 207 | def image_import(self, image_id, method='glance-direct', |
| 208 | all_stores_must_succeed=None, all_stores=True, |
Dan Smith | 5ac5c18 | 2022-08-09 09:42:59 -0700 | [diff] [blame] | 209 | stores=None, import_params=None): |
Abhishek Kekane | 7cff130 | 2020-07-16 10:30:13 +0000 | [diff] [blame] | 210 | """Import data from staging area to glance store. |
| 211 | |
| 212 | For a full list of available parameters, please refer to the official |
| 213 | API reference (stage API: |
| 214 | https://docs.openstack.org/api-ref/image/v2/#interoperable-image-import |
| 215 | |
| 216 | :param method: The import method (i.e. glance-direct) to use |
| 217 | :param all_stores_must_succeed: Boolean indicating if all store imports |
| 218 | must succeed for the import to be |
| 219 | considered successful. Must be None if |
| 220 | server does not support multistore. |
| 221 | :param all_stores: Boolean indicating if image should be imported to |
| 222 | all available stores (incompatible with stores) |
| 223 | :param stores: A list of destination store names for the import. Must |
| 224 | be None if server does not support multistore. |
Dan Smith | 5ac5c18 | 2022-08-09 09:42:59 -0700 | [diff] [blame] | 225 | :param import_params: A dict of import method parameters |
Abhishek Kekane | 7cff130 | 2020-07-16 10:30:13 +0000 | [diff] [blame] | 226 | """ |
| 227 | url = 'images/%s/import' % image_id |
Dan Smith | 5ac5c18 | 2022-08-09 09:42:59 -0700 | [diff] [blame] | 228 | if import_params is None: |
| 229 | import_params = {} |
Abhishek Kekane | 7cff130 | 2020-07-16 10:30:13 +0000 | [diff] [blame] | 230 | data = { |
| 231 | "method": { |
| 232 | "name": method |
| 233 | }, |
| 234 | } |
| 235 | if stores is not None: |
| 236 | data["stores"] = stores |
| 237 | else: |
| 238 | data["all_stores"] = all_stores |
| 239 | |
| 240 | if all_stores_must_succeed is not None: |
| 241 | data['all_stores_must_succeed'] = all_stores_must_succeed |
Dan Smith | 5ac5c18 | 2022-08-09 09:42:59 -0700 | [diff] [blame] | 242 | if import_params: |
| 243 | data['method'].update(import_params) |
Abhishek Kekane | 7cff130 | 2020-07-16 10:30:13 +0000 | [diff] [blame] | 244 | data = json.dumps(data) |
| 245 | headers = {'Content-Type': 'application/json'} |
| 246 | resp, _ = self.post(url, data, headers=headers) |
| 247 | |
| 248 | self.expected_success(202, resp.status) |
| 249 | return rest_client.ResponseBody(resp) |
| 250 | |
Ken'ichi Ohmichi | 6bd6f20 | 2015-11-20 05:29:38 +0000 | [diff] [blame] | 251 | def show_image_file(self, image_id): |
Anthony Washington | 4dcd002 | 2016-06-30 18:24:46 +0000 | [diff] [blame] | 252 | """Download binary image data. |
bkopilov | cb1c629 | 2016-06-30 09:20:34 +0300 | [diff] [blame] | 253 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 254 | For a full list of available parameters, please refer to the official |
| 255 | API reference: |
Andreas Jaeger | bf30ae7 | 2019-07-22 19:22:57 +0200 | [diff] [blame] | 256 | https://docs.openstack.org/api-ref/image/v2/#download-binary-image-data |
bkopilov | cb1c629 | 2016-06-30 09:20:34 +0300 | [diff] [blame] | 257 | """ |
Andrea Frittoli | cf40a86 | 2016-06-07 14:45:32 +0900 | [diff] [blame] | 258 | url = 'images/%s/file' % image_id |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 259 | resp, body = self.get(url) |
zhufl | fd5a14b | 2018-03-16 15:24:17 +0800 | [diff] [blame] | 260 | self.expected_success([200, 204, 206], resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 261 | return rest_client.ResponseBodyData(resp, body) |
Anju Tiwari | c495298 | 2013-10-20 07:10:02 +0530 | [diff] [blame] | 262 | |
| 263 | def add_image_tag(self, image_id, tag): |
bkopilov | cb1c629 | 2016-06-30 09:20:34 +0300 | [diff] [blame] | 264 | """Add an image tag. |
| 265 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 266 | For a full list of available parameters, please refer to the official |
| 267 | API reference: |
Andreas Jaeger | bf30ae7 | 2019-07-22 19:22:57 +0200 | [diff] [blame] | 268 | https://docs.openstack.org/api-ref/image/v2/#add-image-tag |
bkopilov | cb1c629 | 2016-06-30 09:20:34 +0300 | [diff] [blame] | 269 | """ |
Andrea Frittoli | cf40a86 | 2016-06-07 14:45:32 +0900 | [diff] [blame] | 270 | url = 'images/%s/tags/%s' % (image_id, tag) |
Valeriy Ponomaryov | 88686d8 | 2014-02-16 12:24:51 +0200 | [diff] [blame] | 271 | resp, body = self.put(url, body=None) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 272 | self.expected_success(204, resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 273 | return rest_client.ResponseBody(resp, body) |
Anju Tiwari | c495298 | 2013-10-20 07:10:02 +0530 | [diff] [blame] | 274 | |
| 275 | def delete_image_tag(self, image_id, tag): |
bkopilov | cb1c629 | 2016-06-30 09:20:34 +0300 | [diff] [blame] | 276 | """Delete an image tag. |
| 277 | |
OTSUKA, Yuanying | faac571 | 2016-09-15 13:53:55 +0900 | [diff] [blame] | 278 | For a full list of available parameters, please refer to the official |
| 279 | API reference: |
Andreas Jaeger | bf30ae7 | 2019-07-22 19:22:57 +0200 | [diff] [blame] | 280 | https://docs.openstack.org/api-ref/image/v2/#delete-image-tag |
bkopilov | cb1c629 | 2016-06-30 09:20:34 +0300 | [diff] [blame] | 281 | """ |
Andrea Frittoli | cf40a86 | 2016-06-07 14:45:32 +0900 | [diff] [blame] | 282 | url = 'images/%s/tags/%s' % (image_id, tag) |
Anju Tiwari | c495298 | 2013-10-20 07:10:02 +0530 | [diff] [blame] | 283 | resp, _ = self.delete(url) |
David Kranz | 9c3b3b6 | 2014-06-19 16:05:53 -0400 | [diff] [blame] | 284 | self.expected_success(204, resp.status) |
Ken'ichi Ohmichi | e76510d | 2016-03-02 10:33:48 -0800 | [diff] [blame] | 285 | return rest_client.ResponseBody(resp) |