def prepareAsSource(self):
     self.getVolumeGroup().init_from_disk()
     for pv in LinuxVolumeManager.pvlist(self.getVolumeGroup(), self.getDocument()):
         pv.init_from_disk()
         self.getVolumeGroup().addPhysicalVolume(pv)
     for lv in LinuxVolumeManager.lvlist(self.getVolumeGroup(), self.getDocument()):
         lv.init_from_disk()
         self.getVolumeGroup().addLogicalVolume(lv)
         if not lv.isActivated() and not self.activated:
             self.activated=True
             self.vg.activate()
Exemple #2
0
 def prepareAsSource(self):
     self.getVolumeGroup().init_from_disk()
     for pv in LinuxVolumeManager.pvlist(self.getVolumeGroup(),
                                         self.getDocument()):
         pv.init_from_disk()
         self.getVolumeGroup().addPhysicalVolume(pv)
     for lv in LinuxVolumeManager.lvlist(self.getVolumeGroup(),
                                         self.getDocument()):
         lv.init_from_disk()
         self.getVolumeGroup().addLogicalVolume(lv)
         if not lv.isActivated() and not self.activated:
             self.activated = True
             self.vg.activate()
 def _getLVM_physicalVolume(self, device):
     from comoonics.storage.ComLVM import LogicalVolume, LinuxVolumeManager, VolumeGroup 
     try:
         (vgname, lvname)=LogicalVolume.splitLVPath(device)
         _vg=VolumeGroup(vgname)
         _pv=LinuxVolumeManager.pvlist(_vg)
         ComLog.getLogger(__logStrLevel__).debug("detected physical volume %s" %_pv) 
         return _pv[0].getAttribute("name")
     except LogicalVolume.LVMInvalidLVPathException, e:
         ComLog.errorTraceLog()
         return
 def _getLVM_physicalVolume(self, device):
     from comoonics.storage.ComLVM import LogicalVolume, LinuxVolumeManager, VolumeGroup
     try:
         (vgname, lvname) = LogicalVolume.splitLVPath(device)
         _vg = VolumeGroup(vgname)
         _pv = LinuxVolumeManager.pvlist(_vg)
         ComLog.getLogger(__logStrLevel__).debug(
             "detected physical volume %s" % _pv)
         return _pv[0].getAttribute("name")
     except LogicalVolume.LVMInvalidLVPathException, e:
         ComLog.errorTraceLog()
         return
    def testVgList(self):
        try:
            vgs = LinuxVolumeManager.vglist()
            for _vg in vgs:
                print "Volume group: "
                print _vg
                for lv in _vg.getLogicalVolumes():
                    print "Logical volume: ", lv

                for pv in _vg.getPhysicalVolumes():
                    print "Physical volume: ", pv
        except RuntimeError, re:
            self.assert_("Caught unexpected exception during vglist %s." % re)
    def testVgList(self):
        try:
            vgs=LinuxVolumeManager.vglist()
            for _vg in vgs:
                print "Volume group: "
                print _vg
                for lv in _vg.getLogicalVolumes():
                    print "Logical volume: ", lv

                for pv in _vg.getPhysicalVolumes():
                    print "Physical volume: ", pv
        except RuntimeError, re:
            self.assert_("Caught unexpected exception during vglist %s." %re)
   def cleanupDest(self):
      if self.disk.hasPartitionTable():
         self.disk.savePartitionTable(self.__tmp.name)
         self.journal(self.disk, "savePartitionTable", self.__tmp.name)
      else:
         self.journal(self.disk, "noPartitionTable")

      # if disk already contians LVM configuration remove it
      pvs=list()
      from comoonics.storage.ComLVM import PhysicalVolume, LinuxVolumeManager
      try:
         pv=PhysicalVolume(self.disk.getAttribute("name"), self.getDocument())
         pv.init_from_disk()
         pvs.append(pv)
      except LinuxVolumeManager.LVMCommandException:
         try:
            for partition in self.disk.getAllPartitions():
               pv=PhysicalVolume(self.disk.getDeviceName()+self.disk.getPartitionDelim()+partition.getAttribute("name"), self.getDocument())
               pv.init_from_disk()
               pvs.append(pv)
         except LinuxVolumeManager.LVMCommandException:
            ComLog.debugTraceLog(self.logger)
      if not pvs or len(pvs)==0:
         self.log.debug("Could not find LVM physical volume on device %s. OK." %self.disk.getAttribute("name"))
      for pv in pvs:
         try:
            for lv in LinuxVolumeManager.lvlist(pv.parentvg):
               lv.remove()
            pv.parentvg.remove()
            pv.remove()
         except LinuxVolumeManager.LVMCommandException:
            ComLog.debugTraceLog(self.logger)
            self.log.info("Could not remove LVM configuration from device %s. Will continue nevertheless." %pv.getAttribute("name"))

      self.disk.createPartitions()
      self.disk.restore()