Skip to content
Permalink
Browse files

treewide: rename NetworkUSBStorageDriver -> USBStorageDriver, add dep…

…recated NetworkUSBStorageDriver

Renaming the driver is done in order to have consistent driver names.

Users of the NetworkUSBStorageDriver are still able to use it. A
DeprecationWarning is shown. After the transition period the 0.4.0
release can remove the NetworkUSBStorageDriver finally.

Signed-off-by: Bastian Krause <bst@pengutronix.de>
  • Loading branch information
Bastian-Krause committed Feb 7, 2020
1 parent f38e6b9 commit 37b8f8b76046b1cfe3a100cbe16fe03a0b6d7e53
@@ -52,6 +52,10 @@ Breaking changes in 0.3.0
``resources.yaml`` are now also stored in the crossbar configuration folder.
Previously it would use ``..``.
- The ``HawkbitTestClient`` and ``USBStick`` classes have been removed
- The original USBStorageDriver was removed, ``NetworkUSBStorageDriver`` was
renamed to `USBStorageDriver`.
A deprecated `NetworkUSBStorageDriver` exists temporarily for compatibility
reasons.

Release 0.2.0 (released Jan 4, 2019)
------------------------------------
@@ -104,7 +108,7 @@ New and Updated Drivers
- The new `DigitalOutputResetDriver` adapts a driver implementing the
DigitalOutputProtocol to the ResetProtocol.
- The new `ModbusCoilDriver` support outputs on a ModbusTCP device.
- The new `NetworkUSBStorageDriver` allows writing to remote USB storage
- The new ``NetworkUSBStorageDriver`` allows writing to remote USB storage
devices (such as SD cards or memory sticks connected to a mux).
- The new `QEMUDriver` runs a system image in QEmu and implements the
:any:`ConsoleProtocol` and :any:`PowerProtocol`.
@@ -253,15 +253,15 @@ A USBMassStorage resource describes a USB memory stick or similar device.
- match (str): key and value for a udev match, see `udev Matching`_

Used by:
- `NetworkUSBStorageDriver`_
- `USBStorageDriver`_

NetworkUSBMassStorage
~~~~~~~~~~~~~~~~~~~~~
A NetworkUSBMassStorage resource describes a USB memory stick or similar
device available on a remote computer.

Used by:
- `NetworkUSBStorageDriver`_
- `USBStorageDriver`_

The NetworkUSBMassStorage can be used in test cases by calling the
`write_image()`, and `get_size()` functions.
@@ -1354,9 +1354,9 @@ Arguments:
- image (str): The key in :ref:`images <labgrid-device-config-images>` containing the path of an image to bootstrap onto the target
- usb_loader (srt): The key in :ref:`images <labgrid-device-config-images>` containing the path of an image to bootstrap onto the target

NetworkUSBStorageDriver
USBStorageDriver
~~~~~~~~~~~~~~~~~~~~~~~
A NetworkUSBStorageDriver allows access to a USB stick or similar local or
A USBStorageDriver allows access to a USB stick or similar local or
remote device.

Binds to:
@@ -1368,7 +1368,7 @@ Implements:

.. code-block:: yaml
NetworkUSBStorageDriver:
USBStorageDriver:
image: flashimage
.. code-block:: yaml
@@ -5,4 +5,4 @@ targets:
match:
'ID_PATH': 'pci-0000:06:00.0-usb-0:1.3.2:1.0-scsi-0:0:0:3'
drivers:
NetworkUSBStorageDriver: {}
USBStorageDriver: {}
@@ -3,5 +3,5 @@ def test_usb_storage(target):
assert r.path is not None

def test_usb_storage_size(target):
d = target.get_driver('NetworkUSBStorageDriver')
d = target.get_driver('USBStorageDriver')
assert d.get_size() > 0
@@ -20,7 +20,7 @@
from .qemudriver import QEMUDriver
from .modbusdriver import ModbusCoilDriver
from .sigrokdriver import SigrokDriver
from .usbstoragedriver import NetworkUSBStorageDriver, Mode
from .usbstoragedriver import USBStorageDriver, NetworkUSBStorageDriver, Mode
from .resetdriver import DigitalOutputResetDriver
from .gpiodriver import GpioDigitalOutputDriver
from .filedigitaloutput import FileDigitalOutputDriver
@@ -22,7 +22,7 @@ class Mode(enum.Enum):

@target_factory.reg_driver
@attr.s(eq=False)
class NetworkUSBStorageDriver(Driver):
class USBStorageDriver(Driver):
bindings = {
"storage": {
"USBMassStorage",
@@ -117,3 +117,13 @@ def get_size(self):
args = ["cat", "/sys/class/block/{}/size".format(self.storage.path[5:])]
size = processwrapper.check_output(self.storage.command_prefix + args)
return int(size)


@target_factory.reg_driver
@attr.s(eq=False)
class NetworkUSBStorageDriver(USBStorageDriver):
def __attrs_post_init__(self):
import warnings
warnings.warn("NetworkUSBStorageDriver is deprecated, use USBStorageDriver instead",
DeprecationWarning)
super().__attrs_post_init__()
@@ -1082,16 +1082,16 @@ def write_image(self):
target = self._get_target(place)
drv = None
from ..resource.remote import NetworkUSBMassStorage, NetworkUSBSDMuxDevice
from ..driver import NetworkUSBStorageDriver
from ..driver import USBStorageDriver
try:
drv = target.get_driver(NetworkUSBStorageDriver)
drv = target.get_driver(USBStorageDriver)
except NoDriverFoundError:
for resource in target.resources:
if isinstance(resource, (NetworkUSBSDMuxDevice, NetworkUSBMassStorage)):
try:
drv = target.get_driver(NetworkUSBStorageDriver)
drv = target.get_driver(USBStorageDriver)
except NoDriverFoundError:
drv = NetworkUSBStorageDriver(target, name=None)
drv = USBStorageDriver(target, name=None)
drv.storage.timeout = self.args.wait
break
if not drv:

0 comments on commit 37b8f8b

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