-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathramdisk.py
More file actions
130 lines (102 loc) · 3.82 KB
/
ramdisk.py
File metadata and controls
130 lines (102 loc) · 3.82 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
"""
Template for the ramdisk classes
@author: Roy Nielsen
"""
#--- Native python libraries
from tempfile import mkdtemp
#--- non-native python libraries in this source tree
from lib.loggers import LogPriority as lp
from lib.loggers import CyLogger
from lib.environment import Environment
from lib.CheckApplicable import CheckApplicable
from commonRamdiskTemplate import RamDiskTemplate, BadRamdiskArguments, NotValidForThisOS
###############################################################################
class RamDisk(object):
"""
"""
def __init__(self, size=0, mountpoint=False, logger=False, environ=False):
"""
"""
#####
# Version/timestamp is
# <YYYY><MM><DD>.<HH><MM><SS>.<microseconds>
# in UTC time
self.module_version = '20160224.032043.009191'
if not logger:
self.logger = CyLogger()
else:
self.logger = logger
if not environ:
self.environ = Environment()
else:
self.environ = environ
self.chkApp = CheckApplicable(self.environ, self.logger)
###########################################################################
def createRamdisk(self, *args, **kwargs):
"""
"""
#####
# Check applicability to the current OS
macApplicable = {'type': 'white',
'family': ['darwin'],
'os': {'Mac OS X': ['10.8', '+']}}
macApplicableHere = self.chkApp.isApplicable(macApplicable)
linuxApplicable = {'type': 'white',
'family': ['linux']}
linuxApplicableHere = self.chkApp.isApplicable(linuxApplicable)
if linuxApplicableHere:
from linuxTmpfsRamdisk import RamDisk
self.ramdisk = RamDisk(*args, **kwargs)
elif macApplicableHere:
from macRamdisk import RamDisk
self.ramdisk = RamDisk(*args, **kwargs)
else:
raise NotValidForThisOS("Ramdisk not available here...")
###########################################################################
def getRamdisk(self):
"""
"""
return self.ramdisk
###########################################################################
def unionOver(self, *args, **kwargs):
"""
"""
success = False
success = self.ramdisk.unionOver(*args, **kwargs)
return success
###########################################################################
def umount(self, *args, **kwargs):
"""
"""
success = False
success = self.ramdisk.umount(*args, **kwargs)
return success
###########################################################################
def getVersion(self):
"""
"""
return self.ramdisk.getVersion()
###########################################################################
def getDevice(self):
"""
Getter for the device name the ramdisk is using
Must be over-ridden to provide OS/Method specific functionality
@author: Roy Nielsen
"""
return self.ramdisk.getDevice()
###########################################################################
def getMountPoint(self):
"""
Getter for the mount point name the ramdisk is using
Must be over-ridden to provide OS/Method specific functionality
@author: Roy Nielsen
"""
return self.ramdisk.getMountPoint()
###########################################################################
def setDevice(self, device=None):
"""
Setter for the device so it can be ejected.
Must be over-ridden to provide OS/Method specific functionality
@author: Roy Nielsen
"""
self.ramdisk.setDevice(device)