value - value of variable, by default - empty string
mode - permissions for user, by default only read. Modes ("r" - read, "w" - write)
official - variable for internal use in program, by default flag is switched off. Values: True - internal use, False - available to all. If official=True - variable will not be printed.
dynamic - in case dynamic=True, with every call of variable will be called method of determining (warning, there is possible recursive loop in the case of cyclic dependencies of variables), by default dynamic=False. Value: True - permanent call of determining method, False - method of determining called once on the first usage of variable (On subsequent calls of variable will be used stored value obtained on the first call).
Examples of variable defining:
class Data:
# hostname
os_net_hostname = {'mode':"w"}
# allowed networks
os_net_allow = {value:"192.168.0.0/24"}
# ip on all interfaces
os_net_ip = {}
In this example, at the request, will be created of the following variables (values of variables in the absence of filling methods)
os_net_hostname - (value is "", user can change value)
os_net_allow - (value is "192.168.0.0/24", user can't change value)
os_net_ip - (value is "", user can't change value)
The name of the method of defining the value of a variable consists of 'get_', and the variable name. Example for variable os_net_ip:
class fillVars()
def get_os_net_ip(self):
return "192.168.0.1"
In this example the value of variable os_net_ip will be 192.168.0.1
if no method of definition value for variable, value of this variable will be default value from variable parameters.
Files storage of parameters and methods for defining the values¶
Usually, for each utility package of Calculate 2.2 used two files for storage parameters of variables, and two files for storage methods of defining of variable . Example for package calculate-desktop:
files for parameters:
cl_vars_desktop.py
cl_vars.py
files for methods:
cl_fill_desktop.py
cl_fill.py
Where is, first file - package's file, second file - from library calculate-lib.
Section coincides with name of package [client] calculate-client.
Value of variable can be stored in multiple files, in this case value of variable will be value of variable from last processed file. That is the priority of files storing variable values back to their location, the highest priority file is the last in the list (the highest priority file /var/calculate/remote/calculate.env).
Search the parameters of variables for variables, found in the file of storage values
Search methods of defining for variables found in file of storage values
Create variables based on the parameters and methods for defining the values and assigning them values from the file of storage variables
Search variable's parameters. (Search in the current package, then in the library)
Search method for defining the value of the variable (search in the current package, then in the library)
Create a variable based on the parameters and the method of defining the values
Search of variable's parameters occurs first in the parameter's file of the package, then in the library (calculate-lib). This search of algorithm allows you to redefine the parameters for the variable for which there are parameters in the library (calculate-lib). Search of method for defining the value of a variable occurs on the search algorithm parameters variables. This allows you to override the method for determining the value of the variable for which there is a method in the library (calculate-lib).
ld_bind_dn - dn of bind user: cn=proxyuser,dc=calculate
ld_bind_pw - password of bind user: calculate
ld_repl_dn - dn of replication user (not used, kept for backward compatibility)
ld_samba_dn - dn of Samba administrator: ou=Samba,ou=Services,dc=calculate
ld_services_dn - dn of branch of all services: ou=Services,dc=calculate
ld_unix_dn - dn of Unix administrator: ou=Unix,ou=Services,dc=calculate
os_remote_auth - name of server which uses for authorization (in case of authorization on server under management of Calculate2 utilities - DNS server name, otherwise - local)
os_remote_client - version of the program which last time were applied templates (note: 2.1.9)
sr_jabber_crypt - encryption when dealing with Jabber server managed with Calculate2 utilities (note: ssl)
sr_jabber_host - DNS name of server with Jabber service, managed with Calculate2 utilities (note: jabber.domain.ru)
sr_jabber_port - Jabber server port (note: 5223)
sr_mail_crypt - encryption when receiving mail from the configured service Mail, managed with Calculate2 utilities (none, tls) (прим: tls)
sr_mail_host - DNS name of Mail server (note: mail.domain.ru)
sr_mail_port - Mail server port (note: 143)
sr_mail_send_crypt - encryption when sending mail to the configured Mail Service
sr_mail_send_host - DNS name of Mail server to send e-mails (note: mail.domain.ru)
sr_mail_send_port - port of Mail server to send e-mails (note: 25)
sr_mail_type - mail receiving protocol (pop, imap) (note: imap)
sr_proxy_host - DNS name of server with Proxy service, managed with Calculate2 utilities (note: proxy.domain.ru)
sr_proxy_port - Proxy server port (note: 8080)
sr_samba_host - DNS name of server with Samba service, managed with Calculate2 utilities (note: office.domain.ru)
ur_fullname - full user name (note: Michael Jordan)