本文整理汇总了Python中testlib.make_uuid函数的典型用法代码示例。如果您正苦于以下问题:Python make_uuid函数的具体用法?Python make_uuid怎么用?Python make_uuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_uuid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: make_env
def make_env(env_type, base, top):
img_id = make_uuid()
base_id = make_uuid()
top_id = make_uuid()
if env_type == "block" and base.format == "raw":
prealloc = sc.PREALLOCATED_VOL
else:
prealloc = sc.SPARSE_VOL
with fake_env(env_type) as env:
env.make_volume(base.virtual * GB, img_id, base_id, vol_format=sc.name2type(base.format), prealloc=prealloc)
env.make_volume(top.virtual * GB, img_id, top_id, parent_vol_id=base_id, vol_format=sc.COW_FORMAT)
env.subchain = merge.SubchainInfo(
dict(sd_id=env.sd_manifest.sdUUID, img_id=img_id, base_id=base_id, top_id=top_id), 0
)
if env_type == "block":
# Simulate allocation by adjusting the LV sizes
env.lvm.extendLV(env.sd_manifest.sdUUID, base_id, base.physical * GB / MB)
env.lvm.extendLV(env.sd_manifest.sdUUID, top_id, top.physical * GB / MB)
rm = FakeResourceManager()
with MonkeyPatchScope(
[
(guarded, "context", fake_guarded_context()),
(merge, "sdCache", env.sdcache),
(blockVolume, "rm", rm),
(blockVolume, "sdCache", env.sdcache),
(image.Image, "getChain", lambda self, sdUUID, imgUUID: [env.subchain.base_vol, env.subchain.top_vol]),
(blockVolume.BlockVolume, "extendSize", partial(fake_blockVolume_extendSize, env)),
(fileVolume.FileVolume, "extendSize", partial(fake_fileVolume_extendSize, env)),
]
):
yield env
开发者ID:nirs,项目名称:vdsm,代码行数:35,代码来源:storage_merge_test.py
示例2: fake_volume
def fake_volume(storage_type='file', size=MB, format=sc.RAW_FORMAT):
img_id = make_uuid()
vol_id = make_uuid()
with fake_env(storage_type) as env:
env.make_volume(size, img_id, vol_id, vol_format=format)
vol = env.sd_manifest.produceVolume(img_id, vol_id)
yield vol
开发者ID:oVirt,项目名称:vdsm,代码行数:7,代码来源:storagetestlib.py
示例3: fake_volume
def fake_volume(self, vol_fmt, sd_version=3):
with fake_file_env(sd_version=sd_version) as env:
img_id = make_uuid()
vol_id = make_uuid()
make_file_volume(env.sd_manifest, self.SIZE, img_id, vol_id,
vol_format=vol_fmt)
yield env.sd_manifest.produceVolume(img_id, vol_id)
开发者ID:EdDev,项目名称:vdsm,代码行数:7,代码来源:storage_hsm_test.py
示例4: make_volume
def make_volume(env, size, md_fmt, real_fmt):
img_id = make_uuid()
vol_id = make_uuid()
env.make_volume(size, img_id, vol_id, vol_format=md_formats[md_fmt])
vol = env.sd_manifest.produceVolume(img_id, vol_id)
qemuimg.create(vol.getVolumePath(), size, qemu_formats[real_fmt])
return vol
开发者ID:EdDev,项目名称:vdsm,代码行数:7,代码来源:storage_workarounds_test.py
示例5: make_blocksd_manifest
def make_blocksd_manifest(tmpdir, fake_lvm, sduuid=None, devices=None,
sd_version=3):
if sduuid is None:
sduuid = make_uuid()
if devices is None:
devices = get_random_devices()
spuuid = make_uuid()
fake_lvm.createVG(sduuid, devices, blockSD.STORAGE_DOMAIN_TAG,
blockSD.VG_METADATASIZE)
fake_lvm.createLV(sduuid, sd.METADATA, blockSD.SD_METADATA_SIZE)
# Create the rest of the special LVs
special = blockSD.BlockStorageDomainManifest.special_volumes(sd_version)
for name, size_mb in sd.SPECIAL_VOLUME_SIZES_MIB.iteritems():
if name in special:
fake_lvm.createLV(sduuid, name, size_mb)
fake_lvm.createLV(sduuid, blockSD.MASTERLV, blockSD.MASTER_LV_SIZE_MB)
# We'll store the domain metadata in the VG's tags
metadata = make_sd_metadata(sduuid, version=sd_version, pools=[spuuid])
assert(metadata[sd.DMDK_VERSION] >= 3) # Tag based MD is V3 and above
tag_md = blockSD.TagBasedSDMetadata(sduuid)
tag_md.update(metadata)
manifest = blockSD.BlockStorageDomainManifest(sduuid, tag_md)
os.makedirs(os.path.join(manifest.domaindir, sd.DOMAIN_IMAGES))
# Make the repo directory structure
repo_pool_dir = os.path.join(tmpdir, spuuid)
os.mkdir(repo_pool_dir)
os.symlink(manifest.domaindir, os.path.join(repo_pool_dir, sduuid))
return manifest
开发者ID:oVirt,项目名称:vdsm,代码行数:34,代码来源:storagetestlib.py
示例6: _get_args
def _get_args(self):
job_id = make_uuid()
host_id = 1
sd_manifest = FakeDomainManifest(make_uuid())
vol_info = _get_vol_info()
vol_info_obj = storage.sdm.api.create_volume.CreateVolumeInfo(vol_info)
return dict(job_id=job_id, host_id=host_id, sd_manifest=sd_manifest,
vol_info=vol_info_obj)
开发者ID:EdDev,项目名称:vdsm,代码行数:8,代码来源:storage_sdm_create_volume_test.py
示例7: test_volume_type
def test_volume_type(self, vol_type):
with fake_block_env() as env:
img_id = make_uuid()
vol_id = make_uuid()
make_block_volume(env.lvm, env.sd_manifest, 0,
img_id, vol_id, vol_type=vol_type)
vol = env.sd_manifest.produceVolume(img_id, vol_id)
self.assertEqual(vol.getVolType(), sc.type2name(vol_type))
开发者ID:nirs,项目名称:vdsm,代码行数:8,代码来源:testlib_test.py
示例8: make_volume
def make_volume(self, size, storage_type='block', format=sc.RAW_FORMAT):
img_id = make_uuid()
vol_id = make_uuid()
# TODO fix make_volume helper to create the qcow image when needed
with fake_env(storage_type) as env:
if format == sc.RAW_FORMAT:
env.make_volume(size, img_id, vol_id, vol_format=format)
vol = env.sd_manifest.produceVolume(img_id, vol_id)
yield vol
else:
chain = make_qemu_chain(env, size, format, 1)
yield chain[0]
开发者ID:nirs,项目名称:vdsm,代码行数:12,代码来源:blockvolume_test.py
示例9: test_get_image_volumes
def test_get_image_volumes(self):
img_id = make_uuid()
vol_id = make_uuid()
remote_path = "[2001:db8:85a3::8a2e:370:7334]:1234:/path"
size = 5 * MEGAB
# Simulate a domain with an ipv6 address
with fake_env(storage_type='file', remote_path=remote_path) as env:
env.make_volume(size, img_id, vol_id)
vol = env.sd_manifest.produceVolume(img_id, vol_id)
vol_path = vol.getVolumePath()
sduuid = fileVolume.getDomUuidFromVolumePath(vol_path)
assert vol.getImageVolumes(sduuid, img_id) == [vol_id]
开发者ID:oVirt,项目名称:vdsm,代码行数:14,代码来源:filevolume_test.py
示例10: make_filesd_manifest
def make_filesd_manifest(mnt_dir, sd_version=3):
spuuid = make_uuid()
sduuid = make_uuid()
domain_path = os.path.join(mnt_dir, sduuid)
metafile = get_metafile_path(domain_path)
make_file(metafile)
metadata = fileSD.FileSDMetadata(metafile)
metadata.update(make_sd_metadata(sduuid, version=sd_version,
pools=[spuuid]))
manifest = fileSD.FileStorageDomainManifest(domain_path, metadata)
os.makedirs(os.path.join(manifest.domaindir, sd.DOMAIN_IMAGES))
return manifest
开发者ID:oVirt,项目名称:vdsm,代码行数:14,代码来源:storagetestlib.py
示例11: make_init_params
def make_init_params(**kwargs):
res = dict(
domain=make_uuid(),
image=make_uuid(),
puuid=make_uuid(),
capacity=1024 * MB,
format=sc.type2name(sc.RAW_FORMAT),
type=sc.type2name(sc.SPARSE_VOL),
voltype=sc.type2name(sc.LEAF_VOL),
disktype=image.SYSTEM_DISK_TYPE,
description="",
legality=sc.LEGAL_VOL,
generation=sc.DEFAULT_GENERATION)
res.update(kwargs)
return res
开发者ID:nirs,项目名称:vdsm,代码行数:15,代码来源:volume_metadata_test.py
示例12: make_sd_metadata
def make_sd_metadata(sduuid, version=3, dom_class=sd.DATA_DOMAIN, pools=None):
md = FakeMetadata()
md[sd.DMDK_SDUUID] = sduuid
md[sd.DMDK_VERSION] = version
md[sd.DMDK_CLASS] = dom_class
md[sd.DMDK_POOLS] = pools if pools is not None else [make_uuid()]
return md
开发者ID:oVirt,项目名称:vdsm,代码行数:7,代码来源:storagetestlib.py
示例13: test_lookup_updating
def test_lookup_updating(self):
record = xlease.Record(make_uuid(), 0, updating=True)
with make_volume((42, record)) as vol:
leases = vol.leases()
assert leases[record.resource]["updating"]
with pytest.raises(xlease.LeaseUpdating):
vol.lookup(record.resource)
开发者ID:oVirt,项目名称:vdsm,代码行数:7,代码来源:xlease_test.py
示例14: test_intra_domain_copy
def test_intra_domain_copy(self, env_type, src_fmt, dst_fmt):
src_fmt = sc.name2type(src_fmt)
dst_fmt = sc.name2type(dst_fmt)
job_id = make_uuid()
with self.make_env(env_type, src_fmt, dst_fmt) as env:
src_vol = env.src_chain[0]
dst_vol = env.dst_chain[0]
write_qemu_chain(env.src_chain)
self.assertRaises(ChainVerificationError,
verify_qemu_chain, env.dst_chain)
source = dict(endpoint_type='div', sd_id=src_vol.sdUUID,
img_id=src_vol.imgUUID, vol_id=src_vol.volUUID)
dest = dict(endpoint_type='div', sd_id=dst_vol.sdUUID,
img_id=dst_vol.imgUUID, vol_id=dst_vol.volUUID)
job = storage.sdm.api.copy_data.Job(job_id, 0, source, dest)
job.run()
wait_for_job(job)
self.assertEqual(sorted(self.expected_locks(src_vol, dst_vol)),
sorted(guarded.context.locks))
self.assertEqual(jobs.STATUS.DONE, job.status)
self.assertEqual(100.0, job.progress)
self.assertNotIn('error', job.info())
verify_qemu_chain(env.dst_chain)
self.assertEqual(sc.fmt2str(dst_fmt),
qemuimg.info(dst_vol.volumePath)['format'])
开发者ID:EdDev,项目名称:vdsm,代码行数:29,代码来源:storage_sdm_copy_data_test.py
示例15: test_bad_vm_configuration_volume
def test_bad_vm_configuration_volume(self):
"""
When copying a volume containing VM configuration information the
volume format may be set incorrectly due to an old bug. Check that the
workaround we have in place allows the copy to proceed without error.
"""
job_id = make_uuid()
vm_conf_size = workarounds.VM_CONF_SIZE_BLK * sc.BLOCK_SIZE
vm_conf_data = "VM Configuration"
with self.make_env('file', sc.COW_FORMAT, sc.COW_FORMAT,
size=vm_conf_size) as env:
src_vol = env.src_chain[0]
dst_vol = env.dst_chain[0]
# Corrupt the COW volume by writing raw data. This simulates how
# these "problem" volumes were created in the first place.
with open(src_vol.getVolumePath(), "w") as f:
f.write(vm_conf_data)
source = dict(endpoint_type='div', sd_id=src_vol.sdUUID,
img_id=src_vol.imgUUID, vol_id=src_vol.volUUID)
dest = dict(endpoint_type='div', sd_id=dst_vol.sdUUID,
img_id=dst_vol.imgUUID, vol_id=dst_vol.volUUID)
job = storage.sdm.api.copy_data.Job(job_id, 0, source, dest)
job.run()
wait_for_job(job)
self.assertEqual(jobs.STATUS.DONE, job.status)
# Verify that the copy succeeded
with open(dst_vol.getVolumePath(), "r") as f:
# Qemu pads the file to a 1k boundary with null bytes
self.assertTrue(f.read().startswith(vm_conf_data))
开发者ID:EdDev,项目名称:vdsm,代码行数:33,代码来源:storage_sdm_copy_data_test.py
示例16: test_volume_operation
def test_volume_operation(self, env_type, error,
final_legality, final_status, final_gen):
job_id = make_uuid()
fmt = sc.RAW_FORMAT
with self.make_env(env_type, fmt, fmt) as env:
src_vol = env.src_chain[0]
dst_vol = env.dst_chain[0]
self.assertEqual(sc.LEGAL_VOL, dst_vol.getLegality())
source = dict(endpoint_type='div', sd_id=src_vol.sdUUID,
img_id=src_vol.imgUUID, vol_id=src_vol.volUUID,
generation=0)
dest = dict(endpoint_type='div', sd_id=dst_vol.sdUUID,
img_id=dst_vol.imgUUID, vol_id=dst_vol.volUUID,
generation=0)
fake_convert = FakeQemuConvertChecker(src_vol, dst_vol,
error=error)
with MonkeyPatchScope([(qemuimg, 'convert', fake_convert)]):
job = storage.sdm.api.copy_data.Job(job_id, 0, source, dest)
job.run()
self.assertEqual(final_status, job.status)
self.assertEqual(final_legality, dst_vol.getLegality())
self.assertEqual(final_gen, dst_vol.getMetaParam(sc.GENERATION))
开发者ID:EdDev,项目名称:vdsm,代码行数:25,代码来源:storage_sdm_copy_data_test.py
示例17: test_abort_during_copy
def test_abort_during_copy(self, env_type):
fmt = sc.RAW_FORMAT
with self.make_env(env_type, fmt, fmt) as env:
src_vol = env.src_chain[0]
dst_vol = env.dst_chain[0]
gen_id = dst_vol.getMetaParam(sc.GENERATION)
source = dict(endpoint_type='div', sd_id=src_vol.sdUUID,
img_id=src_vol.imgUUID, vol_id=src_vol.volUUID,
generation=0)
dest = dict(endpoint_type='div', sd_id=dst_vol.sdUUID,
img_id=dst_vol.imgUUID, vol_id=dst_vol.volUUID,
generation=gen_id)
fake_convert = FakeQemuConvertChecker(src_vol, dst_vol,
wait_for_abort=True)
with MonkeyPatchScope([(qemuimg, 'convert', fake_convert)]):
job_id = make_uuid()
job = storage.sdm.api.copy_data.Job(job_id, 0, source, dest)
t = start_thread(job.run)
if not fake_convert.ready_event.wait(1):
raise RuntimeError("Timeout waiting for thread")
job.abort()
t.join(1)
if t.isAlive():
raise RuntimeError("Timeout waiting for thread")
self.assertEqual(jobs.STATUS.ABORTED, job.status)
self.assertEqual(sc.ILLEGAL_VOL, dst_vol.getLegality())
self.assertEqual(gen_id, dst_vol.getMetaParam(sc.GENERATION))
开发者ID:EdDev,项目名称:vdsm,代码行数:27,代码来源:storage_sdm_copy_data_test.py
示例18: test_set_generation
def test_set_generation(self, env_type):
with self.make_env(env_type) as env:
vol = env.chain[0]
job = update_volume.Job(make_uuid(), 0,
make_endpoint_from_volume(vol),
dict(generation=44))
job.run()
self.assertEqual(jobs.STATUS.DONE, job.status)
self.assertEqual(44, vol.getMetaParam(sc.GENERATION))
开发者ID:nirs,项目名称:vdsm,代码行数:9,代码来源:sdm_update_volume_test.py
示例19: test_add_exists
def test_add_exists(self, fake_sanlock):
with make_volume() as vol:
lease_id = make_uuid()
lease = vol.add(lease_id)
with pytest.raises(xlease.LeaseExists):
vol.add(lease_id)
res = fake_sanlock.read_resource(lease.path, lease.offset)
assert res["lockspace"] == lease.lockspace
assert res["resource"] == lease.resource
开发者ID:oVirt,项目名称:vdsm,代码行数:9,代码来源:xlease_test.py
示例20: make_env
def make_env(env_type, base, top):
img_id = make_uuid()
base_id = make_uuid()
top_id = make_uuid()
if env_type == 'block' and base.format == 'raw':
prealloc = sc.PREALLOCATED_VOL
else:
prealloc = sc.SPARSE_VOL
with fake_env(env_type) as env:
env.make_volume(base.virtual * GB, img_id, base_id,
vol_format=sc.name2type(base.format),
prealloc=prealloc)
env.make_volume(top.virtual * GB, img_id, top_id,
parent_vol_id=base_id,
vol_format=sc.COW_FORMAT)
env.subchain = merge.SubchainInfo(
dict(sd_id=env.sd_manifest.sdUUID, img_id=img_id,
base_id=base_id, top_id=top_id), 0)
if env_type == 'block':
# Simulate allocation by adjusting the LV sizes
env.lvm.extendLV(env.sd_manifest.sdUUID, base_id,
base.physical * GB // MB)
env.lvm.extendLV(env.sd_manifest.sdUUID, top_id,
top.physical * GB // MB)
with MonkeyPatch().context() as mp:
mp.setattr(guarded, 'context', fake_guarded_context())
mp.setattr(merge, 'sdCache', env.sdcache)
mp.setattr(blockVolume, 'rm', FakeResourceManager())
mp.setattr(blockVolume, 'sdCache', env.sdcache)
mp.setattr(
image.Image, 'getChain',
lambda self, sdUUID, imgUUID:
[env.subchain.base_vol, env.subchain.top_vol])
mp.setattr(
blockVolume.BlockVolume, 'extendSize',
partial(fake_blockVolume_extendSize, env))
mp.setattr(
fileVolume.FileVolume, 'extendSize',
partial(fake_fileVolume_extendSize, env))
yield env
开发者ID:oVirt,项目名称:vdsm,代码行数:44,代码来源:merge_test.py
注:本文中的testlib.make_uuid函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论