|
15 | 15 |
|
16 | 16 | import logging |
17 | 17 |
|
18 | | -from glanceclient import exc as gc_exceptions |
19 | | -from glanceclient.v1 import client as gc_v1_client |
20 | | -from glanceclient.v1 import images as gc_v1_images |
21 | 18 | from openstackclient.common import utils |
22 | 19 |
|
23 | 20 |
|
|
27 | 24 | API_VERSION_OPTION = 'os_image_api_version' |
28 | 25 | API_NAME = "image" |
29 | 26 | API_VERSIONS = { |
30 | | - "1": "openstackclient.image.client.Client_v1", |
| 27 | + "1": "glanceclient.v1.client.Client", |
31 | 28 | "2": "glanceclient.v2.client.Client", |
32 | 29 | } |
33 | 30 |
|
@@ -89,54 +86,3 @@ def build_option_parser(parser): |
89 | 86 | DEFAULT_IMAGE_API_VERSION + |
90 | 87 | ' (Env: OS_IMAGE_API_VERSION)') |
91 | 88 | return parser |
92 | | - |
93 | | - |
94 | | -# NOTE(dtroyer): glanceclient.v1.image.ImageManager() doesn't have a find() |
95 | | -# method so add one here until the common client libs arrive |
96 | | -# A similar subclass will be required for v2 |
97 | | - |
98 | | -class Client_v1(gc_v1_client.Client): |
99 | | - """An image v1 client that uses ImageManager_v1""" |
100 | | - |
101 | | - def __init__(self, *args, **kwargs): |
102 | | - super(Client_v1, self).__init__(*args, **kwargs) |
103 | | - self.images = ImageManager_v1(getattr(self, 'http_client', self)) |
104 | | - |
105 | | - |
106 | | -class ImageManager_v1(gc_v1_images.ImageManager): |
107 | | - """Add find() and findall() to the ImageManager class""" |
108 | | - |
109 | | - def find(self, **kwargs): |
110 | | - """Find a single item with attributes matching ``**kwargs``. |
111 | | -
|
112 | | - This isn't very efficient: it loads the entire list then filters on |
113 | | - the Python side. |
114 | | - """ |
115 | | - rl = self.findall(**kwargs) |
116 | | - num = len(rl) |
117 | | - |
118 | | - if num == 0: |
119 | | - raise gc_exceptions.NotFound |
120 | | - elif num > 1: |
121 | | - raise gc_exceptions.NoUniqueMatch |
122 | | - else: |
123 | | - return rl[0] |
124 | | - |
125 | | - def findall(self, **kwargs): |
126 | | - """Find all items with attributes matching ``**kwargs``. |
127 | | -
|
128 | | - This isn't very efficient: it loads the entire list then filters on |
129 | | - the Python side. |
130 | | - """ |
131 | | - found = [] |
132 | | - searches = kwargs.items() |
133 | | - |
134 | | - for obj in self.list(): |
135 | | - try: |
136 | | - if all(getattr(obj, attr) == value |
137 | | - for (attr, value) in searches): |
138 | | - found.append(obj) |
139 | | - except AttributeError: |
140 | | - continue |
141 | | - |
142 | | - return found |
0 commit comments