ignore already mounted devices and add options to mount cmd
This commit is contained in:
parent
0ba9d64dae
commit
aa1ea0e8de
|
@ -12,17 +12,25 @@ def SlaveLogger(name, level, queue):
|
||||||
return logger
|
return logger
|
||||||
|
|
||||||
class GlusterFS():
|
class GlusterFS():
|
||||||
def __init__(self, server, volume, mountpoint):
|
def __init__(self, server, volume, mountpoint, options=None):
|
||||||
self.server = server
|
|
||||||
self.volume = volume
|
|
||||||
|
|
||||||
if not os.path.exists(mountpoint):
|
if not os.path.exists(mountpoint):
|
||||||
raise FileNotFoundError
|
raise FileNotFoundError
|
||||||
|
|
||||||
self.mountpoint = mountpoint
|
self.mountpoint = mountpoint
|
||||||
|
self.server = server
|
||||||
|
self.volume = volume
|
||||||
|
self.options = options
|
||||||
|
|
||||||
def mount(self):
|
def mount(self):
|
||||||
self._run(['mount', '-t', 'glusterfs', self.server + ':/' + self.volume, self.mountpoint])
|
if os.path.ismount(self.mountpoint):
|
||||||
|
# NOTE: this assumes that the already-mounted device is the one intended
|
||||||
|
fallbackLogger(__name__, 'WARNING', 'Device already mounted at {}'.format(self.mountpoint))
|
||||||
|
else:
|
||||||
|
dst = self.server + ':/' + self.volume
|
||||||
|
cmd = ['mount', '-t', 'glusterfs', dst, self.mountpoint]
|
||||||
|
if self.options:
|
||||||
|
cmd[1:1] = ['-o', self.options]
|
||||||
|
self._run(cmd)
|
||||||
|
|
||||||
def unmount(self):
|
def unmount(self):
|
||||||
self._run(['umount', self.mountpoint])
|
self._run(['umount', self.mountpoint])
|
||||||
|
@ -41,7 +49,7 @@ class MasterLogger():
|
||||||
def __init__(self, name, level, queue):
|
def __init__(self, name, level, queue):
|
||||||
mountpoint = '/mnt/glusterfs/pyledriver'
|
mountpoint = '/mnt/glusterfs/pyledriver'
|
||||||
|
|
||||||
self.fs = GlusterFS('192.168.11.39', 'pyledriver', mountpoint)
|
self.fs = GlusterFS('192.168.11.39', 'pyledriver', mountpoint, 'backupvolfile-server=192.168.11.48')
|
||||||
self.fs.mount()
|
self.fs.mount()
|
||||||
|
|
||||||
consoleFormat = logging.Formatter('[%(name)s] [%(levelname)s] %(message)s')
|
consoleFormat = logging.Formatter('[%(name)s] [%(levelname)s] %(message)s')
|
||||||
|
|
Loading…
Reference in New Issue