-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlinuxLoopRamdisk.py
More file actions
169 lines (123 loc) · 4.53 KB
/
linuxLoopRamdisk.py
File metadata and controls
169 lines (123 loc) · 4.53 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
"""
Template for creating a linux "loop" ramdisk. Dangerous as the "loop" disk
will continue to dynamically grow until it is out of memory (virtual included)
@author: Roy Nielsen
"""
#--- Native python libraries
import os
import re
import sys
import unittest
from tempfile import mkdtemp
#--- non-native python libraries in this source tree
from lib.run_commands import RunWith
from lib.loggers import CyLogger
from lib.loggers import LogPriority as lp
from commonRamdiskTemplate import RamDiskTemplate, NotValidForThisOS
###############################################################################
class RamDisk(RamDiskTemplate):
"""
"""
def __init__(self, size=0, mountpoint="", logger=False):
"""
"""
RamDiskTemplate.__init__(self, size, mountpoint, logger)
self.module_version = '20160224.032043.009191'
if not sys.platform.startswith("linux"):
raise NotValidForThisOS("This ramdisk is only viable for a Linux.")
raise NotValidForThisOS("Not yet implemented......")
print "#=====================================#"
print "# Not yet implemented... #"
print "#=====================================#"
###########################################################################
def __create(self) :
"""
Create a ramdisk device
Must be over-ridden to provide OS/method specific ramdisk creation
@author: Roy Nielsen
"""
success = False
return success
###########################################################################
def __mount(self) :
"""
Mount the disk
@author: Roy Nielsen
"""
success = False
return success
###########################################################################
def __remove_journal(self) :
"""
Having a journal in ramdisk makes very little sense. Remove the journal
after creating the ramdisk device
Must be over-ridden to provide OS/Method specific functionality
@author: Roy Nielsen
"""
success = False
return success
###########################################################################
def unmount(self) :
"""
Unmount the disk - same functionality as __eject on the mac
Must be over-ridden to provide OS/Method specific functionality
@author: Roy Nielsen
"""
success = False
return success
###########################################################################
def _format(self) :
"""
Format the ramdisk
Must be over-ridden to provide OS/Method specific functionality
@author: Roy Nielsen
"""
success = False
return success
###########################################################################
def __isMemoryAvailable(self) :
"""
Check to make sure there is plenty of memory of the size passed in
before creating the ramdisk
Must be over-ridden to provide OS/Method specific functionality
@author: Roy Nielsen
"""
#mem_free = psutil.phymem_usage()[2]
#print "Memory free = " + str(mem_free)
success = False
return success
###########################################################################
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.myRamdiskDev
###########################################################################
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
"""
success = False
return success
###########################################################################
def getVersion(self):
"""
Getter for the version of the ramdisk
Must be over-ridden to provide OS/Method specific functionality
@author: Roy Nielsen
"""
success = False
return success
###############################################################################
def unmount(device=" ", message_level="normal"):
"""
Eject the ramdisk
Must be over-ridden to provide OS/Method specific functionality
@author: Roy Nielsen
"""
success = False
return success