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