def _getSanitizedProductDefinition(self): project = self.project if not self.namespace: self.namespace = project.namespace Project.validateNamespace(self.namespace) prodDef = helperfuncs.sanitizeProductDefinition( project.name, project.description, project.repository_hostname, project.short_name, self.name, self.description, self.namespace) return prodDef
def createProductVersion(self, fqdn, version, namespace, description, platformLabel): product = self.getProduct(fqdn) if not namespace: namespace = product.namespace projectId = product.productId # Check the namespace projects._validateNamespace(namespace) # make sure it is a valid product version projects._validateProductVersion(version) # initial product definition prodDef = helperfuncs.sanitizeProductDefinition(product.name, description, product.repositoryHostname, product.shortname, version, '', namespace) label = prodDef.getDefaultLabel() # validate the label, which will be added later. This is done # here so the project is not created before this error occurs if projects.validLabel.match(label) == None: raise mint_error.InvalidLabel(label) if platformLabel: cclient = self.reposMgr.getUserClient() prodDef.rebase(cclient, platformLabel) self.setProductVersionDefinition(fqdn, version, prodDef) try: versionId = self.db.db.productVersions.new(projectId=projectId, namespace=namespace, name=version, description=description, label=prodDef.getProductDefinitionLabel(), timeCreated=time.time()) except mint_error.DuplicateItem: raise mint_error.DuplicateProductVersion if product.prodtype == 'Appliance' or product.prodtype == 'PlatformFoundation': groupName = helperfuncs.getDefaultImageGroupName(product.hostname) className = util.convertPackageNameToClassName(groupName) # convert from unicode recipeStr = str(templates.write(groupTemplate, cfg = self.cfg, groupApplianceLabel=platformLabel, groupName=groupName, recipeClassName=className, version=version) + '\n') self.reposMgr.createSourceTrove(fqdn, groupName, label, version, {'%s.recipe' % groupName: recipeStr}, 'Initial appliance image group template') return versionId
def _setupProduct(self): version = self.productVersion projectName = self.productName shortName = self.productShortName domainName = self.productDomainName description = self.productVersionDescription db = self.openRestDatabase() self.createUser("adminuser", admin=True) self.setDbUser(db, "adminuser") self.createProduct(shortName, name=projectName, domainname=domainName, db=db) self.createProductVersion(db, shortName, version, description=description, namespace=self.mintCfg.namespace) pd = helperfuncs.sanitizeProductDefinition( projectName, "", ".".join((shortName, domainName)), shortName, version, "", self.mintCfg.namespace ) stageRefs = [x.name for x in pd.getStages()] for _name, displayName, _flavor in self.architectures: pd.addArchitecture(_name, displayName, _flavor) for _name, displayName, _flavor in self.flavorSets: pd.addFlavorSet(_name, displayName, _flavor) for _name, opts in self.containerTemplates: pd.addContainerTemplate(pd.imageType(_name, opts)) for buildName, flavorSetRef, archRef, containerTemplateRef in self.buildTemplates: pd.addBuildTemplate( name=buildName, displayName=buildName, flavorSetRef=flavorSetRef, architectureRef=archRef, containerTemplateRef=containerTemplateRef, ) for buildName, flavorSetRef, archRef, containerTemplateRef in self.buildDefs: pd.addBuildDefinition( name=buildName, flavorSetRef=flavorSetRef, architectureRef=archRef, containerTemplateRef=containerTemplateRef, stages=stageRefs, ) client = db.productMgr.reposMgr.getAdminClient(write=True) pd.setPlatformName("localhost@rpath:plat-1") pd.saveToRepository(client, "Product Definition commit\n") return pd