Beispiel #1
0
 def test_lvpath(self):
     with namedTemporaryDir() as tmpdir:
         lvm = FakeLVM(tmpdir)
         vg_name = 'foo'
         lv_name = 'bar'
         expected = os.path.join(tmpdir, 'dev', vg_name, lv_name)
         self.assertEqual(expected, lvm.lvPath(vg_name, lv_name))
Beispiel #2
0
 def test_lvpath(self):
     with namedTemporaryDir() as tmpdir:
         lvm = FakeLVM(tmpdir)
         vg_name = 'foo'
         lv_name = 'bar'
         expected = os.path.join(tmpdir, 'dev', vg_name, lv_name)
         self.assertEqual(expected, lvm.lvPath(vg_name, lv_name))
Beispiel #3
0
 def test_lv_size_rounding(self):
     vg_name = 'foo'
     lv_name = 'bar'
     devices = ['360014054d75cb132d474c0eae9825766']
     with namedTemporaryDir() as tmpdir:
         lvm = FakeLVM(tmpdir)
         lvm.createVG(vg_name, devices, blockSD.STORAGE_UNREADY_DOMAIN_TAG,
                      blockSD.VG_METADATASIZE)
         lvm.createLV(vg_name, lv_name, sc.VG_EXTENT_SIZE_MB - 1)
         lv = lvm.getLV(vg_name, lv_name)
         self.assertEqual(sc.VG_EXTENT_SIZE_MB * MB, int(lv.size))
Beispiel #4
0
    def base_config(self):
        """
        Create a simple volume group from a single 10G LUN.

        lvm.createVG('1ffead52-7363-4968-a8c7-3bc34504d452',
                     ['360014054d75cb132d474c0eae9825766'],
                     blockSD.STORAGE_UNREADY_DOMAIN_TAG,
                     blockSD.VG_METADATASIZE)

        print lvm.getVG('1ffead52-7363-4968-a8c7-3bc34504d452')
        VG(uuid='15hlPF-V3eG-F9Cp-SGtu-4Mq0-28Do-HC806y',
           name='1ffead52-7363-4968-a8c7-3bc34504d452',
           attr=VG_ATTR(permission='w', resizeable='z', exported='-',
                        partial='-', allocation='n', clustered='-'),
           size='10334765056', free='10334765056', extent_size='134217728',
           extent_count='77', free_count='77',
           tags=('RHAT_storage_domain_UNREADY',), vg_mda_size='134217728',
           vg_mda_free='67107328', lv_count='0', pv_count='1',
           pv_name=('/dev/mapper/360014054d75cb132d474c0eae9825766',),
           writeable=True, partial='OK')

        print lvm.getPV('360014054d75cb132d474c0eae9825766')
        PV(uuid='fIRjbD-usOA-tYgW-b2Uz-oUly-AJ49-bMMjYe',
           name='/dev/mapper/360014054d75cb132d474c0eae9825766',
           size='10334765056', vg_name='1ffead52-7363-4968-a8c7-3bc34504d452',
           vg_uuid='15hlPF-V3eG-F9Cp-SGtu-4Mq0-28Do-HC806y',
           pe_start='138412032', pe_count='77', pe_alloc_count='0',
           mda_count='2', dev_size='10737418240',
           guid='360014054d75cb132d474c0eae9825766')
        """
        with namedTemporaryDir() as tmpdir:
            lvm = FakeLVM(tmpdir)
            lvm.createVG(self.VG_NAME, self.DEVICES,
                         blockSD.STORAGE_UNREADY_DOMAIN_TAG,
                         blockSD.VG_METADATASIZE)
            yield lvm
Beispiel #5
0
    def base_config(self):
        """
        Create a simple volume group from a single 10G LUN.

        lvm.createVG('1ffead52-7363-4968-a8c7-3bc34504d452',
                     ['360014054d75cb132d474c0eae9825766'],
                     blockSD.STORAGE_UNREADY_DOMAIN_TAG,
                     blockSD.VG_METADATASIZE)

        print lvm.getVG('1ffead52-7363-4968-a8c7-3bc34504d452')
        VG(uuid='15hlPF-V3eG-F9Cp-SGtu-4Mq0-28Do-HC806y',
           name='1ffead52-7363-4968-a8c7-3bc34504d452',
           attr=VG_ATTR(permission='w', resizeable='z', exported='-',
                        partial='-', allocation='n', clustered='-'),
           size='10334765056', free='10334765056', extent_size='134217728',
           extent_count='77', free_count='77',
           tags=('RHAT_storage_domain_UNREADY',), vg_mda_size='134217728',
           vg_mda_free='67107328', lv_count='0', pv_count='1',
           pv_name=('/dev/mapper/360014054d75cb132d474c0eae9825766',),
           writeable=True, partial='OK')

        print lvm.getPV('360014054d75cb132d474c0eae9825766')
        PV(uuid='fIRjbD-usOA-tYgW-b2Uz-oUly-AJ49-bMMjYe',
           name='/dev/mapper/360014054d75cb132d474c0eae9825766',
           size='10334765056', vg_name='1ffead52-7363-4968-a8c7-3bc34504d452',
           vg_uuid='15hlPF-V3eG-F9Cp-SGtu-4Mq0-28Do-HC806y',
           pe_start='138412032', pe_count='77', pe_alloc_count='0',
           mda_count='2', dev_size='10737418240',
           guid='360014054d75cb132d474c0eae9825766')
        """
        with namedTemporaryDir() as tmpdir:
            lvm = FakeLVM(tmpdir)
            lvm.createVG(self.VG_NAME, self.DEVICES,
                         blockSD.STORAGE_UNREADY_DOMAIN_TAG,
                         blockSD.VG_METADATASIZE)
            yield lvm
Beispiel #6
0
 def test_lv_size_rounding(self):
     vg_name = 'foo'
     lv_name = 'bar'
     devices = ['360014054d75cb132d474c0eae9825766']
     with namedTemporaryDir() as tmpdir:
         lvm = FakeLVM(tmpdir)
         lvm.createVG(vg_name, devices, blockSD.STORAGE_UNREADY_DOMAIN_TAG,
                      blockSD.VG_METADATASIZE)
         lvm.createLV(vg_name, lv_name, sc.VG_EXTENT_SIZE_MB - 1)
         lv = lvm.getLV(vg_name, lv_name)
         self.assertEqual(sc.VG_EXTENT_SIZE_MB * MB, int(lv.size))
Beispiel #7
0
def fake_block_env(obj=None, sd_version=3):
    with namedTemporaryDir() as tmpdir:
        lvm = FakeLVM(tmpdir)
        fake_sdc = FakeStorageDomainCache()
        with MonkeyPatchScope([
            (blockSD, 'lvm', lvm),
            (blockVolume, 'lvm', lvm),
            (blockVolume, 'sdCache', fake_sdc),
            (volume_artifacts, 'lvm', lvm),
            (sd, 'storage_repository', tmpdir),
            (volume, 'sdCache', fake_sdc),
            (hsm, 'sdCache', fake_sdc),
        ]):
            sd_manifest = make_blocksd_manifest(tmpdir, lvm,
                                                sd_version=sd_version)
            fake_sdc.domains[sd_manifest.sdUUID] = FakeSD(sd_manifest, lvm)
            try:
                yield FakeBlockEnv(tmpdir, sd_manifest, fake_sdc, lvm)
            finally:
                oop.stop()
Beispiel #8
0
def fake_block_env(obj=None, sd_version=3, data_center=None):
    with temp_dir(path=data_center) as tmpdir:
        lvm = FakeLVM(tmpdir)
        fake_sdc = FakeStorageDomainCache()
        with MonkeyPatchScope([
            (blockSD, 'lvm', lvm),
            (blockVolume, 'lvm', lvm),
            (blockVolume, 'sdCache', fake_sdc),
            (sc, 'REPO_DATA_CENTER', tmpdir),
            (sc, "REPO_MOUNT_DIR", os.path.join(tmpdir, sc.DOMAIN_MNT_POINT,
                                                sd.BLOCKSD_DIR)),
            (volume, 'sdCache', fake_sdc),
            (hsm, 'sdCache', fake_sdc),
            [nbd, 'sdCache', fake_sdc],
        ]):
            sd_manifest = make_blocksd_manifest(tmpdir, lvm,
                                                sd_version=sd_version)
            fake_sdc.domains[sd_manifest.sdUUID] = FakeSD(sd_manifest, lvm)
            try:
                yield FakeBlockEnv(tmpdir, sd_manifest, fake_sdc, lvm)
            finally:
                oop.stop()
Beispiel #9
0
 def test_bad_args(self, exception, fn, args):
     with namedTemporaryDir() as tmpdir:
         lvm = FakeLVM(tmpdir)
         lvm_fn = getattr(lvm, fn)
         self.assertRaises(exception, lvm_fn, *args)