From 6b0b511e914192f9ab61af3dec87d829cfab37c8 Mon Sep 17 00:00:00 2001 From: nicholasyang Date: Wed, 26 Jun 2024 17:35:36 +0800 Subject: [PATCH] Dev: ui_corosync: add subcommand 'crm corosync link add' (jsc#PED-8083) --- crmsh/ui_corosync.py | 33 ++++++++++++++++++++++++++---- test/unittests/test_ui_corosync.py | 28 ++++++++++++------------- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/crmsh/ui_corosync.py b/crmsh/ui_corosync.py index 68ea5b707..9173f98db 100644 --- a/crmsh/ui_corosync.py +++ b/crmsh/ui_corosync.py @@ -57,12 +57,13 @@ class LinkArgumentParser: class SyntaxException(Exception): pass - def parse(self, args: typing.Sequence[str]): + def parse(self, parse_linknumber: bool, args: typing.Sequence[str]): if not args: raise LinkArgumentParser.SyntaxException('linknumber is required') i = 0 - self.linknumber = self.__parse_linknumber(args, i) - i += 1 + if parse_linknumber: + self.linknumber = self.__parse_linknumber(args, i) + i += 1 while i < len(args): if args[i] == 'options': i += 1 @@ -147,7 +148,7 @@ def do_update(self, context, *argv): logger.error('Corosync is not using knet transport') return False try: - args = LinkArgumentParser().parse(argv) + args = LinkArgumentParser().parse(True, argv) except LinkArgumentParser.SyntaxException as e: logger.error('%s', str(e)) print('Usage: link update [= ...] [options