Fix pep8 errors
[snf-image-creator] / image_creator / main.py
index fa2e23d..fde3b7d 100644 (file)
@@ -185,17 +185,20 @@ def image_creator():
         snapshot = disk.snapshot()
 
         dev = disk.get_device(snapshot)
-        dev.mount()
+
+        # If no customization is to be applied, the image should be mounted ro
+        readonly = not (options.sysprep or options.shrink)
+        dev.mount(readonly)
 
         cls = os_cls(dev.distro, dev.ostype)
         image_os = cls(dev.root, dev.g, out)
         out.output()
 
         for sysprep in options.disabled_syspreps:
-            image_os.disable_sysprep(sysprep)
+            image_os.disable_sysprep(image_os.get_sysprep_by_name(sysprep))
 
         for sysprep in options.enabled_syspreps:
-            image_os.enable_sysprep(sysprep)
+            image_os.enable_sysprep(image_os.get_sysprep_by_name(sysprep))
 
         if options.print_sysprep:
             image_os.print_syspreps()
@@ -246,7 +249,7 @@ def image_creator():
             if options.upload:
                 out.output("Uploading image to pithos:")
                 kamaki = Kamaki(options.account, options.token, out)
-                with open(snapshot) as f:
+                with open(snapshot, 'rb') as f:
                     uploaded_obj = kamaki.upload(f, size, options.upload,
                                             "(1/4)  Calculating block hashes",
                                             "(2/4)  Uploading missing blocks")