def test_templateBuiltInReady(self): """ built-in templates CentOS to be ready """ for z in self.zones_list: retry = self.retry while retry != 0: self.debug("Looking for at least one ready builtin template") templates = listTemplates.listTemplatesCmd() templates.templatefilter = 'featured' templates.listall = 'true' templates_list = self.apiClient.listTemplates(templates) if templates_list is not None: builtins = [tmpl for tmpl in templates_list if tmpl.templatetype == 'BUILTIN' and tmpl.isready] if len(builtins) > 0: self.debug("Found %d builtins ready for use %s" % (len(builtins), builtins)) break retry = retry - 1 delay(60) # wait a minute for retry self.assertNotEqual(retry, 0, "builtIn templates not ready in zone %s" % z.name)
def get_template(apiclient, zoneid, ostype, services=None, templatefilter='featured', templatetype='BUILTIN'): "Returns a template" cmd = listOsTypes.listOsTypesCmd() cmd.description = ostype ostypes = apiclient.listOsTypes(cmd) if isinstance(ostypes, list): ostypeid = ostypes[0].id else: raise Exception( "Failed to find OS type with description: %s" % ostype) cmd = listTemplates.listTemplatesCmd() cmd.templatefilter = templatefilter cmd.zoneid = zoneid if services: if "template" in services: cmd.id = services["template"] list_templates = apiclient.listTemplates(cmd) if isinstance(list_templates, list): assert len(list_templates) > 0, "received empty response on template of type %s"%ostype for template in list_templates: if template.ostypeid == ostypeid and template.isready and template.templatetype == templatetype: return template raise Exception("Exception: Failed to find template of type %s with OSTypeID and which is in " "ready state: %s" %(templatetype, ostypeid)) return
def getKubernetesTemplate(cls, cks_templates=None): if cks_templates is None: cks_templates = cls.services["cks_templates"] hypervisor = cls.hypervisor.lower() if hypervisor not in cks_templates.keys(): cls.debug("Provided hypervisor has no CKS template") return FAILED, False cks_template = cks_templates[hypervisor] cmd = listTemplates.listTemplatesCmd() cmd.name = cks_template['name'] cmd.templatefilter = 'all' cmd.zoneid = cls.zone.id cmd.hypervisor = hypervisor templates = cls.apiclient.listTemplates(cmd) if validateList(templates)[0] != PASS: details = None if hypervisor in ["vmware"]: details = [{"keyboard": "us"}] template = Template.register(cls.apiclient, cks_template, zoneid=cls.zone.id, hypervisor=hypervisor.lower(), randomize_name=False, details=details) template.download(cls.apiclient) return template, False for template in templates: if template.isready and template.ispublic: return Template(template.__dict__), True return FAILED, False
def get_template(apiclient, zoneid, ostype, services=None, templatefilter='featured', templatetype='BUILTIN'): "Returns a featured built in template in given zone" cmd = listTemplates.listTemplatesCmd() cmd.templatefilter = templatefilter cmd.zoneid = zoneid if services: if "template" in services: cmd.id = services["template"] list_templates = apiclient.listTemplates(cmd) if isinstance(list_templates, list): assert len(list_templates ) > 0, "received empty response on featured templates" for template in list_templates: if template.isready and template.templatetype == templatetype: return template raise Exception("Exception: Failed to find built in template which is in " "ready state: %s" % templatetype) return
def list_templates(apiclient, **kwargs): """List all templates matching criteria""" cmd = listTemplates.listTemplatesCmd() [setattr(cmd, k, v) for k, v in kwargs.items()] if "account" in kwargs.keys() and "domainid" in kwargs.keys(): cmd.listall = True return apiclient.listTemplates(cmd)
def list_templates(apiclient, **kwargs): """List all templates matching criteria""" cmd = listTemplates.listTemplatesCmd() [setattr(cmd, k, v) for k, v in kwargs.items()] if 'account' in kwargs.keys() and 'domainid' in kwargs.keys(): cmd.listall = True return (apiclient.listTemplates(cmd))
def get_windows_template( apiclient, zone_id=None, ostype_desc=None, template_filter="featured", template_type="USER", template_id=None, template_name=None, account=None, domain_id=None, project_id=None, hypervisor=None, ): """ @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 Information matching the inputs """ cmd = listTemplates.listTemplatesCmd() cmd.templatefilter = template_filter if domain_id is not None: cmd.domainid = domain_id if zone_id is not None: cmd.zoneid = zone_id if template_id is not None: cmd.id = template_id if template_name is not None: cmd.name = template_name if hypervisor is not None: cmd.hypervisor = hypervisor if project_id is not None: cmd.projectid = project_id if account is not None: cmd.account = account """ Get the Templates pertaining to the inputs provided """ list_templatesout = apiclient.listTemplates(cmd) # print("template result is %s"%(list_templatesout)) if list_templatesout is None: return FAILED if validateList(list_templatesout[0]) == FAIL: return FAILED for template in list_templatesout: if template.isready and template.templatetype == "USER" and template.ostypename == ostype_desc: return template """ Return default first template, if no template matched """ return FAILED
def get_windows_template(apiclient, zone_id=None, ostype_desc=None, template_filter="featured", template_type='USER', template_id=None, template_name=None, account=None, domain_id=None, project_id=None, hypervisor=None): ''' @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 Information matching the inputs ''' cmd = listTemplates.listTemplatesCmd() cmd.templatefilter = template_filter if domain_id is not None: cmd.domainid = domain_id if zone_id is not None: cmd.zoneid = zone_id if template_id is not None: cmd.id = template_id if template_name is not None: cmd.name = template_name if hypervisor is not None: cmd.hypervisor = hypervisor if project_id is not None: cmd.projectid = project_id if account is not None: cmd.account = account ''' Get the Templates pertaining to the inputs provided ''' list_templatesout = apiclient.listTemplates(cmd) #print("template result is %s"%(list_templatesout)) if list_templatesout is None: return FAILED if validateList(list_templatesout[0]) == FAIL: return FAILED for template in list_templatesout: if template.isready and template.templatetype == "USER" and template.ostypename == ostype_desc: return template ''' Return default first template, if no template matched ''' return FAILED
def get_template(api_client, zone_id=None, template_filter="featured", template_type='BUILTIN', template_id=None, template_name=None, account=None, domain_id=None, project_id=None, hypervisor=None): """ @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 Information matching the inputs """ cmd = listTemplates.listTemplatesCmd() cmd.templatefilter = template_filter if domain_id is not None: cmd.domainid = domain_id if zone_id is not None: cmd.zoneid = zone_id if template_id is not None: cmd.id = template_id if template_name is not None: cmd.name = template_name if hypervisor is not None: cmd.hypervisor = hypervisor if project_id is not None: cmd.projectid = project_id if account is not None: cmd.account = account ''' Get the Templates pertaining to the inputs provided ''' list_templatesout = api_client.listTemplates(cmd) if validate_list(list_templatesout)[0] != PASS: return FAILED for template in list_templatesout: if template.isready and template.templatetype == template_type: return template ''' Return default first template, if no template matched ''' return list_templatesout[0]
def get_template( 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): ''' @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 Information matching the inputs ''' cmd = listTemplates.listTemplatesCmd() cmd.templatefilter = template_filter if domain_id is not None: cmd.domainid = domain_id if zone_id is not None: cmd.zoneid = zone_id if template_id is not None: cmd.id = template_id if template_name is not None: cmd.name = template_name if hypervisor is not None: cmd.hypervisor = hypervisor if project_id is not None: cmd.projectid = project_id if account is not None: cmd.account = account ''' Get the Templates pertaining to the inputs provided ''' list_templatesout = apiclient.listTemplates(cmd) if validateList(list_templatesout)[0] != PASS: return FAILED for template in list_templatesout: if template.isready and template.templatetype == template_type: return template ''' Return default first template, if no template matched ''' return list_templatesout[0]
def get_template(apiclient, zoneid, ostype, services=None, templatefilter='featured', templatetype='BUILTIN'): "Returns a template" cmd = listOsTypes.listOsTypesCmd() cmd.description = ostype ostypes = apiclient.listOsTypes(cmd) if isinstance(ostypes, list): ostypeid = ostypes[0].id else: raise Exception("Failed to find OS type with description: %s" % ostype) cmd = listTemplates.listTemplatesCmd() cmd.templatefilter = templatefilter cmd.zoneid = zoneid if services: if "template" in services: cmd.id = services["template"] list_templates = apiclient.listTemplates(cmd) if isinstance(list_templates, list): assert len( list_templates ) > 0, "received empty response on template of type %s" % ostype for template in list_templates: if template.ostypeid == ostypeid and template.isready and template.templatetype == templatetype: return template raise Exception( "Exception: Failed to find template of type %s with OSTypeID and which is in " "ready state: %s" % (templatetype, ostypeid)) return
def get_template(apiclient, zoneid, ostype, services=None, templatefilter='featured', templatetype='BUILTIN'): "Returns a featured built in template in given zone" cmd = listTemplates.listTemplatesCmd() cmd.templatefilter = templatefilter cmd.zoneid = zoneid if services: if "template" in services: cmd.id = services["template"] list_templates = apiclient.listTemplates(cmd) if isinstance(list_templates, list): assert len(list_templates) > 0, "received empty response on featured templates" for template in list_templates: if template.isready and template.templatetype == templatetype: return template raise Exception("Exception: Failed to find built in template which is in " "ready state: %s" % templatetype) return
def list_templates(apiclient, **kwargs): """List all templates matching criteria""" cmd = listTemplates.listTemplatesCmd() [setattr(cmd, k, v) for k, v in kwargs.items()] return(apiclient.listTemplates(cmd))
def list_templates(apiclient, **kwargs): """List all templates matching criteria""" cmd = listTemplates.listTemplatesCmd() [setattr(cmd, k, v) for k, v in kwargs.items()] return (apiclient.listTemplates(cmd))