replica promotion: check domain level before ipaservers membership

Check domain level before checking ipaservers membership to prevent
"not found" error when attempting replica promotion in domain level 0.

https://fedorahosted.org/freeipa/ticket/5401

Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
This commit is contained in:
Jan Cholasta
2015-12-10 07:23:18 +01:00
parent 8f36a5bd68
commit b4a78db4e7

View File

@@ -975,6 +975,20 @@ def promote_check(installer):
replman = ReplicationManager(config.realm_name,
config.master_host_name, None)
# Detect the current domain level
try:
current = remote_api.Command['domainlevel_get']()['result']
except errors.NotFound:
# If we're joining an older master, domain entry is not
# available
current = constants.DOMAIN_LEVEL_0
if current == constants.DOMAIN_LEVEL_0:
raise RuntimeError(
"You must provide a file generated by ipa-replica-prepare to "
"create a replica when the domain is at level 0."
)
# Check authorization
result = remote_api.Command['hostgroup_find'](
cn=u'ipaservers',
@@ -1029,20 +1043,6 @@ def promote_check(installer):
config.host_name)
sys.exit(3)
# Detect the current domain level
try:
current = remote_api.Command['domainlevel_get']()['result']
except errors.NotFound:
# If we're joining an older master, domain entry is not
# available
current = constants.DOMAIN_LEVEL_0
if current == constants.DOMAIN_LEVEL_0:
raise RuntimeError(
"You must provide a file generated by ipa-replica-prepare to "
"create a replica when the domain is at level 0."
)
# Detect if current level is out of supported range
# for this IPA version
under_lower_bound = current < constants.MIN_DOMAIN_LEVEL