Calculate2 service variables

Calculate 2.2 variables used in templates, and also in program logic.
Values of variables replaces definitions of variables in templates.

Description of variable

Description of each variable consists of two parts:
  • parameters of variable (name, permissions, should it be printed? etc.)
  • method of defining the value of the variable (optional part)
Parameters and methods for variables are in different files:
  • file with parameters of variables;
  • file of methods for defining the values of variables.
For package calculate-lib:
  • cl_vars.py - parameters of variables;
  • cl_fill.py - methods for defining the values of variables.
For package calculate-desktop:
  • cl_vars_desktop.py - parameters of variables;
  • cl_fill_desktop.py - methods for defining the values of variables.

Similarly, for other packages.

Parameters of variable

The variable has the following parameters:
  • 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)

Method for definition the value of variable

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.

Write value of variable to file

The variable can be written to a file to save and then read.

Paths to files storing the values of variables are in the variable * cl_env_path *:
  • /etc/calculate/calculate.env
  • /var/calculate/calculate.env
  • /var/calculate/remote/calculate.env

The variable is saved in the format samba.
An example of a stored value of variable from package calculate-client:

[client] 
ld_samba_dn = ou=Samba,ou=Services,dc=calculate
ld_unix_dn = ou=Unix,ou=Services,dc=calculate

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).

Algorithm for creating a variable

  1. Runs once for all variables:
    1. Find variables in the file storage of variables
    2. Search the parameters of variables for variables, found in the file of storage values
    3. Search methods of defining for variables found in file of storage values
    4. Create variables based on the parameters and methods for defining the values and assigning them values from the file of storage variables
  2. Search variable's parameters. (Search in the current package, then in the library)
  3. Search method for defining the value of the variable (search in the current package, then in the library)
  4. 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).

Groups variables

Variables are divided into groups depending on the type of information (type, application/service, function):
  • cl - general settings of calculate
  • hr - equipment settings
  • ld - ldap attributes
  • os - operating system
  • sr - service settings
  • ur - user information

calculate-lib

Common variables

  • cl_env_path - list of paths to. env files in order of priority, from low to high
  • cl_pass_file - full path to the currently configuration file
  • cl_pass_step - first/next - pass of applying of the template (first, next)
  • cl_pass_action - action program, is used to select the directory with templates:
    • profile - generate of user's profile
    • install / uninstall - install, uninstall programs
    • domain / undomain - enter or exit from domain
  • hr_virtual - name of the virtual machine (virtualbox, vmware, qemu)
  • os_arch_machine - System Architecture (i686, x86_64)
  • os_linux_name - full system name (note: Calculate Linux Desktop)
  • os_linux_shortname - short system name (прим: CLD)
  • os_linux_subname - window manager (note: KDE)
  • os_linux_ver - system version (note: 10.2)
  • os_locale_lang - system language (note: ru_RU)
  • os_locale_language - system language (note: ru)
  • os_locale_locale - system locale (note: ru_RU.UTF-8)
  • os_locale_xkb - keyboard layout for X-server (note: us,ru(winkeys))
  • os_locale_xkbname - names of using keyboard layouts (note: us,ru)
  • os_net_allow - authorized networks (note: 10.0.0.0/24)
  • os_net_domain - network domain (прим: domain.ru)
  • os_net_hostname - hostname (прим: comp1)
  • os_net_ip - list of ip's on all interfaces (note: 10.0.0.53)
  • os_root_dev - root file system (note: /dev/sda3)
  • os_root_type - media type, which is the root partition (ram, hdd, usb-hdd, livecd)

calculate-client

  • cl_name - program name (note: calculate-desktop)
  • cl_template_path - list of directories storing the templates
  • cl_remote_ftp - DNS name of server with FTP, managed with Calculate2 utilities (note: ftp.domain.ru)
  • cl_remote_host - DNS name of server with Samba, managed with Calculate2 utilities(note: office.domain.ru)
  • cl_remote_pw - Samba password of user client for connecting to server
  • cl_root_path - path to the directory on which are superimposed on the profile system files (note: /)
  • cl_ver - program version (note: 2.2.0)
  • hr_laptop - if computer is laptop - manufacturer
  • hr_video - manufacturer of GPU (note: ati)
  • hr_x11_height - vertical screen resolution (note: 1024)
  • hr_x11_standart - the nearest standard size of the image to the current resolution (note: 1280x1024)
  • hr_x11_video_drv - name to use video driver (note: radeon)
  • hr_x11_width - horizontal screen resolution (note: 1280)
  • ld_base_dn - base LDAP suffix: dc=calculate
  • 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)
  • ur_group - user primary group (note: it)
  • ur_jid - jabber id (note: )
  • ur_jid_host - host name from user's jabber id (note: jabber.domain.ru)
  • ur_login - user name (note: michael)
  • ur_mail - user's e-mail (note: )
  • ur_organization - user's company (note: Компания "Калкулэйт")
  • ur_signature - user signature (note: Germany, Hamburg, Bedestrasse, 4\nhttp://www.haburburger.de \n+7 647 3363632\n+7 865 7727678)
Thank you!