Beispiel #1
0
 def getLVInfo(self, lvName=None):
     result = dict()
     lvs = []
     if lvName is None:
         lvs = self.lvs.keys()
     elif self.lvs.get(lvName):
         lvs = [lvName]
     for lvName in lvs:
         lvInfo = self.lvs[lvName]
         lvutilInfo = lvutil.LVInfo(lvName)
         lvutilInfo.size = lvInfo.size
         lvutilInfo.active = lvInfo.active
         lvutilInfo.open = (lvInfo.open > 0)
         lvutilInfo.readonly = lvInfo.readonly
         if lvutil.LV_TAG_HIDDEN in lvInfo.tags:
             lvutilInfo.hidden = True
         result[lvName] = lvutilInfo
     return result
Beispiel #2
0
    def test_clone_success(self, mock_xenapi, mock_lock, mock_lvhdutil,
                           mock_lock_context, mock_vhdutil, mock_exists,
                           mock_lvutil):
        """
        Successfully create snapshot
        """

        # Arrange
        self.stubout('lvmcache.LVMCache')
        self.stubout('LVHDSR.LVHDSR._ensureSpaceAvailable')
        self.stubout('journaler.Journaler.create')
        self.stubout('journaler.Journaler.remove')
        self.stubout('LVHDSR.RefCounter.set')
        self.stubout('LVHDSR.RefCounter.put')
        self.stubout('LVHDSR.LVMMetadataHandler')

        vdi_uuid = 'some VDI UUID'
        mock_lvhdutil.getVDIInfo.return_value = {
            vdi_uuid: lvhdutil.VDIInfo(vdi_uuid)
        }
        mock_lv = lvutil.LVInfo('test-lv')
        mock_lv.size = 10240
        mock_lv.active = True
        mock_lv.hidden = False
        mock_lv.vdiType = vhdutil.VDI_TYPE_VHD

        mock_lvhdutil.getLVInfo.return_value = {vdi_uuid: mock_lv}

        test_vhdInfo = vhdutil.VHDInfo(vdi_uuid)
        test_vhdInfo.hidden = False
        mock_vhdutil.getVHDInfo.return_value = test_vhdInfo
        sr = self.create_LVHDSR()
        sr.isMaster = True
        sr.legacyMode = False
        sr.srcmd.params = {'vdi_ref': 'test ref'}

        vdi = sr.vdi('some VDI UUID')
        mock_exists.return_value = True

        # Act
        clone = vdi.clone(sr.uuid, 'some VDI UUID')

        # Assert
        self.assertIsNotNone(clone)