예제 #1
0
 def test_mkIsoFs(self, label):
     """
     Tests mkimage.mkIsoFs creating an image and checking its content
     """
     checkSudo(["mount", "-o", "loop", "somefile", "target"])
     checkSudo(["umount", "target"])
     iso_img = mkimage.mkIsoFs("vmId_iso", self.files, label)
     self.assertTrue(os.path.exists(iso_img))
     m = storage.mount.Mount(iso_img, self.workdir)
     m.mount(mntOpts='loop')
     try:
         self._check_content()
         self._check_label(iso_img, label)
         self._check_permissions(iso_img, ((stat.S_IRUSR, True),
                                           (stat.S_IWUSR, True),
                                           (stat.S_IXUSR, False)))
         self._check_permissions(iso_img, ((stat.S_IRGRP, True),
                                           (stat.S_IWGRP, False),
                                           (stat.S_IXGRP, False)))
         self._check_permissions(iso_img, ((stat.S_IROTH, False),
                                           (stat.S_IWOTH, False),
                                           (stat.S_IXOTH, False)))
     finally:
         m.umount(force=True)
         os.unlink(iso_img)
예제 #2
0
 def test_mkIsoFs(self, label):
     """
     Tests mkimage.mkIsoFs creating an image and checking its content
     """
     checkSudo(["mount", "-o", "loop", "somefile", "target"])
     checkSudo(["umount", "target"])
     iso_img = mkimage.mkIsoFs("vmId_iso", self.files, label)
     self.assertTrue(os.path.exists(iso_img))
     m = storage.mount.Mount(iso_img, self.workdir)
     m.mount(mntOpts='loop')
     try:
         self._check_content()
         self._check_label(iso_img, label)
         self._check_permissions(iso_img,
                                 ((stat.S_IRUSR, True),
                                  (stat.S_IWUSR, True),
                                  (stat.S_IXUSR, False)))
         self._check_permissions(iso_img,
                                 ((stat.S_IRGRP, True),
                                  (stat.S_IWGRP, False),
                                  (stat.S_IXGRP, False)))
         self._check_permissions(iso_img,
                                 ((stat.S_IROTH, False),
                                  (stat.S_IWOTH, False),
                                  (stat.S_IXOTH, False)))
     finally:
         m.umount(force=True)
         os.unlink(iso_img)
예제 #3
0
 def test_mkIsoFs(self, label):
     """
     Tests mkimage.mkIsoFs creating an image and checking its content
     """
     checkSudo(["mount", "-o", "loop", "somefile", "target"])
     checkSudo(["umount", "target"])
     iso_img = mkimage.mkIsoFs("vmId_iso", self.files, label)
     self.assertTrue(os.path.exists(iso_img))
     m = storage.mount.Mount(iso_img, self.workdir)
     m.mount(mntOpts='loop')
     try:
         self._check_content()
         self._check_label(iso_img, label)
         self._check_permissions(iso_img,
                                 ((stat.S_IRUSR, True),
                                  (stat.S_IWUSR, True),
                                  (stat.S_IXUSR, False)))
         self._check_permissions(iso_img,
                                 ((stat.S_IRGRP, True),
                                  (stat.S_IWGRP, False),
                                  (stat.S_IXGRP, False)))
         self._check_permissions(iso_img,
                                 ((stat.S_IROTH, False),
                                  (stat.S_IWOTH, False),
                                  (stat.S_IXOTH, False)))
     finally:
         m.umount(force=True, freeloop=True)
         # TODO: Use libudev to wait for specific event
         with stopwatch("Wait for udev events"):
             udevadm.settle(5)
예제 #4
0
 def test_removeFs(self):
     """
     Tests mkimage.removeFs creating an image and removing it.
     Check also that removeFs doesn't remove anything
     outside mkimage._P_PAYLOAD_IMAGES
     """
     checkSudo(["mount", "-o", "loop", "somefile", "target"])
     checkSudo(["umount", "target"])
     iso_img = mkimage.mkIsoFs("vmId_iso", self.files)
     self.assertTrue(os.path.exists(iso_img))
     mkimage.removeFs(iso_img)
     self.assertFalse(os.path.exists(iso_img))
     self.assertRaises(Exception, mkimage.removeFs, self.workdir)
예제 #5
0
 def test_removeFs(self):
     """
     Tests mkimage.removeFs creating an image and removing it.
     Check also that removeFs doesn't remove anything
     outside mkimage._P_PAYLOAD_IMAGES
     """
     checkSudo(["mount", "-o", "loop", "somefile", "target"])
     checkSudo(["umount", "target"])
     iso_img = mkimage.mkIsoFs("vmId_iso", self.files)
     self.assertTrue(os.path.exists(iso_img))
     mkimage.removeFs(iso_img)
     self.assertFalse(os.path.exists(iso_img))
     self.assertRaises(Exception, mkimage.removeFs, self.workdir)
예제 #6
0
 def test_mkIsoFs(self):
     """
     Tests mkimage.mkIsoFs creating an image and checking its content
     """
     checkSudo(["mount", "-o", "loop", "somefile", "target"])
     checkSudo(["umount", "target"])
     iso_img = mkimage.mkIsoFs("vmId_iso", self.files)
     self.assertTrue(os.path.exists(iso_img))
     m = storage.mount.Mount(iso_img, self.workdir)
     m.mount(mntOpts='loop')
     try:
         self._check_content()
     finally:
         m.umount(force=True)
         os.unlink(iso_img)
예제 #7
0
 def test_mkIsoFs(self, label):
     """
     Tests mkimage.mkIsoFs creating an image and checking its content
     """
     iso_img = mkimage.mkIsoFs("vmId_iso", self.files, label)
     self.assertTrue(os.path.exists(iso_img))
     m = mount.Mount(iso_img, self.workdir)
     try:
         m.mount(mntOpts='loop')
     except mount.MountError as e:
         raise SkipTest("Error mounting iso image: %s" % e)
     try:
         self._check_content()
         self._check_label(iso_img, label)
     finally:
         m.umount()
예제 #8
0
 def test_mkIsoFs(self, label):
     """
     Tests mkimage.mkIsoFs creating an image and checking its content
     """
     iso_img = mkimage.mkIsoFs("vmId_iso", self.files, label)
     self.assertTrue(os.path.exists(iso_img))
     m = mount.Mount(iso_img, self.workdir)
     try:
         m.mount(mntOpts='loop')
     except mount.MountError as e:
         raise SkipTest("Error mounting iso image: %s" % e)
     try:
         self._check_content()
         self._check_label(iso_img, label)
     finally:
         m.umount(force=True, freeloop=True)
         # TODO: Use libudev to wait for specific event
         with stopwatch("Wait for udev events"):
             udevadm.settle(5)
예제 #9
0
 def test_mkIsoFs(self, label):
     """
     Tests mkimage.mkIsoFs creating an image and checking its content
     """
     iso_img = mkimage.mkIsoFs("vmId_iso", self.files, label)
     self.assertTrue(os.path.exists(iso_img))
     m = mount.Mount(iso_img, self.workdir)
     try:
         m.mount(mntOpts="loop")
     except mount.MountError as e:
         raise SkipTest("Error mounting iso image: %s" % e)
     try:
         self._check_content()
         self._check_label(iso_img, label)
     finally:
         m.umount(force=True, freeloop=True)
         # TODO: Use libudev to wait for specific event
         with stopwatch("Wait for udev events"):
             udevadm.settle(5)
예제 #10
0
 def mkIsoFs(self, vmId, files, volId):
     return mkimage.mkIsoFs(vmId, files, volId)