Merge "dom0 rootwrap - case insensitive xenapi section"

This commit is contained in:
Jenkins 2013-06-29 06:06:52 +00:00 committed by Gerrit Code Review
commit b89e454181
2 changed files with 11 additions and 2 deletions

View File

@ -51,13 +51,22 @@ def parse_args():
return exec_name, config_file, user_args return exec_name, config_file, user_args
def _xenapi_section_name(config):
sections = [sect for sect in config.sections() if sect.lower() == "xenapi"]
if len(sections) == 1:
return sections[0]
print "Multiple [xenapi] sections or no [xenapi] section found!"
sys.exit(RC_BADCONFIG)
def load_configuration(exec_name, config_file): def load_configuration(exec_name, config_file):
config = ConfigParser.RawConfigParser() config = ConfigParser.RawConfigParser()
config.read(config_file) config.read(config_file)
try: try:
exec_dirs = config.get("DEFAULT", "exec_dirs").split(",") exec_dirs = config.get("DEFAULT", "exec_dirs").split(",")
filters_path = config.get("DEFAULT", "filters_path").split(",") filters_path = config.get("DEFAULT", "filters_path").split(",")
section = 'XENAPI' section = _xenapi_section_name(config)
url = config.get(section, "xenapi_connection_url") url = config.get(section, "xenapi_connection_url")
username = config.get(section, "xenapi_connection_username") username = config.get(section, "xenapi_connection_username")
password = config.get(section, "xenapi_connection_password") password = config.get(section, "xenapi_connection_password")

View File

@ -9,7 +9,7 @@ filters_path=/etc/quantum/rootwrap.d,/usr/share/quantum/rootwrap
# These directories MUST all be only writeable by root ! # These directories MUST all be only writeable by root !
exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin
[XENAPI] [xenapi]
# XenAPI configuration is only required by the L2 agent if it is to # XenAPI configuration is only required by the L2 agent if it is to
# target a XenServer/XCP compute host's dom0. # target a XenServer/XCP compute host's dom0.
xenapi_connection_url=<None> xenapi_connection_url=<None>