Thread-safe object, protected by a global RLock, with a licornd property giving access to the Licorn® daemon (to benefit from the service* facility).
The __getitem__(), __setitem__(), and __delitem__() methods automatically aquire and release the global lock.
Note
the lock attribute is really a method returning the RLock object, because the lock object itself is not stored inside the instance: as Pyro can’t pickle a RLock object, it must be stored in the LockManager and looked up everytime, until we found a better solution.
New in version 1.3.
acquire the controller global lock.
Return True if current controller lock is acquired, else False.
Warning
calling this is_locked() method costs a few CPU cycles, because of the object lookup (see note above). Try to avoid using it as much as possible.
release the controller global lock.
The CoreController class implements multiple functionnalities:
Warning
updating CoreUnitObject s attributes directly doesn’t update the reverse mappings yet. This may be implemented in a future release. The reverse mapping functionnality may thus be considered incomplete, because a part of the update process must be done manually. Sorry for that, folks.
New in version 1.3.
Dump the internal data structures (debug and development use).
iterate through active backends and find the prefered one. We use a copy, in case there is no prefered yet: LMC.backends will change and this would crash the for_loop.
Note
TODO: this method may soon move into the BackendsManager instead of the controller.
special case for SystemController.
load extensions if possible. This could not be possible if the controller is reload() ing during the CLIENT-daemon first launch of its method init_client_first_pass().
load all our extensions.
FIXME: TO BE DOCUMENTED
New in version 1.3.
load special rules (rules defined by user) and merge system rules with them. Only the system default rule can be overwriten by the user default rule. If any other user rule is in conflict with a system rule, the system one will be used.
This function return only applicable rules
load system rules
parse a rule from a line to a fsapi.FsapiObject. Returns a single Enumeration, containing either ONE ‘~’ rule, or a bunch of rules.
reload the templates rules generated from systems rules.
Common attributes for unit objects and modules in Licorn® core.
This class defines the following attributes:
this attribute is the Licorn® object internal unique number (it’s unique among all instances of a given class). If not given in __init__(), it will be determined from next free oid stored in the CoreUnitObject.counter class attribute.
a reference to the object’s container (manager or controller). Must be passed as __init__() argument, else the object won’t be able to easily find it’s parent when it needs it.
New in version 1.3.
Common attributes for stored objects (users, groups...). Add individual locking capability (better fine grained than global controller lock when possible), and the backend name of the current object storage.
New in version 1.2.
It’s the base for backends and extensions, because their principles are the same.
The basics of a module manager. Backends and extensions are just particular cases of this class.
Note
TODO: implement module_sym_path auto-detection, for the day we will use it. For now we don’t care about it.
New in version 1.3.
the generic way, called from RWI.select()
Check all enabled modules, then all available modules. Checking them will make them configure themselves, configure the required underlying system daemons, services or files, and eventually start services (depending of which type of module it is).
For more details, refer to the check() method of the desired module.
Try to disable a given module. What is exactly done is left to the module itself, because the current method will just call the disable() method of the module.
Try to disable a given module. What is exactly done is left to the module itself, because the current method will just call the disable() method of the module.
Try to enable a given module_name. What is exactly done is left to the module itself, because the current method will just call the enable() method of the module.
Try to enable a given module_name. What is exactly done is left to the module itself, because the current method will just call the enable() method of the module.
Return a list of modules (real instances, not just names) compatible with a given controller.
| Parameters: | controller – the controller for which we want to lookup compatible extensions, passed as intance reference (not just the name, please). |
|---|
load our modules (can be different type but the principle is the always the same).
If we are on the server, activate every module we can. If we are on a client, activate module only if module is enable on the server.
Note
TODO: implement module dependancies resolution. this is needed for the upcoming rdiff-backup/volumes extensions couple (at least).
CoreModule is the base class for backends and extensions. It provides the generate_exception() method, called by controllers when a high-level problem occurs (for example, a conflict between duplicate-data coming from different backends; this is the typical problem a backend can’t detect).
A module class defines these class attributes:
It must also define these instance attributes:
Note
[work in progress] if self.controllers_compat contains system (name of SystemController global instance), the current class must implement the special system_load() method. This method will be called after module load and after SystemController instanciation, to reconnect the module data to its controller.
This is mainly because extensions are loaded after the SystemController instanciation in LMC, and we currently can’t do it differently, system needs to be up very early in the inter-daemon connection process.
New in version 1.2.
FIXME: better comment
default check method.
Internal configuration and data, loaded as objects.
FIXME: better comment
In this abstract method, just return True (an abstract module is always disabled).
It’s up to derivatives to overload this method to implement whatever they need.
Note
your own module’s disable() method has to return True if the disable process succeeds, otherwise False.
In this abstract method, just return False (an abstract module can’t be enabled in any way).
It’s up to derivatives to overload this method to implement whatever they need.
Note
your own module’s enable() method has to return True if the enable process succeeds, otherwise False.
FIXME: better comment
A collection of Event used to synchronize my threads.
Generic mechanism for Exception dynamic generation.
Every module (backend or extension) can implement only the exceptions it handles, by defining special methods whose names start with genex_.
| Parameters: |
|
|---|
For an abstract module, this method always return False. For a standard module, it must return the attribute self.available, after having determined if the module is available or not.
Conditions of availability vary from a module to another. Generally speaking, a service-helper module should gather its service main configuration file and main binary, to check if they are installed.
Note
For more specific details, see classes LicornExtension and derivatives, and CoreBackend and derivatives, because there are other things to take in consideration when implementing end-of-road modules.
In standard operations, this method checks if the module can be enabled (in particular conditions). but the abstract method of the base class just return self.available:
A real backend will setup its own needed attributes with values strictly needed to work. This is done in case these values are not present in configuration files.
Any configuration file containing these values, will be loaded afterwards and will overwrite these attributes.
a collection of RLocks for multi-thread safety.
Filenames of useful files, stored as strings.
A list of compatible modules. See Importing Modules for details
indicates that this module is meant to be used on server only (not replicated / configured on CLIENTS).
Threads that will be collected by daemon to be started/stopped.