Revision 0144d7c7 image_creator/os_type/__init__.py
b/image_creator/os_type/__init__.py | ||
---|---|---|
42 | 42 |
return map(lambda x: prefix + x, target(self, *args)) |
43 | 43 |
return wrapper |
44 | 44 |
|
45 |
def exclude_task(func): |
|
46 |
func.excluded = True |
|
47 |
return func |
|
45 | 48 |
|
46 | 49 |
class OSBase(object): |
47 | 50 |
"""Basic operating system class""" |
... | ... | |
116 | 119 |
|
117 | 120 |
output('Cleaning up sensitive data out of the OS image:') |
118 | 121 |
|
119 |
is_cleanup = lambda x: x.startswith('data_cleanup_') and \ |
|
120 |
callable(getattr(self, x)) |
|
121 |
tasks = [getattr(self, x) for x in dir(self) if is_cleanup(x)] |
|
122 |
tasks, _ = self.list_data_cleanup() |
|
122 | 123 |
size = len(tasks) |
123 | 124 |
cnt = 0 |
124 | 125 |
for task in tasks: |
... | ... | |
132 | 133 |
|
133 | 134 |
output('Preparing system for image creation:') |
134 | 135 |
|
135 |
is_sysprep = lambda x: x.startswith('sysprep_') and \ |
|
136 |
callable(getattr(self, x)) |
|
137 |
tasks = [getattr(self, x) for x in dir(self) if is_sysprep(x)] |
|
136 |
tasks, _ = self.list_sysprep() |
|
138 | 137 |
size = len(tasks) |
139 | 138 |
cnt = 0 |
140 | 139 |
for task in tasks: |
... | ... | |
143 | 142 |
task() |
144 | 143 |
output() |
145 | 144 |
|
145 |
def list_sysprep(self): |
|
146 |
"""List all sysprep actions""" |
|
147 |
|
|
148 |
is_sysprep = lambda x: x.startswith('sysprep_') and \ |
|
149 |
callable(getattr(self, x)) |
|
150 |
tasks = [getattr(self, x) for x in dir(self) if is_sysprep(x)] |
|
151 |
|
|
152 |
included = [t for t in tasks if not getattr(t, "excluded", False)] |
|
153 |
excluded = [t for t in tasks if getattr(t, "excluded", False)] |
|
154 |
|
|
155 |
return included, excluded |
|
156 |
|
|
157 |
def list_data_cleanup(self): |
|
158 |
"""List all data_cleanup actions""" |
|
159 |
|
|
160 |
is_cleanup = lambda x: x.startswith('data_cleanup_') and \ |
|
161 |
callable(getattr(self, x)) |
|
162 |
tasks = [getattr(self, x) for x in dir(self) if is_cleanup(x)] |
|
163 |
|
|
164 |
included = [t for t in tasks if not getattr(t, "excluded", False)] |
|
165 |
excluded = [t for t in tasks if getattr(t, "excluded", False)] |
|
166 |
|
|
167 |
return included, excluded |
|
168 |
|
|
146 | 169 |
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai : |
Also available in: Unified diff