summaryrefslogtreecommitdiff
path: root/python/vyos/utils/disk.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-09-22 06:17:22 +0200
committerGitHub <noreply@github.com>2023-09-22 06:17:22 +0200
commit7253377e754ed8bc95cbe59840ed3a70c6945b93 (patch)
tree333128015588c810cee417b756c4468a6c4cb302 /python/vyos/utils/disk.py
parenta4aad112042b5bb4988468a5af871f5a81a851e5 (diff)
parent2d3f3297b575f88662495e14a7c7324ff73b6bfc (diff)
downloadveeos-1x-7253377e754ed8bc95cbe59840ed3a70c6945b93.tar.gz
veeos-1x-7253377e754ed8bc95cbe59840ed3a70c6945b93.zip
Merge pull request #2298 from jestabro/disk-by-id
smoketest: T5607: support getting SCSI device by drive-id
Diffstat (limited to 'python/vyos/utils/disk.py')
-rw-r--r--python/vyos/utils/disk.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/python/vyos/utils/disk.py b/python/vyos/utils/disk.py
new file mode 100644
index 000000000..ee540b107
--- /dev/null
+++ b/python/vyos/utils/disk.py
@@ -0,0 +1,23 @@
+# Copyright 2023 VyOS maintainers and contributors <maintainers@vyos.io>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+from pathlib import Path
+
+def device_from_id(id):
+ """ Return the device name from (partial) disk id """
+ path = Path('/dev/disk/by-id')
+ for device in path.iterdir():
+ if device.name.endswith(id):
+ return device.readlink().stem