Re: [Freeipa-devel] [PATCH] 0094 Make it possible to list also winsync replicas

2011-03-02 Thread Simo Sorce
On Wed, 02 Mar 2011 09:16:50 -0500
Rob Crittenden  wrote:

> Simo Sorce wrote:
> >
> > This patch registers winsync replica in the public tree with enough
> > information to know which master is handling the agreement.
> >
> > Now when listing replicas, the type is also returned and winsync
> > agreements are listed.
> > When listing a specific server with --verbose, in case of a winsync
> > peer the winsync peer status is shown by contacting the master that
> > has the agreement.
> >
> > On winsync link removal, the public information about the agreement
> > is also removed.
> >
> > Ticket 1007
> >
> > Simo.
> 
> Works great, good call on the update file. I updated my existing 
> installation and it worked fine.
> 
> ack
> 
> rob

Thanks, pushed to master.

Simo.


-- 
Simo Sorce * Red Hat, Inc * New York

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 0094 Make it possible to list also winsync replicas

2011-03-02 Thread Rob Crittenden

Rob Crittenden wrote:

Simo Sorce wrote:


This patch registers winsync replica in the public tree with enough
information to know which master is handling the agreement.

Now when listing replicas, the type is also returned and winsync
agreements are listed.
When listing a specific server with --verbose, in case of a winsync
peer the winsync peer status is shown by contacting the master that has
the agreement.

On winsync link removal, the public information about the agreement is
also removed.

Ticket 1007

Simo.


Works great, good call on the update file. I updated my existing
installation and it worked fine.

ack

rob



BTW, this needs a small rebase, it fails to apply the change to 
install/updates/Makefile.am


rob

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 0094 Make it possible to list also winsync replicas

2011-03-02 Thread Rob Crittenden

Simo Sorce wrote:


This patch registers winsync replica in the public tree with enough
information to know which master is handling the agreement.

Now when listing replicas, the type is also returned and winsync
agreements are listed.
When listing a specific server with --verbose, in case of a winsync
peer the winsync peer status is shown by contacting the master that has
the agreement.

On winsync link removal, the public information about the agreement is
also removed.

Ticket 1007

Simo.


Works great, good call on the update file. I updated my existing 
installation and it worked fine.


ack

rob

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


[Freeipa-devel] [PATCH] 0094 Make it possible to list also winsync replicas

2011-03-01 Thread Simo Sorce

This patch registers winsync replica in the public tree with enough
information to know which master is handling the agreement.

Now when listing replicas, the type is also returned and winsync
agreements are listed.
When listing a specific server with --verbose, in case of a winsync
peer the winsync peer status is shown by contacting the master that has
the agreement.

On winsync link removal, the public information about the agreement is
also removed.

Ticket 1007

Simo.

-- 
Simo Sorce * Red Hat, Inc * New York
>From 3bf5a3f8fcb257e5f91d4327fd15c281c01cce92 Mon Sep 17 00:00:00 2001
From: Simo Sorce 
Date: Mon, 28 Feb 2011 17:35:44 -0500
Subject: [PATCH] Store list of non-master replicas in DIT and provide way to list them

Fixes: https://fedorahosted.org/freeipa/ticket/1007
---
 install/share/bootstrap-template.ldif|6 ++
 install/tools/ipa-replica-manage |  124 ++
 install/updates/21-replicas_container.update |9 ++
 install/updates/Makefile.am  |1 +
 ipaserver/install/replication.py |   12 +++
 5 files changed, 115 insertions(+), 37 deletions(-)
 create mode 100644 install/updates/21-replicas_container.update

diff --git a/install/share/bootstrap-template.ldif b/install/share/bootstrap-template.ldif
index 3cfff958733bd89f4aefb4433be52a9ace41aab8..9ad8fef3d52503093808ef39bb624bc080072887 100644
--- a/install/share/bootstrap-template.ldif
+++ b/install/share/bootstrap-template.ldif
@@ -143,6 +143,12 @@ objectClass: nsContainer
 objectClass: top
 cn: masters
 
+dn: cn=replicas,cn=ipa,cn=etc,$SUFFIX
+changetype: add
+objectClass: nsContainer
+objectClass: top
+cn: replicas
+
 dn: cn=dna,cn=ipa,cn=etc,$SUFFIX
 changetype: add
 objectClass: nsContainer
diff --git a/install/tools/ipa-replica-manage b/install/tools/ipa-replica-manage
index 931b13921b3a3bf4a340a7f301d325a487333497..87c994aa5a494364d28123a4fb68eba1b7942d05 100755
--- a/install/tools/ipa-replica-manage
+++ b/install/tools/ipa-replica-manage
@@ -117,42 +117,77 @@ def test_connection(realm, host):
 except ldap.LOCAL_ERROR:
 return False
 
-def list_masters(realm, host, replica, dirman_passwd, verbose):
-
-if replica:
-try:
-repl = replication.ReplicationManager(realm, replica, dirman_passwd)
-except Exception, e:
-print "Failed to get data from '%s': %s" % (replica, str(e))
-return
-
-entries = repl.find_replication_agreements()
-
-for entry in entries:
-print entry.nsds5replicahost
-
-if verbose:
-print "  last init status: %s" % entry.nsds5replicalastinitstatus
-print "  last init ended: %s" % str(ipautil.parse_generalized_time(entry.nsds5replicalastinitend))
-print "  last update status: %s" % entry.nsds5replicalastupdatestatus
-print "  last update ended: %s" % str(ipautil.parse_generalized_time(entry.nsds5replicalastupdateend))
-else:
-try:
-conn = ipaldap.IPAdmin(host, 636, cacert=CACERT)
-if dirman_passwd:
-conn.do_simple_bind(bindpw=dirman_passwd)
-else:
-conn.do_sasl_gssapi_bind()
-
-dn = 'cn=masters,cn=ipa,cn=etc,%s' % util.realm_to_suffix(realm)
-entries = conn.search_s(dn, ldap.SCOPE_ONELEVEL)
-
-for ent in entries:
-print ent.cn
-
-except Exception, e:
-print "Failed to get data from '%s': %s" % (host, str(e))
-return
+def list_replicas(realm, host, replica, dirman_passwd, verbose):
+
+is_replica = False
+winsync_peer = None
+peers = {}
+
+try:
+conn = ipaldap.IPAdmin(host, 636, cacert=CACERT)
+if dirman_passwd:
+conn.do_simple_bind(bindpw=dirman_passwd)
+else:
+conn.do_sasl_gssapi_bind()
+
+dn = 'cn=masters,cn=ipa,cn=etc,%s' % util.realm_to_suffix(realm)
+entries = conn.search_s(dn, ldap.SCOPE_ONELEVEL)
+
+for ent in entries:
+peers[ent.cn] = ['master', '']
+
+dn = 'cn=replicas,cn=ipa,cn=etc,%s' % util.realm_to_suffix(realm)
+entries = conn.search_s(dn, ldap.SCOPE_ONELEVEL)
+
+for ent in entries:
+peers[ent.cn] = ent.ipaconfigstring.split(':')
+
+except Exception, e:
+print "Failed to get data from '%s': %s" % (host, str(e))
+return
+
+
+if not replica:
+for k, p in peers.iteritems():
+print '%s: %s' % (k, p[0])
+return
+
+# ok we are being ask for info about a specific replica
+for k, p in peers.iteritems():
+if replica == k:
+is_replica = True
+if p[0] == 'winsync':
+winsync_peer = p[1]
+
+if not is_replica:
+print "Cannot find %s in public server list" % replica
+return
+
+try:
+if winsync_peer:
+repl = replication.ReplicationManager(rea