ipa-replica-manage: remove "last init status" if it's None.

we remove the "last init status" section in the output of
ipa-replica-manage to avoid confusion and show epoch date
when status is None

Fixes: https://pagure.io/freeipa/issue/7716

Signed-off-by: German Parente <gparente@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
Reviewed-By: Francois Cami <fcami@redhat.com>
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
German Parente 2018-10-01 17:39:20 +02:00 committed by Florence Blanc-Renaud
parent 581b7148f4
commit ef324a7f13
2 changed files with 14 additions and 9 deletions

View File

@ -134,8 +134,9 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose):
print('%s' % entry.single_value.get('nsds5replicahost'))
if verbose:
print(" last init status: %s" % entry.single_value.get(
'nsds5replicalastinitstatus'))
initstatus = entry.single_value.get('nsds5replicalastinitstatus')
if initstatus is not None:
print(" last init status: %s" % initstatus)
print(" last init ended: %s" % str(
ipautil.parse_generalized_time(
entry.single_value['nsds5replicalastinitend'])))
@ -145,6 +146,7 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose):
ipautil.parse_generalized_time(
entry.single_value['nsds5replicalastupdateend'])))
def del_link(realm, replica1, replica2, dirman_passwd, force=False):
repl2 = None

View File

@ -236,9 +236,11 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose, nolookup=False):
print('%s: %s' % (entry.single_value.get('nsds5replicahost'), ent_type))
if verbose:
print(" last init status: %s" % entry.single_value.get(
'nsds5replicalastinitstatus'))
print(" last init ended: %s" % str(ipautil.parse_generalized_time(
initstatus = entry.single_value.get('nsds5replicalastinitstatus')
if initstatus is not None:
print(" last init status: %s" % initstatus)
print(" last init ended: %s" % str(
ipautil.parse_generalized_time(
entry.single_value['nsds5replicalastinitend'])))
print(" last update status: %s" % entry.single_value.get(
'nsds5replicalastupdatestatus'))
@ -246,6 +248,7 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose, nolookup=False):
ipautil.parse_generalized_time(
entry.single_value['nsds5replicalastupdateend'])))
def del_link(realm, replica1, replica2, dirman_passwd, force=False):
"""
Delete a replication agreement from host A to host B.