Revision fe402df2 ci/utils.py
b/ci/utils.py | ||
---|---|---|
332 | 332 |
|
333 | 333 |
list_flavors = self.compute_client.list_flavors() |
334 | 334 |
for flv in flavors: |
335 |
[flv_type, flv_value] = flv.strip().split(':')
|
|
335 |
flv_type, flv_value = parse_typed_option(option="flavor", value=flv)
|
|
336 | 336 |
if flv_type == "name": |
337 | 337 |
# Filter flavors by name |
338 | 338 |
self.logger.debug( |
... | ... | |
374 | 374 |
|
375 | 375 |
list_images = self.image_client.list_public(detail=True)['images'] |
376 | 376 |
for img in images: |
377 |
[img_type, img_value] = img.strip().split(':')
|
|
377 |
img_type, img_value = parse_typed_option(option="image", value=img)
|
|
378 | 378 |
if img_type == "name": |
379 | 379 |
# Filter images by name |
380 | 380 |
self.logger.debug( |
... | ... | |
778 | 778 |
self.fetch_compressed("synnefo_build-area", dest) |
779 | 779 |
self.logger.info("Downloaded debian packages to %s" % |
780 | 780 |
_green(dest)) |
781 |
|
|
782 |
|
|
783 |
def parse_typed_option(option, value): |
|
784 |
try: |
|
785 |
[type_, val] = value.strip().split(':') |
|
786 |
if type_ not in ["id", "name"]: |
|
787 |
raise ValueError |
|
788 |
return type_, val |
|
789 |
except ValueError: |
|
790 |
msg = "Invalid %s format. Must be [id|name]:.+" % option |
|
791 |
raise ValueError(msg) |
Also available in: Unified diff