示例#1
0
    def updateProduct(self, hostname, name,
                       description, projecturl, commitEmail,
                       prodtype=None, hidden=True, namespace=None):
        oldproduct = self._getProducts([('hostname = ?', (hostname,))])[0]
        cu = self.db.cursor()
        params = dict(name=name,
                      description=description,
                      projecturl=projecturl,
                      commitEmail=commitEmail,
                      timeModified=time.time())
        if prodtype is not None:
            params['prodtype'] = prodtype
            params['isAppliance'] = (prodtype == 'Appliance' or prodtype == 'PlatformFoundation')
        if namespace is not None:
            v = helperfuncs.validateNamespace(namespace)
            if v != True:
                raise mint_error.InvalidNamespace
            params['namespace'] = namespace

        if hidden:
            # only admin can hide
            if self.auth.isAdmin:
                params['hidden'] = True
        else:
            params['hidden'] = False

        keys = '=?, '.join(params) + '=?'
        values = params.values()
        values.append(hostname)
        try:
            cu.execute('''UPDATE Projects SET %s
                      WHERE hostname=?''' % keys,
                   *values)
        except sqlerrors.CursorError, e:
            raise mint_error.InvalidError(e.msg)
示例#2
0
    def createProduct(self, name, description, hostname,
                      domainname, namespace,
                      projecturl, shortname, prodtype,
                      version, commitEmail, isPrivate):
        if namespace is None:
            namespace = self.cfg.namespace
        else:
            v = helperfuncs.validateNamespace(namespace)
            if v != True:
                raise mint_error.InvalidNamespace
        createTime = time.time()
        if self.auth.userId > 0:
            creatorId = self.auth.userId
        else:
            creatorId = None

        try:
            projectId = self.db.db.projects.new(
                name=name,
                creatorId=creatorId,
                description=description, 
                hostname=hostname,
                domainname=domainname, 
                fqdn='%s.%s' % (hostname, domainname),
                database=self.cfg.defaultDatabase,
                namespace=namespace,
                isAppliance=(prodtype == 'Appliance' or prodtype == 'PlatformFoundation'),
                projecturl=projecturl,
                timeModified=createTime, 
                timeCreated=createTime,
                shortname=shortname, 
                prodtype=prodtype, 
                commitEmail=commitEmail, 
                hidden=bool(isPrivate),
                version=version,
                commit=False)
        except sqlerrors.CursorError, e:
            raise mint_error.InvalidError(e.msg)
示例#3
0
def _validateNamespace( namespace):
    v = helperfuncs.validateNamespace(namespace)
    if v != True:
        raise mint_error.InvalidNamespace