本文整理汇总了Python中comoonics.ComSystem.execLocalStatusOutput方法的典型用法代码示例。如果您正苦于以下问题:Python ComSystem.execLocalStatusOutput方法的具体用法?Python ComSystem.execLocalStatusOutput怎么用?Python ComSystem.execLocalStatusOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comoonics.ComSystem
的用法示例。
在下文中一共展示了ComSystem.execLocalStatusOutput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: formatDevice
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalStatusOutput [as 别名]
def formatDevice(self, device):
__devicePath = device.getDevicePath()
__cmd = self.getMkfsCmd() + " " + __devicePath
__rc, __ret = ComSystem.execLocalStatusOutput(__cmd)
log.debug("formatDevice: " + __cmd + ": " + __ret)
if __rc != 0:
raise ComException(__cmd + __ret)
示例2: mount
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalStatusOutput [as 别名]
def mount(self, device, mountpoint):
""" mount a filesystem
device: ComDevice.Device
mountpoint: ComMountPoint.MountPoint
"""
exclusive=self.getAttribute("exlock", "")
mkdir=self.getAttributeBoolean("mkdir", True)
mp=mountpoint.getAttribute("name")
if not isinstance(self, nfsFileSystem) and not os.path.exists(device.getDevicePath()):
raise IOError("Devicepath %s does not exist." %device.getDevicePath())
if not os.path.exists(mp) and mkdir:
log.debug("Path %s does not exists. I'll create it." % mp)
ComSystem.execMethod(os.makedirs, mp)
if exclusive and exclusive != "" and os.path.exists(exclusive):
raise ComException("lockfile " + exclusive + " exists!")
cmd = self.mkmountcmd(device, mountpoint)
rc, ret = ComSystem.execLocalStatusOutput(cmd)
log.debug("mount:" + cmd + ": " + ret)
if rc != 0:
raise ComException(cmd + ret)
if exclusive:
fd=open(exclusive, 'w')
fd.write(device.getDevicePath() + " is mounted ")
示例3: mount
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalStatusOutput [as 别名]
def mount(self, device, mountpoint):
""" mount a filesystem
device: ComDevice.Device
mountpoint: ComMountPoint.MountPoint
"""
__exclusive=self.getAttribute("exlock", "")
__mkdir=self.getAttributeBoolean("mkdir", True)
__mp=mountpoint.getAttribute("name")
if not os.path.exists(__mp) and __mkdir:
log.debug("Path %s does not exists. I'll create it." % __mp)
ComSystem.execMethod(os.makedirs, __mp)
if __exclusive and __exclusive != "" and os.path.exists(__exclusive):
raise ComException("lockfile " + __exclusive + " exists!")
__cmd = self.mkmountcmd(device, mountpoint)
__rc, __ret = ComSystem.execLocalStatusOutput(__cmd)
log.debug("mount:" + __cmd + ": " + __ret)
if __rc != 0:
raise ComException(__cmd + __ret)
if __exclusive:
__fd=open(__exclusive, 'w')
__fd.write(device.getDevicePath() + " is mounted ")
示例4: labelDevice
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalStatusOutput [as 别名]
def labelDevice(self, device, label):
__devicePath = device.getDevicePath()
__cmd = self.labelCmd + " " + __devicePath + " " + label
__rc, __ret = ComSystem.execLocalStatusOutput(__cmd)
log.debug("labelDevice: " + __cmd + ": " + __ret)
if __rc:
raise ComException(__cmd + __ret)
self.setAttribute("label", label)
示例5: formatDevice
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalStatusOutput [as 别名]
def formatDevice(self, device):
__cmd = self.getMkfsCmd() + self.getOptionsString() + device.getDevicePath()
if not os.path.exists(device.getDevicePath()):
raise IOError("Devicepath %s does not exist." %device.getDevicePath())
__rc, __ret = ComSystem.execLocalStatusOutput(__cmd)
#self.getLog().debug("formatDevice: \n" , __cmd + __ret)
if __rc != 0:
raise ComException(__cmd + __ret)
示例6: getLabelFromDevice
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalStatusOutput [as 别名]
def getLabelFromDevice(self, device):
# BUG: Cannot function!!!!
__devicePath= device.getDevicePath()
__cmd = self.labelCmd + " " + __devicePath
__rc, __ret = ComSystem.execLocalStatusOutput(__cmd)
log.debug("getLabel: " + __cmd + ": " + __ret)
if __rc:
raise ComException(__cmd + __ret)
return __ret
示例7: umountDev
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalStatusOutput [as 别名]
def umountDev(self, device):
""" umount a filesystem with the use of the device name
device: ComDevice.Device
"""
__cmd = self.cmd_umount + " " + device.getDevicePath()
__rc, __ret = ComSystem.execLocalStatusOutput(__cmd)
log.debug("umount:" + __cmd + ": " + __ret)
if __rc != 0:
raise ComException(__cmd + __ret)
self.unlinkLockfile()
示例8: umountDir
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalStatusOutput [as 别名]
def umountDir(self, mountpoint):
""" umount a filesystem with the use of the mountpoint
mountpoint: ComMountPoint.MountPoint
"""
__cmd = self.cmd_umount + " " + mountpoint.getAttribute("name")
__rc, __ret = ComSystem.execLocalStatusOutput(__cmd)
log.debug("umount: " + __cmd + ": " + __ret)
if __rc != 0:
raise ComException(__cmd + __ret)
self.unlinkLockfile()
示例9: getLabelFromDevice
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalStatusOutput [as 别名]
def getLabelFromDevice(self, device):
# BUG: Cannot function!!!!
__devicePath= device.getDevicePath()
if not os.path.exists(__devicePath):
raise IOError("Devicepath %s does not exist." %__devicePath)
__cmd = self.labelCmd + " " + __devicePath
__rc, __ret = ComSystem.execLocalStatusOutput(__cmd)
log.debug("getLabel: " + __cmd + ": " + __ret)
if __rc:
raise ComException(__cmd + __ret)
return __ret
示例10: doModifications
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalStatusOutput [as 别名]
def doModifications(self, _file):
# TODO create bckup of file ?
# TODO raise Warning Exception
__cmd = "mv -f "
__cmd += _file.getAttribute("sourcefile")
__cmd += " "
__cmd += _file.getAttribute("name")
__rc, __ret = ComSystem.execLocalStatusOutput(__cmd)
if __rc:
ComLog.getLogger("MoveModification").error("doMove: " + __cmd + " " + __ret)
else:
ComLog.getLogger("MoveModification").debug("doMove: " + __cmd +" "+ __ret)
示例11: doModifications
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalStatusOutput [as 别名]
def doModifications(self, file):
# TODO create bckup of file ?
# TODO raise Warning Exception
cmd = "cp -a "
cmd += file.getAttribute("sourcefile")
cmd += " "
cmd += file.getAttribute("name")
rc, ret = ComSystem.execLocalStatusOutput(cmd)
if rc:
ComLog.getLogger("CopyModification").error("doCopy: " + cmd + " " + ret)
else:
ComLog.getLogger("CopyModification").debug("doCopy: " + cmd +" "+ ret)
示例12: copyPartitionTable
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalStatusOutput [as 别名]
def copyPartitionTable(source_device, destination_device):
__cmd = (
CMD_SFDISK
+ " -d "
+ source_device.getDeviceName()
+ " | "
+ CMD_SFDISK
+ " "
+ destination_device.getDeviceName()
)
__rc, __ret = ComSystem.execLocalStatusOutput(__cmd)
log.debug("copyPartitionTable " + __ret)
if __rc != 0:
raise ComException(__cmd)
示例13: ismount
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalStatusOutput [as 别名]
def ismount(path):
"""
Uses os.path.ismount (see L{os.path} for details) and wrap it to detect
bind mounts.
"""
from comoonics import ComSystem
import os.path
if os.path.ismount(path):
return True
_tmp1 = ComSystem.execLocalStatusOutput("mount")[1]
if not _tmp1:
return False
_tmp2 = _tmp1.split("\n")
for line in _tmp2:
if os.path.realpath(line.split()[2]) == os.path.realpath(path):
return True
return False
示例14: __doCopy_alt
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalStatusOutput [as 别名]
def __doCopy_alt(self):
__tmp=os.tempnam("/tmp")
if not self.needPartitionTableUpdate():
ComLog.getLogger("Copyset").debug("partition tables are the same. No need to update")
else:
if self.destination.hasPartitionTable():
self.destination.savePartitionTable(__tmp)
self.journal(self.destination, "savePartitionTable", __tmp)
else:
self.journal(self.destination, "noPartitionTable")
if self.source.hasPartitionTable():
__cmd = self.source.getDumpStdout()
__cmd += " | "
__cmd += self.destination.getRestoreStdin(True)
__rc, __ret = ComSystem.execLocalStatusOutput(__cmd)
ComLog.getLogger("Copyset").debug(__cmd + ": " + __ret)
if __rc != 0:
raise ComException(__cmd + __ret)
else:
if not self.destination.deletePartitionTable():
raise ComException("Partition table on device %s coud not be deleted",
self.destination.getDeviceName())
示例15: fromXML
# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import execLocalStatusOutput [as 别名]
def fromXML(options, xmlfile):
from comoonics import XmlTools
import xml.dom
if options.xml=="-":
logger.debug("Parsing document from stdin")
doc = XmlTools.parseXMLFP(sys.stdin, options.xmlvalidate)
elif os.path.isfile(options.xml):
logger.debug("Parsing document %s " % options.xml)
doc = XmlTools.parseXMLFile(options.xml, options.xmlvalidate)
if options.clusterconf:
from xml import xpath
if options.nodename != None or options.nodename != "":
(rc, options.nodename)=ComSystem.execLocalStatusOutput("cman_tool status | grep 'Node name:'")
logger.debug("options.nodename: %s" %options.nodename)
options.nodename=options.nodename.split(" ")[2]
_xmlnodepath='/cluster/clusternodes/clusternode[@name="%s"]/com_info/fenceackserver' %(options.nodename)
logger.debug("Nodename: %s, path: %s" %(options.nodename, _xmlnodepath))
node=xpath.Evaluate(_xmlnodepath, doc)[0]
elif options.xmlnodepath and options.xmlnodepath != "":
from xml import xpath
logger.debug("Path2Config: %s" %options.xmlnodepath)
node=xpath.Evaluate(options.xmlnodepath, doc)[0]
else:
node=doc.documentElement
if node.hasAttribute("port"): options.port=node.getAttribute("port")
if node.hasAttribute("user"): options.user=node.getAttribute("user")
if node.hasAttribute("passwd"): options.password=node.getAttribute("passwd")
if node.hasAttribute("bind"): options.bind=node.getAttribute("bind")
sslnodes=node.getElementsByTagName("ssl")
if sslnodes:
options.ssl=True
if node.hasAttribute("keyfile"): options.ssl_keyfile=node.getAttribute("keyfile")
if node.hasAttribute("certfile"): options.ssl_certfile=node.getAttribute("certfile")
if node.hasAttribute("verifyfile"): options.ssl_verifyfile=node.getAttribute("verifyfile")
return