[node-patches] Change in ovirt-node[master]: Extend utils.system.Mount to support new mounts instead of r...
rbarry at redhat.com
rbarry at redhat.com
Tue Jun 10 14:18:25 UTC 2014
Ryan Barry has uploaded a new change for review.
Change subject: Extend utils.system.Mount to support new mounts instead of remount
......................................................................
Extend utils.system.Mount to support new mounts instead of remount
Add support for new mountpoints instead of simply remounting an
extant mount as rw or ro to provide a convenience wrapper around
repeated calls to utils.process.check_call(["mount"....)
Change-Id: I14c0e863bc1467ca7e1af1d18d788446353a6064
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M src/ovirt/node/utils/system.py
1 file changed, 23 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/65/28565/1
diff --git a/src/ovirt/node/utils/system.py b/src/ovirt/node/utils/system.py
index 3fbb448..2c93ea5 100644
--- a/src/ovirt/node/utils/system.py
+++ b/src/ovirt/node/utils/system.py
@@ -694,13 +694,16 @@
that filesystem for access
"""
- def __init__(self, path):
- if os.path.ismount(path):
- self.path = path
- else:
- raise RuntimeError("Must be called with a mount point")
+ def __init__(self, path, device=None, fstype=None):
+ self.path = path
+ self.fstype = fstype
+ self.device = device
def remount(self, rw=False):
+ if not os.path.ismount(self.path):
+ self.logger.exception("%s is not a mount point" % self.path)
+ raise RuntimeError("%s is not a mount point" % self.path)
+
# EL6 won't let you remount if it's not in mtab or fstab
# So we'll parse /proc/mounts ourselves to find it
device = self._find_device()
@@ -715,6 +718,21 @@
self.logger.exception("Can't remount %s on %s!" % (device,
self.path))
+ def mount(self):
+ if not self.device:
+ self.logger.exception("Can't mount without a device specified")
+ raise RuntimeError("No device was specified when Mount() "
+ "was initialized")
+
+ fstype = self.fstype if self.fstype else "auto"
+
+ try:
+ utils.process.check_call(["mount", "-t", fstype,
+ self.device, self.path])
+ except:
+ self.logger.exception("Can't mount %s on %s" % (self.device,
+ self.path))
+
def _find_device(self):
try:
return process.check_output(["findmnt", "-o", "SOURCE", "-n",
--
To view, visit http://gerrit.ovirt.org/28565
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I14c0e863bc1467ca7e1af1d18d788446353a6064
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>
More information about the node-patches
mailing list