本文整理汇总了Python中lib389.DirSrv.clearTmpDir方法的典型用法代码示例。如果您正苦于以下问题:Python DirSrv.clearTmpDir方法的具体用法?Python DirSrv.clearTmpDir怎么用?Python DirSrv.clearTmpDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib389.DirSrv
的用法示例。
在下文中一共展示了DirSrv.clearTmpDir方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: topology
# 需要导入模块: from lib389 import DirSrv [as 别名]
# 或者: from lib389.DirSrv import clearTmpDir [as 别名]
def topology(request):
"""Create DS Deployment"""
# Creating standalone instance ...
if DEBUGGING:
standalone = DirSrv(verbose=True)
else:
standalone = DirSrv(verbose=False)
args_instance[SER_HOST] = HOST_STANDALONE
args_instance[SER_PORT] = PORT_STANDALONE
args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
args_standalone = args_instance.copy()
standalone.allocate(args_standalone)
instance_standalone = standalone.exists()
if instance_standalone:
standalone.delete()
standalone.create()
standalone.open()
def fin():
"""If we are debugging just stop the instances, otherwise remove
them
"""
if DEBUGGING:
standalone.stop(60)
else:
standalone.delete()
request.addfinalizer(fin)
# Clear out the tmp dir
standalone.clearTmpDir(__file__)
return TopologyStandalone(standalone)
示例2: topology
# 需要导入模块: from lib389 import DirSrv [as 别名]
# 或者: from lib389.DirSrv import clearTmpDir [as 别名]
def topology(request):
global installation1_prefix
if installation1_prefix:
args_instance[SER_DEPLOYED_DIR] = installation1_prefix
# Creating standalone instance ...
standalone = DirSrv(verbose=False)
args_instance[SER_HOST] = HOST_STANDALONE
args_instance[SER_PORT] = PORT_STANDALONE
args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
args_standalone = args_instance.copy()
standalone.allocate(args_standalone)
instance_standalone = standalone.exists()
if instance_standalone:
standalone.delete()
standalone.create()
standalone.open()
# Clear out the tmp dir
standalone.clearTmpDir(__file__)
def fin():
standalone.delete()
request.addfinalizer(fin)
return TopologyStandalone(standalone)
示例3: topology
# 需要导入模块: from lib389 import DirSrv [as 别名]
# 或者: from lib389.DirSrv import clearTmpDir [as 别名]
def topology(request):
'''
This fixture is used to standalone topology for the 'module'.
'''
standalone = DirSrv(verbose=True)
# Args for the standalone instance
args_instance[SER_HOST] = HOST_STANDALONE
args_instance[SER_PORT] = PORT_STANDALONE
args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
args_standalone = args_instance.copy()
standalone.allocate(args_standalone)
# Get the status of the instance and restart it if it exists
instance_standalone = standalone.exists()
# Remove the instance
if instance_standalone:
standalone.delete()
# Create the instance
standalone.create()
# Used to retrieve configuration information (dbdir, confdir...)
standalone.open()
# clear the tmp directory
standalone.clearTmpDir(__file__)
# Here we have standalone instance up and running
return TopologyStandalone(standalone)
示例4: topology
# 需要导入模块: from lib389 import DirSrv [as 别名]
# 或者: from lib389.DirSrv import clearTmpDir [as 别名]
def topology(request):
"""
Creating standalone instance ...
"""
standalone = DirSrv(verbose=False)
args_instance[SER_HOST] = HOST_STANDALONE
args_instance[SER_PORT] = PORT_STANDALONE
args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
args_standalone = args_instance.copy()
standalone.allocate(args_standalone)
instance_standalone = standalone.exists()
if instance_standalone:
standalone.delete()
standalone.create()
standalone.open()
# Delete each instance in the end
def fin():
""" Clean up instance """
standalone.delete()
request.addfinalizer(fin)
# Clear out the tmp dir
standalone.clearTmpDir(__file__)
return TopologyStandalone(standalone)
示例5: topology
# 需要导入模块: from lib389 import DirSrv [as 别名]
# 或者: from lib389.DirSrv import clearTmpDir [as 别名]
def topology(request):
# Creating standalone instance ...
standalone = DirSrv(verbose=False)
args_instance[SER_HOST] = HOST_STANDALONE
args_instance[SER_PORT] = PORT_STANDALONE
args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
args_standalone = args_instance.copy()
standalone.allocate(args_standalone)
instance_standalone = standalone.exists()
if instance_standalone:
standalone.delete()
standalone.create()
standalone.open()
# Delete each instance in the end
def fin():
# This is useful for analysing the test env.
standalone.db2ldif(bename=DEFAULT_BENAME, suffixes=[DEFAULT_SUFFIX], excludeSuffixes=[], encrypt=False, \
repl_data=True, outputfile='%s/ldif/%s.ldif' % (standalone.dbdir,SERVERID_STANDALONE ))
standalone.clearBackupFS()
standalone.backupFS()
standalone.delete()
request.addfinalizer(fin)
# Clear out the tmp dir
standalone.clearTmpDir(__file__)
return TopologyStandalone(standalone)
示例6: topology
# 需要导入模块: from lib389 import DirSrv [as 别名]
# 或者: from lib389.DirSrv import clearTmpDir [as 别名]
def topology(request):
return
# Create the realm first
krb = MitKrb5(realm=REALM)
if krb.check_realm():
krb.destroy_realm()
krb.create_realm()
DEBUG = False
# Creating master 1...
master1 = DirSrv(verbose=DEBUG)
args_instance[SER_HOST] = HOST_MASTER_1
args_instance[SER_PORT] = PORT_MASTER_1
args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_1
args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
args_instance[SER_REALM] = REALM
args_instance[SER_STRICT_HOSTNAME_CHECKING] = False
args_master = args_instance.copy()
master1.allocate(args_master)
instance_master1 = master1.exists()
if instance_master1:
master1.delete()
master1.create() # There is some magic in .create that finds the realm, and adds the keytab for us.
master1.open()
master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_1)
# Creating master 2...
master2 = DirSrv(verbose=DEBUG)
args_instance[SER_HOST] = HOST_MASTER_2
args_instance[SER_PORT] = PORT_MASTER_2
args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_2
args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
args_instance[SER_REALM] = REALM
args_instance[SER_STRICT_HOSTNAME_CHECKING] = False
args_master = args_instance.copy()
master2.allocate(args_master)
instance_master2 = master2.exists()
if instance_master2:
master2.delete()
master2.create()
master2.open()
master2.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_2)
# Delete each instance in the end
def fin():
master1.delete()
master2.delete()
if krb.check_realm():
krb.destroy_realm()
request.addfinalizer(fin)
# Clear out the tmp dir
master1.clearTmpDir(__file__)
return TopologyReplication(master1, master2)
示例7: topology
# 需要导入模块: from lib389 import DirSrv [as 别名]
# 或者: from lib389.DirSrv import clearTmpDir [as 别名]
def topology(request):
"""Create Replication Deployment"""
# Creating master 1...
if DEBUGGING:
master1 = DirSrv(verbose=True)
else:
master1 = DirSrv(verbose=False)
args_instance[SER_HOST] = HOST_MASTER_1
args_instance[SER_PORT] = PORT_MASTER_1
args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_1
args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
args_master = args_instance.copy()
master1.allocate(args_master)
instance_master1 = master1.exists()
if instance_master1:
master1.delete()
master1.create()
master1.open()
master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_1)
# Creating master 2...
if DEBUGGING:
master2 = DirSrv(verbose=True)
else:
master2 = DirSrv(verbose=False)
args_instance[SER_HOST] = HOST_MASTER_2
args_instance[SER_PORT] = PORT_MASTER_2
args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_2
args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
args_master = args_instance.copy()
master2.allocate(args_master)
instance_master2 = master2.exists()
if instance_master2:
master2.delete()
master2.create()
master2.open()
master2.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_2)
#
# Create all the agreements
#
# Creating agreement from master 1 to master 2
properties = {RA_NAME: 'meTo_' + master2.host + ':' + str(master2.port),
RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
m1_m2_agmt = master1.agreement.create(suffix=SUFFIX, host=master2.host, port=master2.port, properties=properties)
if not m1_m2_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
log.debug("%s created" % m1_m2_agmt)
# Creating agreement from master 2 to master 1
properties = {RA_NAME: 'meTo_' + master1.host + ':' + str(master1.port),
RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
m2_m1_agmt = master2.agreement.create(suffix=SUFFIX, host=master1.host, port=master1.port, properties=properties)
if not m2_m1_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
log.debug("%s created" % m2_m1_agmt)
# Allow the replicas to get situated with the new agreements...
time.sleep(5)
#
# Initialize all the agreements
#
master1.agreement.init(SUFFIX, HOST_MASTER_2, PORT_MASTER_2)
master1.waitForReplInit(m1_m2_agmt)
# Check replication is working...
if master1.testReplication(DEFAULT_SUFFIX, master2):
log.info('Replication is working.')
else:
log.fatal('Replication is not working.')
assert False
def fin():
"""If we are debugging just stop the instances, otherwise remove
them
"""
if DEBUGGING:
master1.stop()
master2.stop()
else:
master1.delete()
master2.delete()
request.addfinalizer(fin)
# Clear out the tmp dir
master1.clearTmpDir(__file__)
return TopologyReplication(master1, master2)
示例8: topology
# 需要导入模块: from lib389 import DirSrv [as 别名]
# 或者: from lib389.DirSrv import clearTmpDir [as 别名]
#.........这里部分代码省略.........
master1.open()
master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
replicaId=REPLICAID_MASTER_1)
# Creating hub 1...
hub1 = DirSrv(verbose=False)
args_instance[SER_HOST] = HOST_HUB_1
args_instance[SER_PORT] = PORT_HUB_1
args_instance[SER_SERVERID_PROP] = SERVERID_HUB_1
args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
args_hub = args_instance.copy()
hub1.allocate(args_hub)
instance_hub1 = hub1.exists()
if instance_hub1:
hub1.delete()
hub1.create()
hub1.open()
hub1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_HUB,
replicaId=REPLICAID_HUB_1)
# Creating consumer 1...
consumer1 = DirSrv(verbose=False)
args_instance[SER_HOST] = HOST_CONSUMER_1
args_instance[SER_PORT] = PORT_CONSUMER_1
args_instance[SER_SERVERID_PROP] = SERVERID_CONSUMER_1
args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
args_consumer = args_instance.copy()
consumer1.allocate(args_consumer)
instance_consumer1 = consumer1.exists()
if instance_consumer1:
consumer1.delete()
consumer1.create()
consumer1.open()
consumer1.changelog.create()
consumer1.replica.enableReplication(suffix=SUFFIX,
role=REPLICAROLE_CONSUMER,
replicaId=CONSUMER_REPLICAID)
#
# Create all the agreements
#
# Creating agreement from master 1 to hub 1
properties = {RA_NAME: r'meTo_$host:$port',
RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
m1_h1_agmt = master1.agreement.create(suffix=SUFFIX, host=hub1.host,
port=hub1.port,
properties=properties)
if not m1_h1_agmt:
log.fatal("Fail to create a master -> hub replica agreement")
sys.exit(1)
log.debug("%s created" % m1_h1_agmt)
# Creating agreement from hub 1 to consumer 1
properties = {RA_NAME: r'meTo_$host:$port',
RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
h1_c1_agmt = hub1.agreement.create(suffix=SUFFIX, host=consumer1.host,
port=consumer1.port,
properties=properties)
if not h1_c1_agmt:
log.fatal("Fail to create a hub -> consumer replica agreement")
sys.exit(1)
log.debug("%s created" % h1_c1_agmt)
# Allow the replicas to get situated with the new agreements...
time.sleep(5)
#
# Initialize all the agreements
#
master1.agreement.init(SUFFIX, HOST_HUB_1, PORT_HUB_1)
master1.waitForReplInit(m1_h1_agmt)
hub1.agreement.init(SUFFIX, HOST_CONSUMER_1, PORT_CONSUMER_1)
hub1.waitForReplInit(h1_c1_agmt)
# Check replication is working...
if master1.testReplication(DEFAULT_SUFFIX, consumer1):
log.info('Replication is working.')
else:
log.fatal('Replication is not working.')
assert False
# Delete each instance in the end
def fin():
master1.delete()
hub1.delete()
consumer1.delete()
pass
request.addfinalizer(fin)
# Clear out the tmp dir
master1.clearTmpDir(__file__)
return TopologyReplication(master1, hub1, consumer1)
示例9: topology
# 需要导入模块: from lib389 import DirSrv [as 别名]
# 或者: from lib389.DirSrv import clearTmpDir [as 别名]
def topology(request):
'''
This fixture is used to create a replicated topology for the 'module'.
The replicated topology is MASTER1 <-> Master2.
'''
global installation1_prefix
global installation2_prefix
# allocate master1 on a given deployement
master1 = DirSrv(verbose=False)
if installation1_prefix:
args_instance[SER_DEPLOYED_DIR] = installation1_prefix
# Args for the master1 instance
args_instance[SER_HOST] = HOST_MASTER_1
args_instance[SER_PORT] = PORT_MASTER_1
args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_1
args_master = args_instance.copy()
master1.allocate(args_master)
# allocate master1 on a given deployement
master2 = DirSrv(verbose=False)
if installation2_prefix:
args_instance[SER_DEPLOYED_DIR] = installation2_prefix
# Args for the consumer instance
args_instance[SER_HOST] = HOST_MASTER_2
args_instance[SER_PORT] = PORT_MASTER_2
args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_2
args_master = args_instance.copy()
master2.allocate(args_master)
# Get the status of the instance and restart it if it exists
instance_master1 = master1.exists()
instance_master2 = master2.exists()
# Remove all the instances
if instance_master1:
master1.delete()
if instance_master2:
master2.delete()
# Create the instances
master1.create()
master1.open()
master2.create()
master2.open()
#
# Now prepare the Master-Consumer topology
#
# First Enable replication
master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_1)
master2.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_2)
# Initialize the supplier->consumer
properties = {RA_NAME: r'meTo_$host:$port',
RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
AGMT_DN = master1.agreement.create(suffix=SUFFIX, host=master2.host, port=master2.port, properties=properties)
master1.agreement
if not AGMT_DN:
log.fatal("Fail to create a replica agreement")
sys.exit(1)
log.debug("%s created" % AGMT_DN)
properties = {RA_NAME: r'meTo_$host:$port',
RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
master2.agreement.create(suffix=DEFAULT_SUFFIX, host=master1.host, port=master1.port, properties=properties)
master1.agreement.init(SUFFIX, HOST_MASTER_2, PORT_MASTER_2)
master1.waitForReplInit(AGMT_DN)
# Check replication is working fine
if master1.testReplication(DEFAULT_SUFFIX, master2):
log.info('Replication is working.')
else:
log.fatal('Replication is not working.')
assert False
# clear the tmp directory
master1.clearTmpDir(__file__)
def fin():
master1.delete()
master2.delete()
request.addfinalizer(fin)
return TopologyMaster1Master2(master1, master2)
示例10: topology
# 需要导入模块: from lib389 import DirSrv [as 别名]
# 或者: from lib389.DirSrv import clearTmpDir [as 别名]
#.........这里部分代码省略.........
RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
m3_m1_agmt = master3.agreement.create(suffix=SUFFIX, host=master1.host, port=master1.port, properties=properties)
if not m3_m1_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
log.debug("%s created" % m3_m1_agmt)
# Creating agreement from master 3 to master 2
properties = {RA_NAME: 'meTo_%s:%s' % (master2.host, master2.port),
RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
m3_m2_agmt = master3.agreement.create(suffix=SUFFIX, host=master2.host, port=master2.port, properties=properties)
if not m3_m2_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
log.debug("%s created" % m3_m2_agmt)
# Creating agreement from master 3 to master 4
properties = {RA_NAME: 'meTo_%s:%s' % (master4.host, master4.port),
RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
m3_m4_agmt = master3.agreement.create(suffix=SUFFIX, host=master4.host, port=master4.port, properties=properties)
if not m3_m4_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
log.debug("%s created" % m3_m4_agmt)
# Creating agreement from master 4 to master 1
properties = {RA_NAME: 'meTo_%s:%s' % (master1.host, master1.port),
RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
m4_m1_agmt = master4.agreement.create(suffix=SUFFIX, host=master1.host, port=master1.port, properties=properties)
if not m4_m1_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
log.debug("%s created" % m4_m1_agmt)
# Creating agreement from master 4 to master 2
properties = {RA_NAME: 'meTo_%s:%s' % (master2.host, master2.port),
RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
m4_m2_agmt = master4.agreement.create(suffix=SUFFIX, host=master2.host, port=master2.port, properties=properties)
if not m4_m2_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
log.debug("%s created" % m4_m2_agmt)
# Creating agreement from master 4 to master 3
properties = {RA_NAME: 'meTo_%s:%s' % (master3.host, master3.port),
RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
m4_m3_agmt = master4.agreement.create(suffix=SUFFIX, host=master3.host, port=master3.port, properties=properties)
if not m4_m3_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
log.debug("%s created" % m4_m3_agmt)
# Allow the replicas to get situated with the new agreements
time.sleep(5)
#
# Initialize all the agreements
#
master1.agreement.init(SUFFIX, HOST_MASTER_2, PORT_MASTER_2)
master1.waitForReplInit(m1_m2_agmt)
master1.agreement.init(SUFFIX, HOST_MASTER_3, PORT_MASTER_3)
master1.waitForReplInit(m1_m3_agmt)
master1.agreement.init(SUFFIX, HOST_MASTER_4, PORT_MASTER_4)
master1.waitForReplInit(m1_m4_agmt)
# Check replication is working...
if master1.testReplication(DEFAULT_SUFFIX, master2):
log.info('Replication is working.')
else:
log.fatal('Replication is not working.')
assert False
# Clear out the tmp dir
master1.clearTmpDir(__file__)
def fin():
master1.delete()
master2.delete()
master3.delete()
master4.delete()
request.addfinalizer(fin)
return TopologyReplication(master1, master2, master3, master4, m1_m2_agmt, m1_m3_agmt, m1_m4_agmt)
示例11: topology
# 需要导入模块: from lib389 import DirSrv [as 别名]
# 或者: from lib389.DirSrv import clearTmpDir [as 别名]
def topology(request):
global installation1_prefix
if installation1_prefix:
args_instance[SER_DEPLOYED_DIR] = installation1_prefix
# Creating master 1...
master1 = DirSrv(verbose=False)
args_instance[SER_HOST] = HOST_MASTER_1
args_instance[SER_PORT] = PORT_MASTER_1
args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_1
args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
args_master = args_instance.copy()
master1.allocate(args_master)
instance_master1 = master1.exists()
if instance_master1:
master1.delete()
master1.create()
master1.open()
master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_1)
# Creating master 2...
master2 = DirSrv(verbose=False)
args_instance[SER_HOST] = HOST_MASTER_2
args_instance[SER_PORT] = PORT_MASTER_2
args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_2
args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
args_master = args_instance.copy()
master2.allocate(args_master)
instance_master2 = master2.exists()
if instance_master2:
master2.delete()
master2.create()
master2.open()
master2.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_2)
#
# Create all the agreements
#
# Creating agreement from master 1 to master 2
properties = {RA_NAME: 'meTo_%s:%s' %(master2.host, master2.port),
RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
m1_m2_agmt = master1.agreement.create(suffix=SUFFIX, host=master2.host, port=master2.port, properties=properties)
if not m1_m2_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
log.debug("%s created" % m1_m2_agmt)
# Creating agreement from master 2 to master 1
properties = {RA_NAME: 'meTo_%s:%s' %(master1.host, master1.port),
RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
m2_m1_agmt = master2.agreement.create(suffix=SUFFIX, host=master1.host, port=master1.port, properties=properties)
if not m2_m1_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
log.debug("%s created" % m2_m1_agmt)
# Allow the replicas to get situated with the new agreements...
time.sleep(5)
#
# Initialize all the agreements
#
master1.agreement.init(SUFFIX, HOST_MASTER_2, PORT_MASTER_2)
master1.waitForReplInit(m1_m2_agmt)
master2.agreement.init(SUFFIX, HOST_MASTER_1, PORT_MASTER_1)
master2.waitForReplInit(m2_m1_agmt)
# Check replication is working...
if master1.testReplication(DEFAULT_SUFFIX, master2):
log.info('Replication is working.')
else:
log.fatal('Replication is not working.')
assert False
log.info("Set Replication Debugging loglevel for the errorlog")
master1.setLogLevel(LOG_REPLICA)
master2.setLogLevel(LOG_REPLICA)
logging_attr = 'nsslapd-logging-hr-timestamps-enabled'
master1.modify_s("cn=config", [(ldap.MOD_REPLACE, logging_attr, "off")])
master2.modify_s("cn=config", [(ldap.MOD_REPLACE, logging_attr, "off")])
# Delete each instance in the end
def fin():
master1.delete()
master2.delete()
request.addfinalizer(fin)
# Clear out the tmp dir
master1.clearTmpDir(__file__)
return TopologyReplication(master1, master2, m1_m2_agmt, m2_m1_agmt)
示例12: topology
# 需要导入模块: from lib389 import DirSrv [as 别名]
# 或者: from lib389.DirSrv import clearTmpDir [as 别名]
#.........这里部分代码省略.........
properties=properties)
if not m2_m1_agmt:
log.fatal("Fail to create a master -> master replica agreement")
sys.exit(1)
log.debug("%s created" % m2_m1_agmt)
# Allow the replicas to get situated with the new agreements...
time.sleep(5)
#
# Import tests entries into master1 before we initialize master2
#
ldif_dir = master1.get_ldif_dir()
import_ldif = ldif_dir + '/rel7.5-entries.ldif'
# First generate an ldif
try:
ldif = open(import_ldif, 'w')
except IOError as e:
log.fatal('Failed to create test ldif, error: %s - %s' %
(e.errno, e.strerror))
assert False
# Create the root node
ldif.write('dn: ' + DEFAULT_SUFFIX + '\n')
ldif.write('objectclass: top\n')
ldif.write('objectclass: domain\n')
ldif.write('dc: example\n')
ldif.write('\n')
# Create the entries
idx = 0
while idx < NUM_USERS:
count = str(idx)
ldif.write('dn: uid=master1_entry' + count + ',' +
DEFAULT_SUFFIX + '\n')
ldif.write('objectclass: top\n')
ldif.write('objectclass: person\n')
ldif.write('objectclass: inetorgperson\n')
ldif.write('objectclass: organizationalperson\n')
ldif.write('uid: master1_entry' + count + '\n')
ldif.write('cn: master1 entry' + count + '\n')
ldif.write('givenname: master1 ' + count + '\n')
ldif.write('sn: entry ' + count + '\n')
ldif.write('userpassword: master1_entry' + count + '\n')
ldif.write('description: ' + 'a' * random.randint(1, 1000) + '\n')
ldif.write('\n')
ldif.write('dn: uid=master2_entry' + count + ',' +
DEFAULT_SUFFIX + '\n')
ldif.write('objectclass: top\n')
ldif.write('objectclass: person\n')
ldif.write('objectclass: inetorgperson\n')
ldif.write('objectclass: organizationalperson\n')
ldif.write('uid: master2_entry' + count + '\n')
ldif.write('cn: master2 entry' + count + '\n')
ldif.write('givenname: master2 ' + count + '\n')
ldif.write('sn: entry ' + count + '\n')
ldif.write('userpassword: master2_entry' + count + '\n')
ldif.write('description: ' + 'a' * random.randint(1, 1000) + '\n')
ldif.write('\n')
idx += 1
ldif.close()
# Now import it
try:
master1.tasks.importLDIF(suffix=DEFAULT_SUFFIX, input_file=import_ldif,
args={TASK_WAIT: True})
except ValueError:
log.fatal('test_reliab_7.5: Online import failed')
assert False
#
# Initialize all the agreements
#
master1.agreement.init(SUFFIX, HOST_MASTER_2, PORT_MASTER_2)
master1.waitForReplInit(m1_m2_agmt)
# Check replication is working...
if master1.testReplication(DEFAULT_SUFFIX, master2):
log.info('Replication is working.')
else:
log.fatal('Replication is not working.')
assert False
# Clear out the tmp dir
master1.clearTmpDir(__file__)
# Delete each instance in the end
def fin():
master1.delete()
master2.delete()
if ENABLE_VALGRIND:
sbin_dir = get_sbin_dir(prefix=master1.prefix)
valgrind_disable(sbin_dir)
request.addfinalizer(fin)
return TopologyReplication(master1, master2)