Ejemplo n.º 1
0
 def upload_image(self):
     vdi_ref = self._get_vdi_ref()
     with vm_utils.vdi_attached_here(self.session, vdi_ref,
                                     read_only=True) as dev:
         devpath = utils.make_dev_path(dev)
         with utils.temporary_chown(devpath):
             self._perform_upload(devpath)
Ejemplo n.º 2
0
 def upload_image(self):
     vdi_ref = self._get_vdi_ref()
     with vm_utils.vdi_attached_here(self.session, vdi_ref,
                                     read_only=True) as dev:
         devpath = utils.make_dev_path(dev)
         with utils.temporary_chown(devpath):
             self._perform_upload(devpath)
Ejemplo n.º 3
0
    def test_temporary_chown(self):
        def fake_execute(*args, **kwargs):
            if args[0] == 'chown':
                fake_execute.uid = args[1]
        self.stubs.Set(utils, 'execute', fake_execute)

        with tempfile.NamedTemporaryFile() as f:
            with utils.temporary_chown(f.name, owner_uid=2):
                self.assertEqual(fake_execute.uid, 2)
            self.assertEqual(fake_execute.uid, os.getuid())
Ejemplo n.º 4
0
    def test_temporary_chown(self):
        def fake_execute(*args, **kwargs):
            if args[0] == 'chown':
                fake_execute.uid = args[1]

        self.stubs.Set(utils, 'execute', fake_execute)

        with tempfile.NamedTemporaryFile() as f:
            with utils.temporary_chown(f.name, owner_uid=2):
                self.assertEqual(fake_execute.uid, 2)
            self.assertEqual(fake_execute.uid, os.getuid())