def run(self): tplName = self.get_option('name') orgName = self.get_option('org') envName = self.get_option('env') template = get_template(orgName, envName, tplName) template["products"] = [p["name"] for p in template["products"]] template["repositories"] = [r["name"] for r in template["repositories"]] template["packages"] = [self._build_nvrea(p) for p in template["packages"]] template["parameters"] = [key+":\t"+value for key, value in template["parameters"].iteritems()] template["package_groups"] = [p["name"] for p in template["package_groups"]] template["package_group_categories"] = [p["name"] for p in template["pg_categories"]] self.printer.add_column('id') self.printer.add_column('name') self.printer.add_column('revision', show_with=printer.VerboseStrategy) self.printer.add_column('description', multiline=True) self.printer.add_column('environment_id') self.printer.add_column('parent_id') self.printer.add_column('errata', multiline=True, show_with=printer.VerboseStrategy) self.printer.add_column('products', multiline=True, show_with=printer.VerboseStrategy) self.printer.add_column('repositories', multiline=True, show_with=printer.VerboseStrategy) self.printer.add_column('packages', multiline=True, show_with=printer.VerboseStrategy) self.printer.add_column('parameters', multiline=True, show_with=printer.VerboseStrategy) self.printer.add_column('package_groups', multiline=True, show_with=printer.VerboseStrategy) self.printer.add_column('package_group_categories', multiline=True, show_with=printer.VerboseStrategy) self.printer.set_header(_("Template Info")) self.printer.print_item(template) return os.EX_OK
def run(self): tplName = self.get_option('name') orgName = self.get_option('org') newName = self.get_option('new_name') desc = self.get_option('description') parentName = self.get_option('parent') content = self.getContent() env = get_library(orgName) if env == None: return os.EX_DATAERR template = get_template(orgName, env["name"], tplName) if template != None: if parentName != None: parentId = self.get_parent_id(orgName, env["name"], parentName) else: parentId = None run_spinner_in_bg(self.updateTemplate, [template["id"], newName, desc, parentId], _("Updating the template, please wait... ")) run_spinner_in_bg(self.updateContent, [template["id"], content], _("Updating the template, please wait... ")) print _("Successfully updated template [ %s ]") % template['name'] return os.EX_OK else: return os.EX_DATAERR
def run(self): tplName = self.get_option('name') orgName = self.get_option('org') envName = self.get_option('environment') template = get_template(orgName, envName, tplName) template["products"] = [p["name"] for p in template["products"]] template["repositories"] = [r["name"] for r in template["repositories"]] template["packages"] = [self._build_nvrea(p) for p in template["packages"]] template["parameters"] = [key+":\t"+value for key, value in template["parameters"].iteritems()] template["package_groups"] = [p["name"] for p in template["package_groups"]] template["package_group_categories"] = [p["name"] for p in template["pg_categories"]] batch_add_columns(self.printer, {'id': _("ID")}, {'name': _("Name")}) self.printer.add_column('revision', _("Revision"), show_with=printer.VerboseStrategy) self.printer.add_column('description', _("Description"), multiline=True) self.printer.add_column('environment_id', _("Environment ID")) self.printer.add_column('parent_id', _("Parent ID")) batch_add_columns(self.printer, {'errata': _("Errata")}, {'products': _("Products")}, \ {'repositories': _("Repositories")}, {'packages': _("Packages")}, \ {'parameters': _("Parameters")}, {'package_groups': _("Package Groups")}, \ {'package_group_categories': _("Package Group Categories")}, multiline=True, \ show_with=printer.VerboseStrategy) self.printer.set_header(_("Template Info")) self.printer.print_item(template) return os.EX_OK
def run(self): tplName = self.get_option('name') orgName = self.get_option('org') envName = self.get_option('env') template = get_template(orgName, envName, tplName) msg = self.api.delete(template["id"]) print msg return os.EX_OK
def run(self): tplName = self.get_option("name") orgName = self.get_option("org") envName = self.get_option("environment") template = get_template(orgName, envName, tplName) msg = self.api.delete(template["id"]) print msg return os.EX_OK
def run(self): tplName = self.get_option('name') orgName = self.get_option('org') newName = self.get_option('new_name') desc = self.get_option('description') parentName = self.get_option('parent') content = self.getContent() env = get_library(orgName) template = get_template(orgName, env["name"], tplName) if parentName != None: parentId = self.get_parent_id(orgName, env["name"], parentName) else: parentId = None run_spinner_in_bg(self.updateTemplate, [template["id"], newName, desc, parentId], _("Updating the template, please wait... ")) run_spinner_in_bg(self.updateContent, [template["id"], content], _("Updating the template, please wait... ")) print _("Successfully updated template [ %s ]") % template['name'] return os.EX_OK
def run(self): tplName = self.get_option('name') orgName = self.get_option('org') envName = self.get_option('env') format = self.get_option('format') or "json" tplPath = self.get_option('file') template = get_template(orgName, envName, tplName) try: f = self.open_file(tplPath) except: print >> sys.stderr, _("Could not create file %s") % tplPath return os.EX_IOERR self.api.validate_tpl(template["id"], format) response = run_spinner_in_bg(self.api.export_tpl, (template["id"], format), message=_("Exporting template, please wait... ")) f.write(response) f.close() print _("Template was exported successfully to file %s") % tplPath return os.EX_OK
def run(self): tplName = self.get_option("name") orgName = self.get_option("org") newName = self.get_option("new_name") desc = self.get_option("description") parentName = self.get_option("parent") content = self.getContent() env = get_library(orgName) template = get_template(orgName, env["name"], tplName) if parentName != None: parentId = self.get_parent_id(orgName, env["name"], parentName) else: parentId = None run_spinner_in_bg( self.updateTemplate, [template["id"], newName, desc, parentId], _("Updating the template, please wait... ") ) run_spinner_in_bg(self.updateContent, [template["id"], content], _("Updating the template, please wait... ")) print _("Successfully updated template [ %s ]") % template["name"] return os.EX_OK
def run(self): tplName = self.get_option("name") orgName = self.get_option("org") envName = self.get_option("environment") format_in = self.get_option("format") or "json" tplPath = self.get_option("file") template = get_template(orgName, envName, tplName) try: f = self.open_file(tplPath) except IOError: print >> sys.stderr, _("Could not create file [ %s ]") % tplPath return os.EX_IOERR self.api.validate_tpl(template["id"], format_in) response = run_spinner_in_bg( self.api.export_tpl, (template["id"], format_in), message=_("Exporting template, please wait... ") ) f.write(response) f.close() print _("Template was exported successfully to file [ %s ]") % tplPath return os.EX_OK
def template_id(self, options): tpl = get_template(self.orgName, self.priorEnvName, options['name']) if tpl == None: system_exit(os.EX_DATAERR) return tpl['id']
def get_parent_id(self, orgName, envName, parentName): parent = get_template(orgName, envName, parentName) if parent != None: return parent["id"] system_exit(os.EX_DATAERR)
def template_id(self, options): tpl = get_template(self.org_name, self.env_name, options['name']) return tpl['id']
def template_id(self, options): tpl = get_template(self.org_name, self.prior_env_name, options['name']) return tpl['id']