From 051e5e95a58c27ef17f15fde8a9043bc1d1fffa5 Mon Sep 17 00:00:00 2001 From: Adam Gandelman Date: Mon, 4 Mar 2013 16:58:22 -0800 Subject: [PATCH] Synchronize charm helpers across all current ha branches. --- hooks/lib/openstack-common | 28 ++++++++++++++++++++++++++++ revision | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/hooks/lib/openstack-common b/hooks/lib/openstack-common index 720a50af..7cb85621 100644 --- a/hooks/lib/openstack-common +++ b/hooks/lib/openstack-common @@ -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 +" +} diff --git a/revision b/revision index b4de3947..48082f72 100644 --- a/revision +++ b/revision @@ -1 +1 @@ -11 +12