@Name : get_test_ovf_templates @Desc : Retrieves the list of test ovf templates used to running tests. When the template is missing it will be download at most one in a zone for a hypervisor. @Input : returns a list of templates
(apiclient, zone_id=None, test_ovf_templates=None, hypervisor=None)
| 399 | |
| 400 | |
| 401 | def get_test_ovf_templates(apiclient, zone_id=None, test_ovf_templates=None, hypervisor=None): |
| 402 | """ |
| 403 | @Name : get_test_ovf_templates |
| 404 | @Desc : Retrieves the list of test ovf templates used to running tests. When the template |
| 405 | is missing it will be download at most one in a zone for a hypervisor. |
| 406 | @Input : returns a list of templates |
| 407 | """ |
| 408 | result = [] |
| 409 | |
| 410 | if test_ovf_templates is None: |
| 411 | test_ovf_templates = test_data["test_ovf_templates"] |
| 412 | if test_ovf_templates is None: |
| 413 | return result |
| 414 | if hypervisor is None: |
| 415 | return result |
| 416 | hypervisor = hypervisor.lower() |
| 417 | if hypervisor != 'vmware': |
| 418 | return result |
| 419 | |
| 420 | for test_template in test_ovf_templates: |
| 421 | |
| 422 | cmd = listTemplates.listTemplatesCmd() |
| 423 | cmd.name = test_template['name'] |
| 424 | cmd.templatefilter = 'all' |
| 425 | if zone_id is not None: |
| 426 | cmd.zoneid = zone_id |
| 427 | if hypervisor is not None: |
| 428 | cmd.hypervisor = hypervisor |
| 429 | templates = apiclient.listTemplates(cmd) |
| 430 | |
| 431 | if validateList(templates)[0] != PASS: |
| 432 | template = Template.register(apiclient, test_template, zoneid=zone_id, hypervisor=hypervisor.lower(), randomize_name=False) |
| 433 | template.download(apiclient) |
| 434 | retries = 3 |
| 435 | while (not hasattr(template, 'deployasisdetails') or len(template.deployasisdetails.__dict__) == 0) and retries > 0: |
| 436 | time.sleep(10) |
| 437 | template_list = Template.list(apiclient, id=template.id, zoneid=zone_id, templatefilter='all') |
| 438 | if isinstance(template_list, list): |
| 439 | template = Template(template_list[0].__dict__) |
| 440 | retries = retries - 1 |
| 441 | if not hasattr(template, 'deployasisdetails') or len(template.deployasisdetails.__dict__) == 0: |
| 442 | template.delete(apiclient) |
| 443 | else: |
| 444 | result.append(template) |
| 445 | |
| 446 | if templates: |
| 447 | for template in templates: |
| 448 | if template.isready and template.ispublic and template.deployasisdetails and len(template.deployasisdetails.__dict__) > 0: |
| 449 | result.append(template) |
| 450 | |
| 451 | return result |
| 452 | |
| 453 | def get_vm_vapp_configs(apiclient, config, setup_zone, vm_name): |
| 454 | zoneDetailsInConfig = [zone for zone in config.zones |