Home | Trees | Index | Help |
|
---|
Module deployables_lib |
|
Deployables_lib provides functions that simplifies implementation of a Power Tool. Most common tasks in managing a DSP for an Ensim server are available through this API.
To simplify understanding of the API arguments to the functions follow same name convention as given below -site_conf structure looks as shown below. { <service1-name> : { 'version' : <service1-version>, 'enabled' : '0' | '1', # String 'service1-attr1' : 'value1', 'service1-attr2' : 'value2' }, <service2-name> : { 'version' : <service1-version>, .... } : } 'ssh', 'apache', 'imap', 'mysql' are the examples of servicess.
Classes | |
---|---|
Msgs |
|
TranslationWrapper |
Function Summary | |
---|---|
Adds trailing slash ('/') to a URL / path if it is not already there. | |
apply_instance_patches(site,
site_conf,
old_site_conf,
instance_conf,
old_instance_conf,
patches)
| |
archive_manifest(instance_conf,
dir_moves,
patches,
file_mods,
file_manifest)
| |
Unpacks the archive in directory given by 'instance_conf["install_loc"]'. | |
Verifies that the license acceptance ('accept_lic' option in site configuration ) is True. | |
Checks if the index file (index.htm/index.html/index.shtml) exists in given directory inside specified site's filesystem. | |
Verifies that MySQL is installed and enabled for the site. | |
check_output applies provided success and failure patterns to output. | |
Chmods file with specified uid gid and the permissions. | |
Creates htdigest file within the specified directory. | |
Creates htdigest password for the instance. | |
Generate a 2-character salt. | |
Generate an 8-character salt. | |
Creates a database (if it doesn't exist) with name and admin as 'dbname' and 'dbadmin'. | |
Drops MySQL databse used by DSP. | |
Executes given sql query on DSP database. | |
Opens the SQL file from install location and executes the file. | |
directory_merge(srcdir,
dstdir,
fileinfo)
| |
Return status of Disk Quota. | |
Backup files given by instance_conf['backup_files'] and db of the given instance to a backup location given by instance_conf['backup_loc'] . | |
do_install_actions executes the list of actions required to install a DSP. | |
do_reconfigure_actions executes the actions required in order to upgrade a DSPI, This function takes the actions as one of the arguments and executes them in order. | |
do_upgrade_actions executes the actions required in order to upgrade a DSPI, This function takes the actions as one of the arguments and executes them in order. | |
dsp_create_doc(instance)
| |
Returns the instance of DSP i.e a dictionary representing DSP elements (keyed by element names) A DSP description is a dictionary with the following elements: | |
This function takes an instance description (dictionary representing dsp.xml) , a site configuration, a new instance configuration, and optional old instance configuration and list of well-known options, and fills in the various properties of the passed in instance. | |
dsp_get_localization(instance_conf,
locale)
| |
dsp_get_theme(instance_conf,
theme)
| |
Returns Install directory for requested DSP (name and version) | |
Returns lib directory for requested DSP (name and version). | |
Helper function for User administration. | |
dsp_load_localizations(dsp_desc)
| |
dsp_load_themes(dsp_desc)
| |
Returns the themes directory -> /usr/lib/ensim/deployables/<DSP>-<version>/lib/locale/ | |
Returns source directory for requested DSP (name and version) The source directory is $Install_Dir/lib -> /usr/lib/ensim/deployables/<DSP>-<version>/source | |
Returns the themes directory -> /usr/lib/ensim/deployables/<DSP>-<version>/lib/themes/ | |
Returns string - <DSP>-<version> for given DSP-name and version | |
| |
Edits a conf file for the provided key, value and comment(optional) triplet tuples in vars argument. | |
Enables patches for the instance. | |
Executes the command | |
Executes curl command with requested opts. | |
Executes SQL statements given by 'sql'. | |
Executes php scripts (given by argument 'script'). | |
Returns a (non-existing) MySQL databse name for DSPI installation. | |
Find a (non-existing) directory for DSPI installation. | |
Constructs the DSPI URL from provided parameters and appends this URL to msgs. | |
Finds subdomains and paths to their publishing(html) directory. | |
Returns dictionary for a DSP with specified version | |
Returns mysql host for the site | |
Returns (uid, gid) pair for the user. | |
Find the username and group for specified uid,gid. | |
Get site users for requested site. | |
Rename a DSP MySQL database if the DB prefix is changed. | |
Sets file and directory permissions for files based on weather 'jail' is 'True' or 'False'. | |
Computes the new value of instance_conf['url_loc'] if there is a change in site domain (during a site edit). | |
Corrects the file ownerships of DSP files if the site user is changed. | |
Recursively deletes all files/directory ( within install location ) which were - | |
Loads and returns ref to the dAPI module of requested DSP | |
Reads and converts requested dsp.xml to dictionary format | |
Reads and converts requested DSP xml string to dictionary format | |
Load 'msgs' module deployed in the 'lib' directory of requested DSP into the 'systab' system table | |
Prefix site fst path to given string(path) if the site is a high security site. | |
Return 1 if mysql service is enabled for the site else returns 0. | |
Slightly paranoid file reader. | |
This function is intended to provide a safe recursive chown. | |
This function is automatically called when the module is loaded. | |
regression helper method | |
Recursively removes all files/directories (within install location ) given in 'files'. | |
Checks if instance_conf has the key - 'url_loc' Adds error 'URL_LOCATION_REQUIRED' to msgs on not finding the key. | |
Given url_net and url_path (in Instance Conf), resolves these two variables to an installation location in the filesystem and a URL location. | |
Edits ".htdigest" to set htdigest for the instance. | |
Sets htdigest password for the instance. | |
Escapes any 's in the given string so that the given string may be surrounded in 's prior to being used in a command line context. | |
Returns site file system path from given site. | |
Returns site file system path from given site. | |
This function replaces the (trailing) portion of the domain name segment of a URL. | |
This function replaces the old domainname to new(changed) domainname from given str. | |
This function replaces the entire domain and the starting portion of the path of URLs. | |
File writer method that writes given data to specified file path and assigns uid, gid. | |
__chmod(perms,
dirname,
names)
| |
__chown(id,
dirname,
names)
| |
Add quotes requested string | |
Unquotes requested string | |
__find_conflicts(info,
dirname,
names)
| |
__load_dsp_description(doc)
| |
__rename(info,
src_dir,
names)
|
Variable Summary | |
---|---|
int |
CONTEXT_AUTO_UPGRADE = 6 |
dict |
context_dict = {1: 'install', 2: 'upgrade', 3: 'remove',...
|
int |
CONTEXT_INSTALL = 1 |
int |
CONTEXT_RECONFIGURE = 4 |
int |
CONTEXT_REMOVE = 3 |
int |
CONTEXT_SITE_EDIT = 5 |
int |
CONTEXT_UPGRADE = 2 |
dict |
dsp_modules = {}
|
NullTranslations |
dsp_null_translation = <gettext.NullTranslations instanc...
|
dict |
dsp_themes = {'default': {'doc': <xmlDoc (/usr/lib/ensim...
|
lock |
libuser_lock = <thread.lock object at 0xb7f0a0f0>
|
int |
MODSTR_JAIL = 1 |
int |
REGRESSION_DO_TEST = 2 |
int |
REGRESSION_GET_TEST_STRING = 1 |
tuple |
__supported_types = ('Boolean', 'ExclusiveSelect', 'Mult...
|
str |
_cryptsalt = './abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN...
|
Function Details |
---|
add_slash(url)Adds trailing slash ('/') to a URL / path if it is not already there.
|
archive_unpack(msgs, st, site, site_conf, instance_conf, dir_moves, file_mods, patches, fileinfo=None, context=1)Unpacks the archive in directory given by 'instance_conf["install_loc"]'. It creates the install path (with chmod 755) if it doesn't exists. The supported formats are:
After unpacking all the 'source' and 'dest' pairs identified from 'dir_moves' and directories are moved accordingly. File or directory specific actions are Directories and files (with some default content) can also be created/deleted with specific ownership and permissions using 'file_mods'. Default permission for directories and files is 0755 and 0644 respectively. Args:
NOTE: If these arguments are not present in args_dict empty objects are passed as defaults. Errors : Throws Critical errors if any of the following -
|
check_accept_lic(msgs, st, conf)Verifies that the license acceptance ('accept_lic' option in site configuration ) is True.
|
check_index(msgs, st, site, dir)Checks if the index file (index.htm/index.html/index.shtml) exists in given directory inside specified site's filesystem.
|
check_mysql_enabled(msgs, st, conf)Verifies that MySQL is installed and enabled for the site.
|
check_output(output, success_re='', failure_re='')check_output applies provided success and failure patterns to output. Most useful when you want to process a commands output for certain condition.
|
chmodfile(path, uid, gid, perms)Chmods file with specified uid gid and the permissions. Permissions should be in in octal format (eg. 07000). Does not return success/failure. |
create_htdigest(msg, st, site, instance_conf, appuser, realm, directory, password)Creates htdigest file within the specified directory.
|
create_htpasswd(msgs, st, site, instance_conf, appuser, realm, directory, password)Creates htdigest password for the instance.
|
crypt_DES_password(password)Generate a 2-character salt.
|
crypt_MD5_password(password)Generate an 8-character salt.
|
db_create(msgs, st, site, dbadmin, dbname)Creates a database (if it doesn't exist) with name and admin as 'dbname' and 'dbadmin'.
|
db_drop(site, site_conf, instance_conf)Drops MySQL databse used by DSP. Name of MySQL DB is decided by instance_conf dict['dbname']. |
db_exec_sql(site, site_conf, instance_conf, sql)Executes given sql query on DSP database.
|
db_exec_sql_file(site, site_conf, instance_conf, sql_file)Opens the SQL file from install location and executes the file. The file is broken into lines separated by "; " and each line is executed individually.
|
disk_quota_exhausted(site, user)
|
do_backup(msgs, st, site, site_conf, instance_conf)Backup files given by instance_conf['backup_files'] and db of the given instance to a backup location given by instance_conf['backup_loc'] . Errors stop execution of queued actions. |
do_install_actions(site, site_conf, instance_conf, msgs, st, actions, args_dict)do_install_actions executes the list of actions required to install a DSP. It supports a range of actions commonly required in installing a DSP. Most actions expect some data to perform given task. This data is provided in the form of python dictionary (args_dict) to do_install_actions method. An args_dict structure looks like:args_dict = {'action1': {'action1Arg1': action1Arg1Data, 'action1Arg2': action1Arg2Data, .. }, 'action2': ... }List of Permitted actions -
check_accept_licVerifies that the license aceptence ('accept_lic' option in site configuration ) is True. Adds error message to msgs if SA refuses accept the DSP license.check_mysql_enabledVerifies that MySQL is installed and enabled for this site.resolve_locationGiven url_net and url_path (in Instance Conf), resolves these two variables to an installation location in the filesystem and a URL location. Adds these variables as install_loc and url_loc to instance_conf.check_indexChecks if the index file (index.htm/index.html/index.shtml) exists in given directory inside specified site's filesystem. If it exists it appends a warning to msgs. Doesn't stop the execution either ways.args
db_createCreates a database table (if it doesn't exist) with name and admin as 'dbname' and 'dbadmin'. The args are not required to be specified for the most of the DSPs.args
archive unpackUnpacks the DSP source archive.args
run_sql_fileExecules sql statements from given file.args
edit_conf_fileEdits a conf file for the provided key, value and comment(optional) tripplet tuples in vars argument.argsedit_conf_file actions need following args. Referedit_conf_file for details.
handle_security_modeSets the permissions on file as specified in args. We need to pass two sets of (octal)permissions. One is for low and medium security mode while the other is for high security mode sites.args
exec_php_scriptargs
finish_urlConstructs the DSPI URL from provided parameters and appends this URL to msgs.access_urlConstructs the DSP URL for SA to access after DSP install. The same URL will be deplayed after successful DSP install. args ----
check_passCompares instance_pass1 and instance_pass2 in instance_conf. Adds 'PASSWORD_MISMATCH' error to 'st' object if comparison fails.check_install_loc_ownerChecks if user specified during DSP install is the owner and group owner of the install directory. Adds 'DIR_OWNER_MISMATCH' or 'DIR_GROUP_MISMATCH' error on mismatch.db_probedb_probe action checks if the database is accessible with given mysql connection details(in site_conf and instance_conf). If database is not accessible it appends ERROR message to msgs object.exec_mysqlExecutes sql query as in sql arg. Results of sql query is stored in args_dict['exec_mysql']['results'].args
set_php_cgiAdds necessary directives to ".htaccess" file placed in dstdir to turn off php cgi mode. .htaccess is created if it is not there already. Default value of 'install_loc' is taken for dstdir unless specified. Useful in cases where a tool requires to override global php configuration. args_dict { 'dir': path_to_write_htaccess } By default this writes into install_loc directory which can be changed by providing 'dir' in args_dictcreate_htdigestCreates htdigest file within the specified directory. Refercreate_htdigest for details
args
set_htdigestEdits ".htdigest" to set htdigest for the instance. It appends following content to .htaccess in specified directory.:AuthType Digest AuthName <realm> AuthDigestFile <directory>/.htdigest Require valid-user args
create_htpasswdCreates .htpasswd file in given directory. File configuration is based on the args provided.args
set_htpasswdCreates .htpasswd file in given directory. It points AuthUserFile directive to i.htaccess file given directory path. File contents looks as given below. AuthType Basic AuthName "<realm>" AuthUserFile <directory>/.htpasswd Require valid-userargs
remove_filesRecursively removes all files/directories (within install location ) given in 'files' arg.args:
require_url_locChecks instance_conf for key url_loc and adds error 'URL_LOCATION_REQUIRED' if key is not present.check_disk_quotaChecks the diskquota of given user and adds the error messages if quota available is not sufficient. args ----
|
do_reconfigure_actions(context, site, site_conf, old_site_conf, instance_conf, old_instance_conf, msgs, st, actions, args_dict)do_reconfigure_actions executes the actions required in order to
upgrade a DSPI, This function takes the actions as one of the arguments
and executes them in order. Below is the list of permitted actions. See
apply_patchApplies patches specified in patches list. args ----
|
do_upgrade_actions(site, site_conf, instance_conf, old_instance_conf, msgs, st, actions, args_dict)do_upgrade_actions executes the actions required in order to upgrade
a DSPI, This function takes the actions as one of the arguments and
executes them in order. Below is the list of permitted actions. See
|
dsp_create_instance(dsp, version=None)Returns the instance of DSP i.e a dictionary representing DSP elements (keyed by element names) A DSP description is a dictionary with the following elements:- 'shortname' : short name of DSP - 'longname' : long name of DSP - 'version' : version of DSP (this is the script package's version) - 'dapiversion' : dAPI version of DSP (this is Ensim dAPI version) - 'dapirelease' : dAPI release of DSP (this is dAPI's release number) - 'upgrades' : list of dictionaries, where each dictionary contains a shortname, version, dapiversion, and dapirelease of a DSP that this DSP can upgrade - 'options' : a list of option dictionaries, where each dictionary contains at least the following: - 'name' : name of option - 'title' : displayed title for option - 'type' : type of option (see supported types) - 'hidden' : whether this option should be displayed in the form - 'inschema' : whether this option is part of the database schema for the DSP - 'insummary' : whether this option should be part of an instance summary display - 'summaryTitle' : what title should be displayed for a given summary option; if not present, it will default to the title content - Following parameters can also be used with option - 'parent' : the option that this option is a suboption of - 'helpmsg' : a help message for this option This dictionary is simply a copy of dsp_modules['dsp']['desc']. supported types = ('Boolean', 'ExclusiveSelect', 'MultiInput', 'SingleInput', 'MultiSelect', 'Label') |
dsp_fill_instance(context, instance, site, site_conf, new_conf, old_conf=None, common_options=None)This function takes an instance description (dictionary representing dsp.xml) , a site configuration, a new instance configuration, and optional old instance configuration and list of well-known options, and fills in the various properties of the passed in instance. This function is not invoked when an instance is edited due to a site edit.
|
dsp_install_directory(dsp=None, version=None)Returns Install directory for requested DSP (name and version)
|
dsp_lib_directory(dsp, version=None)Returns lib directory for requested DSP (name and version). The lib directory is $Install_Dir/lib -> /usr/lib/ensim/deployables/<DSP>-<version>/lib/
|
dsp_libuser_admin(site)Helper function for User administration.
|
dsp_locale_directory(dsp=None, version=None)Returns the themes directory -> /usr/lib/ensim/deployables/<DSP>-<version>/lib/locale/ |
dsp_source_directory(dsp, version=None)Returns source directory for requested DSP (name and version) The source directory is $Install_Dir/lib -> /usr/lib/ensim/deployables/<DSP>-<version>/source
|
dsp_theme_directory(dsp=None, version=None)Returns the themes directory -> /usr/lib/ensim/deployables/<DSP>-<version>/lib/themes/ |
dsp_versioned_name(dsp, version=None)Returns string - <DSP>-<version> for given DSP-name and version |
dump_command(cmd, out='')
|
edit_conf_file(site, site_conf, instance_conf, file, lang, pat, sub, vars)Edits a conf file for the provided key, value and comment(optional) triplet tuples in vars argument. eg. conversion vars("somekey","somevalue","somecomment") => "somekey" = "somevalue"; #somecomment
|
enable_patches(instance, instance_patches)Enables patches for the instance. |
exec_cmd(cmd)Executes the command
|
exec_curl_cmd(url, opts=[])Executes curl command with requested opts.
|
exec_mysql(msgs, st, site, site_conf, instance_conf, sql)Executes SQL statements given by 'sql'. The result of execution is returned and eventually stored in args_dict['exec_mysql']['results']. |
exec_php_script(site, site_conf, instance_conf, exec_dir, script, args, success_re, failure_re, post=1)Executes php scripts (given by argument 'script'). Most of the times these are the web-installer/wizard scripts that configures and installs a DSP.
|
find_free_dbname(prefix, dbname)Returns a (non-existing) MySQL databse name for DSPI installation.
|
find_free_path(site, path)Find a (non-existing) directory for DSPI installation.
|
finish_url(msgs, st, site, site_conf, instance_conf, file)Constructs the DSPI URL from provided parameters and appends this URL to msgs. |
get_domain_path_pairs(site, site_conf)Finds subdomains and paths to their publishing(html) directory.
|
get_module(dsp, version=None)Returns dictionary for a DSP with specified version eg.>>> dl.get_module('gallery','1.4.1').keys() ['themes', 'desc_last_modified', 'dAPI_last_modified', 'msgs', 'locale', 'msgs_last_modified', 'module', 'desc'] >>> print dl.get_module('gallery','1.4.1')['themes'] {'default': {'doc': <xmlDoc (/usr/lib/ensim/deployables/gallery-1.4.1/lib/themes/default.xsl) object at 0x885dcb4>, 'last_modified': 1077180404, 'xsl': <libxslt.stylesheet instance at 0x88b1854>}} |
get_mysql_host(site)Returns mysql host for the site |
get_site_user_ids(site, user, context=None)Returns (uid, gid) pair for the user.
|
get_site_user_name(site, uid=None, gid=None, context=None)Find the username and group for specified uid,gid.
|
get_site_users(site, site_conf, context=None)Get site users for requested site.
|
handle_db_changes(context, site, new_siteconf, old_siteconf, new_conf, old_conf)Rename a DSP MySQL database if the DB prefix is changed.
|
handle_security_mode(site, site_conf, instance_conf, files)Sets file and directory permissions for files based on weather 'jail' is 'True' or 'False'.
|
handle_url_loc(context, site_conf, old_site_conf, instance_conf, old_instance_conf)Computes the new value of instance_conf['url_loc'] if there is a change in site domain (during a site edit). |
handle_username_change(site, old_conf, new_conf)Corrects the file ownerships of DSP files if the site user is changed.
|
install_loc_cleanup(site, site_conf, instance_conf, dir_moves, patches=None, file_mods=None)Recursively deletes all files/directory ( within install location ) which were -
|
load_dAPI_module(dsp, version=None)Loads and returns ref to the dAPI module of requested DSP
|
load_dsp_description_from_file(xml_path)Reads and converts requested dsp.xml to dictionary format |
load_dsp_description_from_string(xml_str)Reads and converts requested DSP xml string to dictionary format |
load_msgs_module(dsp, version=None, symtab=None)Load 'msgs' module deployed in the 'lib' directory of requested DSP into the 'systab' system table |
modify_string(site, site_conf, str_or_tuple)Prefix site fst path to given string(path) if the site is a high security site.
|
mysql_installed(conf, old_conf=None)
|
readfile(path, uid, gid)Slightly paranoid file reader.
|
recursive_chown(dir, orig_uid, orig_gid, uid, gid)This function is intended to provide a safe recursive chown. It refuses to follow symlinks, uses fchown, and will not chown anything unless it matches the expected uid/gid.
|
refresh_dsps(dsp=None, version=None)This function is automatically called when the module is loaded. Locates the deployable with name and version as 'dsp' and 'version' in deployables install dir. i.e - "/usr/lib/ensim/deployables". If no name('dsp') or version info is passed it considers all deployables in the install directory. (Re-)Builds a dictionary 'dsp_modules' keyed by 'dsp' containing objects and last-modified-date of -
|
regression_check_index(action, index, test_data, string)regression helper method |
remove_files(site, instance_conf, files)Recursively removes all files/directories (within install location ) given in 'files'.
|
require_url_loc(msgs, st, instance_conf)Checks if instance_conf has the key - 'url_loc' Adds error 'URL_LOCATION_REQUIRED' to msgs on not finding the key. |
resolve_location(msgs, st, context, site, site_conf, instance_conf)Given url_net and url_path (in Instance Conf), resolves these two variables to an installation location in the filesystem and a URL location. Adds these variables as install_loc and url_loc to instance_conf.
|
set_htdigest(msgs, st, site, instance_conf, realm, directory)Edits ".htdigest" to set htdigest for the instance. Args:
|
set_htpasswd(msgs, st, site, instance_conf, realm, directory)Sets htdigest password for the instance.
|
shell_escape_arg(arg)Escapes any 's in the given string so that the given string may be surrounded in 's prior to being used in a command line context. This is typically needed when we want to execute a command that is going to have user input as part of its parameters, and we want to prevent the user from trying to get us to execute something we shouldn't. |
site_fs(site)Returns site file system path from given site. NOTE: YOU RARELY WILL NEED TO USE THIS FUNCTION! IN ALMOST ALL CASES, YOU WANT SITE_FS_JAIL INSTEAD! ONLY USE THIS FUNCTION WHEN YOU ARE ATTEMPTING TO ACTUALLY MANIPULATE A FILE WITHIN A SITE!!! (rationale: site_fs_jail makes allowances for export/import that this function can't)
|
site_fs_jail(site, site_conf)Returns site file system path from given site. |
url_net_sub(url, new_domain, old_domain)This function replaces the (trailing) portion of the domain name segment of a URL. It is meant to be used in CONTEXT_SITE_EDIT mode. |
url_path_sub(str, new_url, old_url)This function replaces the old domainname to new(changed) domainname from given str. eg.
>>> dl.url_path_sub('My Domain: foo.com','foo-bar.com','foo.com')
>>> 'My Domain: foo-bar.com'
It is meant to be used in CONTEXT_RECONFIGURE mode.
|
url_sub(url, new_url, old_url)This function replaces the entire domain and the starting portion of the path of URLs. It is meant to be used in CONTEXT_RECONFIGURE mode. |
writefile(path, uid, gid, data)File writer method that writes given data to specified file path and assigns uid, gid. Does not return success/failure. |
__conf_quote(value, lang)Add quotes requested string eg.>>> import deployables_lib as dl >>> dl.__conf_quote("XX",'php') "'XX'"Supported languages
|
__conf_unquote(value, lang)Unquotes requested string eg.>>> import deployables_lib as dl dl.__conf_unquote("'XX'",'php') 'XX'Supported languages
|
Variable Details |
---|
CONTEXT_AUTO_UPGRADE
|
context_dict
|
CONTEXT_INSTALL
|
CONTEXT_RECONFIGURE
|
CONTEXT_REMOVE
|
CONTEXT_SITE_EDIT
|
CONTEXT_UPGRADE
|
dsp_modules
|
dsp_null_translation
|
libuser_lock
|
MODSTR_JAIL
|
REGRESSION_DO_TEST
|
REGRESSION_GET_TEST_STRING
|
__supported_types
|
_cryptsalt
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Wed Mar 23 00:13:48 2005 | http://epydoc.sf.net |