Beispiel #1
0
def list_volumes(request):
    """Get the list of mounted volumes."""
    volumes = podutils.list_volumes()
    volumes_out = [{"type": "clone",
                    "name": volume.name,
                    "mount_point": path,
                    "size": size,
                    "size_type": "",
                    "snapshot": False}
                   for path, volume, size in volumes]
    return volumes_out
Beispiel #2
0
def interactive_snapshot_and_get_volumes(bucket=DEFAULT_BUCKET):
    """Take a Rok snapshot of the Pod with interactive progress."""
    log.info("Taking a snapshot of the Pod's volumes...")
    task = snapshot_pod(bucket=bucket, wait=True, interactive=True)

    # FIXME: Duplicated code from rpc.nb.list_volumes
    vols = [{
        "type": "clone",
        "name": volume.name,
        "mount_point": path,
        "size": size,
        "size_type": "",
        "snapshot": False
    } for path, volume, size in podutils.list_volumes()]

    return replace_cloned_volumes(bucket=task["bucket"],
                                  obj=task["result"]["event"]["object"],
                                  version=task["result"]["event"]["version"],
                                  volumes=vols)
Beispiel #3
0
    def list_volumes(args, logger):
        """This function gets invoked by the sub-command 'list'."""
        volumes = podutils.list_volumes()

        if args.output == "table":
            headers = ["Mount Path", "Volume Name", "PVC Name", "Volume Size"]
            data = [(path, volume.name,
                     volume.persistent_volume_claim.claim_name, size)
                    for path, volume, size in volumes]
            logger.info(tabulate.tabulate(data, headers=headers))
        else:
            volumes_out = [{"type": "clone",
                            "name": volume.name,
                            "mount_point": path,
                            "size": size,
                            "size_type": "",
                            "snapshot": False}
                           for path, volume, size in volumes]
            print(json.dumps(volumes_out,
                             sort_keys=True,
                             indent=3,
                             separators=(",", ": ")))