def _update_to_glance(self, context, image_service, filepath,
                       meta_id, metadata):
     with libvirt_utils.file_open(filepath) as image_file:
         image_service.update(context,
                              meta_id,
                              metadata,
                              image_file)
예제 #2
0
    def test_file_open(self):
        dst_fd, dst_path = tempfile.mkstemp()
        try:
            os.close(dst_fd)

            # We have a test for write_to_file. If that is sound, this suffices
            libvirt_utils.write_to_file(dst_path, 'hello')
            with libvirt_utils.file_open(dst_path, 'r') as fp:
                self.assertEqual(fp.read(), 'hello')
        finally:
            os.unlink(dst_path)
예제 #3
0
    def test_file_open(self):
        dst_fd, dst_path = tempfile.mkstemp()
        try:
            os.close(dst_fd)

            with open(dst_path, 'w') as f:
                f.write('hello')
            with libvirt_utils.file_open(dst_path, 'r') as fp:
                self.assertEqual(fp.read(), 'hello')
        finally:
            os.unlink(dst_path)
예제 #4
0
 def _update_to_glance(self, context, image_service, filepath, meta_id,
                       metadata):
     with libvirt_utils.file_open(filepath) as image_file:
         image_service.update(context, meta_id, metadata, image_file)