From ecf303df4e569a9de65705dd267187700e6e4b79 Mon Sep 17 00:00:00 2001 From: Rene Peinthor Date: Thu, 20 May 2021 12:45:11 +0200 Subject: [PATCH] rsc-cmds: add make available command --- linstor_client/commands/commands.py | 4 ++++ linstor_client/commands/rsc_cmds.py | 32 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/linstor_client/commands/commands.py b/linstor_client/commands/commands.py index ffbfa7f..752815c 100644 --- a/linstor_client/commands/commands.py +++ b/linstor_client/commands/commands.py @@ -120,6 +120,10 @@ class Create(object): LONG = "create" SHORT = "c" + class MakeAvailable(object): + LONG = "make-available" + SHORT = "mkavail" + class AutoPlace(object): LONG = "auto-place" SHORT = "ap" diff --git a/linstor_client/commands/rsc_cmds.py b/linstor_client/commands/rsc_cmds.py index 8fb67b2..3e3bd7d 100644 --- a/linstor_client/commands/rsc_cmds.py +++ b/linstor_client/commands/rsc_cmds.py @@ -59,6 +59,7 @@ def __init__(self, state_service): def setup_commands(self, parser): subcmds = [ Commands.Subcommands.Create, + Commands.Subcommands.MakeAvailable, Commands.Subcommands.List, Commands.Subcommands.ListVolumes, Commands.Subcommands.Delete, @@ -131,6 +132,32 @@ def setup_commands(self, parser): help='Name of the resource definition').completer = self.resource_dfn_completer p_new_res.set_defaults(func=self.create, allowed_states=[DefaultState, ResourceCreateTransactionState]) + # make available + p_mkavial = res_subp.add_parser( + Commands.Subcommands.MakeAvailable.LONG, + aliases=[Commands.Subcommands.MakeAvailable.SHORT], + description='Make a resource available on a node, noop if already exists.') + p_mkavial.add_argument( + '--diskful', + action="store_true", + help='Make the resource diskful on the node.' + ) + p_mkavial.add_argument( + '-l', '--layer-list', + type=self.layer_data_check, + help="Comma separated layer list, order is from left to right top-down " + "This means the top most layer is on the left. " + "Possible layers are: " + ",".join(linstor.Linstor.layer_list())) + p_mkavial.add_argument( + 'node_name', + type=str, + help='Name of the node to deploy the resource').completer = self.node_completer + p_mkavial.add_argument( + 'resource_name', + type=str, + help='Name of the resource definition').completer = self.resource_dfn_completer + p_mkavial.set_defaults(func=self.make_available) + # remove-resource p_rm_res = res_subp.add_parser( Commands.Subcommands.Delete.LONG, @@ -485,6 +512,11 @@ def create(self, args): replies = self._linstor.resource_create(rscs, async_flag) return self.handle_replies(args, replies) + def make_available(self, args): + replies = self.get_linstorapi().resource_make_available( + args.node_name, args.resource_name, args.diskful, args.layer_list) + return self.handle_replies(args, replies) + def delete(self, args): async_flag = vars(args)["async"]