本文整理汇总了Python中util.pread函数的典型用法代码示例。如果您正苦于以下问题:Python pread函数的具体用法?Python pread怎么用?Python pread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pread函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _probe_hba
def _probe_hba(self):
try:
# use sysfs tree to gather FC data
dom = xml.dom.minidom.Document()
hbalist = dom.createElement("HBAInfoList")
dom.appendChild(hbalist)
hostlist = util.listdir("/sys/class/fc_host")
for host in hostlist:
hbainfo = dom.createElement("HBAInfo")
hbalist.appendChild(hbainfo)
cmd = ["cat", "/sys/class/fc_host/%s/symbolic_name" % host]
sname = util.pread(cmd)[:-1]
entry = dom.createElement("model")
hbainfo.appendChild(entry)
textnode = dom.createTextNode(sname)
entry.appendChild(textnode)
cmd = ["cat", "/sys/class/fc_host/%s/node_name" % host]
nname = util.pread(cmd)[:-1]
nname = util.make_WWN(nname)
entry = dom.createElement("nodeWWN")
hbainfo.appendChild(entry)
# adjust nodename to look like expected string
textnode = dom.createTextNode(nname)
entry.appendChild(textnode)
port = dom.createElement("Port")
hbainfo.appendChild(port)
cmd = ["cat", "/sys/class/fc_host/%s/port_name" % host]
pname = util.pread(cmd)[:-1]
pname = util.make_WWN(pname)
entry = dom.createElement("portWWN")
port.appendChild(entry)
# adjust nodename to look like expected string
textnode = dom.createTextNode(pname)
entry.appendChild(textnode)
cmd = ["cat", "/sys/class/fc_host/%s/port_state" % host]
state = util.pread(cmd)[:-1]
entry = dom.createElement("state")
port.appendChild(entry)
# adjust nodename to look like expected string
textnode = dom.createTextNode(state)
entry.appendChild(textnode)
entry = dom.createElement("deviceName")
port.appendChild(entry)
# adjust nodename to look like expected string
textnode = dom.createTextNode("/sys/class/scsi_host/%s" % host)
entry.appendChild(textnode)
return dom.toxml()
except:
raise xs_errors.XenError('CSLGXMLParse', \
opterr='HBA probe failed')
开发者ID:JohnGarbutt,项目名称:xcp-storage-managers,代码行数:60,代码来源:HBASR.py
示例2: setSize
def setSize(path, size, confirm):
sizeMB = size / (1024 * 1024)
cmd = [CMD_LVRESIZE, "-L", str(sizeMB), path]
if confirm:
util.pread3(cmd, "y\n")
else:
util.pread(cmd)
开发者ID:JohnGarbutt,项目名称:xcp-storage-managers,代码行数:7,代码来源:lvutil.py
示例3: detach
def detach(self, sr_uuid):
if not util.ioretry(lambda: self._checkmount()):
return
try:
util.pread(["umount", self.path])
os.rmdir(self.path)
except util.CommandException, inst:
raise xs_errors.XenError('NFSUnMount', \
opterr='error is %d' % inst.code)
开发者ID:BobBall,项目名称:sm,代码行数:9,代码来源:NFSSR.py
示例4: detach
def detach(self, sr_uuid):
if self._checkmount():
try:
util.SMlog("Aborting GC/coalesce")
cleanup.abort(self.uuid)
os.chdir(SR.MOUNT_BASE)
util.pread(["umount", self.path])
os.rmdir(self.path)
except Exception, e:
raise xs_errors.XenError('SRInUse', opterr=str(e))
开发者ID:falaa,项目名称:sm,代码行数:10,代码来源:FileSR.py
示例5: _lvmBugCleanup
def _lvmBugCleanup(path):
# the device should not exist at this point. If it does, this was an LVM
# bug, and we manually clean up after LVM here
mapperDevice = path[5:].replace("-", "--").replace("/", "-")
mapperPath = "/dev/mapper/" + mapperDevice
nodeExists = False
cmd = [CMD_DMSETUP, "status", mapperDevice]
try:
util.pread(cmd, expect_rc=1)
except util.CommandException, e:
if e.code == 0:
nodeExists = True
开发者ID:MarkSymsCtx,项目名称:sm,代码行数:13,代码来源:lvutil.py
示例6: attach
def attach(self, sr_uuid):
if not self._checkmount():
try:
util.ioretry(lambda: util.makedirs(self.path))
except util.CommandException, inst:
if inst.code != errno.EEXIST:
raise xs_errors.XenError("FileSRCreate", \
opterr='fail to create mount point. Errno is %s' % inst.code)
try:
util.pread(["mount", "--bind", self.remotepath, self.path])
except util.CommandException, inst:
raise xs_errors.XenError('FileSRCreate', \
opterr='fail to mount FileSR. Errno is %s' % inst.code)
开发者ID:falaa,项目名称:sm,代码行数:13,代码来源:FileSR.py
示例7: check_server_service
def check_server_service(server):
"""Ensure NFS service is up and available on the remote server.
Returns False if fails to detect service after
NFS_SERVICE_RETRY * NFS_SERVICE_WAIT
"""
retries = 0
errlist = [errno.EPERM, errno.EPIPE, errno.EIO]
while True:
try:
services = util.pread([RPCINFO_BIN, "-s", "%s" % server])
services = services.split("\n")
for i in range(len(services)):
if services[i].find("nfs") > 0:
return True
except util.CommandException, inst:
if not int(inst.code) in errlist:
raise
util.SMlog("NFS service not ready on server %s" % server)
retries += 1
if retries >= NFS_SERVICE_RETRY:
break
time.sleep(NFS_SERVICE_WAIT)
开发者ID:chandrikas,项目名称:sm,代码行数:27,代码来源:nfs.py
示例8: removeDevMapperEntry
def removeDevMapperEntry(path, strict=True):
try:
# remove devmapper entry using dmsetup
cmd = [CMD_DMSETUP, "remove", path]
util.pread2(cmd)
return True
except Exception, e:
if not strict:
cmd = [CMD_DMSETUP, "status", path]
try:
util.pread(cmd, expect_rc=1)
return True
except:
pass # Continuining will fail and log the right way
util.SMlog("removeDevMapperEntry: dmsetup remove failed for file %s " \
"with error %s." % (path, str(e)))
return False
开发者ID:MarkSymsCtx,项目名称:sm,代码行数:17,代码来源:lvutil.py
示例9: create
def create(self, sr_uuid, size):
if util.pathexists(self.blockdevice):
util.zeroOut(self.blockdevice, 0, 1024 * 1024)
cmd = ["mkfs", "-t", "ocfs2", "-b", "4K", "-C", "1M", "-N", "16", "-F", self.blockdevice]
try:
ret = util.pread(cmd)
except util.CommandException, inst:
raise xs_errors.XenError("OCFSFilesystem", opterr="mkfs failed error %d" % os.strerror(inst.code))
开发者ID:MarkSymsCtx,项目名称:sm,代码行数:8,代码来源:OCFSSR.py
示例10: create
def create(self, sr_uuid, size):
if util.pathexists(self.blockdevice):
util.zeroOut(self.blockdevice, 0, 1024*1024)
cmd = ['mkfs', '-t', 'ocfs2', '-b', '4K', '-C', '1M', '-N', '16', '-F', self.blockdevice ]
try:
ret = util.pread(cmd)
except util.CommandException, inst:
raise xs_errors.XenError('OCFSFilesystem', \
opterr='mkfs failed error %d' % os.strerror(inst.code))
开发者ID:Sisimon,项目名称:sm,代码行数:9,代码来源:OCFSSR.py
示例11: _query_info
def _query_info(self, path):
diskinfo = {}
cmd = [SR.TAPDISK_UTIL, "query", SR.DEFAULT_TAP, "-vpf", path]
txt = util.pread(cmd).split('\n')
diskinfo['size'] = txt[0]
for val in filter(util.exactmatch_uuid, [txt[1].split('/')[-1].replace(".%s" % SR.DEFAULT_TAP,"")]):
diskinfo['parent'] = val
diskinfo['hidden'] = txt[2].split()[1]
return diskinfo
开发者ID:redivy,项目名称:xe-storage-plugins,代码行数:9,代码来源:FileSR.py
示例12: _probe_hba
def _probe_hba(self):
try:
cmd = [HBA_CLI, "xml"]
fc_xml = util.pread(cmd)
#strip junk until xml
return fc_xml[fc_xml.index("<HBAInfoList>"):len(fc_xml)]
except:
raise xs_errors.XenError('CSLGXMLParse', \
opterr='HBA probe failed')
开发者ID:redivy,项目名称:xe-storage-plugins,代码行数:9,代码来源:HBASR.py
示例13: _query_info
def _query_info(self, path):
diskinfo = {}
cmd = [SR.TAPDISK_UTIL, "query", SR.DEFAULT_TAP, "-vpf", path]
txt = util.pread(cmd).split('\n')
diskinfo['size'] = txt[0]
if txt[1].find("has no parent") == -1:
diskinfo['parent'] = txt[1].split('/')[-1].replace(".%s" % SR.DEFAULT_TAP,"")
diskinfo['hidden'] = txt[2].split()[1]
return diskinfo
开发者ID:BobBall,项目名称:sm,代码行数:9,代码来源:FileSR.py
示例14: create
def create(self, sr_uuid, size):
if self._checkmount():
raise xs_errors.XenError('SRExists')
# Check none of the devices already in use by other PBDs
if util.test_hostPBD_devs(self.session, sr_uuid, self.root):
raise xs_errors.XenError('SRInUse')
# Check serial number entry in SR records
for dev in self.root.split(','):
if util.test_scsiserial(self.session, dev):
raise xs_errors.XenError('SRInUse')
if not lvutil._checkVG(self.vgname):
lvutil.createVG(self.root, self.vgname)
if lvutil._checkLV(self.remotepath):
raise xs_errors.XenError('SRExists')
try:
numdevs = len(self.root.split(','))
cmd = ["lvcreate", "-n", sr_uuid]
if numdevs > 1:
lowest = -1
for dev in self.root.split(','):
stats = lvutil._getPVstats(dev)
if lowest < 0 or stats['freespace'] < lowest:
lowest = stats['freespace']
size_mb = (lowest / (1024 * 1024)) * numdevs
# Add stripe parameter to command
cmd += ["-i", str(numdevs), "-I", "2048"]
else:
stats = lvutil._getVGstats(self.vgname)
size_mb = stats['freespace'] / (1024 * 1024)
assert(size_mb > 0)
cmd += ["-L", str(size_mb), self.vgname]
text = util.pread(cmd)
cmd = ["lvchange", "-ay", self.remotepath]
text = util.pread(cmd)
except util.CommandException, inst:
raise xs_errors.XenError('LVMCreate', \
opterr='lv operation, error %d' % inst.code)
开发者ID:chandrikas,项目名称:sm,代码行数:44,代码来源:EXTSR.py
示例15: _query_info
def _query_info(self, path):
diskinfo = {}
cmd = [SR.TAPDISK_UTIL, "query", vhdutil.VDI_TYPE_VHD, "-vpf", path]
txt = util.pread(cmd).split('\n')
diskinfo['size'] = txt[0]
lst = [txt[1].split('/')[-1].replace(vhdutil.FILE_EXTN_VHD, "")]
for val in filter(util.exactmatch_uuid, lst):
diskinfo['parent'] = val
diskinfo['hidden'] = txt[2].split()[1]
return diskinfo
开发者ID:Sisimon,项目名称:sm,代码行数:10,代码来源:FileSR.py
示例16: check_server_tcp
def check_server_tcp(server):
"""Make sure that NFS over TCP/IP V3 is supported on the server.
Returns True if everything is OK, False otherwise."""
try:
util.ioretry(lambda: util.pread([RPCINFO_BIN,"-t",
"%s" % server, "nfs","3"]),
errlist=[errno.EPERM], maxretry=2, nofail=True)
except util.CommandException, inst:
raise NfsException("rpcinfo failed or timed out: return code %d" %
inst.code)
开发者ID:andycjw,项目名称:CloudStack,代码行数:10,代码来源:nfs.py
示例17: check_server_service
def check_server_service(server):
"""Ensure NFS service is up and available on the remote server.
Raises exception if fails to detect service after
NFS_SERVICE_RETRY * NFS_SERVICE_WAIT
"""
util.ioretry(lambda:
util.pread([RPCINFO_BIN, "-t", "%s" % server, "nfs"]),
errlist=[errno.EPERM, errno.EPIPE, errno.EIO],
maxretry=NFS_SERVICE_RETRY,
period=NFS_SERVICE_WAIT, nofail=True)
开发者ID:MarkSymsCtx,项目名称:sm,代码行数:11,代码来源:nfs.py
示例18: _getVHDParentNoCheck
def _getVHDParentNoCheck(path):
cmd = [VHD_UTIL, "read", "-p", "-n", "%s" % path]
text = util.pread(cmd)
util.SMlog(text)
for line in text.split('\n'):
if line.find("decoded name :") != -1:
val = line.split(':')[1].strip()
vdi = val.replace("--", "-")[-40:]
if vdi[1:].startswith("LV-"):
vdi = vdi[1:]
return vdi
return None
开发者ID:BobBall,项目名称:sm,代码行数:12,代码来源:vhdutil.py
示例19: activateNoRefcount
def activateNoRefcount(path, refresh):
cmd = [CMD_LVCHANGE, "-ay", path]
if refresh:
cmd.append("--refresh")
text = util.pread2(cmd)
if not _checkActive(path):
raise util.CommandException(-1, str(cmd), "LV not activated")
if refresh:
mapperDevice = path[5:].replace("-", "--").replace("/", "-")
cmd = [CMD_DMSETUP, "table", mapperDevice]
ret = util.pread(cmd)
util.SMlog("DM table for %s: %s" % (path, ret.strip()))
开发者ID:JohnGarbutt,项目名称:xcp-storage-managers,代码行数:12,代码来源:lvutil.py
示例20: _query_info
def _query_info(self, path, use_bkp_footer=False):
diskinfo = {}
qopts = '-vpf'
if use_bkp_footer:
qopts += 'b'
cmd = [SR.TAPDISK_UTIL, "query", vhdutil.VDI_TYPE_VHD, qopts, path]
txt = util.pread(cmd).split('\n')
diskinfo['size'] = txt[0]
lst = [txt[1].split('/')[-1].replace(vhdutil.FILE_EXTN_VHD, "")]
for val in filter(util.exactmatch_uuid, lst):
diskinfo['parent'] = val
diskinfo['hidden'] = txt[2].split()[1]
return diskinfo
开发者ID:falaa,项目名称:sm,代码行数:13,代码来源:FileSR.py
注:本文中的util.pread函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论