// Copyright (c) Vitaliy Filippov, 2019+ // License: VNPL-1.1 (see README.md for details) /** * CLI tool and also a library for administrative tasks */ #include #include #include "cli.h" #include "epoll_manager.h" #include "cluster_client.h" #include "pg_states.h" #include "str_util.h" static const char *exe_name = NULL; static const char* help_text = "Vitastor command-line tool " VERSION "\n" "(c) Vitaliy Filippov, 2019+ (VNPL-1.1)\n" "\n" "COMMANDS:\n" "\n" "vitastor-cli status\n" " Show cluster status\n" "\n" "vitastor-cli df\n" " Show pool space statistics\n" "\n" "vitastor-cli ls [-l] [-p POOL] [--sort FIELD] [-r] [-n N] [ ...]\n" " List images (only matching patterns if passed).\n" " -p|--pool POOL Filter images by pool ID or name\n" " -l|--long Also report allocated size and I/O statistics\n" " --del Also include delete operation statistics\n" " --sort FIELD Sort by specified field (name, size, used_size, _)\n" " -r|--reverse Sort in descending order\n" " -n|--count N Only list first N items\n" "\n" "vitastor-cli create -s|--size [-p|--pool ] [--parent [@]] \n" " Create an image. You may use K/M/G/T suffixes for . If --parent is specified,\n" " a copy-on-write image clone is created. Parent must be a snapshot (readonly image).\n" " Pool must be specified if there is more than one pool.\n" "\n" "vitastor-cli create --snapshot [-p|--pool ] \n" "vitastor-cli snap-create [-p|--pool ] @\n" " Create a snapshot of image . May be used live if only a single writer is active.\n" "\n" "vitastor-cli modify [--rename ] [--resize ] [--readonly | --readwrite] [-f|--force] [--down-ok]\n" " Rename, resize image or change its readonly status. Images with children can't be made read-write.\n" " If the new size is smaller than the old size, extra data will be purged.\n" " You should resize file system in the image, if present, before shrinking it.\n" " -f|--force Proceed with shrinking or setting readwrite flag even if the image has children.\n" " --down-ok Proceed with shrinking even if some data will be left on unavailable OSDs.\n" "\n" "vitastor-cli rm [] [--writers-stopped] [--down-ok]\n" " Remove or all layers between and ( must be a child of ),\n" " rebasing all their children accordingly. --writers-stopped allows merging to be a bit\n" " more effective in case of a single 'slim' read-write child and 'fat' removed parent:\n" " the child is merged into parent and parent is renamed to child in that case.\n" " In other cases parent layers are always merged into children.\n" " Other options:\n" " --down-ok Continue deletion/merging even if some data will be left on unavailable OSDs.\n" "\n" "vitastor-cli flatten \n" " Flatten a layer, i.e. merge data and detach it from parents.\n" "\n" "vitastor-cli rm-data --pool --inode [--wait-list] [--min-offset ]\n" " Remove inode data without changing metadata.\n" " --wait-list Retrieve full objects listings before starting to remove objects.\n" " Requires more memory, but allows to show correct removal progress.\n" " --min-offset Purge only data starting with specified offset.\n" "\n" "vitastor-cli merge-data [--target ]\n" " Merge layer data without changing metadata. Merge .. to .\n" " must be a child of and may be one of the layers between\n" " and , including and .\n" "\n" "vitastor-cli describe [OPTIONS]\n" " Describe unclean object locations in the cluster. Options:\n" " --osds \n" " Only list objects from primary OSD(s) .\n" " --object-state \n" " Only list objects in given state(s). State(s) may include:\n" " degraded, misplaced, incomplete, corrupted, inconsistent.\n" " --pool \n" " Only list objects in the given pool.\n" " --pg \n" " Only list objects in the given PG of the pool.\n" " --inode, --min-inode, --max-inode\n" " Restrict listing to specific inode numbers.\n" " --min-offset, --max-offset\n" " Restrict listing to specific offsets inside inodes.\n" "\n" "vitastor-cli fix [--objects ] [--bad-osds ] [--part ] [--check no]\n" " Fix inconsistent objects in the cluster by deleting some copies.\n" " --objects \n" " Objects to fix, either in plain text or JSON format. If not specified,\n" " object list will be read from STDIN in one of the same formats.\n" " Plain text format: 0x:0x 0x:0x ...\n" " JSON format: [{\"inode\":\"0x...\",\"stripe\":\"0x...\"},...]\n" " --bad-osds \n" " Remove inconsistent copies/parts of objects from these OSDs, effectively\n" " marking them bad and allowing Vitastor to recover objects from other copies.\n" " --part \n" " Only remove EC part (from 0 to pg_size-1), required for extreme\n" " edge cases where one OSD has multiple parts of a EC object.\n" " --check no\n" " Do not recheck that requested objects are actually inconsistent,\n" " delete requested copies/parts anyway.\n" "\n" "vitastor-cli alloc-osd\n" " Allocate a new OSD number and reserve it by creating empty /osd/stats/ key.\n" "\n" "vitastor-cli rm-osd [--force] [--allow-data-loss] [--dry-run] [osd_id...]\n" " Remove metadata and configuration for specified OSD(s) from etcd.\n" " Refuses to remove OSDs with data without --force and --allow-data-loss.\n" " With --dry-run only checks if deletion is possible without data loss and\n" " redundancy degradation.\n" "\n" "vitastor-cli create-pool|pool-create (-s |--ec +) -n [OPTIONS]\n" " Create a pool. Required parameters:\n" " -s|--pg_size R Number of replicas for replicated pools\n" " --ec N+K Number of data (N) and parity (K) chunks for erasure-coded pools\n" " -n|--pg_count N PG count for the new pool (start with 10*/pg_size rounded to a power of 2)\n" " Optional parameters:\n" " --pg_minsize R or N+K minus number of failures to tolerate without downtime\n" " --failure_domain host Failure domain: host, osd or a level from placement_levels. Default: host\n" " --root_node Put pool only on child OSDs of this placement tree node\n" " --osd_tags [,]... Put pool only on OSDs tagged with all specified tags\n" " --block_size 128k Put pool only on OSDs with this data block size\n" " --bitmap_granularity 4k Put pool only on OSDs with this logical sector size\n" " --immediate_commit none Put pool only on OSDs with this or larger immediate_commit (none < small < all)\n" " --level_placement Use additional failure domain rules (example: \"dc=112233\")\n" " --raw_placement Specify raw PG generation rules (see documentation for details)\n" " --primary_affinity_tags tags Prefer to put primary copies on OSDs with all specified tags\n" " --scrub_interval