Revision f165adc0 image_creator/main.py
b/image_creator/main.py | ||
---|---|---|
35 | 35 |
|
36 | 36 |
from image_creator import get_os_class |
37 | 37 |
from image_creator import __version__ as version |
38 |
from image_creator import FatalError |
|
39 | 38 |
from image_creator.disk import Disk |
40 |
from image_creator.util import get_command, error, success, output |
|
39 |
from image_creator.util import get_command, error, success, output, FatalError
|
|
41 | 40 |
from image_creator import util |
42 | 41 |
import sys |
43 | 42 |
import os |
... | ... | |
65 | 64 |
parser.add_option("-f", "--force", dest="force", default=False, |
66 | 65 |
action="store_true", help="overwrite output files if they exist") |
67 | 66 |
|
68 |
parser.add_option("--no-cleanup", dest="cleanup", default=True, |
|
69 |
help="don't cleanup sensitive data", action="store_false") |
|
70 |
|
|
71 | 67 |
parser.add_option("--no-sysprep", dest="sysprep", default=True, |
72 | 68 |
help="don't perform system preperation", action="store_false") |
73 | 69 |
|
... | ... | |
78 | 74 |
default=None, action="callback", callback=check_writable_dir, |
79 | 75 |
help="dump image to FILE", metavar="FILE") |
80 | 76 |
|
81 |
parser.add_option("--print-sysprep", dest="print_sysprep", default=False,
|
|
82 |
help="Print the enabled and disable sysprep actions for this image",
|
|
83 |
action="store_true")
|
|
77 |
parser.add_option("--enable-sysprep", dest="enabled_syspreps", default=[],
|
|
78 |
help="Run SYSPREP operation on the input media",
|
|
79 |
action="append", metavar="SYSPREP")
|
|
84 | 80 |
|
85 |
parser.add_option("--print-data-cleanup", dest="print_data_cleanup", |
|
86 |
default=False, help="Print the enabled and disable data cleanup " |
|
87 |
"operations actions for this source", action="store_true") |
|
81 |
parser.add_option("--disable-sysprep", dest="disabled_syspreps", |
|
82 |
help="Prevent SYSPREP operation from running on the input media", |
|
83 |
default=[], action="append", metavar="SYSPREP") |
|
84 |
|
|
85 |
parser.add_option("--print-sysprep", dest="print_sysprep", default=False, |
|
86 |
help="Print the enabled and disabled sysprep operations for this " |
|
87 |
"input media", action="store_true") |
|
88 | 88 |
|
89 | 89 |
parser.add_option("-s", "--silent", dest="silent", default=False, |
90 |
help="silent mode, only output error", action="store_true") |
|
90 |
help="silent mode, only output errors", action="store_true")
|
|
91 | 91 |
|
92 | 92 |
parser.add_option("-u", "--upload", dest="upload", default=False, |
93 | 93 |
help="upload the image to pithos", action="store_true") |
... | ... | |
116 | 116 |
util.silent = True |
117 | 117 |
|
118 | 118 |
if options.outfile is None and not options.upload \ |
119 |
and not options.print_sysprep and not options.print_data_cleanup:
|
|
120 |
FatalError("At least one of the following: `-o', `-u', "
|
|
121 |
"`--print-sysprep' `--print-data-cleanup' must be set")
|
|
119 |
and not options.print_sysprep:
|
|
120 |
raise FatalError("At least one of `-o', `-u' or" \
|
|
121 |
"`--print-sysprep' must be set")
|
|
122 | 122 |
|
123 | 123 |
output('snf-image-creator %s\n' % version) |
124 | 124 |
|
... | ... | |
144 | 144 |
|
145 | 145 |
output() |
146 | 146 |
|
147 |
if options.print_sysprep: |
|
148 |
image_os.print_sysprep() |
|
149 |
output() |
|
147 |
for sysprep in options.disabled_syspreps: |
|
148 |
image_os.disable_sysprep(sysprep) |
|
149 |
|
|
150 |
for sysprep in options.enabled_syspreps: |
|
151 |
image_os.enable_sysprep(sysprep) |
|
150 | 152 |
|
151 |
if options.print_data_cleanup:
|
|
152 |
image_os.print_data_cleanup()
|
|
153 |
if options.print_sysprep:
|
|
154 |
image_os.print_syspreps()
|
|
153 | 155 |
output() |
154 | 156 |
|
155 | 157 |
if options.outfile is None and not options.upload: |
156 | 158 |
return 0 |
157 | 159 |
|
158 | 160 |
if options.sysprep: |
159 |
image_os.sysprep() |
|
160 |
|
|
161 |
if options.cleanup: |
|
162 |
image_os.data_cleanup() |
|
161 |
image_os.do_sysprep() |
|
163 | 162 |
|
164 | 163 |
dev.umount() |
165 | 164 |
|
Also available in: Unified diff