本文整理汇总了Python中daos_api.DaosPool类的典型用法代码示例。如果您正苦于以下问题:Python DaosPool类的具体用法?Python DaosPool怎么用?Python DaosPool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DaosPool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_handle
def check_handle(buf_len, iov_len, buf, uuidstr, rank):
"""
This gets run in a child process and verifyes the global
handle can be turned into a local handle in another process.
"""
try:
# get paths from the build_vars generated by build
with open('../../../.build_vars.json') as build_file:
build_paths = json.load(build_file)
# setup the DAOS python API in this process
context = DaosContext(build_paths['PREFIX'] + '/lib/')
pool = DaosPool(context)
pool.set_uuid_str(uuidstr)
pool.set_svc(rank)
pool.group = "daos_server"
# note that the handle is stored inside the pool as well
dummy_local_handle = pool.global2local(context, iov_len, buf_len, buf)
# perform some operations that will use the new handle
pool.pool_query()
container = DaosContainer(context)
container.create(pool.handle)
except DaosApiError as excep:
print(excep)
print(traceback.format_exc())
raise
return
示例2: test_many_servers
def test_many_servers(self):
"""
Test destroy on a large (relative) number of servers.
:avocado: tags=pool,pooldestroy,destroybig
"""
try:
# write out a hostfile and start the servers with it
self.hostlist = self.params.get("test_machines6", '/run/hosts/')
hostfile = write_host_file.write_host_file(self.hostlist, self.tmp)
self.agent_sessions = AgentUtils.run_agent(self.basepath,
self.hostlist)
server_utils.run_server(hostfile, self.server_group, self.basepath)
# parameters used in pool create
createmode = self.params.get("mode", '/run/poolparams/createmode/')
createuid = self.params.get("uid", '/run/poolparams/createuid/')
creategid = self.params.get("gid", '/run/poolparams/creategid/')
createsetid = self.params.get("setname",
'/run/poolparams/createset/')
createsize = self.params.get("size", '/run/poolparams/createsize/')
# initialize a python pool object then create the underlying
# daos storage
pool = DaosPool(self.context)
pool.create(createmode, createuid, creategid,
createsize, createsetid, None)
time.sleep(1)
# okay, get rid of it
pool.destroy(1)
except DaosApiError as excep:
print(excep)
print(traceback.format_exc())
self.fail("6 server test failed.\n")
except Exception as excep:
self.fail("Daos code segfaulted most likely. Error: %s" % excep)
# no matter what happens cleanup
finally:
if self.agent_sessions:
AgentUtils.stop_agent(self.hostlist, self.agent_sessions)
server_utils.stop_server(hosts=self.hostlist)
os.remove(hostfile)
示例3: setUp
def setUp(self):
self.agent_sessions = None
with open('../../../.build_vars.json') as json_f:
build_paths = json.load(json_f)
basepath = os.path.normpath(build_paths['PREFIX'] + "/../")
server_group = self.params.get("name",
'/server_config/',
'daos_server')
self.context = DaosContext(build_paths['PREFIX'] + '/lib/')
self.container = None
self.hostlist = self.params.get("test_machines", '/run/hosts/*')
self.hostfile = write_host_file.write_host_file(self.hostlist,
self.workdir)
self.agent_sessions = AgentUtils.run_agent(basepath, self.hostlist)
server_utils.run_server(self.hostfile, server_group, basepath)
self.pool = DaosPool(self.context)
self.pool.create(self.params.get("mode", '/run/pool/createmode/*'),
os.geteuid(),
os.getegid(),
self.params.get("size", '/run/pool/createsize/*'),
self.params.get("setname", '/run/pool/createset/*'),
None)
self.pool.connect(1 << 1)
示例4: setUp
def setUp(self):
""" setup for the test """
self.agent_sessions = None
# get paths from the build_vars generated by build
with open('../../../.build_vars.json') as build_file:
build_paths = json.load(build_file)
self.context = DaosContext(build_paths['PREFIX'] + '/lib/')
self.basepath = os.path.normpath(build_paths['PREFIX'] + "/../")
# generate a hostfile
self.hostlist = self.params.get("test_machines", '/run/hosts/')
self.hostfile = write_host_file.write_host_file(self.hostlist,
self.workdir)
# fire up the DAOS servers
self.server_group = self.params.get("name", '/run/server_config/',
'daos_server')
self.agent_sessions = AgentUtils.run_agent(self.basepath, self.hostlist)
server_utils.run_server(self.hostfile, self.server_group,
build_paths['PREFIX'] + '/../')
# create a pool to test with
createmode = self.params.get("mode", '/run/pool/createmode/')
createuid = self.params.get("uid", '/run/pool/createuid/')
creategid = self.params.get("gid", '/run/pool/creategid/')
createsetid = self.params.get("setname", '/run/pool/createset/')
createsize = self.params.get("size", '/run/pool/createsize/')
self.pool = DaosPool(self.context)
self.pool.create(createmode, createuid, creategid, createsize,
createsetid)
self.pool.get_uuid_str()
time.sleep(2)
示例5: test_createasync
def test_createasync(self):
"""
Test container create for asynchronous mode.
:avocado: tags=container,containerasync,createasync
"""
global GLOB_SIGNAL
global GLOB_RC
# parameters used in pool create
createmode = self.params.get("mode", '/run/createtests/createmode/*/')
createsetid = self.params.get("setname", '/run/createtests/createset/')
createsize = self.params.get("size", '/run/createtests/createsize/')
createuid = os.geteuid()
creategid = os.getegid()
try:
# initialize a python pool object then create the underlying
# daos storage
self.pool = DaosPool(self.context)
self.pool.create(createmode, createuid, creategid,
createsize, createsetid, None)
poh = self.pool.handle
self.pool.connect(1 << 1)
# Container initialization and creation
self.container1 = DaosContainer(self.context)
self.container2 = DaosContainer(self.context)
GLOB_SIGNAL = threading.Event()
self.container1.create(poh, None, cb_func)
GLOB_SIGNAL.wait()
if GLOB_RC != 0:
self.fail("RC not as expected in async test")
print("RC after successful container create: ", GLOB_RC)
# Try to recreate container after destroying pool,
# this should fail. Checking rc after failure.
self.pool.destroy(1)
GLOB_SIGNAL = threading.Event()
GLOB_RC = -9900000
self.container2.create(poh, None, cb_func)
GLOB_SIGNAL.wait()
if GLOB_RC == 0:
self.fail("RC not as expected in async test")
print("RC after unsuccessful container create: ", GLOB_RC)
# cleanup the pool and container
self.pool = None
except DaosApiError as excep:
print(excep)
print(traceback.format_exc())
示例6: test_destroy_connect
def test_destroy_connect(self):
"""
Test destroying a pool that has a connected client with force == false.
Should fail.
:avocado: tags=pool,pooldestroy,x
"""
host = self.hostlist[0]
try:
# write out a hostfile and start the servers with it
self.hostlist = self.params.get("test_machines1", '/run/hosts/')
hostfile = write_host_file.write_host_file(self.hostlist, self.tmp)
self.agent_sessions = AgentUtils.run_agent(self.basepath,
self.hostlist)
server_utils.run_server(hostfile, self.server_group, self.basepath)
# parameters used in pool create
createmode = self.params.get("mode", '/run/poolparams/createmode/')
createuid = self.params.get("uid", '/run/poolparams/createuid/')
creategid = self.params.get("gid", '/run/poolparams/creategid/')
createsetid = self.params.get("setname",
'/run/poolparams/createset/')
createsize = self.params.get("size", '/run/poolparams/createsize/')
# initialize a python pool object then create the underlying
# daos storage
pool = DaosPool(self.context)
pool.create(createmode, createuid, creategid,
createsize, createsetid, None)
# need a connection to create container
pool.connect(1 << 1)
# destroy pool with connection open
pool.destroy(0)
# should throw an exception and not hit this
self.fail("Shouldn't hit this line.\n")
except DaosApiError as excep:
print("got exception which is expected so long as it is BUSY")
print(excep)
print(traceback.format_exc())
# pool should still be there
exists = check_for_pool.check_for_pool(host, pool.get_uuid_str)
if exists != 0:
self.fail("Pool gone, but destroy should have failed.\n")
# no matter what happens cleanup
finally:
if self.agent_sessions:
AgentUtils.stop_agent(self.hostlist, self.agent_sessions)
server_utils.stop_server(hosts=self.hostlist)
os.remove(hostfile)
示例7: test_singleserver
def test_singleserver(self):
"""
Test IOR with Single Server config.
:avocado: tags=ior,singleserver
"""
# parameters used in pool create
createmode = self.params.get("mode", '/run/createtests/createmode/*/')
createuid = os.geteuid()
creategid = os.getegid()
createsetid = self.params.get("setname", '/run/createtests/createset/')
createsize = self.params.get("size", '/run/createtests/createsize/')
createsvc = self.params.get("svcn", '/run/createtests/createsvc/')
iteration = self.params.get("iter", '/run/ior/iteration/')
ior_flags = self.params.get("F", '/run/ior/iorflags/')
transfer_size = self.params.get("t", '/run/ior/transfersize/')
record_size = self.params.get("r", '/run/ior/recordsize/')
segment_count = self.params.get("s", '/run/ior/segmentcount/')
stripe_count = self.params.get("c", '/run/ior/stripecount/')
async_io = self.params.get("a", '/run/ior/asyncio/')
object_class = self.params.get("o", '/run/ior/objectclass/')
try:
# initialize a python pool object then create the underlying
# daos storage
self.pool = DaosPool(self.context)
self.pool.create(createmode, createuid, creategid,
createsize, createsetid, None, None, createsvc)
pool_uuid = self.pool.get_uuid_str()
print ("pool_uuid: {}".format(pool_uuid))
tmp_rank_list = []
svc_list = ""
for i in range(createsvc):
tmp_rank_list.append(int(self.pool.svc.rl_ranks[i]))
svc_list += str(tmp_rank_list[i]) + ":"
svc_list = svc_list[:-1]
if len(self.hostlist_clients) == 1:
block_size = '12g'
elif len(self.hostlist_clients) == 2:
block_size = '6g'
elif len(self.hostlist_clients) == 4:
block_size = '3g'
ior_utils.run_ior(self.hostfile_clients, ior_flags, iteration,
block_size, transfer_size, pool_uuid, svc_list,
record_size, segment_count, stripe_count,
async_io, object_class, self.basepath)
except (DaosApiError, ior_utils.IorFailed) as excep:
self.fail("<Single Server Test FAILED>\n {}".format(excep))
示例8: setUp
def setUp(self):
self.agent_sessions = None
self.pool = None
self.container = None
self.obj = None
self.ioreq = None
self.hostlist = None
self.hostfile = None
self.no_of_dkeys = None
self.no_of_akeys = None
self.array_size = None
self.record_length = None
with open('../../../.build_vars.json') as json_f:
build_paths = json.load(json_f)
basepath = os.path.normpath(build_paths['PREFIX'] + "/../")
server_group = self.params.get("name",
'/server_config/',
'daos_server')
self.context = DaosContext(build_paths['PREFIX'] + '/lib/')
self.d_log = DaosLog(self.context)
self.hostlist = self.params.get("test_machines", '/run/hosts/*')
self.hostfile = write_host_file.write_host_file(self.hostlist,
self.workdir)
self.no_of_dkeys = self.params.get("no_of_dkeys", '/run/dkeys/*')[0]
self.no_of_akeys = self.params.get("no_of_akeys", '/run/akeys/*')[0]
self.array_size = self.params.get("size", '/array_size/')
self.record_length = self.params.get("length", '/run/record/*')
self.agent_sessions = AgentUtils.run_agent(basepath, self.hostlist)
server_utils.run_server(self.hostfile, server_group, basepath)
self.pool = DaosPool(self.context)
self.pool.create(self.params.get("mode", '/run/pool/createmode/*'),
os.geteuid(),
os.getegid(),
self.params.get("size", '/run/pool/createsize/*'),
self.params.get("setname", '/run/pool/createset/*'),
None)
self.pool.connect(2)
self.container = DaosContainer(self.context)
self.container.create(self.pool.handle)
self.container.open()
self.obj = DaosObj(self.context, self.container)
self.obj.create(objcls=1)
self.obj.open()
self.ioreq = IORequest(self.context,
self.container,
self.obj, objtype=4)
示例9: setUp
def setUp(self):
self.agent_sessions = None
try:
# get paths from the build_vars generated by build
with open('../../../.build_vars.json') as build_file:
build_paths = json.load(build_file)
self.basepath = os.path.normpath(build_paths['PREFIX'] + "/../")
self.server_group = self.params.get("name", '/server_config/',
'daos_server')
# setup the DAOS python API
self.context = DaosContext(build_paths['PREFIX'] + '/lib/')
self.hostlist = self.params.get("test_machines", '/run/hosts/*')
self.hostfile = write_host_file.write_host_file(self.hostlist,
self.workdir)
self.agent_sessions = AgentUtils.run_agent(self.basepath,
self.hostlist)
server_utils.run_server(self.hostfile, self.server_group,
self.basepath)
# parameters used in pool create
createmode = self.params.get("mode", '/run/pool/createmode/')
createsetid = self.params.get("setname", '/run/pool/createset/')
createsize = self.params.get("size", '/run/pool/createsize/')
createuid = os.geteuid()
creategid = os.getegid()
# initialize a python pool object then create the underlying
# daos storage
self.pool = DaosPool(self.context)
self.pool.create(createmode, createuid, creategid,
createsize, createsetid, None)
self.pool.connect(1 << 1)
# create a container
self.container = DaosContainer(self.context)
self.container.create(self.pool.handle)
# now open it
self.container.open()
except DaosApiError as excep:
print(excep)
print(traceback.format_exc())
self.fail("Test failed during setup.\n")
示例10: test_create
def test_create(self):
"""
Test basic pool creation.
:avocado: tags=pool,poolcreate,simplecreate
"""
# Accumulate a list of pass/fail indicators representing what is
# expected for each parameter then "and" them to determine the
# expected result of the test
expected_for_param = []
modelist = self.params.get("mode", '/run/tests/modes/*')
mode = modelist[0]
expected_for_param.append(modelist[1])
uidlist = self.params.get("uid", '/run/tests/uids/*', os.geteuid())
if uidlist[0] == 'valid':
uid = os.geteuid()
else:
uid = uidlist[0]
expected_for_param.append(uidlist[1])
gidlist = self.params.get("gid", '/run/tests/gids/*', os.getegid())
if gidlist[0] == 'valid':
gid = os.getegid()
else:
gid = gidlist[0]
expected_for_param.append(gidlist[1])
setidlist = self.params.get("setname", '/run/tests/setnames/*')
setid = setidlist[0]
expected_for_param.append(setidlist[1])
expected_result = 'PASS'
for result in expected_for_param:
if result == 'FAIL':
expected_result = 'FAIL'
break
try:
self.pool = DaosPool(self.context)
self.pool.create(mode, uid, gid, 1073741824, setid)
if expected_result in ['FAIL']:
self.fail("Test was expected to fail but it passed.\n")
except DaosApiError as exc:
print(exc)
print(traceback.format_exc())
if expected_result not in ['FAIL']:
self.fail("Test was expected to pass but it failed.\n")
示例11: setUp
def setUp(self):
# get paths from the build_vars generated by build
with open('../../../.build_vars.json') as finput:
build_paths = json.load(finput)
basepath = os.path.normpath(build_paths['PREFIX'] + "/../")
server_group = self.params.get("name", '/server_config/',
'daos_server')
# setup the DAOS python API
self.context = DaosContext(build_paths['PREFIX'] + '/lib/')
self.d_log = DaosLog(self.context)
self.hostlist = self.params.get("test_machines", '/run/hosts/*')
hostfile = write_host_file.write_host_file(self.hostlist, self.workdir)
server_utils.run_server(hostfile, server_group, basepath)
# Set up the pool and container.
try:
# parameters used in pool create
createmode = self.params.get("mode", '/run/pool/createmode/')
createsetid = self.params.get("setname", '/run/pool/createset/')
createsize = self.params.get("size", '/run/pool/createsize/*')
createuid = os.geteuid()
creategid = os.getegid()
# initialize a pool object then create the underlying
# daos storage
self.pool = DaosPool(self.context)
self.pool.create(createmode, createuid, creategid,
createsize, createsetid, None)
# need a connection to create container
self.pool.connect(1 << 1)
# create a container
self.container = DaosContainer(self.context)
self.container.create(self.pool.handle)
# now open it
self.container.open()
except DaosApiError as error:
print(error)
print(traceback.format_exc())
self.fail("Test failed before snapshot taken")
示例12: create_pool
def create_pool(self):
"""
Creates a pool that the various tests use for storage.
"""
createmode = self.params.get("mode", '/run/pool1/createmode/*/')
createuid = os.geteuid()
creategid = os.getegid()
createsetid = self.params.get("setname", '/run/pool1/createset/')
createsize = self.params.get("size", '/run/pool1/createsize/')
self.createsvc = self.params.get("svcn", '/run/pool1/createsvc/')
self.pool = DaosPool(self.context)
self.pool.create(createmode, createuid, creategid,
createsize, createsetid, None, None,
self.createsvc)
示例13: executable
def executable(self, iorflags=None):
"""
Executable function to run ior for ssf and fpp
"""
# parameters used in pool create
createmode = self.params.get("mode", '/run/pool/createmode/*/')
createuid = os.geteuid()
creategid = os.getegid()
createsetid = self.params.get("setname", '/run/pool/createset/')
createscm_size = self.params.get("scm_size", '/run/pool/createsize/')
createnvme_size = self.params.get("nvme_size", '/run/pool/createsize/')
createsvc = self.params.get("svcn", '/run/pool/createsvc/')
iteration = self.params.get("iter", '/run/ior/iteration/')
block_size = self.params.get("b", '/run/ior/transfersize_blocksize/*/')
transfer_size = self.params.get("t",
'/run/ior/transfersize_blocksize/*/')
try:
# initialize MpioUtils
self.mpio = MpioUtils()
if self.mpio.mpich_installed(self.hostlist_clients) is False:
self.fail("Exiting Test: Mpich not installed")
#print self.mpio.mpichinstall
# initialize a python pool object then create the underlying
# daos storage
self.pool = DaosPool(self.context)
self.pool.create(createmode, createuid, creategid,
createscm_size, createsetid, None, None, createsvc,
createnvme_size)
pool_uuid = self.pool.get_uuid_str()
svc_list = ""
for i in range(createsvc):
svc_list += str(int(self.pool.svc.rl_ranks[i])) + ":"
svc_list = svc_list[:-1]
print ("svc_list: {}".format(svc_list))
ior_utils.run_ior_mpiio(self.basepath, self.mpio.mpichinstall,
pool_uuid, svc_list, self.num_procs,
self.hostfile_clients, iorflags, iteration,
transfer_size, block_size, True)
except (DaosApiError, MpioFailed) as excep:
print(excep)
示例14: test_global_handle
def test_global_handle(self):
"""
Test ID: DAO
Test Description: Use a pool handle in another process.
:avocado: tags=pool,poolhandle,vm,small,regression
"""
try:
# use the uid/gid of the user running the test, these should
# be perfectly valid
createuid = os.geteuid()
creategid = os.getegid()
# parameters used in pool create that are in yaml
createmode = self.params.get("mode", '/run/testparams/createmode/')
createsetid = self.params.get("setname",
'/run/testparams/createset/')
createsize = self.params.get("size", '/run/testparams/createsize/')
# initialize a python pool object then create the underlying
# daos storage
pool = DaosPool(self.context)
pool.create(createmode, createuid, creategid,
createsize, createsetid, None)
pool.connect(1 << 1)
# create a container just to make sure handle is good
container = DaosContainer(self.context)
container.create(pool.handle)
# create a global handle
iov_len, buf_len, buf = pool.local2global()
# this should work in the future but need on-line server addition
#arg_list = (buf_len, iov_len, buf, pool.get_uuid_str(), 0)
#p = Process(target=check_handle, args=arg_list)
#p.start()
#p.join()
# for now verifying global handle in the same process which is not
# the intended use case
check_handle(buf_len, iov_len, buf, pool.get_uuid_str(), 0)
except DaosApiError as excep:
print(excep)
print(traceback.format_exc())
self.fail("Expecting to pass but test has failed.\n")
示例15: setUp
def setUp(self):
""" setup for the test """
self.agent_sessions = None
# get paths from the build_vars generated by build
with open('../../../.build_vars.json') as build_file:
build_paths = json.load(build_file)
self.context = DaosContext(build_paths['PREFIX'] + '/lib/')
self.basepath = os.path.normpath(build_paths['PREFIX'] + "/../")
# generate a hostfile
self.hostlist = self.params.get("test_machines", '/run/hosts/')
self.hostfile = write_host_file.write_host_file(self.hostlist,
self.workdir)
# fire up the DAOS servers
self.server_group = self.params.get("name", '/run/server_config/',
'daos_server')
self.agent_sessions = AgentUtils.run_agent(self.basepath, self.hostlist)
server_utils.run_server(self.hostfile, self.server_group,
build_paths['PREFIX'] + '/../')
# create a pool to test with
createmode = self.params.get("mode", '/run/pool/createmode/')
createuid = self.params.get("uid", '/run/pool/createuid/')
creategid = self.params.get("gid", '/run/pool/creategid/')
createsetid = self.params.get("setname", '/run/pool/createset/')
createsize = self.params.get("size", '/run/pool/createsize/')
self.pool = DaosPool(self.context)
self.pool.create(createmode, createuid, creategid, createsize,
createsetid)
uuid = self.pool.get_uuid_str()
time.sleep(2)
# stuff some bogus data into the pool
how_many_bytes = long(self.params.get("datasize",
'/run/testparams/datatowrite/'))
exepath = os.path.join(build_paths['PREFIX'],
"/../src/tests/ftest/util/write_some_data.py")
cmd = "export DAOS_POOL={0}; export DAOS_SVCL=1; mpirun"\
" --np 1 --host {1} {2} {3} testfile".format(
uuid, self.hostlist[0], exepath, how_many_bytes)
subprocess.call(cmd, shell=True)