def test_cache_works_after_cleanup(self): first = func() clear_cache(func) second = func() third = func() self.assertNotEqual(first, second) self.assertEqual(second, third)
def create_partition_for_whole_table(self, file_system_object, alignment_in_bytes=None): self._disk_drive._get_parted_disk_drive( ).create_partition_for_whole_drive(file_system_object.get_name(), alignment_in_bytes) clear_cache(self) return self.get_partitions()[0]
def unmount(self, mount_object): """A utility function that calls the :meth:`.FileSystem.unmount` method of a `infi.storagemodel.base.filesystem.FileSystem` object **mount_object**: a `infi.storagemodel.base.mount..Mount` object """ mount_point = mount_object.get_mount_point() block_access_path = mount_object.get_block_access_path() mount_object.get_filesystem().unmount(block_access_path, mount_point) clear_cache(self)
def unmount(self, mount_object): """A utility function that calls the :method:`.FileSystem.unmount` method of a :class:`.FileSystem` object :param mount_object: a :class:`.Mount` object """ mount_point = mount_object.get_mount_point() block_access_path = mount_object.get_block_access_path() mount_object.get_filesystem().unmount(block_access_path, mount_point) clear_cache(self)
def _set_tasks(self, tasks): extension = self._get_extensions_data_object()[0] extension.description.summary = dumps(tasks) if len(extension.description.summary) > self.MAX_LENGTH: raise ExtensionIsFullException extension.taskList = [self._new_task_type_info(task_id) for task_id, _ in tasks] extension.resourceList = self._new_task_extension_resource_info(tasks) self._managed_object.UpdateExtension(extension) clear_cache(self)
def _add_task(self, task_id, task_name): extension = self._get_extensions_data_objects()[0] tasks = self._get_tasks() tasks[task_id] = task_name extension.taskList = [self._new_task_type_info(task_id) for task_id in tasks.keys()] task_resources = [("{}.label".format(key), value) for key, value in tasks.items()] # TODO events extension.resourceList = [self._new_task_extension_resource_info('en', 'task', task_resources)] self._managed_object.UpdateExtension(extension) clear_cache(self)
def _set_tasks(self, tasks): extension = self._get_extensions_data_object()[0] extension.description.summary = dumps(tasks) if len(extension.description.summary) > self.MAX_LENGTH: raise ExtensionIsFullException extension.taskList = [ self._new_task_type_info(task_id) for task_id, _ in tasks ] extension.resourceList = self._new_task_extension_resource_info(tasks) self._managed_object.UpdateExtension(extension) clear_cache(self)
def veritas_multipathing_context(output): if "windows" in get_platform_string(): raise SkipTest with patch('infi.storagemodel.unix.veritas_multipath.VeritasMultipathClient.read_paths_list') as read_paths_list: with patch('infi.storagemodel.linux.sysfs.Sysfs.find_scsi_disk_by_hctl') as find_scsi_disk_by_hctl: with patch('infi.storagemodel.base.scsi.SCSIModel.find_scsi_block_device_by_block_access_path') as find_func: find_func.return_value = MockSCSIBlockDevice(None) find_scsi_disk_by_hctl.return_value = None read_paths_list.return_value = output sm = get_storage_model() clear_cache(sm) yield sm.get_veritas_multipath()
def _add_task(self, task_id, task_name): extension = self._get_extensions_data_objects()[0] tasks = self._get_tasks() tasks[task_id] = task_name extension.taskList = [ self._new_task_type_info(task_id) for task_id in tasks.keys() ] task_resources = [("{}.label".format(key), value) for key, value in tasks.items()] # TODO events extension.resourceList = [ self._new_task_extension_resource_info('en', 'task', task_resources) ] self._managed_object.UpdateExtension(extension) clear_cache(self)
def refresh(self): """clears the model cache""" from ..connectivity import ConnectivityFactory clear_cache(self) clear_cache(ConnectivityFactory)
def refresh(self): from infi.pyutils.lazy import clear_cache from .scsi import AixSCSIDevice super(AixStorageModel, self).refresh() clear_cache(AixSCSIDevice)
def register(self): if self.is_registered(): raise ExtensionAlreadyRegisteredException() extension = self._new_extension() self._managed_object.RegisterExtension(extension) clear_cache(self)
def test_clear_cache(self): self.assertEqual(self.subject.get_counter(), 1) clear_cache(self.subject) self.assertEqual(self.subject.get_counter(), 2)
def add_task(self, task_name): task_id = str(hash(task_name)) self._set_tasks([(task_id, task_name)] + self._get_tasks()) clear_cache(self)
def _install_custom_field(self): self._manager.AddCustomFieldDef(name=self._field_name, moType=vim.Folder, fieldDefPolicy=None, fieldPolicy=None) clear_cache(self)
def clear_cached_properties(self): clear_cache(self)
def test__no_args_and_kwargs(self): clear_cache(self.subject) self.assertEquals(self.subject.cached_method_4(), 1) self.assertEquals(self.subject.prop, 2) self.assertEquals(self.subject.cached_method_4(), 1) clear_cache(self.subject)
def test__kwargs(self): clear_cache(self.subject) self.assertEquals(self.subject.cached_method_3(value=1), 1) self.assertEquals(self.subject.cached_method_3(value=1), 1) self.assertEquals(self.subject.cached_method_3(value=2), 2) self.assertEquals(self.subject.cached_method_3(value=2), 2)
def test__clear_cache(self): self.assertEquals(self.subject.cached_method_1(1), 1) self.assertEquals(self.subject.cached_method_1(1), 1) clear_cache(self.subject) self.assertEquals(self.subject.cached_method_1(1), 2)
def test__clear_cache(self): self.assertEquals(self.subject.prop, 1) clear_cache(self.subject) self.assertEquals(self.subject.prop, 2)
def test__args(self): clear_cache(self.subject) self.assertEquals(self.subject.cached_method_3(1), 1) self.assertEquals(self.subject.cached_method_3(1), 1) self.assertEquals(self.subject.cached_method_3(2), 2) self.assertEquals(self.subject.cached_method_3(2), 2)
def test__mutable_kwargs(self): clear_cache(self.subject) self.assertEquals(self.subject.cached_method_3(value=[1]), 1) self.assertEquals(self.subject.cached_method_3(value=[1]), 2)
def _set_json_string(self, json): self._manager.SetField(entity=self._managed_object, key=self._get_custom_field_key(), value=json) clear_cache(self)
def test_clear_cache_works(self): before = func() clear_cache(func) after = func() self.assertNotEqual(before, after)
def create_partition_for_whole_table(self, file_system_object, alignment_in_bytes=None): self._disk_drive._get_parted_disk_drive().create_partition_for_whole_drive(file_system_object.get_name(), alignment_in_bytes) clear_cache(self) return self.get_partitions()[0]
def create_partition_for_whole_table(self, file_system_object): self._disk_drive._get_parted_disk_drive().create_partition_for_whole_drive(file_system_object.get_name()) clear_cache(self) return self.get_partitions()[0]