Skip to content
Permalink
Browse files

driver/networkusbstoragedriver: support images configuration

Previously the NetworkUSBStorageDriver only took absolute paths in the
write_image function. Allow the specification of an image attribute which is
used as a fallback if no explicit filename is given.
This brings this driver in line with other drivers which can also retrieve their
files from the environment configuration.

Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
  • Loading branch information...
Emantor authored and jluebbe committed Dec 10, 2018
1 parent 572e811 commit 243bf6b1b273e6191d5339253b39254538cb0347
Showing with 16 additions and 3 deletions.
  1. +8 −2 doc/configuration.rst
  2. +8 −1 labgrid/driver/networkusbstoragedriver.py
@@ -1178,10 +1178,16 @@ Implements:

.. code-block:: yaml
NetworkUSBStorageDriver: {}
NetworkUSBStorageDriver:
image: flashimage
.. code-block:: yaml
images:
flashimage: ../images/myusb.image
Arguments:
- None
- image (str): filename of the image to write to the remote usb storage

OneWirePIODriver
~~~~~~~~~~~~~~~~
@@ -24,6 +24,10 @@ class NetworkUSBStorageDriver(Driver):
NetworkUSBSDMuxDevice
},
}
image = attr.ib(
default=None,
validator=attr.validators.optional(attr.validators.instance_of(str))
)

def __attrs_post_init__(self):
super().__attrs_post_init__()
@@ -36,11 +40,14 @@ def on_deactivate(self):
pass

@step(args=['filename'])
def write_image(self, filename):
def write_image(self, filename=None):
if not self.storage.path:
raise ExecutionError(
"{} is not available".format(self.storage_path)
)
if filename is None and self.image is not None:
filename = self.target.env.config.get_image_path(self.image)
assert filename, "write_image requires a filename"
mf = ManagedFile(filename, self.storage)
mf.sync_to_resource()
self.logger.info("pwd: %s", os.getcwd())

0 comments on commit 243bf6b

Please sign in to comment.
You can’t perform that action at this time.