def fake_file_env(obj=None): with namedTemporaryDir() as tmpdir: sd_manifest = make_filesd_manifest(tmpdir) fake_sdc = FakeStorageDomainCache() with MonkeyPatchScope([ [sd, 'storage_repository', tmpdir], [volume, 'sdCache', fake_sdc], [hsm, 'sdCache', fake_sdc], ]): fake_sdc.domains[sd_manifest.sdUUID] = FakeSD(sd_manifest) try: yield FakeFileEnv(tmpdir, sd_manifest, fake_sdc) finally: oop.stop()
def fake_block_env(obj=None): with namedTemporaryDir() as tmpdir: lvm = FakeLVM(tmpdir) fake_sdc = FakeStorageDomainCache() with MonkeyPatchScope([ (blockSD, 'lvm', lvm), (blockVolume, 'lvm', lvm), (volume_artifacts, 'lvm', lvm), (sd, 'storage_repository', tmpdir), (volume, 'sdCache', fake_sdc), (hsm, 'sdCache', fake_sdc), ]): sd_manifest = make_blocksd_manifest(tmpdir, lvm) fake_sdc.domains[sd_manifest.sdUUID] = FakeSD(sd_manifest) try: yield FakeBlockEnv(tmpdir, sd_manifest, fake_sdc, lvm) finally: oop.stop()