Revision f9457c89
b/kamaki/cli/commands/image.py | ||
---|---|---|
86 | 86 |
size_min=IntArgument('filter by minimum size', '--size-min'), |
87 | 87 |
size_max=IntArgument('filter by maximum size', '--size-max'), |
88 | 88 |
status=ValueArgument('filter by status', '--status'), |
89 |
owner=ValueArgument('filter by owner', '--owner'), |
|
89 | 90 |
order=ValueArgument( |
90 | 91 |
'order by FIELD ( - to reverse order)', |
91 | 92 |
'--order', |
... | ... | |
96 | 97 |
'--more') |
97 | 98 |
) |
98 | 99 |
|
100 |
def _filtered_by_owner(self, detail, *list_params): |
|
101 |
images = [] |
|
102 |
MINKEYS = set([ |
|
103 |
'id', 'size', 'status', 'disk_format', 'container_format', 'name']) |
|
104 |
for img in self.client.list_public(True, *list_params): |
|
105 |
if img['owner'] == self['owner']: |
|
106 |
if not detail: |
|
107 |
for key in set(img.keys()).difference(MINKEYS): |
|
108 |
img.pop(key) |
|
109 |
images.append(img) |
|
110 |
return images |
|
111 |
|
|
99 | 112 |
@errors.generic.all |
100 | 113 |
@errors.cyclades.connection |
101 | 114 |
def _run(self): |
... | ... | |
112 | 125 |
|
113 | 126 |
order = self['order'] |
114 | 127 |
detail = self['detail'] |
115 |
images = self.client.list_public(detail, filters, order) |
|
128 |
if self['owner']: |
|
129 |
images = self._filtered_by_owner(detail, filters, order) |
|
130 |
else: |
|
131 |
images = self.client.list_public(detail, filters, order) |
|
132 |
|
|
116 | 133 |
if self['more']: |
117 | 134 |
print_items( |
118 | 135 |
images, |
Also available in: Unified diff