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,17 +134,19 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose):
print('%s' % entry.single_value.get('nsds5replicahost')) print('%s' % entry.single_value.get('nsds5replicahost'))
if verbose: if verbose:
print(" last init status: %s" % entry.single_value.get( initstatus = entry.single_value.get('nsds5replicalastinitstatus')
'nsds5replicalastinitstatus')) if initstatus is not None:
print(" last init ended: %s" % str( print(" last init status: %s" % initstatus)
ipautil.parse_generalized_time( print(" last init ended: %s" % str(
entry.single_value['nsds5replicalastinitend']))) ipautil.parse_generalized_time(
entry.single_value['nsds5replicalastinitend'])))
print(" last update status: %s" % entry.single_value.get( print(" last update status: %s" % entry.single_value.get(
'nsds5replicalastupdatestatus')) 'nsds5replicalastupdatestatus'))
print(" last update ended: %s" % str( print(" last update ended: %s" % str(
ipautil.parse_generalized_time( ipautil.parse_generalized_time(
entry.single_value['nsds5replicalastupdateend']))) entry.single_value['nsds5replicalastupdateend'])))
def del_link(realm, replica1, replica2, dirman_passwd, force=False): def del_link(realm, replica1, replica2, dirman_passwd, force=False):
repl2 = None repl2 = None

View File

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