def _get_templates_names(self): """ Get templates name from cache """ self.templates = lxc.get_templates() dist = [] for template in self.templates: dist.append(template["dist"]) unique = list(set(dist)) # return unique list return unique
def _get_template_version(self, tpl): """ Get template version from cache """ if len(self.templates) < 1: self.templates = lxc.get_templates() # init cache versions = [] for template in self.templates: if template["dist"] == tpl: versions.append(template["release"]) unique = list(set(versions)) # return unique versions list return unique
def tpl_get_version(self, tpl): """ get available templates """ if len(self.templates) < 1: self.templates = lxc.get_templates() return self._get_template_version(tpl)
def tpl_get_distro(self): """ Get available distributions """ if len(self.templates) < 1: self.templates = lxc.get_templates() return self._get_templates_names()
def tpl_get(self): """ Get available distributions """ self.templates = lxc.get_templates() # refresh templates cache return self.templates