44 |
44 |
import traceback
|
45 |
45 |
|
46 |
46 |
from kamaki.clients.cyclades import CycladesClient, CycladesNetworkClient
|
47 |
|
from kamaki.clients.astakos import CachedAstakosClient
|
|
47 |
from kamaki.clients.astakos import AstakosClient, parse_endpoints
|
48 |
48 |
from kamaki.clients.compute import ComputeClient
|
49 |
49 |
from kamaki.clients.pithos import PithosClient
|
50 |
50 |
from kamaki.clients.image import ImageClient
|
... | ... | |
134 |
134 |
|
135 |
135 |
def initialize_clients(self):
|
136 |
136 |
"""Initialize all the Kamaki Clients"""
|
137 |
|
self.astakos = CachedAstakosClient(self.auth_url, self.token)
|
|
137 |
self.astakos = AstakosClient(self.auth_url, self.token)
|
138 |
138 |
self.astakos.CONNECTION_RETRY_LIMIT = self.retry
|
139 |
139 |
|
140 |
|
self.compute_url = \
|
141 |
|
self.astakos.get_service_endpoints('compute')['publicURL']
|
|
140 |
endpoints = self.astakos.authenticate()
|
|
141 |
|
|
142 |
self.compute_url = _get_endpoint_url(endpoints, "compute")
|
142 |
143 |
self.compute = ComputeClient(self.compute_url, self.token)
|
143 |
144 |
self.compute.CONNECTION_RETRY_LIMIT = self.retry
|
144 |
145 |
|
145 |
146 |
self.cyclades = CycladesClient(self.compute_url, self.token)
|
146 |
147 |
self.cyclades.CONNECTION_RETRY_LIMIT = self.retry
|
147 |
148 |
|
148 |
|
self.network_url = \
|
149 |
|
self.astakos.get_service_endpoints('network')['publicURL']
|
|
149 |
self.network_url = _get_endpoint_url(endpoints, "network")
|
150 |
150 |
self.network = CycladesNetworkClient(self.network_url, self.token)
|
151 |
151 |
self.network.CONNECTION_RETRY_LIMIT = self.retry
|
152 |
152 |
|
153 |
|
self.pithos_url = self.astakos.\
|
154 |
|
get_service_endpoints('object-store')['publicURL']
|
|
153 |
self.pithos_url = _get_endpoint_url(endpoints, "object-store")
|
155 |
154 |
self.pithos = PithosClient(self.pithos_url, self.token)
|
156 |
155 |
self.pithos.CONNECTION_RETRY_LIMIT = self.retry
|
157 |
156 |
|
158 |
|
self.image_url = \
|
159 |
|
self.astakos.get_service_endpoints('image')['publicURL']
|
|
157 |
self.image_url = _get_endpoint_url(endpoints, "image")
|
160 |
158 |
self.image = ImageClient(self.image_url, self.token)
|
161 |
159 |
self.image.CONNECTION_RETRY_LIMIT = self.retry
|
162 |
160 |
|
163 |
161 |
|
|
162 |
def _get_endpoint_url(endpoints, endpoint_type):
|
|
163 |
"""Get the publicURL for the specified endpoint"""
|
|
164 |
|
|
165 |
service_catalog = parse_endpoints(endpoints, ep_type=endpoint_type)
|
|
166 |
return service_catalog[0]['endpoints'][0]['publicURL']
|
|
167 |
|
|
168 |
|
164 |
169 |
class Proper(object):
|
165 |
170 |
"""A descriptor used by tests implementing the TestCase class
|
166 |
171 |
|
... | ... | |
305 |
310 |
self.info("Getting the uuid of the system user")
|
306 |
311 |
system_users = None
|
307 |
312 |
if self.system_user is not None:
|
308 |
|
parsed_su = parse_typed_option(self.system_user)
|
309 |
|
if parsed_su is None:
|
310 |
|
msg = "Invalid system-user format: %s. Must be [id|name]:.+"
|
311 |
|
self.warning(msg, self.system_user)
|
312 |
|
else:
|
313 |
|
su_type, su_value = parsed_su
|
|
313 |
try:
|
|
314 |
su_type, su_value = parse_typed_option(self.system_user)
|
314 |
315 |
if su_type == "name":
|
315 |
316 |
system_users = [su_value]
|
316 |
317 |
elif su_type == "id":
|
... | ... | |
319 |
320 |
else:
|
320 |
321 |
self.error("Unrecognized system-user type %s", su_type)
|
321 |
322 |
self.fail("Unrecognized system-user type")
|
|
323 |
except ValueError:
|
|
324 |
msg = "Invalid system-user format: %s. Must be [id|name]:.+"
|
|
325 |
self.warning(msg, self.system_user)
|
322 |
326 |
|
323 |
327 |
if system_users is None:
|
324 |
328 |
system_users = SYSTEM_USERS
|
325 |
329 |
|
326 |
|
uuids = self.clients.astakos.usernames2uuids(system_users)
|
|
330 |
uuids = self.clients.astakos.get_uuids(system_users)
|
327 |
331 |
for su_name in system_users:
|
328 |
332 |
self.info("Trying username %s", su_name)
|
329 |
333 |
if su_name in uuids:
|
... | ... | |
362 |
366 |
|
363 |
367 |
ret_flavors = []
|
364 |
368 |
for ptrn in patterns:
|
365 |
|
parsed_ptrn = parse_typed_option(ptrn)
|
366 |
|
if parsed_ptrn is None:
|
|
369 |
try:
|
|
370 |
flv_type, flv_value = parse_typed_option(ptrn)
|
|
371 |
except ValueError:
|
367 |
372 |
msg = "Invalid flavor format: %s. Must be [id|name]:.+"
|
368 |
373 |
self.warning(msg, ptrn)
|
369 |
374 |
continue
|
370 |
|
flv_type, flv_value = parsed_ptrn
|
|
375 |
|
371 |
376 |
if flv_type == "name":
|
372 |
377 |
# Filter flavor by name
|
373 |
378 |
msg = "Trying to find a flavor with name %s"
|
... | ... | |
431 |
436 |
|
432 |
437 |
ret_images = []
|
433 |
438 |
for ptrn in patterns:
|
434 |
|
parsed_ptrn = parse_typed_option(ptrn)
|
435 |
|
if parsed_ptrn is None:
|
|
439 |
try:
|
|
440 |
img_type, img_value = parse_typed_option(ptrn)
|
|
441 |
except ValueError:
|
436 |
442 |
msg = "Invalid image format: %s. Must be [id|name]:.+"
|
437 |
443 |
self.warning(msg, ptrn)
|
438 |
444 |
continue
|
439 |
|
img_type, img_value = parsed_ptrn
|
|
445 |
|
440 |
446 |
if img_type == "name":
|
441 |
447 |
# Filter image by name
|
442 |
448 |
msg = "Trying to find an image with name %s"
|
... | ... | |
502 |
508 |
def _get_quotas(self):
|
503 |
509 |
"""Get quotas"""
|
504 |
510 |
self.info("Getting quotas")
|
505 |
|
astakos_client = self.clients.astakos.get_client()
|
506 |
|
return astakos_client.get_quotas()
|
|
511 |
return self.clients.astakos.get_quotas()
|
507 |
512 |
|
508 |
513 |
# Invalid argument name. pylint: disable-msg=C0103
|
509 |
514 |
# Too many arguments. pylint: disable-msg=R0913
|
... | ... | |
611 |
616 |
run_tests(testsuites, failfast=failfast)
|
612 |
617 |
|
613 |
618 |
# Clean up our logger
|
614 |
|
del(logger)
|
|
619 |
del logger
|
615 |
620 |
|
616 |
621 |
# Return
|
617 |
622 |
return 0 if success else 1
|
... | ... | |
660 |
665 |
raise ValueError
|
661 |
666 |
return type_, val
|
662 |
667 |
except ValueError:
|
663 |
|
return None
|
|
668 |
raise
|