本文整理汇总了Python中dsadmin.DSAdmin类的典型用法代码示例。如果您正苦于以下问题:Python DSAdmin类的具体用法?Python DSAdmin怎么用?Python DSAdmin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DSAdmin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
def setup():
global conn
conn = DSAdmin(**config.auth)
conn.verbose = True
conn.added_entries = []
conn.added_backends = set(['o=mockbe2'])
conn.added_replicas = []
harn_nolog()
示例2: setup
def setup():
# uses an existing 389 instance
# add a suffix
# add an agreement
# This setup is quite verbose but to test dsadmin method we should
# do things manually. A better solution would be to use an LDIF.
global conn
conn = DSAdmin(**config.auth)
conn.verbose = True
conn.added_entries = []
conn.added_backends = set(['o=mockbe1'])
conn.added_replicas = []
"""
示例3: setup
def setup():
# uses an existing 389 instance
# add a suffix
# add an agreement
# This setup is quite verbose but to test dsadmin method we should
# do things manually. A better solution would be to use an LDIF.
global conn
conn = DSAdmin(**config.auth)
conn.verbose = True
conn.added_entries = []
conn.added_backends = set(["o=mockbe1"])
conn.added_replicas = []
# add a backend for testing ruv and agreements
addbackend_harn(conn, "testReplica")
# add another backend for testing replica.add()
addbackend_harn(conn, "testReplicaCreation")
示例4: default_test
def default_test():
host = 'localhost'
port = 10200
binddn = "cn=directory manager"
bindpw = "password"
suffix = 'dc=example,dc=com'
basedn = DN_CONFIG
scope = ldap.SCOPE_BASE
filt = "(objectclass=*)"
instance_name = ['m1', 'm2']
instance_config = {
'cfgdshost': host,
'cfgdsport': port,
'cfgdsuser': 'admin',
'cfgdspwd': 'admin',
'newrootpw': 'password',
'newhost': host,
'newport': port,
'newinstance': instance_name[0],
'newsuffix': suffix,
'setup_admin': True,
}
try:
m1 = DSAdmin(host, port, binddn, bindpw)
except:
m1 = DSAdminTools.createInstance(instance_config, verbose=1)
added_instances.append(instance_config['newinstance'])
# filename = "%s/slapd-%s/ldif/Example.ldif" % (m1.sroot, m1.inst)
# m1.importLDIF(filename, "dc=example,dc=com", None, True)
# m1.exportLDIF('/tmp/ldif', "dc=example,dc=com", False, True)
print m1.sroot, m1.inst, m1.errlog
ent = m1.getEntry(basedn, scope, filt, None)
if ent:
print ent.passwordmaxage
instance_config.update({
'newinstance': instance_name[1],
'newport': port + 10,
})
m1 = DSAdminTools.createInstance(instance_config, verbose=1)
added_instances.append(instance_config['newinstance'])
# m1.stop(True)
# m1.start(True)
cn = m1.setupBackend("dc=example2,dc=com")
rc = m1.setupSuffix("dc=example2,dc=com", cn)
entry = m1.getEntry(DN_CONFIG, ldap.SCOPE_SUBTREE, "(cn=" + cn + ")")
print "new backend entry is:"
print entry
print entry.getValues('objectclass')
print entry.OBJECTCLASS
results = m1.search_s("cn=monitor", ldap.SCOPE_SUBTREE)
print results
results = m1.getBackendsForSuffix("dc=example,dc=com")
print results
print "done"
示例5: handle
def handle(self,dn,entry):
"""
Append single record to dictionary of all records.
"""
ent = Entry((dn, entry))
normdn = DSAdmin.normalizeDN(dn)
self.dndict[normdn] = ent
cn = ent.cn
if cn:
self.cndict[cn] = ent
self.dnlist.append(ent);
示例6: handle
def handle(self,dn,entry):
"""
assumes basedns[0] is the parent, basedns[1] already exists,
and we want to create entries for basedns[2]
"""
normdn = DSAdmin.normalizeDN(dn)
for (basedn, ld) in self.iterlist:
if normdn.endswith(basedn):
ld.unparse(dn,entry)
if basedn == self.basedns[1]:
dn = normdn.replace(basedn,self.basedns[2])
for (attr, vals) in entry.iteritems():
for ii in xrange(0, len(vals)):
vals[ii] = vals[ii].replace(basedn,self.basedns[2])
self.outldifs[2].unparse(dn,entry)
break
示例7:
m1replargs = {
'suffix': basedn,
'bename': "userRoot",
'binddn': "cn=replrepl,cn=config",
'bindcn': "replrepl",
'bindpw': "replrepl",
'pd': 5,
'log' : False
}
m2replargs = m1replargs
m1 = DSAdmin.createInstance({
'newrootpw': 'password',
'newhost': host1,
'newport': port1,
'newinst': 'm1',
'newsuffix': basedn,
'verbose': True,
'no_admin': True
})
#os.environ['USE_GDB'] = "1"
m2 = DSAdmin.createInstance({
'newrootpw': 'password',
'newhost': host2,
'newport': port2,
'newinst': 'm2',
'newsuffix': basedn,
'verbose': False,
'no_admin': True
})
示例8: DSAdmin
rootdn2 = rootdn1
rootpw1 = "password"
rootpw2 = rootpw1
basedn = "dc=testdomain, dc=com"
m1replargs = {
'suffix': basedn,
'bename': "userRoot",
'binddn': "cn=replrepl,cn=config",
'bindcn': "replrepl",
'bindpw': "replrepl"
}
#os.environ['USE_DBX'] = "1"
m1 = DSAdmin(host1, port1, rootdn1, rootpw1)
m1.replicaSetupAll(m1replargs)
m2replargs = m1replargs
#os.environ['USE_DBX'] = 1
m2 = DSAdmin(host2, port2, rootdn2, rootpw2)
m2.replicaSetupAll(m2replargs)
print "create agreements and init consumers"
agmtm1tom2 = m1.setupAgreement(m2, m1replargs)
m1.startReplication_async(agmtm1tom2)
print "waiting for init to finish"
m1.waitForReplInit(agmtm1tom2)
agmtm2tom1 = m2.setupAgreement(m1, m2replargs)
nents = 5
示例9:
import os
import ldap
from dsadmin import DSAdmin, Entry
host1 = "localhost.localdomain"
host2 = host1
cfgport = 1100
port1 = cfgport + 30
port2 = port1 + 10
#os.environ['USE_DBX'] = "1"
m1 = DSAdmin.createInstance({
'newrootpw': 'password',
'newhost': host1,
'newport': port1,
'newinst': 'm1',
'newsuffix': 'dc=example,dc=com',
'verbose': True,
'no_admin': True
})
#del os.environ['USE_DBX']
initfile = ''
if os.environ.has_key('SERVER_ROOT'):
initfile = "%s/slapd-%s/ldif/Example.ldif" % (m1.sroot,m1.inst)
else:
initfile = "%s/share/dirsrv/data/Example.ldif" % os.environ.get('PREFIX', '/usr')
m1.importLDIF(initfile, '', "userRoot", True)
示例10:
import os
import ldap
from dsadmin import DSAdmin, Entry
host1 = "localhost.localdomain"
host2 = host1
cfgport = 1100
port1 = cfgport + 30
port2 = port1 + 10
#os.environ['USE_DBX'] = "1"
m1 = DSAdmin.createInstance({
'newrootpw': 'password',
'newhost': host1,
'newport': port1,
'newinst': 'm1',
'newsuffix': 'dc=example,dc=com',
'verbose': True,
'no_admin': True
})
#del os.environ['USE_DBX']
initfile = ''
if os.environ.has_key('SERVER_ROOT'):
initfile = "%s/slapd-%s/ldif/Example.ldif" % (m1.sroot,m1.inst)
else:
initfile = "%s/share/dirsrv/data/Example.ldif" % os.environ.get('PREFIX', '/usr')
m1.importLDIF(initfile, '', "userRoot", True)
#m1.setLogLevel(65535)
示例11:
#os.environ['USE_DBX'] = "1"
m1replargs = {
'suffix': "dc=example,dc=com",
'bename': "userRoot",
'binddn': "cn=replrepl,cn=config",
'bindcn': "replrepl",
'bindpw': "replrepl"
}
m1 = DSAdmin.createAndSetupReplica({
'cfgdshost': host1,
'cfgdsport': cfgport,
'cfgdsuser': 'admin',
'cfgdspwd': 'admin',
'newrootpw': 'password',
'newhost': host1,
'newport': port1,
'newinst': 'm1',
'newsuffix': 'dc=example,dc=com',
'verbose': True
}, m1replargs)
#del os.environ['USE_DBX']
m2replargs = {
'suffix': "dc=example,dc=com",
'bename': "userRoot",
'binddn': "cn=replrepl,cn=config",
'bindcn': "replrepl",
'bindpw': "replrepl"
}
示例12: DSAdmin
import os
import time
import ldap
from dsadmin import DSAdmin, Entry
host = "localhost.localdomain"
port = 10200
#os.environ['USE_DBX'] = "1"
#del os.environ['USE_DBX']
binddn = "cn=directory manager"
bindpw = "secret12"
conn = DSAdmin(host,port,binddn,bindpw)
suffix = "dc=example2,dc=com"
conn.addSuffix(suffix)
initfile = "/var/tmp/reftest.ldif"
conn.importLDIF(initfile, suffix, None, True)
示例13:
import os
import sys
import time
import ldap
import ldif
from dsadmin import DSAdmin, Entry
host1 = "localhost.localdomain"
port1 = 1200
basedn = "dc=example,dc=com"
srv = DSAdmin.createInstance({
'newrootpw': 'password',
'newhost': host1,
'newport': port1,
'newinst': 'srv',
'newsuffix': basedn,
'verbose': False,
'no_admin': True
})
basedns = [basedn]
benames = ['userRoot']
base1 = "ou=people," + basedn
basedns.append(base1)
srv.addSuffix(base1)
ents = srv.getBackendsForSuffix(base1, ['cn'])
benames.append(ents[0].cn)
base2 = "ou=people1," + basedn
basedns.append(base2)
srv.addSuffix(base2)
示例14:
m1replargs = {
'suffix': "dc=example,dc=com",
'bename': "userRoot",
'binddn': "cn=replrepl,cn=config",
'bindcn': "replrepl",
'bindpw': "replrepl",
'log' : True
}
#os.environ['USE_DBX'] = "1"
m1 = DSAdmin.createAndSetupReplica({
'newrootpw': 'password',
'newhost': host1,
'newport': cfgport+10,
'newinst': 'm1',
'newsuffix': 'dc=example,dc=com',
'verbose': True,
'no_admin': True
}, m1replargs
)
#del os.environ['USE_DBX']
m2replargs = {
'suffix': "dc=example,dc=com",
'bename': "userRoot",
'binddn': "cn=replrepl,cn=config",
'bindcn': "replrepl",
'bindpw': "replrepl"
}
#os.environ['USE_DBX'] = 1
m2 = DSAdmin.createAndSetupReplica({
示例15:
basedn = 'dc=example,dc=com'
replargs = {}
srvs = []
m1replargs = {
'suffix': basedn,
'bename': "userRoot",
'binddn': "cn=replrepl,cn=config",
'bindcn': "replrepl",
'bindpw': "replrepl"
}
os.environ['USE_GDB'] = "1"
m1 = DSAdmin.createAndSetupReplica({
'newrootpw': 'password',
'newhost': host1,
'newport': port1,
'newinst': 'm1',
'newsuffix': basedn,
'no_admin': True
}, m1replargs
)
del os.environ['USE_GDB']
replargs[m1] = m1replargs
srvs.append(m1)
m2replargs = m1replargs
m2 = DSAdmin.createAndSetupReplica({
'newrootpw': 'password',
'newhost': host2,
'newport': port2,
'newinst': 'm2',
'newsuffix': basedn,