Skip to content

Commit

Permalink
Rename process_args to config in processors.py
Browse files Browse the repository at this point in the history
The process_args variable name in functions found in processors.py
is a leftover from previous versions. config is a more appropriate
variable name.

Change-Id: I38bc821877ac95c84b0d728a8d40681a993d6aa1
  • Loading branch information
javierpena committed Sep 29, 2014
1 parent 4316fc4 commit 3c91bab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
18 changes: 8 additions & 10 deletions packstack/installer/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'process_ssh_key')


def process_cidr(param, param_name, process_args=None):
def process_cidr(param, param_name, config=None):
"""
Corrects given CIDR if necessary.
"""
Expand All @@ -25,20 +25,18 @@ def process_cidr(param, param_name, process_args=None):
raise ParamProcessingError(str(ex))


def process_host(param, param_name, process_args=None):
def process_host(param, param_name, config=None):
"""
Tries to change given parameter to IP address, if it is in hostname
format
"""
localhost = process_args and \
process_args.get('allow_localhost', False)
try:
return force_ip(param, allow_localhost=localhost)
return force_ip(param, allow_localhost=True)
except NetworkError as ex:
raise ParamProcessingError(str(ex))


def process_ssh_key(param, param_name, process_args=None):
def process_ssh_key(param, param_name, config=None):
"""
Generates SSH key if given key in param doesn't exist. In case param
is an empty string it generates default SSH key ($HOME/.ssh/id_rsa).
Expand All @@ -64,7 +62,7 @@ def create_key(path):
return param


def process_add_quotes_around_values(param, param_name, process_args=None):
def process_add_quotes_around_values(param, param_name, config=None):
"""
Add a single quote character around each element of a comma
separated list of values
Expand All @@ -79,7 +77,7 @@ def process_add_quotes_around_values(param, param_name, process_args=None):
param = ','.join(params_list)
return param

def process_password(param, param_name, process_args=None):
def process_password(param, param_name, config=None):
"""
Process passwords, checking the following:
1- If there is a user-entered password, use it
Expand All @@ -90,8 +88,8 @@ def process_password(param, param_name, process_args=None):
process_password.pw_dict = {}

if param == "PW_PLACEHOLDER":
if process_args["CONFIG_DEFAULT_PASSWORD"] != "":
param = process_args["CONFIG_DEFAULT_PASSWORD"]
if config["CONFIG_DEFAULT_PASSWORD"] != "":
param = config["CONFIG_DEFAULT_PASSWORD"]
else:
# We need to make sure we store the random password we provide
# and return it once we are asked for it again
Expand Down
3 changes: 1 addition & 2 deletions tests/installer/test_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
class ProcessorsTestCase(PackstackTestCaseMixin, TestCase):
def test_process_host(self):
"""Test packstack.installer.processors.process_host"""
proc_local = process_host('localhost', 'HOSTNAME',
process_args={'allow_localhost': True})
proc_local = process_host('localhost', 'HOSTNAME')
self.assertIn(proc_local, ['127.0.0.1', '::1'])

def test_process_ssh_key(self):
Expand Down

0 comments on commit 3c91bab

Please sign in to comment.