Revision 1a3f1298
b/image_creator/main.py | ||
---|---|---|
66 | 66 |
help="Don't shrink any partition before extracting the image", |
67 | 67 |
action="store_false") |
68 | 68 |
|
69 |
parser.add_option("--no-cleanup", dest="cleanup", default=True, |
|
70 |
help="Don't cleanup sensitive data before extracting the image", |
|
71 |
action="store_false") |
|
72 |
|
|
73 |
parser.add_option("-u", "--upload", dest="upload", default=False, |
|
74 |
help="Upload image to a pithos repository using kamaki", |
|
75 |
action="store_true") |
|
76 |
|
|
77 |
parser.add_option("-r", "--register", dest="register", default=False, |
|
78 |
help="Register image to okeanos using kamaki", action="store_true") |
|
79 |
|
|
69 | 80 |
options, args = parser.parse_args(input_args) |
70 | 81 |
|
71 | 82 |
if len(args) != 2: |
... | ... | |
76 | 87 |
if not os.path.exists(options.source): |
77 | 88 |
parser.error('Input media is not accessible') |
78 | 89 |
|
90 |
if options.register: |
|
91 |
options.upload = True |
|
92 |
|
|
79 | 93 |
return options |
80 | 94 |
|
81 | 95 |
|
... | ... | |
88 | 102 |
% os.path.basename(sys.argv[0])) |
89 | 103 |
|
90 | 104 |
if not options.force: |
91 |
for ext in ('diskdump', 'meta'): |
|
92 |
filename = "%s/%s.%s" % (options.outdir, options.name, ext) |
|
105 |
for extension in ('diskdump', 'meta'):
|
|
106 |
filename = "%s/%s.%s" % (options.outdir, options.name, extension)
|
|
93 | 107 |
if os.path.exists(filename): |
94 | 108 |
raise FatalError("Output file %s exists " |
95 | 109 |
"(use --force to overwrite it)." % filename) |
... | ... | |
101 | 115 |
osclass = get_os_class(dev.distro, dev.ostype) |
102 | 116 |
image_os = osclass(dev.root, dev.g) |
103 | 117 |
metadata = image_os.get_metadata() |
104 |
image_os.data_cleanup() |
|
118 |
|
|
119 |
if options.cleanup: |
|
120 |
image_os.data_cleanup() |
|
121 |
|
|
105 | 122 |
dev.umount() |
123 |
|
|
106 | 124 |
size = options.shrink and dev.shrink() or dev.size() |
107 | 125 |
metadata['size'] = str(size // 2 ** 20) |
108 | 126 |
|
... | ... | |
117 | 135 |
finally: |
118 | 136 |
disk.cleanup() |
119 | 137 |
|
138 |
#The image is ready, lets call kamaki if necessary |
|
139 |
if options.upload: |
|
140 |
pass |
|
141 |
|
|
120 | 142 |
return 0 |
121 | 143 |
|
122 | 144 |
COLOR_BLACK = "\033[00m" |
Also available in: Unified diff