Revision 3dabe5d2 kamaki/clients/image.py
b/kamaki/clients/image.py | ||
---|---|---|
33 | 33 |
from kamaki.clients import Client, ClientError |
34 | 34 |
from kamaki.clients.utils import path4url |
35 | 35 |
|
36 |
|
|
36 | 37 |
class ImageClient(Client): |
37 | 38 |
"""OpenStack Image Service API 1.0 and GRNET Plankton client""" |
38 | 39 |
|
... | ... | |
47 | 48 |
super(ImageClient, self).raise_for_status(r) |
48 | 49 |
|
49 | 50 |
def list_public(self, detail=False, filters={}, order=''): |
50 |
path = path4url('images','detail') if detail else path4url('images/') |
|
51 |
path = path4url('images', 'detail') if detail else path4url('images/')
|
|
51 | 52 |
|
52 | 53 |
if isinstance(filters, dict): |
53 | 54 |
self.http_client.params.update(filters) |
... | ... | |
62 | 63 |
return r.json |
63 | 64 |
|
64 | 65 |
def get_meta(self, image_id): |
65 |
path=path4url('images', image_id)
|
|
66 |
path = path4url('images', image_id)
|
|
66 | 67 |
r = self.head(path, success=200) |
67 | 68 |
|
68 | 69 |
reply = {} |
... | ... | |
95 | 96 |
self.set_header(key, val) |
96 | 97 |
|
97 | 98 |
for key, val in properties.items(): |
98 |
self.set_header('X-Image-Meta-Property-'+key, val)
|
|
99 |
self.set_header('X-Image-Meta-Property-%s' % key, val)
|
|
99 | 100 |
|
100 | 101 |
try: |
101 | 102 |
r = self.post(path, success=200) |
102 | 103 |
except ClientError as err: |
103 | 104 |
try: |
104 | 105 |
prefix, suffix = err.details.split('File not found') |
105 |
details = '%s Location %s not found %s'%(prefix, location, suffix) |
|
106 |
details = '%s Location %s not found %s' %\ |
|
107 |
(prefix, location, suffix) |
|
106 | 108 |
raise ClientError(err.message, err.status, details) |
107 | 109 |
except ValueError: |
108 | 110 |
pass |
... | ... | |
110 | 112 |
r.release() |
111 | 113 |
|
112 | 114 |
def list_members(self, image_id): |
113 |
path = path4url('images',image_id,'members')
|
|
115 |
path = path4url('images', image_id, 'members')
|
|
114 | 116 |
r = self.get(path, success=200) |
115 | 117 |
return r.json['members'] |
116 | 118 |
|
... | ... | |
135 | 137 |
req = {'memberships': [{'member_id': member} for member in members]} |
136 | 138 |
r = self.put(path, json=req, success=204) |
137 | 139 |
r.release() |
138 |
|
Also available in: Unified diff