Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev: help: Support '--help' option for cluster properties #1643

Merged
Merged
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
3 changes: 2 additions & 1 deletion crmsh/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,8 @@ def do_help(self, context, *args):
levels = levels[1:] # drop the 1st element "root"
levels.extend(args)
h = help_module.help_contextual(levels)
h.paginate()
if h:
h.paginate()
context.command_name = ""

def get_completions(self):
Expand Down
15 changes: 15 additions & 0 deletions crmsh/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from . import config
from . import clidisplay
from . import log
from . import ra


logger = log.setup_logger(__name__)
Expand Down Expand Up @@ -313,6 +314,10 @@ def _is_level(levels: typing.Sequence[str]):
return node is not None and node.children


def _is_property(levels: typing.Sequence[str]):
return len(levels) == 3 and levels[0] == 'configure' and levels[1] == 'property'


def help_contextual(levels: typing.Sequence[str]):
"""
Returns contextual help
Expand All @@ -324,6 +329,16 @@ def help_contextual(levels: typing.Sequence[str]):
return help_topic(levels[0])
elif _is_command(levels) or _is_level(levels):
return help_command(levels[0:])
elif _is_property(levels):
agent = ra.get_properties_meta()
if agent:
all_properties = agent.params()
property_name = levels[-1]
if property_name in all_properties:
print(agent.meta_parameter(property_name))
else:
raise ValueError(f"Unknown property '{property_name}'")
return None
else:
topic = levels[0].lower()
t = fuzzy_get(_TOPICS, topic)
Expand Down
3 changes: 3 additions & 0 deletions crmsh/ui_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,9 @@ def do_rsc_ticket(self, context, *args):
def do_property(self, context, *args):
"usage: property [$id=<set_id>] <option>=<value>"
self.__override_lower_level_attrs(*args)
if not args:
utils.multicolumn(ra.get_properties_list())
return
return self.__conf_object(context.get_command_name(), *args)

@command.skill_level('administrator')
Expand Down
7 changes: 7 additions & 0 deletions doc/crm.8.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3612,6 +3612,12 @@ When setting the +maintenance-mode+ property, it will
inform the user if there are nodes or resources that
have the +maintenance+ property.

If no property name is passed to the command, the list of known
cluster properties is printed.

To print one property's help, use the +--help+ option; Or use <Tab>
to complete the help text for the property on interactive mode.

For more information on rule expressions, see
<<topics.Syntax.RuleExpressions,Syntax: Rule expressions>>.

Expand All @@ -3621,6 +3627,7 @@ property [<set_id>:] [rule ...] <option>=<value> [<option>=<value> ...]
...............
Example:
...............
property stonith-enabled --help
property stonith-enabled=true
property rule date spec years=2014 stonith-enabled=false
...............
Expand Down