@Name : get_template @Desc : Retrieves the template Information based upon inputs provided Template is retrieved based upon either of the inputs matched condition @Input : returns a template" @Output : FAILED in case of any failure template Info
(
apiclient, zone_id=None, ostype_desc=None, template_filter="featured", template_type='BUILTIN',
template_id=None, template_name=None, account=None, domain_id=None, project_id=None,
hypervisor=None)
| 304 | return cmd_out[0] |
| 305 | |
| 306 | def get_template( |
| 307 | apiclient, zone_id=None, ostype_desc=None, template_filter="featured", template_type='BUILTIN', |
| 308 | template_id=None, template_name=None, account=None, domain_id=None, project_id=None, |
| 309 | hypervisor=None): |
| 310 | ''' |
| 311 | @Name : get_template |
| 312 | @Desc : Retrieves the template Information based upon inputs provided |
| 313 | Template is retrieved based upon either of the inputs matched |
| 314 | condition |
| 315 | @Input : returns a template" |
| 316 | @Output : FAILED in case of any failure |
| 317 | template Information matching the inputs |
| 318 | ''' |
| 319 | cmd = listTemplates.listTemplatesCmd() |
| 320 | cmd.templatefilter = template_filter |
| 321 | if domain_id is not None: |
| 322 | cmd.domainid = domain_id |
| 323 | if zone_id is not None: |
| 324 | cmd.zoneid = zone_id |
| 325 | if template_id is not None: |
| 326 | cmd.id = template_id |
| 327 | if template_name is not None: |
| 328 | cmd.name = template_name |
| 329 | if hypervisor is not None: |
| 330 | cmd.hypervisor = hypervisor |
| 331 | if project_id is not None: |
| 332 | cmd.projectid = project_id |
| 333 | if account is not None: |
| 334 | cmd.account = account |
| 335 | |
| 336 | ''' |
| 337 | Get the Templates pertaining to the inputs provided |
| 338 | ''' |
| 339 | list_templatesout = apiclient.listTemplates(cmd) |
| 340 | if validateList(list_templatesout)[0] != PASS: |
| 341 | return FAILED |
| 342 | |
| 343 | for template in list_templatesout: |
| 344 | if template.isready and template.templatetype == template_type: |
| 345 | return template |
| 346 | ''' |
| 347 | Return default first template, if no template matched |
| 348 | ''' |
| 349 | return list_templatesout[0] |
| 350 | |
| 351 | |
| 352 | def get_test_template(apiclient, zone_id=None, hypervisor=None, test_templates=None, deploy_as_is=False): |