summaryrefslogtreecommitdiffstats
path: root/commands/storage/lmi
diff options
context:
space:
mode:
authorJan Safranek <jsafrane@redhat.com>2014-02-10 12:11:40 +0100
committerJan Safranek <jsafrane@redhat.com>2014-02-10 12:11:40 +0100
commit134494262b21741ecca2f9d73df8805d81bf8916 (patch)
tree212443fccd551320bb18fa2f021ff5258f53781e /commands/storage/lmi
parent0b3e343d3234cd5b21bb40e8ba82c405ea76432f (diff)
downloadopenlmi-scripts-134494262b21741ecca2f9d73df8805d81bf8916.tar.gz
openlmi-scripts-134494262b21741ecca2f9d73df8805d81bf8916.tar.xz
openlmi-scripts-134494262b21741ecca2f9d73df8805d81bf8916.zip
Added heuristics to translate device names to full device paths.
'mount create <device>' should follow the same rules as other storage commands - <device> can be DeviceID or various /dev/disk/by-id, /dev/disk/by-uuid paths.
Diffstat (limited to 'commands/storage/lmi')
-rw-r--r--commands/storage/lmi/scripts/storage/mount.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/commands/storage/lmi/scripts/storage/mount.py b/commands/storage/lmi/scripts/storage/mount.py
index 823809f..f0066b2 100644
--- a/commands/storage/lmi/scripts/storage/mount.py
+++ b/commands/storage/lmi/scripts/storage/mount.py
@@ -140,8 +140,8 @@ def mount_create(ns, device, mountpoint, fs_type=None, options=None, other_optio
"""
Create a mounted filesystem.
- :type device: string
- :param device: device path
+ :type device: string or LMIInstance/CIM_StorageExtent
+ :param device: Device to mount or a mount specifier (like '//server/share' for CIFS).
:type mountpoint: string
:param mountpoint: path where device should be mounted
:type fs_type: string
@@ -151,7 +151,17 @@ def mount_create(ns, device, mountpoint, fs_type=None, options=None, other_optio
:type other_options: string
:param other_options: comma-separated string of filesystem specific mount options
"""
- fs_setting = ns.LMI_FileSystemSetting.first_instance({'InstanceID':'LMI:LMI_FileSystemSetting:'+device})
+ # Try to convert device name to full device path
+ try:
+ device_inst = common.str2device(ns, device)
+ if device_inst:
+ device = device_inst.Name
+ except LmiFailed:
+ # we did not find CIM_StorageExtent for the device, it must be non
+ # device filesystem specification
+ pass
+
+ fs_setting = ns.LMI_FileSystemSetting.first_instance({'InstanceID':'LMI:LMI_FileSystemSetting:' + device})
if fs_setting is None:
raise LmiFailed('Wrong device: %s' % device)
filesystem = fs_setting.associators()[0]
@@ -185,6 +195,16 @@ def mount_delete(ns, target):
:type target: string
:param target: device path or mountpoint
"""
+ # Try to convert device name to full device path
+ try:
+ device_inst = common.str2device(ns, target)
+ if device_inst:
+ target = device_inst.Name
+ except LmiFailed:
+ # we did not find CIM_StorageExtent for the device, it must be non
+ # device filesystem specification
+ pass
+
mnt = ns.LMI_MountedFileSystem.first_instance({'FileSystemSpec':target}) or \
ns.LMI_MountedFileSystem.first_instance({'MountPointPath':target})
if mnt is None: