Revision 71b0ab28 image_creator/main.py

b/image_creator/main.py
221 221

  
222 222
        image = disk.get_image(snapshot)
223 223

  
224
        # If no customization is to be done, the image should be mounted ro
225
        ro = (not (options.sysprep or options.shrink) or options.print_sysprep)
226
        image.mount(ro)
227
        try:
228
            for sysprep in options.disabled_syspreps:
229
                image.os.disable_sysprep(image.os.get_sysprep_by_name(sysprep))
224
        for sysprep in options.disabled_syspreps:
225
            image.os.disable_sysprep(image.os.get_sysprep_by_name(sysprep))
230 226

  
231
            for sysprep in options.enabled_syspreps:
232
                image.os.enable_sysprep(image.os.get_sysprep_by_name(sysprep))
227
        for sysprep in options.enabled_syspreps:
228
            image.os.enable_sysprep(image.os.get_sysprep_by_name(sysprep))
233 229

  
234
            if options.print_sysprep:
235
                image.os.print_syspreps()
236
                out.output()
230
        if options.print_sysprep:
231
            image.os.print_syspreps()
232
            out.output()
233

  
234
        if options.outfile is None and not options.upload:
235
            return 0
236

  
237
        if options.sysprep:
238
            image.os.do_sysprep()
237 239

  
238
            if options.outfile is None and not options.upload:
239
                return 0
240

  
241
            if options.sysprep:
242
                err_msg = "Unable to perform the system preparation tasks. " \
243
                    "Couldn't mount the media%s. Use --no-sysprep if you " \
244
                    "don't won't to perform any system preparation task."
245
                if not image.mounted:
246
                    raise FatalError(err_msg % "")
247
                elif image.mounted_ro:
248
                    raise FatalError(err_msg % " read-write")
249
                image.os.do_sysprep()
250

  
251
            metadata = image.os.meta
252
        finally:
253
            image.umount()
240
        metadata = image.os.meta
254 241

  
255 242
        size = options.shrink and image.shrink() or image.size
256 243
        metadata.update(image.meta)

Also available in: Unified diff