Package rtslib :: Module config :: Class Config
[hide private]
[frames] | no frames]

Class Config

object --+
         |
        Config

The LIO configuration API.

The Config object provide methods to edit, search, validate and update the current configuration, and commit that configuration to the live system on request.

It features pattern-matching search for all configuration objects and attributes as well as multi-level undo capabilities. In addition, all configuration changes are staged before being applied, isolating the current configuration from load-time and validation errors.

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
 
_load_policy(self)
Loads all LIO system policy files.
 
_load_parse_tree(self, parse_tree, cur_stage=None, replace=False, source=None, target='config', allow_new_attrs=False)
target can be 'config', 'policy' or 'reference'
 
_add_missing_attributes(self, obj)
Given an obj node, add all missing attributes and attribute groups in the configuration.
 
validate_val(self, value, val_type, parent=None)
 
validate_obj(self, token, parent)
 
validate_attr(self, token, parent, allow_new_attr=False)
 
undo(self)
Restores the previous state of the configuration, before the last set, load, delete, update or clear operation.
 
set(self, configuration)
Evaluates the configuration (a string in LIO configuration format) and sets the relevant objects, attributes and atttribute groups.
 
delete(self, pattern, node_filter=<function <lambda> at 0x7fedce549398>)
Deletes all configuration objects and attributes whose paths match the pattern, along with their children.
 
load(self, filepath, allow_new_attrs=False)
Loads an LIO configuration file and replace the current configuration with it.
 
load_live(self)
Loads the live-running configuration.
 
update(self, filepath)
Updates the current configuration with the contents of an LIO configuration file.
 
clear(self)
Clears the current configuration.
 
search(self, search_statement, node_filter=<function <lambda> at 0x7fedce549668>)
Returns a list of nodes matching the search_statement, relative to the current node, or an empty list if no match was found.
 
dump(self, search_statement=None, node_filter=<function <lambda> at 0x7fedce549758>)
Returns a LIO configuration file format dump of the nodes matching the search_statement, or of all nodes if search_statement is None.
 
save(self, filepath, pattern=None)
Saves the current configuration to filepath, using LIO configuration file format.
 
verify(self)
Validates the configuration for the following points:
 
apply(self, brute_force=True)
Applies the configuration to the live system:
 
diff_live(self)
Returns a diff between the current configuration and the live configuration as a reference.
 
diff(self)
Computes differences between a valid current configuration and a previously loaded valid reference configuration.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  policy_dir = '/var/target/policy'
Properties [hide private]
  current

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

undo(self)

 

Restores the previous state of the configuration, before the last set, load, delete, update or clear operation. If there is nothing to undo, a ConfigError exception will be raised.

set(self, configuration)

 

Evaluates the configuration (a string in LIO configuration format) and sets the relevant objects, attributes and atttribute groups.

Existing attributes and objects will be updated if needed and new ones will be added.

The list of created configuration nodes will be returned.

If an error occurs, the operation will be aborted, leaving the current configuration intact.

delete(self, pattern, node_filter=<function <lambda> at 0x7fedce549398>)

 

Deletes all configuration objects and attributes whose paths match the
pattern, along with their children.

The pattern is a single LIO configuration statement without any block,
where object identifiers, attributes names, attribute values and
attribute groups are regular expressions patterns. Object types have to
use their exact string representation to match.

node_filter is a function applied to each node before returning it:
    node_filter(node_in) -> node_out | None (aka filtered out)

Returns a list of all deleted nodes.

If an error occurs, the operation will be aborted, leaving the current
configuration intact.

load(self, filepath, allow_new_attrs=False)

 

Loads an LIO configuration file and replace the current configuration with it.

All existing objects and attributes will be deleted, and new ones will be added.

If an error occurs, the operation will be aborted, leaving the current configuration intact.

update(self, filepath)

 

Updates the current configuration with the contents of an LIO configuration file.

Existing attributes and objects will be updated if needed and new ones will be added.

If an error occurs, the operation will be aborted, leaving the current configuration intact.

clear(self)

 

Clears the current configuration.

This removes all current objects and attributes from the configuration.

search(self, search_statement, node_filter=<function <lambda> at 0x7fedce549668>)

 

Returns a list of nodes matching the search_statement, relative to the
current node, or an empty list if no match was found.

The search_statement is a single LIO configuration statement without
any block, where object identifiers, attributes names, attribute values
and attribute groups are regular expressions patterns. Object types
have to use their exact string representation to match.

node_filter is a function applied to each node before returning it:
    node_filter(node_in) -> node_out | None (aka filtered out)

dump(self, search_statement=None, node_filter=<function <lambda> at 0x7fedce549758>)

 

Returns a LIO configuration file format dump of the nodes matching
the search_statement, or of all nodes if search_statement is None.

The search_statement is a single LIO configuration statement without
any block, where object identifiers, attributes names, attribute values
and attribute groups are regular expressions patterns. Object types
have to use their exact string representation to match.

node_filter is a function applied to each node before dumping it:
    node_filter(node_in) -> node_out | None (aka filtered out)

save(self, filepath, pattern=None)

 

Saves the current configuration to filepath, using LIO configuration file format. If path is not None, only objects and attributes starting at path and hanging under it will be saved.

For convenience, the saved configuration will also be returned as a string.

The pattern is a whitespace-separated string of regular expressions, each of which will be matched against configuration objects and attributes. In case of dump, the pattern must be non-ambiguous and match only a single configuration node.

If the pattern matches either zero or more than one configuration nodes, a ConfigError exception will be raised.

verify(self)

 

Validates the configuration for the following points:

  • Portal IP Addresses exist
  • Devices and file paths exist
  • Files for fileio exist
  • No required attributes are missing
  • References are correct

Returns a dictionary of validation_test: [errors]

apply(self, brute_force=True)

 

Applies the configuration to the live system:

  • Remove objects absent from the configuration and objects in the configuration with different required attributes
  • Create new storage objects
  • Create new fabric objects
  • Update relevant storage objects
  • Update relevant fabric objects

diff(self)

 

Computes differences between a valid current configuration and a previously loaded valid reference configuration.

Returns a dict of:

  • 'removed': list of removed objects
  • 'major': list of changed required attributes
  • 'major_obj': list of obj with major changes
  • 'minor': list of changed non-required attributes
  • 'major_obj': list of obj with minor changes
  • 'created': list of new objects in the current configuration

Property Details [hide private]

current

Get Method:
unreachable.current(self)
Set Method:
unreachable.current(self, config_tree)