Add options for printing sysprep and data cleanup
[snf-image-creator] / image_creator / main.py
index ab69b2d..336d795 100755 (executable)
@@ -78,6 +78,14 @@ def parse_options(input_args):
         default=None, action="callback", callback=check_writable_dir,
         help="dump image to FILE", metavar="FILE")
 
+    parser.add_option("--print-sysprep", dest="print_sysprep", default=False,
+        help="Print the enabled and disable sysprep actions for this image",
+        action="store_true")
+
+    parser.add_option("--print-data-cleanup", dest="print_data_cleanup",
+        default=False, help="Print the enabled and disable data cleanup "
+        "operations actions for this source", action="store_true")
+
     parser.add_option("-s", "--silent", dest="silent", default=False,
         help="silent mode, only output error", action="store_true")
 
@@ -98,9 +106,6 @@ def parse_options(input_args):
     if options.register:
         options.upload = True
 
-    if options.outfile is None and not options.upload:
-        parser.error('either outfile (-o) or upload (-u) must be set.')
-
     return options
 
 
@@ -110,6 +115,11 @@ def image_creator():
     if options.silent:
         util.silent = True
 
+    if options.outfile is None and not options.upload \
+        and not options.print_sysprep and not options.print_data_cleanup:
+        FatalError("At least one of the following: `-o', `-u', "
+        "`--print-sysprep' `--print-data-cleanup' must be set")
+
     output('snf-image-creator %s\n' % version)
 
     if os.geteuid() != 0:
@@ -134,6 +144,17 @@ def image_creator():
 
         output()
 
+        if options.print_sysprep:
+            image_os.print_sysprep()
+            output()
+
+        if options.print_data_cleanup:
+            image_os.print_data_cleanup()
+            output()
+
+        if options.outfile is None and not options.upload:
+            return 0
+
         if options.sysprep:
             image_os.sysprep()