Skip to content

Commit 11e262d

Browse files
authored
Merge pull request #1300 from liangxin1300/20240109_crm_configure_service_stopped
[crmsh-4.6] Dev: ui_context: Skip querying CIB when in a sublevel or help command
2 parents f195a89 + 0583b54 commit 11e262d

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

crmsh/constants.py

+2
Original file line numberDiff line numberDiff line change
@@ -511,4 +511,6 @@
511511
RSC_ROLE_PROMOTED_LEGACY = "Master"
512512
RSC_ROLE_UNPROMOTED_LEGACY = "Slave"
513513
PCMK_VERSION_DEFAULT = "2.0.0"
514+
515+
NON_FUNCTIONAL_COMMANDS = ('help', 'cd', 'ls', 'quit', 'up')
514516
# vim:ts=4:sw=4:et:

crmsh/ui_context.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ def run(self, line):
8282
cmd = True
8383
break
8484
if cmd:
85+
if self.command_name not in constants.NON_FUNCTIONAL_COMMANDS:
86+
entry = self.current_level()
87+
if 'requires' in dir(entry) and not entry.requires():
88+
self.fatal_error("Missing requirements")
8589
utils.check_user_access(self.current_level().name)
8690
rv = self.execute_command() is not False
8791
except (ValueError, IOError) as e:
@@ -239,8 +243,7 @@ def previous_level(self):
239243
def enter_level(self, level):
240244
'''
241245
Pushes an instance of the given UILevel
242-
subclass onto self.stack. Checks prerequirements
243-
for the level (if any).
246+
subclass onto self.stack.
244247
'''
245248
# on entering new level we need to set the
246249
# interactive option _before_ creating the level
@@ -251,8 +254,6 @@ def enter_level(self, level):
251254
self._in_transit = True
252255

253256
entry = level()
254-
if 'requires' in dir(entry) and not entry.requires():
255-
self.fatal_error("Missing requirements")
256257
self.stack.append(entry)
257258
self.clear_readline_cache()
258259

@@ -320,7 +321,8 @@ def up(self):
320321
'''
321322
ok = True
322323
if len(self.stack) > 1:
323-
ok = self.current_level().end_game(no_questions_asked=self._in_transit) is not False
324+
if self.command_name and self.command_name not in constants.NON_FUNCTIONAL_COMMANDS:
325+
ok = self.current_level().end_game(no_questions_asked=self._in_transit) is not False
324326
self.stack.pop()
325327
self.clear_readline_cache()
326328
return ok
@@ -341,7 +343,9 @@ def quit(self, rc=0):
341343
'''
342344
Exit from the top level
343345
'''
344-
ok = self.current_level().end_game()
346+
ok = True
347+
if self.command_name and self.command_name not in constants.NON_FUNCTIONAL_COMMANDS:
348+
ok = self.current_level().end_game()
345349
if options.interactive and not options.batch:
346350
if constants.need_reset:
347351
utils.ext_cmd("reset")

test/features/bootstrap_options.feature

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Feature: crmsh bootstrap process - options
1414

1515
@clean
1616
Scenario: Check help output
17+
When Run "crm configure help primitive" OK
1718
When Run "crm -h" on "hanode1"
1819
Then Output is the same with expected "crm" help output
1920
When Run "crm cluster init -h" on "hanode1"

0 commit comments

Comments
 (0)