当前位置: 首页>>代码示例>>Python>>正文


Python ComSystem.isSimulate方法代码示例

本文整理汇总了Python中comoonics.ComSystem.isSimulate方法的典型用法代码示例。如果您正苦于以下问题:Python ComSystem.isSimulate方法的具体用法?Python ComSystem.isSimulate怎么用?Python ComSystem.isSimulate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在comoonics.ComSystem的用法示例。


在下文中一共展示了ComSystem.isSimulate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import isSimulate [as 别名]
    def create(self):
        """
        Newly creates the logical volume
        """
        LinuxVolumeManager.has_lvm()
        size=""

        if self.ondisk and self.getAttribute("overwrite", "false") == "true":
            self.remove()

        try:
            self.init_from_disk()
        except:
            pass

        if self.ondisk:
            raise LinuxVolumeManager.LVMAlreadyExistsException(self.__class__.__name__+"("+str(self.getAttribute("name"))+")")
        try:
            size=self.getAttribute("size")
            if int(self.getAttribute("size")) > int(self.parentvg.getAttribute("free")):
                ComLog.getLogger(self.__logStrLevel__).warn("Requested LV size %s is too big taking free %s" % (self.getAttribute("size"), self.parentvg.getAttribute("free")))
                self.setAttribute("size", self.parentvg.getAttribute("free"))
                size=self.getAttribute("size")
        except NameError:
            if ComSystem.isSimulate():
                size="1000"
            else:
                size=self.parentvg.getAttribute("free")
        LinuxVolumeManager.lvm('lvcreate', '-L %sM' %size, '-n %s' %str(self.getAttribute("name")), '%s' %str(self.parentvg.getAttribute("name")))
        self.init_from_disk()
        if ComSystem.isSimulate():
            self.ondisk=True
开发者ID:Open-Sharedroot,项目名称:Open-Sharedroot-cluster-suite,代码行数:34,代码来源:ComLVM.py

示例2: init_from_disk

# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import isSimulate [as 别名]
    def init_from_disk(self):
        """
      Initializes this volume group from disk and reads all attributes and sets them
      """
        LinuxVolumeManager.has_lvm()
        self.ondisk = False

        rv = LinuxVolumeManager.lvmarray(
            "vgdisplay",
            "-C",
            "--noheadings",
            "--units b",
            "--nosuffix",
            "--separator : ",
            str(self.getAttribute("name")),
        )

        for line in rv:
            try:
                (vgname, numpvs, numlvs, serial, attrs, size, free) = line.strip().split(":")
                if vgname == self.getAttribute("name"):
                    self.setAttribute("numpvs", numpvs)
                    self.setAttribute("numlvs", numlvs)
                    self.setAttribute("serial", serial)
                    self.setAttribute("attrs", attrs)
                    self.setAttribute("size", str(long(math.floor(long(size) / (1024 * 1024)))))
                    self.setAttribute("free", long(math.floor(long(free) / (1024 * 1024))))
            except:
                continue
        if not ComSystem.isSimulate():
            self.ondisk = True
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:33,代码来源:ComLVM.py

示例3: init_from_disk

# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import isSimulate [as 别名]
    def init_from_disk(self):
        """
        Initializes this logical volume from disk and reads all attributes and sets them
        """
        LinuxVolumeManager.has_lvm()

        try:
            rv=LinuxVolumeManager.lvmarray('lvdisplay', '-C', '--noheadings', '--units b', '--nosuffix', '--separator : ', str(self.parentvg.getAttribute("name"))+"/"+str(self.getAttribute("name")))
            self.ondisk=False
            #FIXME
            # an exception should be thrown, if lvdisplay output has changed the syntax.
            # do we really need the for loop ?
            for line in rv:
                try:
                    if line.count(":") == 8:
                        (lvname, vgname, attrs, size, origin, snap, move, log, copy) = line.strip().split(':')
                    else:
                        #This is for newer lvm implementations.
                        (lvname, vgname, attrs, size, origin, snap, move, log, copy, convert) = line.strip().split(':')
                    self.setAttribute("attrs", attrs)
                    self.setAttribute("size", long(math.floor(long(size) / (1024 * 1024))))
                    self.setAttribute("origin", origin)
                except:
                    #FIXME
                    # this should be fixed to get an exception if the values cannot be parsed.
                    continue

            if not ComSystem.isSimulate():
                self.ondisk=True
        except LinuxVolumeManager.LVMCommandException:
            pass
开发者ID:Open-Sharedroot,项目名称:Open-Sharedroot-cluster-suite,代码行数:33,代码来源:ComLVM.py

示例4: doPre

# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import isSimulate [as 别名]
    def doPre(self):
        """
        Unpacks the given file to dest
        """
        srcfile=self.getAttribute("name")
        destfile=self.getAttribute("dest")
        __mkdir=self.getAttributeBoolean("mkdir", default=True)

        if not ComSystem.execMethod(os.path.exists, destfile) and __mkdir:
            ComLog.getLogger(ArchiveRequirement.__logStrLevel__).debug("Path %s does not exists. I'll create it." % destfile)
            os.makedirs(destfile)

        if self.check() and not ComSystem.isSimulate():
            if not os.access(srcfile, os.R_OK) or not os.access(destfile, os.F_OK) or not os.access(destfile, os.W_OK):
                raise ArchiveRequirementException("Either srcfile %s is not readable or dest %s is not writeable" % (srcfile, destfile))

        __cmd="rm -rf %s/*" % destfile
        (rc, rv) = ComSystem.execLocalGetResult(__cmd)
        if rc >> 8 != 0:
            raise RuntimeError("running \"%s\" failed: %u, %s" % (__cmd, rc,rv))

        self.olddir=os.curdir
        ComSystem.execMethod(os.chdir, destfile)
        __cmd="gzip -cd %s | cpio -i" % srcfile
        (rc, rv, stderr) = ComSystem.execLocalGetResult(__cmd, True)
        if rc >> 8 != 0:
            raise RuntimeError("running \"%s\" failed: %u, %s, %s" % (__cmd, rc,rv, stderr))
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:29,代码来源:ComArchiveRequirement.py

示例5: __prepare

# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import isSimulate [as 别名]
 def __prepare(self):
     import os
     self.origpath=self.path.getPath()
     ComSystem.execMethod(self.path.mkdir)
     ComSystem.execMethod(self.path.pushd, self.path.getPath())
     if not ComSystem.isSimulate():
         self.journal(self.path, "pushd")
     PathCopyObject.logger.debug("prepareAsSource() CWD: " + os.getcwd())
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:10,代码来源:ComPathCopyObject.py

示例6: has_lvm

# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import isSimulate [as 别名]
    def has_lvm():
        """
      Just checks if lvm functionality is available.
      Returns true or raises an exception (RuntimeException)
      """
        if ComSystem.isSimulate():
            return 1
        CMD_LVM = "/usr/sbin/lvm"
        if not (os.access(CMD_LVM, os.X_OK) or os.access("/sbin/lvm", os.X_OK)):
            raise RuntimeError("LVM binaries do not seam to be available")

        if not (os.access(CMD_LVM, os.X_OK)) and (os.access("/sbin/lvm", os.X_OK)):
            CMD_LVM = "/sbin/lvm"

        try:
            _cachedir = LinuxVolumeManager.lvm("dumpconfig", "devices/cache_dir")
            _cachedir.strip()
        except LinuxVolumeManager.LVMCommandException:
            if (
                not ComSystem.isSimulate()
                and not os.access("/etc/lvm/.cache", os.R_OK)
                and not os.access("/etc/lvm/cache/.cache", os.R_OK)
            ):
                raise RuntimeError("LVM could not read lvm cache file")

        f = open("/proc/devices", "r")
        lines = f.readlines()
        f.close()

        for line in lines:
            try:
                (dev, name) = line[:-1].split(" ", 2)
            except:
                continue
            if name == "device-mapper":
                __lvmDevicePresent__ = 1
                break

        if __lvmDevicePresent__ == 0:
            raise RuntimeError("LVM Functionality does not seam to be available")
        return 1
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:43,代码来源:ComLVM.py

示例7: __init__

# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import isSimulate [as 别名]
    def __init__(self, *params):
        """
      Constructor

      Valid Constructors are:
      __init__(element, doc=None)
      __init__(name, _pv=None, doc=None)
      """

        self.pvs = dict()
        self.lvs = dict()

        if (len(params) == 1) or (len(params) == 2 and isinstance(params[1], PhysicalVolume)):
            doc = doc = xml.dom.getDOMImplementation().createDocument(None, None, None)
        elif (len(params) == 2) and not isinstance(params[1], PhysicalVolume):
            doc = params[1]
        else:
            raise IndexError("Index out of range for Volume Group constructor (%u)" % len(params))

        if isinstance(params[0], Node):
            self.log.debug(
                "createing volumegroup %s/%s from element" % (params[0].tagName, str(params[0].getAttribute("name")))
            )
            LinuxVolumeManager.__init__(self, params[0], params[1])
            # init all lvs
            __lvs = self.getElement().getElementsByTagName(LogicalVolume.TAGNAME)
            for i in range(len(__lvs)):
                self.addLogicalVolume(LogicalVolume(__lvs[i], self, doc))
            # init all pvs
            __pvs = self.getElement().getElementsByTagName(PhysicalVolume.TAGNAME)
            for i in range(len(__pvs)):
                self.addPhysicalVolume(PhysicalVolume(__pvs[i], self, doc))
        elif isinstance(params[0], basestring):
            self.log.debug("createing volumegroup %s from new element" % params[0])
            LinuxVolumeManager.__init__(self, doc.createElement(self.TAGNAME), doc)
            self.setAttribute("name", params[0])
            if len(params) > 1 and isinstance(params[1], PhysicalVolume):
                self.addPhysicalVolume(params[1])
        else:
            raise TypeError("Unsupported type for constructor %s" % type(params[0]))
        try:
            LinuxVolumeManager.lvm("pvscan", ' | grep "[[:blank:]]%s[[:blank:]]"' % str(self.getAttribute("name")))
            if not ComSystem.isSimulate():
                self.ondisk = True
        except LinuxVolumeManager.LVMCommandException:
            pass
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:48,代码来源:ComLVM.py

示例8: doPost

# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import isSimulate [as 别名]
    def doPost(self):
        """
        Does something afterwards
        """
        srcfile=self.getAttribute("name")
        destfile=self.getAttribute("dest")

        if self.check() and not ComSystem.isSimulate():
            if not os.access(srcfile, os.R_OK) or not os.access(destfile, os.F_OK) or not os.access(destfile, os.W_OK):
                raise ArchiveRequirementException("Either srcfile %s is not readable or dest %s is not writeable" % (srcfile, destfile))
        ComSystem.execMethod(os.chdir, destfile)
        __cmd="cp %s %s" %(srcfile, srcfile+self.getAttribute("bak_suffix", ".bak"))
        try:
            (rc, rv, stderr) = ComSystem.execLocalGetResult(__cmd, True)
            if rc >> 8 != 0:
                raise RuntimeError("running \"%s\" failed: %u, %s, errors: %s" % (__cmd, rc,rv, stderr))
        except RuntimeError, re:
            ComLog.getLogger(ArchiveRequirement.__logStrLevel__).warn("Cannot backup sourcefile %s=%s, %s." %(srcfile, srcfile+".bak", re))
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:20,代码来源:ComArchiveRequirement.py

示例9: test_tools

# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import isSimulate [as 别名]
def test_tools(tools=[ "sg_persist" ]):
    import os
    notfoundtools=list()
    try:
        from comoonics import ComSystem
        if ComSystem.isSimulate():
            return notfoundtools
    except:
        pass
    for tool in tools:
        found=False
        for path in os.environ['PATH'].split(":"):
            cmd=os.path.join(path, tool)
            if os.path.exists(cmd) and os.access(cmd, os.X_OK):
                found=True
        if not found:
            notfoundtools.append(tool)
    return notfoundtools
开发者ID:MarcGrimme,项目名称:comoonics-initrd-ng,代码行数:20,代码来源:fence_scsi_test.py

示例10: __init__

# 需要导入模块: from comoonics import ComSystem [as 别名]
# 或者: from comoonics.ComSystem import isSimulate [as 别名]
 def __init__(self):
     if os.path.isfile(RedHatClusterHelper.defaultclusterstatus_cmd) or ComSystem.isSimulate():
         self.clusterstatus_cmd=RedHatClusterHelper.defaultclusterstatus_cmd
         self.clusterstatus_opts=RedHatClusterHelper.defaultclusterstatus_opts
     else:
         raise HelperNotSupportedError("The helperclass RedHatClusterHelper is not supported in this environment.")
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:8,代码来源:RedHatClusterHelper.py


注:本文中的comoonics.ComSystem.isSimulate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。