def multi_master_replication(): """Multi Master Replication view""" #Check if replication user (dn) and password has been configured app_config = AppConfiguration.query.first() if not app_config: flash("Repication user and/or password has not been defined." " Please go to 'Configuration' and set these before proceed.", "warning") if 'nongluuldapinfo' in session: del session['nongluuldapinfo'] ldap_errors = [] ldaps = Server.query.all() serverStats = {} #Collect replication information for all configured servers for ldp in ldaps: s = LdapOLC( "ldaps://{0}:1636".format(ldp.hostname), "cn=config", ldp.ldap_password) r = None try: r = s.connect() except Exception as e: ldap_errors.append( "Connection to LDAPserver {0} at port 1636 was failed:" " {1}".format(ldp.hostname, e)) if r: sstat = s.getMMRStatus() if sstat['server_id']: serverStats[ldp.hostname] = sstat #If there is no ldap server, return to home if not ldaps: flash("Please add ldap servers.", "warning") return redirect(url_for('index.home')) return render_template('multi_master.html', ldapservers=ldaps, serverStats=serverStats, ldap_errors=ldap_errors, )
def multi_master_replication(): app_config = AppConfiguration.query.first() pr_server = get_primary_server_id() if not app_config: flash( "Repication user and/or password has not been defined." " Please go to 'Configuration' and set these before proceed.", "warning") if 'nongluuldapinfo' in session: del session['nongluuldapinfo'] ldaps = Server.query.all() serverStats = {} for ldp in ldaps: s = LdapOLC("ldaps://{0}:1636".format(ldp.hostname), "cn=config", ldp.ldap_password) r = None try: r = s.connect() except Exception as e: flash( "Connection to LDAPserver {0} at port 1636 was failed:" " {1}".format(ldp.hostname, e), "warning") if not r: flash( "Connection to LDAPserver {0} at port 1636 has " "failed".format(ldp.hostname), "warning") if r: sstat = s.getMMRStatus() if sstat['server_id']: serverStats[ldp.hostname] = sstat if not ldaps: flash("Please add ldap servers.", "warning") return redirect(url_for('index.home')) return render_template( 'multi_master.html', ldapservers=ldaps, serverStats=serverStats, pr_server=pr_server, )
def multi_master_replication(): """Multi Master Replication view for OpenLDAP""" # Check if replication user (dn) and password has been configured app_config = AppConfiguration.query.first() ldaps = Server.query.all() primary_server = Server.query.filter_by(primary_server=True).first() if not app_config: flash( "Repication user and/or password has not been defined." " Please go to 'Configuration' and set these before proceed.", "warning") return redirect(url_for('index.home')) if not ldaps: flash("Servers has not been added. " "Please add servers", "warning") return redirect(url_for('index.home')) ldap_errors = [] prop = get_setup_properties() if prop['ldap_type'] == 'openldap': serverStats = {} # Collect replication information for all configured servers for ldp in ldaps: s = LdapOLC("ldaps://{0}:1636".format(ldp.hostname), "cn=config", ldp.ldap_password) r = None try: r = s.connect() except Exception as e: ldap_errors.append( "Connection to LDAPserver {0} at port 1636 was failed:" " {1}".format(ldp.hostname, e)) if r: sstat = s.getMMRStatus() if sstat['server_id']: serverStats[ldp.hostname] = sstat # If there is no ldap server, return to home if not ldaps: flash("Please add ldap servers.", "warning") return redirect(url_for('index.home')) return render_template( 'multi_master.html', ldapservers=ldaps, serverStats=serverStats, ldap_errors=ldap_errors, replication_status=sstat[primary_server.id], ) else: rep_status = get_opendj_replication_status() stat = '' if not rep_status[0]: flash(rep_status[1], "warning") else: stat = rep_status[1] return render_template( 'opendjmmr.html', servers=ldaps, stat=stat, app_conf=app_config, )