-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStorageConnection.py
More file actions
57 lines (37 loc) · 1.56 KB
/
Copy pathStorageConnection.py
File metadata and controls
57 lines (37 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/ bin/env python
# -*- coding: utf-8 -*-
import os, sys, time, threading
from subprocess import Popen, PIPE, STDOUT
class StorageConnection:
def __init__(self):
"""
This file used to manage connection to the Storage.
This file exists previously called DatafabricConnection.py to handle mounting and unmouting the datafabric
Now storage connections are reliably auto-mounted
"""
self.storageDir = "/mnt/imos-t3"
def connectStorage(self):
return self.isStorageMounted()
def unconnectStorage(self):
"""
Leave it up to automounter to disconnect
"""
return True
def isStorageMounted(self):
"""
# stat on the directory to trigger automount
# Then check the output of mount
"""
#subprocess.call('ls ' + self.storageDir)
#os.system('mount ' + self.storageDir) # call mount directly and wait
p = Popen("mount | grep " + self.storageDir , shell=True, bufsize=0, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
(stdout,stderr) = p.communicate()
if stdout.find(self.storageDir) != -1:
print "It seems the Automount is fine"
return True
else:
print "It seems the Automount isnt working. Contact the sys admin"
return False
if __name__ == "__main__":
d = StorageConnection()
d.connectStorage()