本文整理汇总了Python中testlib.make_uuid函数的典型用法代码示例。如果您正苦于以下问题:Python make_uuid函数的具体用法?Python make_uuid怎么用?Python make_uuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_uuid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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)
示例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
示例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
示例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)
示例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))
示例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]
示例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]
示例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
示例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
示例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
示例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)
示例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'])
示例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))