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


Python comoonics.ComSystem类代码示例

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


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

示例1: testLVMCopyObject

 def testLVMCopyObject(self):
     import comoonics.XmlTools
     from comoonics.enterprisecopy.ComCopyObject import CopyObject
     from comoonics import ComSystem
     sourcexml="""
     <source type="lvm">
        <volumegroup name='centos' free='32' numlvs='2' attrs='wz--n-' numpvs='1' serial='0' size='3456'>
           <physicalvolume attr='a-' size='3456' name='/dev/sdf2' free='32' format='lvm2'/>
           <logicalvolume origin='' size='512' name='swap' attrs='-wi-a-'/>
           <logicalvolume origin='' size='2912' name='system' attrs='-wi-a-'/>
        </volumegroup>
    </source>
     """
     destxml="""
     <destination type="lvm">
         <volumegroup name="centos_new">
             <physicalvolume name="/dev/sde"/>
         </volumegroup>
     </destination>
     """
     ComSystem.setExecMode(ComSystem.SIMULATE)
     sourcedoc=comoonics.XmlTools.parseXMLString(sourcexml)
     destdoc=comoonics.XmlTools.parseXMLString(destxml)
     try:
         source=CopyObject(sourcedoc.documentElement, sourcedoc)
         dest=CopyObject(destdoc.documentElement, destdoc)
         dest.updateMetaData(source.getMetaData())
     except Exception, e:
         self.assert_("Could not execute copyobject %s => %s. Exception %s." %(source, dest, e))
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:29,代码来源:testLVMCopyObject.py

示例2: mount

    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 ")
开发者ID:radicke-atix-de,项目名称:comoonics-cluster-suite,代码行数:25,代码来源:ComFileSystem.py

示例3: rescan

    def rescan(self, __hosts, __bus, __target, __lun):
        """ Rescan SCSI
        invokes a rescan via /sys/class/scsi_host/hostH/scan interface
        IDEAS
        INPUTS
          * host - name of scsi host ( - for all )
          * bus - number of scsi bus (- for all )
          * target - number of target ( - for all )
          * lun - number of lun ( - for all )

        """
        __syspath = "/sys/class/scsi_host"

        if not os.path.isdir(__syspath):
            raise ComException(__syspath + " not found")

        if __hosts == "-":
            __hosts = self.getAllSCSIHosts()

        if not (ComUtils.isInt(__bus) or __bus == "-"):
            raise ComException(__bus + " is not valid to scan SCSI Bus")

        if not (ComUtils.isInt(__target) or __target == "-"):
            raise ComException(__bus + " is not valid to scan SCSI Target")

        if not (ComUtils.isInt(__lun) or __lun == "-"):
            raise ComException(__bus + " is not valid to scan SCSI Lun")

        print "Hosts: ", __hosts

        for __host in __hosts:
            ComSystem.execLocal(
                'echo "' + __bus + '" "' + __target + '" "' + __lun + '" > ' + __syspath + "/" + __host + "/scan"
            )
开发者ID:radicke-atix-de,项目名称:comoonics-cluster-suite,代码行数:34,代码来源:ComScsi.py

示例4: testFilesystemCopyObject2

    def testFilesystemCopyObject2(self):
        from comoonics import ComSystem
        _xml="""
 <copyset type="filesystem" name="save-tmp">
    <source type="filesystem">
      <device id="sourcerootfs" name="/dev/vg_vmware_cluster_sr/lv_sharedroot" options="skipmount">
        <filesystem type="gfs"/>
        <mountpoint name="/">
          <option value="lock_nolock" name="lockproto"/>
          <option value="hdfhgg" name="locktable"/>
        </mountpoint>
      </device>
    </source>
    <destination type="filesystem">
      <device id="destrootfs" name="/dev/vg_vmware_cluster_srC/lv_sharedroot">
        <filesystem clustername="vmware_cluster" type="gfs"/>
        <mountpoint name="/var/lib/com-ec/dest">
          <option value="lock_nolock" name="lockproto"/>
          <option value="jhdshf" name="locktable"/>
        </mountpoint>
      </device>
    </destination>
 </copyset>
        """          
        oldexecmode=ComSystem.getExecMode()
        ComSystem.setExecMode(ComSystem.SIMULATE)
        self.__testCopyset(_xml)
        ComSystem.setExecMode(oldexecmode)
开发者ID:Open-Sharedroot,项目名称:Open-Sharedroot-cluster-suite,代码行数:28,代码来源:testComFilesystemCopyset.py

示例5: mount

   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 ")
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:27,代码来源:ComFileSystem.py

示例6: create

    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,代码行数:32,代码来源:ComLVM.py

示例7: setSimulation

def setSimulation(flag):
    if flag:
        try:
            from comoonics import ComSystem
            ComSystem.setExecMode(ComSystem.SIMULATE)
        except ImportError:
            pass
开发者ID:MarcGrimme,项目名称:comoonics-initrd-ng,代码行数:7,代码来源:fence_scsi.py

示例8: lock

 def lock(self, sleeptime=-1, retries=-1, locktimeout=-1, suspend=-1):
     try:
         ComSystem.execLocalOutput("%s %s %s" %(self.COMMAND, self._buildOptions(sleeptime, retries, locktimeout, suspend), self.filename))
     except ComSystem.ExecLocalException, ele:
         if ele.rc==73<<8:
             raise lockfileTimeout(self.filename)
         else:
             raise ele
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:8,代码来源:lockfile.py

示例9: __prepare

 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,代码行数:8,代码来源:ComPathCopyObject.py

示例10: mount

        def mount(self, device, mountpoint, readOnly=0, bindMount=0, instroot=""):
            if not self.isMountable():
                return
            iutil.mkdirChain("%s/%s" %(instroot, mountpoint))
#            if flags.selinux:
#                log.info("Could not mount nfs filesystem with selinux context enabled.")
#                return
            anacondalog.debug("nfsFileSystem: Mounting nfs %s => %s" %(device, "%s/%s" %(instroot, mountpoint)))
            ComSystem.execLocalOutput("mount -t nfs -o nolock %s %s/%s" %(device, instroot, mountpoint))
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:9,代码来源:nfs.py

示例11: isDMMultipath

 def isDMMultipath(self):
    if not os.path.exists(CMD_DMSETUP):
       return False
    __cmd="%s table %s --target=multipath 2>/dev/null | grep multipath &>/dev/null"  % (CMD_DMSETUP, self.getDeviceName())
    try:
       ComSystem.execLocalOutput(__cmd, True, "")
       return True
    except ComSystem.ExecLocalException: 
       return False
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:9,代码来源:ComDisk.py

示例12: checkFs

 def checkFs(self, device):
     """ check filesystem on device (virtual method)
     device: ComDevice.Device
     """
     if self.getFsckCmd():
         (__cmd)=self.getFsckCmd()+" "+device.getDeviceName()
         log.debug("checkFs: cmd: %s" %(__cmd))
         ComSystem.execLocalOutput(__cmd)
     else:
         raise NotImplementedYetException("Method checkFs is not implemented by filesystem %s (class: %s)." %(self.getName(), self.__class__.__name__))
开发者ID:radicke-atix-de,项目名称:comoonics-cluster-suite,代码行数:10,代码来源:ComFileSystem.py

示例13: _testMethod

 def _testMethod(self, method, execmode, *params):
     oldmode=ComSystem.getExecMode()
     ComSystem.clearSimCommands()
     ComSystem.setExecMode(execmode)
     try:
         method(*params)
     except Exception, e:
         import traceback
         traceback.print_exc()
         self.fail("Could not execute %s method on with parameters %s, Error: %s" %(method, params, e))
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:10,代码来源:testComFileSystem.py

示例14: scsi_remove_disk

def scsi_remove_disk(host, disk_path):
   target=False
   if os.path.isdir(disk_path) and os.access(disk_path, os.W_OK):
      log.debug("scsi_remove_disk(%s/delete)" %(disk_path))
      try: 
         ComSystem.execLocalOutput("echo %s > %s" %(SCSIDELETE_CMD, disk_path+"/device/delete"))
      except Exception, e:
         log.debug("Error during scsi_remove_disk %s." %e)
      #remove=open(disk_path+"/delete", "w")
      #print >> remove, SCSIDELETE_CMD
      target=True
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:11,代码来源:ComSCSI.py

示例15: init

    def init(self):
        import os.path
        ComSystem.setExecMode(ComSystem.SIMULATE)
        super(test_ClusterNodeNic, self).init()
        #create comclusterRepository Object
        self.clusterRepository = getClusterRepository(os.path.join(self._testpath, "cluster2.conf"))

        #create comclusterinfo object
        self.clusterInfo = getClusterInfo(self.clusterRepository)  

        # setup the cashes for clustat for redhat cluster
        self.clusterInfo.helper.setSimOutput()
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:12,代码来源:test_ClusterNodeNic.py


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