Esempio n. 1
0
    def _post(self, transaction, changed_by):
        # a Post here creates a new rule
        form = RuleForm()
        releaseNames = db.releases.getReleaseNames()
        form.mapping.choices = [(item['name'],item['name']) for item in releaseNames]
        form.mapping.choices.insert(0, ('', 'NULL' ) )
        if not form.validate():
            self.log.debug(form.errors)
            return Response(status=400, response=form.errors)

        what = dict(backgroundRate=form.backgroundRate.data,
                mapping=form.mapping.data,
                priority=form.priority.data,
                product = form.product.data,
                version = form.version.data,
                buildID = form.build_id.data,
                channel = form.channel.data,
                locale = form.locale.data,
                distribution = form.distribution.data,
                buildTarget = form.build_target.data,
                osVersion = form.os_version.data,
                distVersion = form.dist_version.data,
                comment = form.comment.data,
                update_type = form.update_type.data,
                headerArchitecturerch = form.header_arch.data)
        rule_id = db.rules.addRule(changed_by=changed_by, what=what,
            transaction=transaction)
        return Response(status=200, response=rule_id)
Esempio n. 2
0
    def _post(self, transaction, changed_by):
        # a Post here creates a new rule
        form = RuleForm()
        releaseNames = dbo.releases.getReleaseNames()
        form.mapping.choices = [(item['name'], item['name'])
                                for item in releaseNames]
        form.mapping.choices.insert(0, ('', 'NULL'))

        if not form.validate():
            self.log.warning("Bad input: %s", form.errors)
            return Response(status=400, response=json.dumps(form.errors))

        what = dict(backgroundRate=form.backgroundRate.data,
                    mapping=form.mapping.data,
                    fallbackMapping=form.fallbackMapping.data,
                    priority=form.priority.data,
                    alias=form.alias.data,
                    product=form.product.data,
                    version=form.version.data,
                    buildID=form.buildID.data,
                    channel=form.channel.data,
                    locale=form.locale.data,
                    distribution=form.distribution.data,
                    buildTarget=form.buildTarget.data,
                    osVersion=form.osVersion.data,
                    systemCapabilities=form.systemCapabilities.data,
                    distVersion=form.distVersion.data,
                    whitelist=form.whitelist.data,
                    comment=form.comment.data,
                    update_type=form.update_type.data,
                    headerArchitecture=form.headerArchitecture.data)
        rule_id = dbo.rules.insert(changed_by=changed_by,
                                   transaction=transaction,
                                   **what)
        return Response(status=200, response=str(rule_id))
Esempio n. 3
0
    def _post(self, transaction, changed_by):
        # a Post here creates a new rule
        form = RuleForm()
        releaseNames = dbo.releases.getReleaseNames()
        form.mapping.choices = [(item['name'], item['name'])
                                for item in releaseNames]
        form.mapping.choices.insert(0, ('', 'NULL'))

        if not form.validate():
            self.log.warning("Bad input: %s", form.errors)
            return Response(status=400, response=json.dumps(form.errors))

        what = dict(
            backgroundRate=form.backgroundRate.data,
            mapping=form.mapping.data,
            fallbackMapping=form.fallbackMapping.data,
            priority=form.priority.data,
            alias=form.alias.data,
            product=form.product.data,
            version=form.version.data,
            buildID=form.buildID.data,
            channel=form.channel.data,
            locale=form.locale.data,
            distribution=form.distribution.data,
            buildTarget=form.buildTarget.data,
            osVersion=form.osVersion.data,
            systemCapabilities=form.systemCapabilities.data,
            distVersion=form.distVersion.data,
            whitelist=form.whitelist.data,
            comment=form.comment.data,
            update_type=form.update_type.data,
            headerArchitecture=form.headerArchitecture.data)
        rule_id = dbo.rules.insert(
            changed_by=changed_by, transaction=transaction, **what)
        return Response(status=200, response=str(rule_id))
Esempio n. 4
0
    def _post(self, transaction, changed_by):
        # a Post here creates a new rule
        form = RuleForm()
        releaseNames = retry(db.releases.getReleaseNames, sleeptime=5, retry_exceptions=(SQLAlchemyError,))
        form.mapping.choices = [(item['name'],item['name']) for item in releaseNames]
        form.mapping.choices.insert(0, ('', 'NULL' ) )
        if not form.validate():
            self.log.debug(form.errors)
            return Response(status=400, response=form.errors)

        what = dict(throttle=form.throttle.data,   
                mapping=form.mapping.data,
                priority=form.priority.data,
                product = form.product.data,
                version = form.version.data,
                build_id = form.build_id.data,
                channel = form.channel.data,
                locale = form.locale.data,
                distribution = form.distribution.data,
                build_target = form.build_target.data,
                os_version = form.os_version.data,
                dist_version = form.dist_version.data,
                comment = form.comment.data,
                update_type = form.update_type.data,
                header_arch = form.header_arch.data)
        rule_id = retry(db.rules.addRule, sleeptime=5, retry_exceptions=(SQLAlchemyError,),
                kwargs=dict(changed_by=changed_by, what=what, transaction=transaction))
        return Response(status=200, response=rule_id)
Esempio n. 5
0
    def _post(self, transaction, changed_by):
        # a Post here creates a new rule
        form = RuleForm()
        releaseNames = dbo.releases.getReleaseNames()
        form.mapping.choices = [(item['name'], item['name'])
                                for item in releaseNames]
        form.mapping.choices.insert(0, ('', 'NULL'))

        if not form.validate():
            cef_event("Bad input", CEF_WARN, errors=form.errors)
            return Response(status=400, response=json.dumps(form.errors))

        what = dict(backgroundRate=form.backgroundRate.data,
                    mapping=form.mapping.data,
                    priority=form.priority.data,
                    product=form.product.data,
                    version=form.version.data,
                    buildID=form.buildID.data,
                    channel=form.channel.data,
                    locale=form.locale.data,
                    distribution=form.distribution.data,
                    buildTarget=form.buildTarget.data,
                    osVersion=form.osVersion.data,
                    distVersion=form.distVersion.data,
                    comment=form.comment.data,
                    update_type=form.update_type.data,
                    headerArchitecture=form.headerArchitecture.data)
        rule_id = dbo.rules.addRule(changed_by=changed_by,
                                    what=what,
                                    transaction=transaction)
        return Response(status=200, response=str(rule_id))
Esempio n. 6
0
    def _post(self, transaction, changed_by):
        # a Post here creates a new rule
        form = RuleForm()
        releaseNames = dbo.releases.getReleaseNames()
        form.mapping.choices = [(item["name"], item["name"]) for item in releaseNames]
        form.mapping.choices.insert(0, ("", "NULL"))

        if not form.validate():
            cef_event("Bad input", CEF_WARN, errors=form.errors)
            return Response(status=400, response=json.dumps(form.errors))

        what = dict(
            backgroundRate=form.backgroundRate.data,
            mapping=form.mapping.data,
            priority=form.priority.data,
            product=form.product.data,
            version=form.version.data,
            buildID=form.buildID.data,
            channel=form.channel.data,
            locale=form.locale.data,
            distribution=form.distribution.data,
            buildTarget=form.buildTarget.data,
            osVersion=form.osVersion.data,
            distVersion=form.distVersion.data,
            comment=form.comment.data,
            update_type=form.update_type.data,
            headerArchitecture=form.headerArchitecture.data,
        )
        rule_id = dbo.rules.addRule(changed_by=changed_by, what=what, transaction=transaction)
        return Response(status=200, response=str(rule_id))
Esempio n. 7
0
    def _post(self, transaction, changed_by):
        # a Post here creates a new rule
        form = RuleForm()
        releaseNames = dbo.releases.getReleaseNames()
        form.mapping.choices = [(item['name'], item['name'])
                                for item in releaseNames]
        form.mapping.choices.insert(0, ('', 'NULL'))
        # print "request data: ", request.data
        # print "request.data Type: ", type(request.data)
        # print "request json: ", request.json
        # print "request.json Type: ", type(request.json)
        '''if not form.validate():
            self.log.warning("Bad input: %s", form.errors)
            return Response(status=400, response=json.dumps(form.errors))'''

        # Replaces wtfForms validations
        nullable_field_dict = dict()
        for key in request.json:
            nullable_field_dict[
                key] = None if request.json[key] == '' else request.json[key]

        what = dict(
            backgroundRate=nullable_field_dict.get('backgroundRate'),
            mapping=nullable_field_dict.get('mapping'),
            fallbackMapping=nullable_field_dict.get('fallbackMapping'),
            priority=nullable_field_dict.get('priority'),
            alias=nullable_field_dict.get('alias'),
            product=nullable_field_dict.get('product'),
            version=nullable_field_dict.get('version'),
            buildID=nullable_field_dict.get('buildID'),
            channel=nullable_field_dict.get('channel'),
            locale=nullable_field_dict.get('locale'),
            distribution=nullable_field_dict.get('distribution'),
            buildTarget=nullable_field_dict.get('buildTarget'),
            osVersion=nullable_field_dict.get('osVersion'),
            systemCapabilities=nullable_field_dict.get('systemCapabilities'),
            distVersion=nullable_field_dict.get('distVersion'),
            whitelist=nullable_field_dict.get('whitelist'),
            comment=nullable_field_dict.get('comment'),
            update_type=nullable_field_dict.get('update_type'),
            headerArchitecture=nullable_field_dict.get('headerArchitecture'))
        """what = dict(backgroundRate=form.backgroundRate.data,
                    mapping=form.mapping.data,
                    fallbackMapping=form.fallbackMapping.data,
                    priority=form.priority.data,
                    alias=form.alias.data,
                    product=form.product.data,
                    version=form.version.data,
                    buildID=form.buildID.data,
                    channel=form.channel.data,
                    locale=form.locale.data,
                    distribution=form.distribution.data,
                    buildTarget=form.buildTarget.data,
                    osVersion=form.osVersion.data,
                    systemCapabilities=form.systemCapabilities.data,
                    distVersion=form.distVersion.data,
                    whitelist=form.whitelist.data,
                    comment=form.comment.data,
                    update_type=form.update_type.data,
                    headerArchitecture=form.headerArchitecture.data)"""
        rule_id = dbo.rules.insert(changed_by=changed_by,
                                   transaction=transaction,
                                   **what)
        return Response(status=200, response=str(rule_id))