Example #1
0
 def test_packageNEVRA(self):
     """Return a string with the NVRA or NEVRA"""
     epoch_0 = {"arch": "noarch",
                "epoch": 0,
                "name": "basesystem",
                "release": "7.el7",
                "version": "10.0"}
     epoch_3 = {"arch": "noarch",
                "epoch": 3,
                "name": "basesystem",
                "release": "7.el7",
                "version": "10.0"}
     self.assertEqual(packageNEVRA(epoch_0), "basesystem-10.0-7.el7.noarch")
     self.assertEqual(packageNEVRA(epoch_3), "basesystem-3:10.0-7.el7.noarch")
Example #2
0
def blueprints_depsolve(socket_path, api_version, args, show_json=False):
    """Display the packages needed to install the blueprint

    :param socket_path: Path to the Unix socket to use for API communication
    :type socket_path: str
    :param api_version: Version of the API to talk to. eg. "0"
    :type api_version: str
    :param args: List of remaining arguments from the cmdline
    :type args: list of str
    :param show_json: Set to True to show the JSON output instead of the human readable output
    :type show_json: bool

    blueprints depsolve <blueprint,...>    Display the packages needed to install the blueprint.
    """
    api_route = client.api_url(
        api_version, "/blueprints/depsolve/%s" % (",".join(argify(args))))
    result = client.get_url_json(socket_path, api_route)

    if show_json:
        print(json.dumps(result, indent=4))
        return 0

    for blueprint in result["blueprints"]:
        if blueprint["blueprint"].get("version", ""):
            print("blueprint: %s v%s" % (blueprint["blueprint"]["name"],
                                         blueprint["blueprint"]["version"]))
        else:
            print("blueprint: %s" % (blueprint["blueprint"]["name"]))
        for dep in blueprint["dependencies"]:
            print("    " + packageNEVRA(dep))

    return 0
Example #3
0
def compose_info(socket_path, api_version, args, show_json=False, testmode=0):
    """Return detailed information about the compose

    :param socket_path: Path to the Unix socket to use for API communication
    :type socket_path: str
    :param api_version: Version of the API to talk to. eg. "0"
    :type api_version: str
    :param args: List of remaining arguments from the cmdline
    :type args: list of str
    :param show_json: Set to True to show the JSON output instead of the human readable output
    :type show_json: bool
    :param testmode: unused in this function
    :type testmode: int

    compose info <uuid>

    This returns information about the compose, including the blueprint and the dependencies.
    """
    if len(args) == 0:
        log.error("info is missing the compose build id")
        return 1

    api_route = client.api_url(api_version, "/compose/info/%s" % args[0])
    result = client.get_url_json(socket_path, api_route)
    if show_json:
        print(json.dumps(result, indent=4))
        return 0

    for err in result.get("errors", []):
        log.error(err)

    if result.get("errors", []):
        return 1

    if result["image_size"] > 0:
        image_size = str(result["image_size"])
    else:
        image_size = ""


    print("%s %-8s %-15s %s %-16s %s" % (result["id"],
                                         result["queue_status"],
                                         result["blueprint"]["name"],
                                         result["blueprint"]["version"],
                                         result["compose_type"],
                                         image_size))
    print("Packages:")
    for p in result["blueprint"]["packages"]:
        print("    %s-%s" % (p["name"], p["version"]))

    print("Modules:")
    for m in result["blueprint"]["modules"]:
        print("    %s-%s" % (m["name"], m["version"]))

    print("Dependencies:")
    for d in result["deps"]["packages"]:
        print("    " + packageNEVRA(d))