Synchronize charm helpers across all current ha branches.

This commit is contained in:
Adam Gandelman 2013-03-04 16:58:22 -08:00
parent f84dd69a55
commit de6211e357
2 changed files with 29 additions and 1 deletions

View File

@ -493,3 +493,31 @@ is_leader() {
return 1
}
##########################################################################
# Description: Print the value for a given config option in an OpenStack
# .ini style configuration file.
# Parameters: File path, option to retrieve, optional
# section name (default=DEFAULT)
# Returns: Prints value if set, prints nothing otherwise.
##########################################################################
local_config_get() {
# return config values set in openstack .ini config files.
# default placeholders starting (eg, %AUTH_HOST%) treated as
# unset values.
local file="$1"
local option="$2"
local section="$3"
[[ -z "$section" ]] && section="DEFAULT"
python -c "
import ConfigParser
config = ConfigParser.RawConfigParser()
config.read('$file')
try:
value = config.get('$section', '$option')
except:
print ''
exit(0)
if value.startswith('%'): exit(0)
print value
"
}

View File

@ -1 +1 @@
81
82