54 |
54 |
self.root = rootdev
|
55 |
55 |
self.g = ghandler
|
56 |
56 |
|
|
57 |
self.sysprep_regexp = re.compile('^sysprep_')
|
|
58 |
self.data_cleanup_regexp = re.compile('^data_cleanup_')
|
|
59 |
|
|
60 |
def _print_task(self, task):
|
|
61 |
name = task.__name__
|
|
62 |
|
|
63 |
if self.sysprep_regexp.match(name):
|
|
64 |
name = self.sysprep_regexp.sub("", name)
|
|
65 |
elif self.data_cleanup_regexp.match(name):
|
|
66 |
name = self.data_cleanup_regexp.sub("", name)
|
|
67 |
else:
|
|
68 |
raise FatalError("%s is not a task" % name)
|
|
69 |
|
|
70 |
name = name.replace('_', '-')
|
|
71 |
|
|
72 |
output(" %s:\n %s" % (name, task.__doc__))
|
|
73 |
|
57 |
74 |
@add_prefix
|
58 |
75 |
def ls(self, directory):
|
59 |
76 |
"""List the name of all files under a directory"""
|
... | ... | |
116 |
133 |
|
117 |
134 |
return meta
|
118 |
135 |
|
|
136 |
def list_sysprep(self):
|
|
137 |
"""List all sysprep actions"""
|
|
138 |
|
|
139 |
is_sysprep = lambda x: x.startswith('sysprep_') and \
|
|
140 |
callable(getattr(self, x))
|
|
141 |
tasks = [getattr(self, x) for x in dir(self) if is_sysprep(x)]
|
|
142 |
|
|
143 |
included = [t for t in tasks if not getattr(t, "excluded", False)]
|
|
144 |
excluded = [t for t in tasks if getattr(t, "excluded", False)]
|
|
145 |
|
|
146 |
return included, excluded
|
|
147 |
|
|
148 |
def list_data_cleanup(self):
|
|
149 |
"""List all data_cleanup actions"""
|
|
150 |
|
|
151 |
is_cleanup = lambda x: x.startswith('data_cleanup_') and \
|
|
152 |
callable(getattr(self, x))
|
|
153 |
tasks = [getattr(self, x) for x in dir(self) if is_cleanup(x)]
|
|
154 |
|
|
155 |
included = [t for t in tasks if not getattr(t, "excluded", False)]
|
|
156 |
excluded = [t for t in tasks if getattr(t, "excluded", False)]
|
|
157 |
|
|
158 |
return included, excluded
|
|
159 |
|
119 |
160 |
def data_cleanup(self):
|
120 |
161 |
"""Cleanup sensitive data out of the OS image."""
|
121 |
162 |
|
... | ... | |
144 |
185 |
task()
|
145 |
186 |
output()
|
146 |
187 |
|
147 |
|
def list_sysprep(self):
|
148 |
|
"""List all sysprep actions"""
|
149 |
|
|
150 |
|
is_sysprep = lambda x: x.startswith('sysprep_') and \
|
151 |
|
callable(getattr(self, x))
|
152 |
|
tasks = [getattr(self, x) for x in dir(self) if is_sysprep(x)]
|
153 |
|
|
154 |
|
included = [t for t in tasks if not getattr(t, "excluded", False)]
|
155 |
|
excluded = [t for t in tasks if getattr(t, "excluded", False)]
|
156 |
|
|
157 |
|
return included, excluded
|
158 |
|
|
159 |
|
def list_data_cleanup(self):
|
160 |
|
"""List all data_cleanup actions"""
|
161 |
|
|
162 |
|
is_cleanup = lambda x: x.startswith('data_cleanup_') and \
|
163 |
|
callable(getattr(self, x))
|
164 |
|
tasks = [getattr(self, x) for x in dir(self) if is_cleanup(x)]
|
165 |
|
|
166 |
|
included = [t for t in tasks if not getattr(t, "excluded", False)]
|
167 |
|
excluded = [t for t in tasks if getattr(t, "excluded", False)]
|
168 |
|
|
169 |
|
return included, excluded
|
|
188 |
def print_task(self, task):
|
|
189 |
name = task.__name__
|
|
190 |
|
|
191 |
if self.sysprep_regexp.match(name):
|
|
192 |
name = self.sysprep_regexp.sub("", name)
|
|
193 |
elif self.data_cleanup_regexp.match(name):
|
|
194 |
name = self.data_cleanup_regexp.sub("", name)
|
|
195 |
else:
|
|
196 |
raise FatalError("%s is not a task" % name)
|
|
197 |
|
|
198 |
name = name.replace('_', '-')
|
|
199 |
|
|
200 |
output(" %s:\n %s" % (name, task.__doc__))
|
|
201 |
|
|
202 |
def print_data_cleanup(self):
|
|
203 |
included, excluded = self.list_data_cleanup()
|
|
204 |
|
|
205 |
output("Included data cleanup operations:")
|
|
206 |
if len(included) == 0:
|
|
207 |
ouput("(none)")
|
|
208 |
else:
|
|
209 |
for task in included:
|
|
210 |
self._print_task(task)
|
|
211 |
output("Ommited data cleanup operations:")
|
|
212 |
if len(excluded) == 0:
|
|
213 |
ouput("(none)")
|
|
214 |
else:
|
|
215 |
for task in excluded:
|
|
216 |
self._print_task(task)
|
|
217 |
|
|
218 |
def print_sysprep(self):
|
|
219 |
included, excluded = self.list_sysprep()
|
|
220 |
|
|
221 |
output("Included sysprep operations:")
|
|
222 |
if len(included) == 0:
|
|
223 |
ouput("(none)")
|
|
224 |
else:
|
|
225 |
for task in included:
|
|
226 |
self._print_task(task)
|
|
227 |
output("Ommited sysprep operations:")
|
|
228 |
if len(excluded) == 0:
|
|
229 |
output("(none)")
|
|
230 |
else:
|
|
231 |
for task in excluded:
|
|
232 |
self._print_task(task)
|
170 |
233 |
|
171 |
234 |
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
|