From b9c065de28371152b7e5914620e7421a9491f60e Mon Sep 17 00:00:00 2001 From: Ian Wienand <iwienand@redhat.com> Date: Tue, 2 May 2017 15:15:26 +1000 Subject: [PATCH] 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 --- diskimage_builder/block_device/blockdevice.py | 15 ++++++++------- diskimage_builder/block_device/cmd.py | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/diskimage_builder/block_device/blockdevice.py b/diskimage_builder/block_device/blockdevice.py index c9d43a8ce..daa1ddd2c 100644 --- a/diskimage_builder/block_device/blockdevice.py +++ b/diskimage_builder/block_device/blockdevice.py @@ -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 diff --git a/diskimage_builder/block_device/cmd.py b/diskimage_builder/block_device/cmd.py index a795e0f1b..4a9b8c6b6 100644 --- a/diskimage_builder/block_device/cmd.py +++ b/diskimage_builder/block_device/cmd.py @@ -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()