How to use the asu.utils.common.get_request_hash 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 / views.py View on Github external
"xz-utils",
        "zlib-dev",
    ]

    packages_hash = get_packages_hash(packages)
    database.insert_packages_hash(packages_hash, packages)

    params = {
        "distro": "openwrt",
        "version": config.get("openwrt").get("latest"),
        "target": "x86/64",
        "profile": "Generic",
        "packages_hash": packages_hash,
    }

    params["request_hash"] = get_request_hash(params)

    database.insert_dict("requests", params)
github aparcar / attendedsysupgrade-server / asu / build_request.py View on Github external
self.response_status = HTTPStatus.NOT_FOUND
                return self.respond()
            else:
                return self.return_status()

        # TODO check for profile or board

        # generic approach for
        # https://github.com/aparcar/attendedsysupgrade-server/issues/91
        self.request_json["board"] = self.request_json["board"].replace(",", "_")

        self.request_json["profile"] = self.request_json[
            "board"
        ]  # TODO fix this workaround

        request_hash = get_request_hash(self.request_json)
        request_database = self.database.check_request_hash(request_hash)

        # if found return instantly the status
        if request_database:
            self.log.debug(
                "found image in database: %s", request_database["request_status"]
            )
            self.request = request_database
            return self.return_status()
        else:
            self.request["request_hash"] = request_hash
            self.response_json["request_hash"] = self.request["request_hash"]

        # if not perform various checks to see if the request is acutally valid

        # validate distro and version
github aparcar / attendedsysupgrade-server / asu / views.py View on Github external
def build_all():
    """Build all profiles of openwrt latest stable"""
    for profile in database.get_all_profiles(
        "openwrt", config.get("openwrt").get("latest")
    ):
        target, profile = profile
        params = {
            "distro": "openwrt",
            "version": config.get("openwrt").get("latest"),
            "target": target,
            "profile": profile,
        }
        params["request_hash"] = get_request_hash(params)
        database.insert_dict("requests", params)