Remove quotes when assigning values from an openrc

The magnum and neutron modules parse an openrc file and create key-value
pairs by literally assigning the key to anything in front of an '=' and
the value to everything after an '='. If the value is surrounded by
quotes, do not include them.

Depends-On: I4b1e7b5cb83061ea35108db545fdfa33cef037a5
Change-Id: Ib44d9fa63332286fe4e51bd818f80b5989815988
This commit is contained in:
Jimmy McCrory 2017-02-14 16:07:51 -08:00
parent 5e2c0c5b55
commit 14d2727c04
2 changed files with 2 additions and 2 deletions

View File

@ -142,7 +142,7 @@ class ManageMagnum(object):
def _parse_openrc(self):
"""Get credentials from an openrc file."""
openrc_path = self.module.params['openrc_path']
line_re = re.compile('^export (?P<key>OS_\w*)=(?P<value>[^\n]*)')
line_re = re.compile('^export (?P<key>OS_\w*)=\'?(?P<value>[^\n\']*)')
with open(openrc_path) as openrc:
matches = [line_re.match(l) for l in openrc]
return dict(

View File

@ -262,7 +262,7 @@ class ManageNeutron(object):
def _parse_openrc(self):
"""Get credentials from an openrc file."""
openrc_path = self.module.params['openrc_path']
line_re = re.compile('^export (?P<key>OS_\w*)=(?P<value>[^\n]*)')
line_re = re.compile('^export (?P<key>OS_\w*)=\'?(?P<value>[^\n\']*)')
with open(openrc_path) as openrc:
matches = [line_re.match(l) for l in openrc]
return dict(