-
Notifications
You must be signed in to change notification settings - Fork 94
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: parse: Consider compatibility for role when complete operation actions with advised values #1083
Dev: parse: Consider compatibility for role when complete operation actions with advised values #1083
Conversation
Hi @gao-yan , please take a look at this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The basic idea looks good to me. Apart from a nitpicking in below, I added some comments on the context of this part of the code:
crmsh/utils.py
Outdated
@@ -3062,6 +3062,14 @@ def is_ocf_1_1_cib_schema_detected(): | |||
return is_larger_than_min_version(cib_factory.get_schema(), constants.SCHEMA_MIN_VER_SUPPORT_OCF_1_1) | |||
|
|||
|
|||
def compatible_role(role1, role2): | |||
master_or_promoted = ("Master", "Promoted") | |||
slave_or_unpromoted = ("Slave", "Unpromoted") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be better to define constants for these role names somewhere and also reuse them in handle_role_for_ocf_1_1()
, for example:
RSC_ROLE_PROMOTED = "Promoted"
RSC_ROLE_UNPROMOTED = "Unpromoted"
RSC_ROLE_PROMOTED_LEGACY = "Master"
RSC_ROLE_UNPROMOTED_LEGACY = "Slave"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
b3a84df
to
0a0bf0a
Compare
@@ -241,8 +241,6 @@ | |||
date_spec_names = '''hours monthdays weekdays yearsdays months \ | |||
weeks years weekyears moon'''.split() | |||
in_range_attrs = ('start', 'end') | |||
roles_names = ('Stopped', 'Started', 'Master', 'Slave') | |||
actions_names = ('start', 'promote', 'demote', 'stop') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete these 2 lines since they are not used
crmsh/ui_resource.py
Outdated
@@ -338,7 +338,7 @@ def do_promote(self, context, rsc): | |||
if not xmlutil.RscState().is_ms_or_promotable_clone(rsc): | |||
logger.error("%s is not a promotable resource", rsc) | |||
return False | |||
role = "Promoted" if config.core.OCF_1_1_SUPPORT else "Master" | |||
role = constants.RSC_ROLE_PROMOTED if config.core.OCF_1_1_SUPPORT else constants.RSC_ROLE_PROMOTED_LEGACY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably this is worth to be functionalized. It's up to you though.
957e606
to
d530fb8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Only other two nitpickings.
crmsh/ui_resource.py
Outdated
@@ -338,7 +338,7 @@ def do_promote(self, context, rsc): | |||
if not xmlutil.RscState().is_ms_or_promotable_clone(rsc): | |||
logger.error("%s is not a promotable resource", rsc) | |||
return False | |||
role = "Promoted" if config.core.OCF_1_1_SUPPORT else "Master" | |||
role = utils.handle_role_for_ocf_1_1("Master") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also use the constant RSC_ROLE_PROMOTED_LEGACY here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed,
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, nice work!
crmsh/ui_resource.py
Outdated
@@ -367,7 +367,7 @@ def do_demote(self, context, rsc): | |||
if not xmlutil.RscState().is_ms_or_promotable_clone(rsc): | |||
logger.error("%s is not a promotable resource", rsc) | |||
return False | |||
role = "Unpromoted" if config.core.OCF_1_1_SUPPORT else "Slave" | |||
role = utils.handle_role_for_ocf_1_1("Slave") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise.
d530fb8
to
aa66751
Compare
…ctions with advised values - Use `utils.handle_role_for_ocf_1_1` to convert roles when cib schema version is lower than pacemaker-3.7 - Use `utils.compatible_role` to make sure always get the advised value if given roles are compatible
… no value is advised in the metadata
289c292
to
2801808
Compare
utils.handle_role_for_ocf_1_1
to convert roles when cib schema version is lower than pacemaker-3.7utils.compatible_role
to make sure always get the advised value if given roles are compatible