Endian banner

endian.data.container package

Submodules

endian.data.container.abstractconfig module

class AbstractConfigFile(configfiles, filename=None, settingsDefault=None, obj=None)

Bases: endian.datatypes.config_list.ConfigList, endian.data.interfaces.ContainerInterface, endian.data.interfaces.ExpireableFile

read(onlyDefault=False)
readDefaults()
exception ConfigFileParseError

Bases: exceptions.Exception

exception InvalidSettingsFile

Bases: exceptions.Exception

class SanitizedFile(fname, mode='r')

Bases: file

next()

endian.data.container.csvconfig module

class CsvConfigFile(configfiles, filename=None, obj=None, delimiter=', ', tolerant=False, settingsDefault=None)

Bases: endian.data.container.abstractconfig.AbstractConfigFile, object

write(filename=None)
exception CsvFileException

Bases: endian.data.container.abstractconfig.ConfigFileParseError

exception InvalidModelException

Bases: exceptions.Exception

endian.data.container.defaultresolver module

class DefaultResolver

Bases: object

endian.data.container.dirconfig module

class Directory(path, searchPath)

Bases: endian.datatypes.config_dict.ConfigDict, endian.data.interfaces.ContainerInterface, endian.data.interfaces.ExpireablePaths

read()
write(filename=None)
exception DirectoryError

Bases: exceptions.Exception

pathsExpirer(obj)

endian.data.container.fileconfig module

class PlainFile(path, obj=None, basePaths={'PROVISIONING_D': '/var/emc', 'PREFIX': '/', 'PERSISTENT_D': '/usr/lib/efw', 'USER_D': '/var/efw', 'STATE_D': '/var/lib/efw'}, readFileOrder=[{'glob': False, 'base': 'USER_D', 'back': False, 'dir': '', 'user': True}, {'glob': False, 'base': 'STATE_D', 'back': False, 'dir': '', 'user': False}, {'glob': True, 'back': True, 'globprio': True, 'base': 'PERSISTENT_D', 'user': False, 'dir': 'default'}, {'glob': False, 'base': 'PROVISIONING_D', 'back': True, 'dir': 'default', 'user': False}, {'glob': False, 'base': 'USER_D', 'back': True, 'dir': 'default', 'user': False}, {'glob': False, 'base': 'STATE_D', 'back': True, 'dir': 'default', 'user': False}], filterSuffices=['old', 'rpmsave', 'rpmnew', 'orig', 'rej'])

Bases: UserList.UserList, endian.data.interfaces.ContainerInterface, endian.data.container.defaultresolver.DefaultResolver, endian.data.interfaces.ExpireableFile

Small interface to efw plain files,

If the file does not exist, PlainFile loads from a number of default files:

<STATE_D>/<path> <USER_D>/<path> <PROVISIONING_D>/<path> (**) <PERSISTENT_D>/dirname(<path>)/default/basename(<path>). (**) <PERSISTENT_D>/dirname(<path>)/default/basename(<path>) (**) <STATE_D>/dirname(<path>)/default/basename(<path>) (**) <USER_D>/dirname(<path>)/default/basename(<path>) (**)

(**) each path will be searched back the directory hierarchy for a default/vendor - directory which contains the searched file. Those files will be read out also and with precedence of it’s hierarchy level.

for example:

PlainFile('ethernet/br0')

reads:

/var/lib/ethernet/settings
/var/efw/ethernet/settings
/var/emc/ethernet/settings
/usr/lib/efw/ethernet/default/settings.
/usr/lib/efw/ethernet/default/settings
/var/efw/ethernet/default/settings
/var/lib/efw/ethernet/default/settings

Meaning of directories:

PERSISTENT_D
   should contain only packaged files which will be changed only
   when upgrading (default: /usr/lib/efw)

STATE_D
  should contain only files which the system creates. This way the
  system can override default values and/or the actual
  configuration (default: /var/lib/efw)

USER_D
  should contain only files the user created/modified (default:
  /var/efw)

PROVISIONING_D
  where the provisioning settings files are stored (default:
  /var/emc)


default:
  contain files with default values packaged by the original
  package.  vendor or product related default files can be done by
  creating files like settings.mybrand
read()
write(filename=None)
fileExpirer(cache)
getFileContent(filename, res)

endian.data.container.jsonconfig module

class JsonConfigFile(filename=None, obj=None, configfiles=[], settingsDefault=None)

Bases: endian.data.container.abstractconfig.AbstractConfigFile, object

write(filename=None)
exception JsonFileException

Bases: endian.data.container.abstractconfig.ConfigFileParseError

endian.data.container.settings module

exception SettingsException

Bases: exceptions.Exception

class SettingsFile(path, d=None, basePaths={'PROVISIONING_D': '/var/emc', 'PREFIX': '/', 'PERSISTENT_D': '/usr/lib/efw', 'USER_D': '/var/efw', 'STATE_D': '/var/lib/efw'}, readFileOrder=[{'glob': True, 'base': 'PERSISTENT_D', 'back': True, 'dir': 'default', 'user': False}, {'glob': False, 'base': 'USER_D', 'back': True, 'dir': 'default', 'user': False}, {'glob': False, 'base': 'PERSISTENT_D', 'back': True, 'dir': 'vendor', 'user': False}, {'glob': False, 'base': 'USER_D', 'back': True, 'dir': 'vendor', 'user': False}, {'glob': False, 'base': 'STATE_D', 'back': True, 'dir': 'default', 'user': False}, {'glob': False, 'base': 'PROVISIONING_D', 'back': False, 'dir': '', 'user': False}, {'glob': False, 'base': 'USER_D', 'back': False, 'dir': '', 'user': True}, {'glob': True, 'base': 'STATE_D', 'back': False, 'dir': '', 'user': False}], inexistentOk=True, strict=False, filterSuffices=['old', 'rpmsave', 'rpmnew', 'orig', 'rej'], **kwargs)

Bases: endian.datatypes.config_dict.ConfigDict, endian.data.interfaces.ContainerInterface, endian.data.container.defaultresolver.DefaultResolver, endian.data.interfaces.ExpireableFile, object

Small interface to the efw settings files, which allows to load all key/value pairs from a file specified by a path. SettingsFile behaves like a dict, which allows to give access to the key/value pairs in an easy manner.

Each key is case in-sensitive and is accessible also through __getattr__.

>>> ds = SettingsFile('ethernet/settings')
>>> ds['GREEN_IPS']
... '10.1.1.1/24'
>>> ds['green_ips']
'10.1.1.1/24'
>>> ds['green_ips']
'10.1.1.1/24'
>>> ds['GREEN_ips']
'10.1.1.1/24'
>>> ds.GREEN_ips
'10.1.1.1/24'
>>> ds.GREEN_IPS
'10.1.1.1/24'
>>> ds.green_ips
'10.1.1.1/24'

SettingsFile pre-loads the dict with default values from a number of files:

<PERSISTENT_D>/dirname(<path>)/default/basename(<path>) (**)
<PERSISTENT_D>/dirname(<path>)/default/basename(<path>).* (**)
<USER_D>/dirname(<path>)/default/basename(<path>) (**)
<PERSISTENT_D>/dirname(<path>)/vendor/basename(<path>) (**)   (deprecated by glob)
<USER_D>/dirname(<path>)/vendor/basename(<path>) (**)         (deprecated by glob)
<STATE_D>/dirname(<path>)/default/basename(<path>) (**)
<USER_D>/<path>
<STATE_D>/<path>
<STATE_D>/<path>.*

(**) each path will be searched back the directory hierarchy for a default/vendor - directory which contains the searched file. Those files will be read out also and with precedence of it’s hierarchy level.

for example:

SettingsFile('openvpnclients/client1/settings')

reads:

/usr/lib/efw/openvpnclients/default/settings
/usr/lib/efw/openvpnclients/default/client1/settings
/usr/lib/efw/openvpnclients/default/settings.*
/usr/lib/efw/openvpnclients/default/client1/settings.*
/var/efw/openvpnclients/default/settings
/var/efw/openvpnclients/default/client1/settings
/usr/lib/efw/openvpnclients/vendor/settings
/usr/lib/efw/openvpnclients/vendir/client1/settings
/var/efw/efw/openvpnclients/vendor/settings
/var/efw/efw/openvpnclients/vendir/client1/settings
/var/lib/efw/openvpnclients/default/settings
/var/lib/efw/openvpnclients/default/client1/settings
/var/efw/openvpnclients/client1/settings
/var/lib/openvpnclients/client1/settings
/var/lib/openvpnclients/client1/settings.*

Meaning of directories:

PERSISTENT_D
should contain only packaged files which will be changed only when upgrading (default: /usr/lib/efw)
STATE_D
should contain only files which the system creates. This way the system can override default values and/or the actual configuration (default: /var/lib/efw)
USER_D
should contain only files the user created/modified (default: /var/efw)
default
contain files with default values packaged by the original package. vendor or product related default files can be done by creating files like settings.mybrand
vendor
DEPRECATED contains files which are packaged by a branding package

The readout of default and vendor files in /var/efw is for backwards compatibility only.

Modifiying values within the dict using __setitem__ allows to alter values. If they will be written down using save() causes to write down only the difference to the default/vendor values.

diffDump()

Returns the configuration in raw mode as a diff to the default settings

dump()

Returns the configuration in raw mode

static load(path, prefix=None)
read(data=None)

Reads out the setting, default and vendor values if they exist. No error will be thrown if no settings exist.

settings()

Returns the configuration settings dictionary.

@deprecated settings Only for backwards compatibily

write(file=None, diff=True)

writes down the new configuration file as a diff to the default settings.

endian.data.container.yamlconfig module

class YamlConfigFile(configfiles, filename=None, settingsDefault=None, obj=None)

Bases: endian.data.container.abstractconfig.AbstractConfigFile, object

write(filename=None)
exception YamlFileException

Bases: endian.data.container.abstractconfig.ConfigFileParseError