本文整理汇总了Python中util.gen_uuid函数的典型用法代码示例。如果您正苦于以下问题:Python gen_uuid函数的具体用法?Python gen_uuid怎么用?Python gen_uuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gen_uuid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: clone
def clone(self, sr_uuid, vdi_uuid):
dest = util.gen_uuid ()
args = []
args.append("vdi_clone")
args.append(sr_uuid)
args.append(vdi_uuid)
args.append(dest)
if self.hidden:
raise xs_errors.XenError('VDIClone', opterr='hidden VDI')
depth = vhdutil.getDepth(self.path)
if depth == -1:
raise xs_errors.XenError('VDIUnavailable', \
opterr='failed to get VHD depth')
elif depth >= vhdutil.MAX_CHAIN_SIZE:
raise xs_errors.XenError('SnapshotChainTooLong')
# Test the amount of actual disk space
if ENFORCE_VIRT_ALLOC:
self.sr._loadvdis()
reserved = self.sr.virtual_allocation
sr_size = self.sr._getsize()
if (sr_size - reserved) < \
((self.size + VDI.VDIMetadataSize(SR.DEFAULT_TAP, self.size))*2):
raise xs_errors.XenError('SRNoSpace')
newuuid = util.gen_uuid()
src = self.path
dst = os.path.join(self.sr.path, "%s.%s" % (dest,self.vdi_type))
newsrc = os.path.join(self.sr.path, "%s.%s" % (newuuid,self.vdi_type))
newsrcname = "%s.%s" % (newuuid,self.vdi_type)
if not self._checkpath(src):
raise xs_errors.XenError('VDIUnavailable', \
opterr='VDI %s unavailable %s' % (vdi_uuid, src))
# wkcfix: multiphase
util.start_log_entry(self.sr.path, self.path, args)
# We assume the filehandle has been released
try:
try:
util.ioretry(lambda: os.rename(src,newsrc))
except util.CommandException, inst:
if inst.code != errno.ENOENT:
# failed to rename, simply raise error
util.end_log_entry(self.sr.path, self.path, ["error"])
raise
try:
util.ioretry(lambda: self._dualsnap(src, dst, newsrcname))
# mark the original file (in this case, its newsrc)
# as hidden so that it does not show up in subsequent scans
util.ioretry(lambda: self._mark_hidden(newsrc))
except util.CommandException, inst:
if inst.code != errno.EIO:
raise
开发者ID:redivy,项目名称:xe-storage-plugins,代码行数:58,代码来源:FileSR.py
示例2: clone
def clone(self, vdi, vdi_info):
meta = read_metadata(self.path, vdi)
parent = data_path(self.path, meta["data"])
# Create two vhd leaves whose parent is [vdi]
left = self.make_fresh_data_name()
vhd.make_leaf(self.path + "/" + data_dir + "/" + left + vhd_suffix, parent)
right = self.make_fresh_data_name()
vhd.make_leaf(self.path + "/" + data_dir + "/" + right + vhd_suffix, parent)
# Remap the original [vdi]'s location to point to the first leaf's path
parent_info = read_metadata(self.path, vdi)
parent_info["data"] = left
write_metadata(self.path, vdi, parent_info)
# The cloned vdi's location points to the second leaf's path
clone = make_fresh_metadata_name(self.path, self.hostname, vdi_info["name_label"])
vdi_info["vdi"] = clone
vdi_info["data"] = right
vdi_info["virtual_size"] = parent_info["virtual_size"]
vdi_info["content_id"] = parent_info["content_id"]
if vdi_info["content_id"] == "":
vdi_info["content_id"] = util.gen_uuid()
vdi_info["read_only"] = parent_info["read_only"]
write_metadata(self.path, clone, vdi_info)
return vdi_info
开发者ID:jonludlam,项目名称:xapi-storage,代码行数:28,代码来源:fs.py
示例3: probe
def probe(self):
self.uuid = util.gen_uuid()
if self.mpath == 'true' and self.dconf.has_key('SCSIid'):
# When multipathing is enabled, since we don't refcount the
# multipath maps, we should not attempt to do the iscsi.attach/
# detach when the map is already present, as this will remove it
# (which may well be in use).
maps = []
try:
maps = mpath_cli.list_maps()
except:
pass
if self.dconf['SCSIid'] in maps:
raise xs_errors.XenError('SRInUse')
self.iscsi.attach(self.uuid)
if not self.iscsi._attach_LUN_bySCSIid(self.SCSIid):
util.SMlog("Unable to detect LUN")
raise xs_errors.XenError('InvalidDev')
self._pathrefresh(OCFSoISCSISR)
out = OCFSSR.OCFSSR.probe(self)
self.iscsi.detach(self.uuid)
return out
开发者ID:BobBall,项目名称:sm,代码行数:25,代码来源:OCFSoISCSISR.py
示例4: parse
def parse(self):
if len(sys.argv) <> 2:
util.SMlog("Failed to parse commandline; wrong number of arguments; argv = %s" % (repr(sys.argv)))
raise xs_errors.XenError('BadRequest')
# Debug logging of the actual incoming command from the caller.
# util.SMlog( "" )
# util.SMlog( "SM.parse: DEBUG: args = %s,\n%s" % \
# ( sys.argv[0], \
# util.splitXmlText( util.hideMemberValuesInXmlParams( \
# sys.argv[1] ), showContd=True ) ), \
# priority=syslog.LOG_DEBUG )
try:
params, methodname = xmlrpclib.loads(sys.argv[1])
self.cmd = methodname
params = params[0] # expect a single struct
self.params = params
# params is a dictionary
self.dconf = params['device_config']
if params.has_key('sr_uuid'):
self.sr_uuid = params['sr_uuid']
if params.has_key('vdi_uuid'):
self.vdi_uuid = params['vdi_uuid']
elif self.cmd == "vdi_create":
self.vdi_uuid = util.gen_uuid ()
except Exception, e:
util.SMlog("Failed to parse commandline; exception = %s argv = %s" % (str(e), repr(sys.argv)))
raise xs_errors.XenError('BadRequest')
开发者ID:letsboogey,项目名称:sm,代码行数:31,代码来源:SRCommand.py
示例5: __init__
def __init__(self, services, block, blockList):
Thread.__init__(self)
self.clientid = str(util.gen_uuid())
self.proposer = Proposer(self.clientid, services, block, blockList)
self.latency = 0
self.master = False
dbg.dbg("Client %s" % self.clientid)
开发者ID:sabativi,项目名称:metasync,代码行数:7,代码来源:disk_paxos.py
示例6: probe
def probe(self):
self.uuid = util.gen_uuid()
# When multipathing is enabled, since we don't refcount the multipath maps,
# we should not attempt to do the iscsi.attach/detach when the map is already present,
# as this will remove it (which may well be in use).
if self.mpath == 'true' and self.dconf.has_key('SCSIid'):
maps = []
mpp_lun = False
try:
if (mpp_luncheck.is_RdacLun(self.dconf['SCSIid'])):
mpp_lun = True
link=glob.glob('/dev/disk/mpInuse/%s-*' % self.dconf['SCSIid'])
else:
maps = mpath_cli.list_maps()
except:
pass
if (mpp_lun):
if (len(link)):
raise xs_errors.XenError('SRInUse')
else:
if self.dconf['SCSIid'] in maps:
raise xs_errors.XenError('SRInUse')
self.iscsi.attach(self.uuid)
if not self.iscsi._attach_LUN_bySCSIid(self.SCSIid):
util.SMlog("Unable to detect LUN")
raise xs_errors.XenError('InvalidDev')
self._pathrefresh(LVHDoISCSISR)
out = LVHDSR.LVHDSR.probe(self)
self.iscsi.detach(self.uuid)
return out
开发者ID:pritha-srivastava,项目名称:sm,代码行数:33,代码来源:LVHDoISCSISR.py
示例7: spaceAvailableForVdis
def spaceAvailableForVdis(self, count):
try:
created = False
try:
# The easiest way to do this, is to create a dummy vdi and write it
uuid = util.gen_uuid()
vdi_info = { UUID_TAG: uuid,
NAME_LABEL_TAG: 'dummy vdi for space check',
NAME_DESCRIPTION_TAG: 'dummy vdi for space check',
IS_A_SNAPSHOT_TAG: 0,
SNAPSHOT_OF_TAG: '',
SNAPSHOT_TIME_TAG: '',
TYPE_TAG: 'user',
VDI_TYPE_TAG: 'vhd',
READ_ONLY_TAG: 0,
MANAGED_TAG: 0,
'metadata_of_pool': ''
}
created = self.addVdiInternal(vdi_info)
except IOError, e:
raise
finally:
if created:
# Now delete the dummy VDI created above
self.deleteVdi(uuid)
return
开发者ID:JohnGarbutt,项目名称:xcp-storage-managers,代码行数:27,代码来源:srmetadata.py
示例8: _db_introduce
def _db_introduce(self):
uuid = util.default(self, "uuid", lambda: util.gen_uuid())
sm_config = util.default(self, "sm_config", lambda: {})
ty = util.default(self, "ty", lambda: "user")
is_a_snapshot = util.default(self, "is_a_snapshot", lambda: False)
metadata_of_pool = util.default(self, "metadata_of_pool", lambda: "OpaqueRef:NULL")
snapshot_time = util.default(self, "snapshot_time", lambda: "19700101T00:00:00Z")
snapshot_of = util.default(self, "snapshot_of", lambda: "OpaqueRef:NULL")
vdi = self.sr.session.xenapi.VDI.db_introduce(
uuid,
self.label,
self.description,
self.sr.sr_ref,
ty,
self.shareable,
self.read_only,
{},
self.location,
{},
sm_config,
self.managed,
str(self.size),
str(self.utilisation),
metadata_of_pool,
is_a_snapshot,
xmlrpclib.DateTime(snapshot_time),
snapshot_of,
)
return vdi
开发者ID:amscanne,项目名称:xcp-storage-managers,代码行数:29,代码来源:VDI.py
示例9: __init__
def __init__(self, services, path):
Thread.__init__(self)
random.seed(time.time())
self.clientid = str(util.gen_uuid())
self.proposer = Proposer(self.clientid, services, path)
self.latency = 0
self.master = False
dbg.dbg("Client %s" % self.clientid)
开发者ID:royels,项目名称:metasync,代码行数:8,代码来源:paxos.py
示例10: probe
def probe(self):
self.uuid = util.gen_uuid()
self.iscsi.attach(self.uuid)
if not self.iscsi._attach_LUN_bySCSIid(self.SCSIid):
util.SMlog("Unable to detect LUN")
raise xs_errors.XenError('InvalidDev')
out = super(LVMoISCSISR, self).probe()
self.iscsi.detach(self.uuid)
return out
开发者ID:JohnGarbutt,项目名称:xcp-storage-managers,代码行数:9,代码来源:LVMoISCSISR.py
示例11: _db_introduce
def _db_introduce(self):
uuid = util.default(self, "uuid", lambda: util.gen_uuid())
sm_config = util.default(self, "sm_config", lambda: {})
vdi = self.sr.session.xenapi.VDI.db_introduce(uuid, self.label, self.description, self.sr.sr_ref, "user", self.shareable, self.read_only, {}, self.location, {}, {})
self.sr.session.xenapi.VDI.set_sm_config(vdi, sm_config)
self.sr.session.xenapi.VDI.set_managed(vdi, self.managed)
self.sr.session.xenapi.VDI.set_virtual_size(vdi, str(self.size))
self.sr.session.xenapi.VDI.set_physical_utilisation(vdi, str(self.utilisation))
return vdi
开发者ID:redivy,项目名称:xe-storage-plugins,代码行数:9,代码来源:VDI.py
示例12: cmd_init
def cmd_init(metasync, args, opts):
"initialize the repo (e.g., metasync init [namespace])"
# namespace to avoid conflict
ns = args[0] if len(args) > 0 else str(util.gen_uuid())
if not metasync.cmd_init(ns):
dbg.err("Can't initialize the repository")
return -1
开发者ID:UWNetworksLab,项目名称:metasync,代码行数:9,代码来源:__init__.py
示例13: deactivate
def deactivate(self, vdi):
meta = read_metadata(self.path, vdi)
if meta["content_id"] == "":
meta["content_id"] = util.gen_uuid()
write_metadata(self.path, vdi, meta)
data = meta["data"]
if data not in self.tapdisks:
raise Backend_error("VDI_NOT_ATTACHED", [ vdi ])
self.tapdisks[data].close()
self.open_dummy_vhd(meta, self.tapdisks[data])
开发者ID:jonludlam,项目名称:xapi-storage,代码行数:11,代码来源:fs.py
示例14: _loadvdis
def _loadvdis(self):
"""Scan the location directory."""
if self.vdis:
return
try:
for name in util.listdir(self.dconf['location']):
if name != "":
self.vdis[name] = SHMVDI(self, util.gen_uuid(), name)
except:
pass
开发者ID:rdobson,项目名称:sm,代码行数:11,代码来源:SHMSR.py
示例15: create
def create(self, sr_uuid, size):
try:
# attach the device
util.SMlog("Trying to attach iscsi disk")
self.iscsi.attach(sr_uuid)
if not self.iscsi.attached:
raise xs_errors.XenError('SRNotAttached')
util.SMlog("Attached iscsi disk at %s \n" % self.iscsi.path)
try:
# generate new UUIDs for VG and LVs
old_vg_name = self._getVgName(self.dconf['device'])
lvm_config_dict = self._getLvmInfo(old_vg_name)
lvUuidMap = {} # Maps old lv uuids to new uuids
for lv_name in lvm_config_dict[old_vg_name]['logical_volumes']:
if lv_name == MDVOLUME_NAME:
continue
oldUuid = lv_name[4:] # remove the VHD-
lvUuidMap[oldUuid] = util.gen_uuid()
new_vg_name = VG_PREFIX + sr_uuid
self._resignLvm(sr_uuid, old_vg_name, lvUuidMap, lvm_config_dict)
# causes creation of nodes and activates the lvm volumes
LVHDSR.LVHDSR.load(self, sr_uuid)
new_vdi_info = self._resignSrMetadata(new_vg_name, self.uuid, lvUuidMap)
self._resignVdis(new_vg_name, lvUuidMap)
self._deleteAllSnapshots(new_vdi_info)
# Detach LVM
self.lvmCache.deactivateNoRefcount(MDVOLUME_NAME)
for newUuid in lvUuidMap.values():
new_lv_name = self.LV_VHD_PREFIX + newUuid
self.lvmCache.deactivateNoRefcount(new_lv_name)
except:
util.logException("RESIGN_CREATE")
raise
finally:
iscsilib.logout(self.iscsi.target, self.iscsi.targetIQN, all=True)
raise xs_errors.XenError("The SR has been successfully resigned. Use the lvmoiscsi type to attach it")
开发者ID:cloudops,项目名称:ReLVHDoISCSISR,代码行数:52,代码来源:ReLVHDoISCSISR.py
示例16: probe
def probe(self):
# N.B. There are no SR references
self._assertValues(['args','host_ref','session_ref','device_config','command'])
assert(len(self.srcmd.params['args'])==0)
# Create some Dummy SR records
entry = {}
entry['size'] = 1024
SRlist = {}
SRlist[util.gen_uuid()] = entry
# Return the Probe XML
return util.SRtoXML(SRlist)
开发者ID:chandrikas,项目名称:sm,代码行数:13,代码来源:DummySR.py
示例17: clone
def clone(self, sr_uuid, vdi_uuid):
self.sr._assertValues(['sr_uuid','args','host_ref','device_config','command','sr_ref'])
assert(len(self.sr.srcmd.params['args'])==0)
dest = util.gen_uuid()
vdi = VDI.VDI(self.sr, dest)
vdi.read_only = False
vdi.location = dest
vdi.size = 0
vdi.utilisation = 0
vdi._db_introduce()
self.run_corner_cases_tests()
return vdi.get_params()
开发者ID:chandrikas,项目名称:sm,代码行数:13,代码来源:DummySR.py
示例18: delete
def delete(self, sr_uuid, vdi_uuid):
util.SMlog("RBDVDI.delete for %s" % self.uuid)
vdis = self.session.xenapi.SR.get_VDIs(self.sr.sr_ref)
clones_uuids = set([])
has_a_snapshot = False
has_a_clone = False
for tmp_vdi in vdis:
tmp_vdi_uuid = self.session.xenapi.VDI.get_uuid(tmp_vdi)
tmp_sm_config = self.session.xenapi.VDI.get_sm_config(tmp_vdi)
if tmp_sm_config.has_key("snapshot-of"):
if tmp_sm_config["snapshot-of"] == vdi_uuid:
has_a_snapshot = True
elif tmp_sm_config.has_key("clone-of"):
if tmp_sm_config["clone-of"] == vdi_uuid:
has_a_clone = True
clones_uuids.add(tmp_vdi_uuid)
if has_a_snapshot == True:
# reverting of VM snapshot
self_vdi_ref = self.session.xenapi.VDI.get_by_uuid(vdi_uuid)
new_uuid = util.gen_uuid()
self.snaps = self.session.xenapi.VDI.get_snapshots(self_vdi_ref)
# renaming base image
self._rename_image(vdi_uuid, new_uuid)
for snap in self.snaps:
util.SMlog("RBDVDI.delete set snapshot_of = %s for %s" % (self.uuid, self.session.xenapi.VDI.get_uuid(snap)))
self.session.xenapi.VDI.add_to_sm_config(snap, 'new_uuid', new_uuid)
self.session.xenapi.VDI.add_to_sm_config(snap, 'rollback', 'true')
else:
# deleting of VDI
self_vdi_ref = self.session.xenapi.VDI.get_by_uuid(vdi_uuid)
self_sm_config = self.session.xenapi.VDI.get_sm_config(self_vdi_ref)
if self_sm_config.has_key("snapshot-of"):
if has_a_clone == True:
for clone_uuid in clones_uuids:
clone_vdi_ref = self.session.xenapi.VDI.get_by_uuid(vdi_uuid)
self.session.xenapi.VDI.remove_from_sm_config(clone_vdi_ref, "clone-of")
self._flatten_clone(clone_uuid)
if self_sm_config.has_key("compose"):
self._delete_snapshot(self_sm_config["compose_vdi1"], vdi_uuid)
self._delete_vdi(self_sm_config["compose_vdi1"])
self.sr.forget_vdi(self_sm_config["compose_vdi1"])
else:
self._delete_snapshot(self_sm_config["snapshot-of"], vdi_uuid)
else:
self._delete_vdi(vdi_uuid)
self.size = int(self.session.xenapi.VDI.get_virtual_size(self_vdi_ref))
self.sr._updateStats(self.sr.uuid, -self.size)
self._db_forget()
开发者ID:mhoffmann75,项目名称:RBDSR,代码行数:51,代码来源:RBDSR.py
示例19: _db_introduce
def _db_introduce(self):
uuid = util.default(self, "uuid", lambda: util.gen_uuid())
sm_config = util.default(self, "sm_config", lambda: {})
if self.sr.srcmd.params.has_key("vdi_sm_config"):
for key in SM_CONFIG_PASS_THROUGH_FIELDS:
val = self.sr.srcmd.params["vdi_sm_config"].get(key)
if val:
sm_config[key] = val
ty = util.default(self, "ty", lambda: "user")
is_a_snapshot = util.default(self, "is_a_snapshot", lambda: False)
metadata_of_pool = util.default(self, "metadata_of_pool", lambda: "OpaqueRef:NULL")
snapshot_time = util.default(self, "snapshot_time", lambda: "19700101T00:00:00Z")
snapshot_of = util.default(self, "snapshot_of", lambda: "OpaqueRef:NULL")
vdi = self.sr.session.xenapi.VDI.db_introduce(uuid, self.label, self.description, self.sr.sr_ref, ty, self.shareable, self.read_only, {}, self.location, {}, sm_config, self.managed, str(self.size), str(self.utilisation), metadata_of_pool, is_a_snapshot, xmlrpclib.DateTime(snapshot_time), snapshot_of)
return vdi
开发者ID:rdobson,项目名称:sm,代码行数:15,代码来源:VDI.py
示例20: _snapshot
def _snapshot(self, sr_uuid, vdi_uuid):
util.SMlog("RBDVDI.snapshot for %s" % (vdi_uuid))
#secondary = None
#if not blktap2.VDI.tap_pause(self.session, sr_uuid, vdi_uuid):
# raise util.SMException("failed to pause VDI %s" % vdi_uuid)
vdi_ref = self.session.xenapi.VDI.get_by_uuid(vdi_uuid)
sm_config = self.session.xenapi.VDI.get_sm_config(vdi_ref)
base_uuid = vdi_uuid
snap_uuid = util.gen_uuid()
vdi_info = self._get_vdi_info(vdi_uuid)
if vdi_info.has_key('VDI_LABEL'):
orig_label = vdi_info['VDI_LABEL']
else:
orig_label = ''
snapVDI = RBDVDI(self.sr, snap_uuid, "%s%s" % (orig_label, " (snapshot)"))
self._do_snapshot(base_uuid, snap_uuid)
snapVDI.path = self.sr._get_snap_path(base_uuid, snap_uuid)
snapVDI.issnap = True
snapVDI.read_only = True
snapVDI.location = snapVDI.uuid
snapVDI.snapshot_of = vdi_ref
snapVDI.size = self.session.xenapi.VDI.get_virtual_size(vdi_ref)
snapVDI.sm_config["vdi_type"] = 'aio'
snapVDI.sm_config["snapshot-of"] = base_uuid
snap_vdi_ref = snapVDI._db_introduce()
self.session.xenapi.VDI.set_physical_utilisation(snap_vdi_ref, self.session.xenapi.VDI.get_physical_utilisation(vdi_ref))
self.session.xenapi.VDI.set_virtual_size(snap_vdi_ref, self.session.xenapi.VDI.get_virtual_size(vdi_ref))
self.size = int(self.session.xenapi.VDI.get_virtual_size(vdi_ref))
self.sr._updateStats(self.sr.uuid, self.size)
#blktap2.VDI.tap_unpause(self.session, sr_uuid, vdi_uuid, secondary)
return snapVDI
开发者ID:zhoubofsy,项目名称:RBDSR-1,代码行数:42,代码来源:RBDSR.py
注:本文中的util.gen_uuid函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论