How to use the asu.request.Request function in asu

To help you get started, we’ve selected a few asu examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aparcar / attendedsysupgrade-server / asu / build_request.py View on Github external
from http import HTTPStatus
from sys import getsizeof

from asu.utils.common import get_hash, get_packages_hash, get_request_hash
from asu.request import Request


class BuildRequest(Request):
    def __init__(self, config, db):
        super().__init__(config, db)

    def _process_request(self):
        self.log.debug("request_json: %s", self.request_json)

        # if request_hash is available check the database directly
        if "request_hash" in self.request_json:
            self.request = self.database.check_request_hash(
                self.request_json["request_hash"]
            )

            if not self.request:
                self.response_status = HTTPStatus.NOT_FOUND
                return self.respond()
            else:
github aparcar / attendedsysupgrade-server / asu / upgrade_check.py View on Github external
from http import HTTPStatus
import logging
import json

from asu.request import Request
from asu.utils.common import get_hash


class UpgradeCheck(Request):
    def __init__(self, config, db):
        super().__init__(config, db)
        self.log = logging.getLogger(__name__)

    def _process_request(self):
        if "distro" not in self.request_json:
            self.response_status = HTTPStatus.PRECONDITION_FAILED  # 412
            self.response_header["X-Missing-Param"] = "distro"
            return self.respond()
        else:
            bad_request = self.check_bad_distro()
            if bad_request:
                return bad_request
            self.log.debug("passed distro check")

        if "target" not in self.request_json: