SettingManager

” Module for SettingManager and Setting classes.

SettingManager

class openlmi.storage.SettingManager.SettingManager(*args, **kwargs)[source]

Class, which manages all persistent, transient and preconfigured LMI_*Setting instances.

Note: LMI_*Setting instances, which represent actual configuration of some element are not managed by this class!

It should be enough to have only one instance of this class.

Settings must be removed using special methods of this class.

Preconfigured settings are stored in /etc/openlmi/storage/setting/ directory. Each LMI_*Setting class has its own file. Name of the file is the same as name of the class. Each file has ini structure. Each section represents one LMI_*Setting instance, with key=value pairs. Name of the ini section is the same as InstanceID of the setting.

Persistent settings have the same structure, but they are stored in /var/lib/openlmi-storage/settings/ directory.

__init__(*args, **kwargs)[source]

Create new SettingManager.

Parameters:
  • storage_configuration – (StorageConfiguration) Current configuration.
  • timer_manager – (TimerManager) Timer manager instance.
allocate_id(*args, **kwargs)[source]

Return new unique InstanceID for given LMI_*Setting class.

clean(*args, **kwargs)[source]

Remove all persistent and preconfigured settings, leaving only transient ones.

create_setting(*args, **kwargs)[source]

Create new Setting instance.

Parameters:
  • classname – (string) Name of related CIM LMI_*Setting class.
  • setting_type – (Setting.TYPE_* constant) Type of the setting to create.
  • setting_id – (string constant) ID of the new setting.
  • class_to_create – (Class) Subclass of Setting, which should be instantiated.
delete_setting(*args, **kwargs)[source]

Remove a setting. If the setting was persistent, it will be immediately removed from disk.

expire_setting(*args, **kwargs)[source]

Removes expired setting.

Parameters:
  • classname – (string) Name of LMI_*Setting CIM class.
  • the_id – (string) ID of the setting instance, which has expired.
get_settings(*args, **kwargs)[source]

Return dictionary of all instances of given LMI_*Setting class.

load(*args, **kwargs)[source]

Load all persistent and preconfigured settings from configuration files.

save(*args, **kwargs)[source]

Save all persistent settings to configuration files. Create the persistent directory if it does not exist.

set_setting(*args, **kwargs)[source]

Add or set setting. If the setting is (or was) persistent, it will be immediately stored to disk.

Setting

class openlmi.storage.SettingManager.Setting(*args, **kwargs)[source]

This class represents generic LMI_*Setting properties. Every instance has name, type and properties (key-value pairs). The value must be string!

__init__(*args, **kwargs)[source]
get(*args, **kwargs)[source]

Emulate dict.get().

has_key(*args, **kwargs)[source]

Emulate dict.has_key().

items(*args, **kwargs)[source]

Return all (key, value) properties.

load(*args, **kwargs)[source]

Load setting with self.the_id from given ini file (ConfigParser instance).

save(*args, **kwargs)[source]

Save setting with self.the_id to given ini file (ConfigParser instance).

touch(*args, **kwargs)[source]

Reset expiration timer of transient setting.

StorageSetting

class openlmi.storage.SettingManager.StorageSetting(*args, **kwargs)[source]

Setting for LMI_StorageSetting subclasses. It has all the redundancy parameters.

set_setting(redundancy)[source]

Set setting according to given DeviceProvider.Redundancy.

Table Of Contents

Previous topic

SettingHelper

Next topic

SettingProvider

This Page