@Name : get_test_template @Desc : Retrieves the test template 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 template
(apiclient, zone_id=None, hypervisor=None, test_templates=None, deploy_as_is=False)
| 350 | |
| 351 | |
| 352 | def get_test_template(apiclient, zone_id=None, hypervisor=None, test_templates=None, deploy_as_is=False): |
| 353 | """ |
| 354 | @Name : get_test_template |
| 355 | @Desc : Retrieves the test template used to running tests. When the template |
| 356 | is missing it will be download at most one in a zone for a hypervisor. |
| 357 | @Input : returns a template |
| 358 | """ |
| 359 | |
| 360 | if test_templates is None: |
| 361 | test_templates = test_data["test_templates"] |
| 362 | |
| 363 | if hypervisor is None: |
| 364 | return FAILED |
| 365 | |
| 366 | hypervisor = hypervisor.lower() |
| 367 | |
| 368 | # Return built-in template for simulator |
| 369 | if hypervisor == 'simulator': |
| 370 | return get_template(apiclient, zone_id) |
| 371 | |
| 372 | if hypervisor not in list(test_templates.keys()): |
| 373 | print("Provided hypervisor has no test template") |
| 374 | return FAILED |
| 375 | |
| 376 | test_template = test_templates[hypervisor] |
| 377 | if deploy_as_is: |
| 378 | test_template['deployasis'] = True |
| 379 | |
| 380 | cmd = listTemplates.listTemplatesCmd() |
| 381 | cmd.name = test_template['name'] |
| 382 | cmd.templatefilter = 'all' |
| 383 | if zone_id is not None: |
| 384 | cmd.zoneid = zone_id |
| 385 | if hypervisor is not None: |
| 386 | cmd.hypervisor = hypervisor |
| 387 | templates = apiclient.listTemplates(cmd) |
| 388 | |
| 389 | if validateList(templates)[0] != PASS: |
| 390 | template = Template.register(apiclient, test_template, zoneid=zone_id, hypervisor=hypervisor.lower(), randomize_name=False) |
| 391 | template.download(apiclient) |
| 392 | return template |
| 393 | |
| 394 | for template in templates: |
| 395 | if template.isready and template.ispublic: |
| 396 | return template |
| 397 | |
| 398 | return FAILED |
| 399 | |
| 400 | |
| 401 | def get_test_ovf_templates(apiclient, zone_id=None, test_ovf_templates=None, hypervisor=None): |