Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions simplyblock_cli/cli-reference.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,28 @@ commands:
help: "Name"
dest: name
type: str
- name: add-replication
help: Assigns the snapshot replication target cluster
arguments:
- name: "cluster_id"
help: "Cluster id"
dest: cluster_id
type: str
completer: _completer_get_cluster_list
- name: "target_cluster_id"
help: "Target Cluster id"
dest: target_cluster_id
type: str
completer: _completer_get_cluster_list
- name: "--timeout"
help: "Snapshot replication network timeout"
dest: timeout
type: int
default: "3600"
- name: "--target-pool"
help: "Target cluster pool ID or name"
dest: target_pool
type: str
- name: "volume"
help: "Logical volume commands"
aliases:
Expand Down Expand Up @@ -1543,6 +1565,11 @@ commands:
dest: npcs
type: int
default: 0
- name: "--replicate"
help: "Replicate LVol snapshot"
dest: replicate
type: bool
action: store_true
- name: qos-set
help: "Changes QoS settings for an active logical volume"
arguments:
Expand Down Expand Up @@ -1744,6 +1771,52 @@ commands:
help: "Logical volume id"
dest: volume_id
type: str
- name: replication-start
help: "Start snapshot replication taken from lvol"
arguments:
- name: "lvol_id"
help: "Logical volume id"
dest: lvol_id
type: str
- name: "--replication-cluster-id"
help: "Cluster ID of the replication target cluster"
dest: replication_cluster_id
type: str
- name: replication-stop
help: "Stop snapshot replication taken from lvol"
arguments:
- name: "lvol_id"
help: "Logical volume id"
dest: lvol_id
type: str
- name: replication-status
help: "Lists replication status"
arguments:
- name: "cluster_id"
help: "Cluster UUID"
dest: cluster_id
type: str
- name: replication-trigger
help: "Start replication for lvol"
arguments:
- name: "lvol_id"
help: "Logical volume id"
dest: lvol_id
type: str
- name: suspend
help: "Suspend lvol subsystems"
arguments:
- name: "lvol_id"
help: "Logical volume id"
dest: lvol_id
type: str
- name: resume
help: "Resume lvol subsystems"
arguments:
- name: "lvol_id"
help: "Logical volume id"
dest: lvol_id
type: str
- name: "control-plane"
help: "Control plane commands"
aliases:
Expand Down Expand Up @@ -1972,6 +2045,16 @@ commands:
dest: all
type: bool
action: store_true
- name: "--cluster-id"
help: "Filter snapshots by cluster UUID"
dest: cluster_id
type: str
required: false
- name: "--with-details"
help: "List snapshots with replicate and chaining details"
dest: with_details
type: bool
action: store_true
- name: delete
help: "Deletes a snapshot"
arguments:
Expand All @@ -1984,6 +2067,13 @@ commands:
dest: force
type: bool
action: store_true
- name: check
help: "Check a snapshot health"
arguments:
- name: "snapshot_id"
help: "Snapshot id"
dest: snapshot_id
type: str
- name: clone
help: "Provisions a new logical volume from an existing snapshot"
arguments:
Expand All @@ -2000,6 +2090,43 @@ commands:
dest: resize
type: size
default: "0"
- name: replication-status
help: "Lists snapshots replication status"
arguments:
- name: "cluster_id"
help: "Cluster UUID"
dest: cluster_id
type: str
- name: delete-replication-only
help: "Delete replicated version of a snapshot"
arguments:
- name: "snapshot_id"
help: "Snapshot UUID"
dest: snapshot_id
type: str
- name: get
help: "Gets a snapshot information"
arguments:
- name: "snapshot_id"
help: "Snapshot UUID"
dest: snapshot_id
type: str
- name: set
help: "set snapshot db value"
private: true
arguments:
- name: "snapshot_id"
help: "snapshot id"
dest: snapshot_id
type: str
- name: "attr_name"
help: "attr_name"
dest: attr_name
type: str
- name: "attr_value"
help: "attr_value"
dest: attr_value
type: str
- name: "qos"
help: "qos commands"
weight: 700
Expand Down
98 changes: 98 additions & 0 deletions simplyblock_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ def init_cluster(self):
if self.developer_mode:
self.init_cluster__set(subparser)
self.init_cluster__change_name(subparser)
self.init_cluster__add_replication(subparser)


def init_cluster__create(self, subparser):
Expand Down Expand Up @@ -567,6 +568,13 @@ def init_cluster__change_name(self, subparser):
subcommand.add_argument('cluster_id', help='Cluster id', type=str).completer = self._completer_get_cluster_list
subcommand.add_argument('name', help='Name', type=str)

def init_cluster__add_replication(self, subparser):
subcommand = self.add_sub_command(subparser, 'add-replication', 'Assigns the snapshot replication target cluster')
subcommand.add_argument('cluster_id', help='Cluster id', type=str).completer = self._completer_get_cluster_list
subcommand.add_argument('target_cluster_id', help='Target Cluster id', type=str).completer = self._completer_get_cluster_list
argument = subcommand.add_argument('--timeout', help='Snapshot replication network timeout', type=int, default=3600, dest='timeout')
argument = subcommand.add_argument('--target-pool', help='Target cluster pool ID or name', type=str, dest='target_pool')


def init_volume(self):
subparser = self.add_command('volume', 'Logical volume commands', aliases=['lvol',])
Expand All @@ -593,6 +601,12 @@ def init_volume(self):
self.init_volume__migrate(subparser)
self.init_volume__migrate_list(subparser)
self.init_volume__migrate_cancel(subparser)
self.init_volume__replication_start(subparser)
self.init_volume__replication_stop(subparser)
self.init_volume__replication_status(subparser)
self.init_volume__replication_trigger(subparser)
self.init_volume__suspend(subparser)
self.init_volume__resume(subparser)


def init_volume__add(self, subparser):
Expand Down Expand Up @@ -623,6 +637,7 @@ def init_volume__add(self, subparser):
argument = subcommand.add_argument('--data-chunks-per-stripe', help='Erasure coding schema parameter k (distributed raid), default: 1', type=int, default=0, dest='ndcs')
argument = subcommand.add_argument('--parity-chunks-per-stripe', help='Erasure coding schema parameter n (distributed raid), default: 1', type=int, default=0, dest='npcs')
argument = subcommand.add_argument('--allowed-hosts', help='Path to JSON file with host NQNs allowed to access this volume\'s subsystem', type=str, dest='allowed_hosts')
argument = subcommand.add_argument('--replicate', help='Replicate LVol snapshot', dest='replicate', action='store_true')

def init_volume__add_host(self, subparser):
subcommand = self.add_sub_command(subparser, 'add-host', 'Add an allowed host NQN to a volume\'s subsystem')
Expand Down Expand Up @@ -734,6 +749,31 @@ def init_volume__migrate_cancel(self, subparser):
subcommand = self.add_sub_command(subparser, 'migrate-cancel', 'Cancel an active volume migration')
subcommand.add_argument('migration_id', help='Migration id', type=str)

def init_volume__replication_start(self, subparser):
subcommand = self.add_sub_command(subparser, 'replication-start', 'Start snapshot replication taken from lvol')
subcommand.add_argument('lvol_id', help='Logical volume id', type=str)
argument = subcommand.add_argument('--replication-cluster-id', help='Cluster ID of the replication target cluster', type=str, dest='replication_cluster_id')

def init_volume__replication_stop(self, subparser):
subcommand = self.add_sub_command(subparser, 'replication-stop', 'Stop snapshot replication taken from lvol')
subcommand.add_argument('lvol_id', help='Logical volume id', type=str)

def init_volume__replication_status(self, subparser):
subcommand = self.add_sub_command(subparser, 'replication-status', 'Lists replication status')
subcommand.add_argument('cluster_id', help='Cluster UUID', type=str)

def init_volume__replication_trigger(self, subparser):
subcommand = self.add_sub_command(subparser, 'replication-trigger', 'Start replication for lvol')
subcommand.add_argument('lvol_id', help='Logical volume id', type=str)

def init_volume__suspend(self, subparser):
subcommand = self.add_sub_command(subparser, 'suspend', 'Suspend lvol subsystems')
subcommand.add_argument('lvol_id', help='Logical volume id', type=str)

def init_volume__resume(self, subparser):
subcommand = self.add_sub_command(subparser, 'resume', 'Resume lvol subsystems')
subcommand.add_argument('lvol_id', help='Logical volume id', type=str)


def init_control_plane(self):
subparser = self.add_command('control-plane', 'Control plane commands', aliases=['cp','mgmt',])
Expand Down Expand Up @@ -834,8 +874,14 @@ def init_snapshot(self):
self.init_snapshot__add(subparser)
self.init_snapshot__list(subparser)
self.init_snapshot__delete(subparser)
self.init_snapshot__check(subparser)
self.init_snapshot__clone(subparser)
self.init_snapshot__backup(subparser)
self.init_snapshot__replication_status(subparser)
self.init_snapshot__delete_replication_only(subparser)
self.init_snapshot__get(subparser)
if self.developer_mode:
self.init_snapshot__set(subparser)


def init_snapshot__add(self, subparser):
Expand All @@ -852,18 +898,42 @@ def init_snapshot__backup(self, subparser):
def init_snapshot__list(self, subparser):
subcommand = self.add_sub_command(subparser, 'list', 'Lists all snapshots')
argument = subcommand.add_argument('--all', help='List soft deleted snapshots', dest='all', action='store_true')
argument = subcommand.add_argument('--cluster-id', help='Filter snapshots by cluster UUID', type=str, dest='cluster_id', required=False)
argument = subcommand.add_argument('--with-details', help='List snapshots with replicate and chaining details', dest='with_details', action='store_true')

def init_snapshot__delete(self, subparser):
subcommand = self.add_sub_command(subparser, 'delete', 'Deletes a snapshot')
subcommand.add_argument('snapshot_id', help='Snapshot id', type=str)
argument = subcommand.add_argument('--force', help='Force remove', dest='force', action='store_true')

def init_snapshot__check(self, subparser):
subcommand = self.add_sub_command(subparser, 'check', 'Check a snapshot health')
subcommand.add_argument('snapshot_id', help='Snapshot id', type=str)

def init_snapshot__clone(self, subparser):
subcommand = self.add_sub_command(subparser, 'clone', 'Provisions a new logical volume from an existing snapshot')
subcommand.add_argument('snapshot_id', help='Snapshot id', type=str)
subcommand.add_argument('lvol_name', help='Logical volume name', type=str)
argument = subcommand.add_argument('--resize', help='New logical volume size: 10M, 10G, 10(bytes). Can only increase.', type=size_type(), default='0', dest='resize')

def init_snapshot__replication_status(self, subparser):
subcommand = self.add_sub_command(subparser, 'replication-status', 'Lists snapshots replication status')
subcommand.add_argument('cluster_id', help='Cluster UUID', type=str)

def init_snapshot__delete_replication_only(self, subparser):
subcommand = self.add_sub_command(subparser, 'delete-replication-only', 'Delete replicated version of a snapshot')
subcommand.add_argument('snapshot_id', help='Snapshot UUID', type=str)

def init_snapshot__get(self, subparser):
subcommand = self.add_sub_command(subparser, 'get', 'Gets a snapshot information')
subcommand.add_argument('snapshot_id', help='Snapshot UUID', type=str)

def init_snapshot__set(self, subparser):
subcommand = self.add_sub_command(subparser, 'set', 'set snapshot db value')
subcommand.add_argument('snapshot_id', help='snapshot id', type=str)
subcommand.add_argument('attr_name', help='attr_name', type=str)
subcommand.add_argument('attr_value', help='attr_value', type=str)


def init_backup(self):
subparser = self.add_command('backup', 'Backup commands')
Expand Down Expand Up @@ -1213,6 +1283,8 @@ def run(self):
ret = self.cluster__set(sub_command, args)
elif sub_command in ['change-name']:
ret = self.cluster__change_name(sub_command, args)
elif sub_command in ['add-replication']:
ret = self.cluster__add_replication(sub_command, args)
else:
self.parser.print_help()

Expand Down Expand Up @@ -1271,6 +1343,18 @@ def run(self):
ret = self.volume__migrate_list(sub_command, args)
elif sub_command in ['migrate-cancel']:
ret = self.volume__migrate_cancel(sub_command, args)
elif sub_command in ['replication-start']:
ret = self.volume__replication_start(sub_command, args)
elif sub_command in ['replication-stop']:
ret = self.volume__replication_stop(sub_command, args)
elif sub_command in ['replication-status']:
ret = self.volume__replication_status(sub_command, args)
elif sub_command in ['replication-trigger']:
ret = self.volume__replication_trigger(sub_command, args)
elif sub_command in ['suspend']:
ret = self.volume__suspend(sub_command, args)
elif sub_command in ['resume']:
ret = self.volume__resume(sub_command, args)
else:
self.parser.print_help()

Expand Down Expand Up @@ -1316,10 +1400,24 @@ def run(self):
ret = self.snapshot__list(sub_command, args)
elif sub_command in ['delete']:
ret = self.snapshot__delete(sub_command, args)
elif sub_command in ['check']:
ret = self.snapshot__check(sub_command, args)
elif sub_command in ['clone']:
ret = self.snapshot__clone(sub_command, args)
elif sub_command in ['backup']:
ret = self.snapshot__backup(sub_command, args)
elif sub_command in ['replication-status']:
ret = self.snapshot__replication_status(sub_command, args)
elif sub_command in ['delete-replication-only']:
ret = self.snapshot__delete_replication_only(sub_command, args)
elif sub_command in ['get']:
ret = self.snapshot__get(sub_command, args)
elif sub_command in ['set']:
if not self.developer_mode:
print("This command is private.")
ret = False
else:
ret = self.snapshot__set(sub_command, args)
else:
self.parser.print_help()

Expand Down
Loading
Loading