sp-rand: reformat with 100 characters per line.
Change-Id: Id1e691fdd9af7f5ece3fda5912094ee23531be55
diff --git a/tools/sp-rand/pyproject.toml b/tools/sp-rand/pyproject.toml
index 9787c3b..e831a49 100644
--- a/tools/sp-rand/pyproject.toml
+++ b/tools/sp-rand/pyproject.toml
@@ -1,3 +1,6 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
+
+[tool.black]
+line-length = 100
diff --git a/tools/sp-rand/setup.cfg b/tools/sp-rand/setup.cfg
index 1273ae8..f62eec1 100644
--- a/tools/sp-rand/setup.cfg
+++ b/tools/sp-rand/setup.cfg
@@ -26,7 +26,7 @@
sp_rand_init = sp_rand.init:main
[flake8]
-max_line_length = 88
+max_line_length = 100
[mypy]
python_version = 3.8
diff --git a/tools/sp-rand/src/sp_rand/cleanup.py b/tools/sp-rand/src/sp_rand/cleanup.py
index 767762b..384f6ab 100644
--- a/tools/sp-rand/src/sp_rand/cleanup.py
+++ b/tools/sp-rand/src/sp_rand/cleanup.py
@@ -52,9 +52,7 @@
print("Looking for target records for our volumes")
targets = {
- tgt.name: tgt.volume
- for tgt in iscsi.targets.values()
- if tgt.volume.startswith(prefix)
+ tgt.name: tgt.volume for tgt in iscsi.targets.values() if tgt.volume.startswith(prefix)
}
if targets:
@@ -116,16 +114,12 @@
if desc.snapshot:
print(f"Will detach snapshot {desc.volume} from client {desc.client}")
to_detach.append(
- sptypes.SnapshotReassignDesc(
- detach=[desc.client], force=True, snapshot=desc.volume
- )
+ sptypes.SnapshotReassignDesc(detach=[desc.client], force=True, snapshot=desc.volume)
)
else:
print(f"Will detach volume {desc.volume} from client {desc.client}")
to_detach.append(
- sptypes.VolumeReassignDesc(
- detach=[desc.client], force=True, volume=desc.volume
- )
+ sptypes.VolumeReassignDesc(detach=[desc.client], force=True, volume=desc.volume)
)
if to_detach:
@@ -192,10 +186,7 @@
parser.add_argument(
"--skip-api",
type=str,
- help=(
- "If explicitly given the 'yes' value, do not "
- "delete any volumes or snapshots"
- ),
+ help=("If explicitly given the 'yes' value, do not " "delete any volumes or snapshots"),
)
args = parser.parse_args()
diff --git a/tools/sp-rand/src/sp_rand/init.py b/tools/sp-rand/src/sp_rand/init.py
index 60baa88..0f0f0ce 100644
--- a/tools/sp-rand/src/sp_rand/init.py
+++ b/tools/sp-rand/src/sp_rand/init.py
@@ -84,9 +84,7 @@
args = parser.parse_args()
- return Config(
- confdir=args.confdir, noop=args.noop, prefix_var=args.prefix_var, tag=args.tag
- )
+ return Config(confdir=args.confdir, noop=args.noop, prefix_var=args.prefix_var, tag=args.tag)
def main() -> None:
diff --git a/tools/sp-rand/unit_tests/test_cleanup.py b/tools/sp-rand/unit_tests/test_cleanup.py
index c3efb2d..101cd62 100644
--- a/tools/sp-rand/unit_tests/test_cleanup.py
+++ b/tools/sp-rand/unit_tests/test_cleanup.py
@@ -160,9 +160,7 @@
)
self.exported = {key: list(value) for key, value in exported.items()}
self.targets = dict(targets)
- self.vols = VolSnapData(
- volumes=list(vols.volumes), snapshots=list(vols.snapshots)
- )
+ self.vols = VolSnapData(volumes=list(vols.volumes), snapshots=list(vols.snapshots))
self.invoked = collections.defaultdict(lambda: 0)
# pylint: disable=invalid-name
@@ -171,14 +169,10 @@
"""Return the current view of what is attached."""
self.invoked["attachmentsList"] += 1
return [
- sptypes.AttachmentDesc(
- volume=name, snapshot=False, client=11, rights="rw", pos=0
- )
+ sptypes.AttachmentDesc(volume=name, snapshot=False, client=11, rights="rw", pos=0)
for name in self.attached.volumes
] + [
- sptypes.AttachmentDesc(
- volume=name, snapshot=True, client=11, rights="ro", pos=0
- )
+ sptypes.AttachmentDesc(volume=name, snapshot=True, client=11, rights="ro", pos=0)
for name in self.attached.snapshots
]
@@ -227,16 +221,12 @@
tgtdel = cmd.deleteTarget
if expdel is not None:
initiator = self.exported[expdel.initiator]
- data = ExportsData(
- portal_group=expdel.portalGroup, volume_name=expdel.volumeName
- )
+ data = ExportsData(portal_group=expdel.portalGroup, volume_name=expdel.volumeName)
assert data in initiator
initiator.remove(data)
elif tgtdel is not None:
found = [
- tid
- for tid, tgt in self.targets.items()
- if tgt.volume == tgtdel.volumeName
+ tid for tid, tgt in self.targets.items() if tgt.volume == tgtdel.volumeName
]
assert len(found) == 1
del self.targets[found[0]]
@@ -284,36 +274,24 @@
def test_remove_volumes() -> None:
"""Make sure the StorPool volumes and snapshots will be removed."""
cfg = r_cleanup.Config.default()
- mock_api = MockApi(
- attached=T_ATTACHED, exported=T_EXPORTED, targets=T_TARGETS, vols=T_VOLS
- )
+ mock_api = MockApi(attached=T_ATTACHED, exported=T_EXPORTED, targets=T_TARGETS, vols=T_VOLS)
r_cleanup.remove_volumes(cfg, mock_api, "testvol-")
assert mock_api.attached == VolSnapData(
- volumes=[
- name for name in T_ATTACHED.volumes if not name.startswith("testvol-")
- ],
- snapshots=[
- name for name in T_ATTACHED.snapshots if not name.startswith("testvol-")
- ],
+ volumes=[name for name in T_ATTACHED.volumes if not name.startswith("testvol-")],
+ snapshots=[name for name in T_ATTACHED.snapshots if not name.startswith("testvol-")],
)
assert mock_api.exported == {
- initiator: [
- item for item in exports if not item.volume_name.startswith("testvol-")
- ]
+ initiator: [item for item in exports if not item.volume_name.startswith("testvol-")]
for initiator, exports in T_EXPORTED.items()
}
assert mock_api.targets == {
- tid: tgt
- for tid, tgt in T_TARGETS.items()
- if not tgt.volume.startswith("testvol-")
+ tid: tgt for tid, tgt in T_TARGETS.items() if not tgt.volume.startswith("testvol-")
}
assert mock_api.vols == VolSnapData(
volumes=[name for name in T_VOLS.volumes if not name.startswith("testvol-")],
- snapshots=[
- name for name in T_VOLS.snapshots if not name.startswith("testvol-")
- ],
+ snapshots=[name for name in T_VOLS.snapshots if not name.startswith("testvol-")],
)
assert mock_api.invoked == {
@@ -323,21 +301,15 @@
"volumesReassignWait": 1,
"volumesList": 1,
"snapshotsList": 1,
- "volumeDelete": len(
- [name for name in T_VOLS[False] if name.startswith("testvol-")]
- ),
- "snapshotDelete": len(
- [name for name in T_VOLS[True] if name.startswith("testvol-")]
- ),
+ "volumeDelete": len([name for name in T_VOLS[False] if name.startswith("testvol-")]),
+ "snapshotDelete": len([name for name in T_VOLS[True] if name.startswith("testvol-")]),
}
def test_remove_volumes_noop() -> None:
"""Make sure the StorPool volumes and snapshots will be removed."""
cfg = r_cleanup.Config.default()._replace(noop=True)
- mock_api = MockApi(
- attached=T_ATTACHED, exported=T_EXPORTED, targets=T_TARGETS, vols=T_VOLS
- )
+ mock_api = MockApi(attached=T_ATTACHED, exported=T_EXPORTED, targets=T_TARGETS, vols=T_VOLS)
r_cleanup.remove_volumes(cfg, mock_api, "testvol-")