Remove args from BlockDevice() init

The args agument was only used to find the symbol for the getval
command.  Have the command pass the symbol to find in directly.  We
can therefore remove the args paramater to the BlockDevice() creation.

Change-Id: I8e357131b70a00e4a2c4792c009f6058d1d5ae9e
This commit is contained in:
Ian Wienand 2017-05-02 15:15:26 +10:00
parent c74ba2fe74
commit b9c065de28
2 changed files with 10 additions and 9 deletions

View File

@ -149,16 +149,14 @@ class BlockDevice(object):
return json.load(fd)
return None
def __init__(self, params, args):
def __init__(self, params):
"""Create BlockDevice object
Arguments:
:param params: YAML file from --params
:param args: arguments from cmd argparse
"""
logger.debug("Creating BlockDevice object")
self.args = args
self.params = params
logger.debug("Params [%s]" % self.params)
@ -250,13 +248,16 @@ class BlockDevice(object):
logger.info("Wrote final block device config to [%s]"
% self.config_json_file_name)
def cmd_getval(self):
def cmd_getval(self, symbol):
"""Retrieve value from block device level
This is needed for backward compatibility (non python) access
to (internal) configuration.
The value of SYMBOL is printed to stdout. This is intended to
be captured into bash-variables for backward compatibility
(non python) access to internal configuration.
Arguments:
:symbol: The symbol to find
"""
symbol = self.args.symbol
logger.info("Getting value for [%s]" % symbol)
if symbol == 'image-block-partition':
# If there is no partition needed, pass back directly the

View File

@ -30,7 +30,7 @@ class BlockDeviceCmd(object):
self.bd.cmd_init()
def cmd_getval(self):
self.bd.cmd_getval()
self.bd.cmd_getval(self.args.symbol)
def cmd_create(self):
self.bd.cmd_create()
@ -110,7 +110,7 @@ class BlockDeviceCmd(object):
sys.exit(1)
# Setup main BlockDevice object from args
self.bd = BlockDevice(self.params, self.args)
self.bd = BlockDevice(self.params)
self.args.func()