Ejemplo n.º 1
0
 def test_fetch_image(self, mock_images):
     context = 'opaque context'
     target = '/tmp/targetfile'
     image_id = '4'
     libvirt_utils.fetch_image(context, target, image_id)
     mock_images.assert_called_once_with(
         context, image_id, target)
Ejemplo n.º 2
0
 def test_fetch_image(self, mock_images):
     context = 'opaque context'
     target = '/tmp/targetfile'
     image_id = '4'
     libvirt_utils.fetch_image(context, target, image_id)
     mock_images.assert_called_once_with(
         context, image_id, target)
Ejemplo n.º 3
0
 def test_fetch_image(self, mock_images):
     context = "opaque context"
     target = "/tmp/targetfile"
     image_id = "4"
     user_id = "fake"
     project_id = "fake"
     libvirt_utils.fetch_image(context, target, image_id, user_id, project_id)
     mock_images.assert_called_once_with(context, image_id, target, user_id, project_id, max_size=0)
Ejemplo n.º 4
0
 def test_cache_image_with_clean(self):
     self.mox.StubOutWithMock(libvirt_utils, "fetch_image")
     temp_f, temp_file = tempfile.mkstemp()
     libvirt_utils.fetch_image(None, temp_file, None, None, None)
     self.mox.ReplayAll()
     utils.cache_image(None, temp_file, None, None, None, clean=True)
     self.mox.VerifyAll()
     self.assertFalse(os.path.exists(temp_file))
Ejemplo n.º 5
0
 def test_cache_image_with_clean(self):
     self.mox.StubOutWithMock(libvirt_utils, "fetch_image")
     temp_f, temp_file = tempfile.mkstemp()
     libvirt_utils.fetch_image(None, temp_file, None, None, None)
     self.mox.ReplayAll()
     utils.cache_image(None, temp_file, None, None, None, clean=True)
     self.mox.VerifyAll()
     self.assertFalse(os.path.exists(temp_file))
Ejemplo n.º 6
0
 def test_fetch_image(self, mock_images):
     context = 'opaque context'
     target = '/tmp/targetfile'
     image_id = '4'
     trusted_certs = objects.TrustedCerts(
         ids=['0b5d2c72-12cc-4ba6-a8d7-3ff5cc1d8cb8',
              '674736e3-f25c-405c-8362-bbf991e0ce0a'])
     libvirt_utils.fetch_image(context, target, image_id, trusted_certs)
     mock_images.assert_called_once_with(
         context, image_id, target, trusted_certs)
Ejemplo n.º 7
0
 def test_fetch_image(self, mock_images):
     context = 'opaque context'
     target = '/tmp/targetfile'
     image_id = '4'
     trusted_certs = objects.TrustedCerts(
         ids=['0b5d2c72-12cc-4ba6-a8d7-3ff5cc1d8cb8',
              '674736e3-f25c-405c-8362-bbf991e0ce0a'])
     libvirt_utils.fetch_image(context, target, image_id, trusted_certs)
     mock_images.assert_called_once_with(
         context, image_id, target, trusted_certs)
Ejemplo n.º 8
0
 def test_fetch_image(self, mock_images):
     context = 'opaque context'
     target = '/tmp/targetfile'
     image_id = '4'
     user_id = 'fake'
     project_id = 'fake'
     libvirt_utils.fetch_image(context, target, image_id,
                               user_id, project_id)
     mock_images.assert_called_once_with(
         context, image_id, target, user_id, project_id,
         max_size=0)
Ejemplo n.º 9
0
    def test_fetch_image(self):
        self.mox.StubOutWithMock(images, "fetch_to_raw")

        context = "opaque context"
        target = "/tmp/targetfile"
        image_id = "4"
        user_id = "fake"
        project_id = "fake"
        images.fetch_to_raw(context, image_id, target, user_id, project_id, max_size=0)

        self.mox.ReplayAll()
        libvirt_utils.fetch_image(context, target, image_id, user_id, project_id)
Ejemplo n.º 10
0
    def test_fetch_image(self):
        self.mox.StubOutWithMock(images, 'fetch_to_raw')

        context = 'opaque context'
        target = '/tmp/targetfile'
        image_id = '4'
        user_id = 'fake'
        project_id = 'fake'
        images.fetch_to_raw(context,
                            image_id,
                            target,
                            user_id,
                            project_id,
                            max_size=0)

        self.mox.ReplayAll()
        libvirt_utils.fetch_image(context, target, image_id, user_id,
                                  project_id)
Ejemplo n.º 11
0
def cache_image(context, target, image_id, user_id, project_id):
    if not os.path.exists(target):
        libvirt_utils.fetch_image(context, target, image_id,
                                  user_id, project_id)
Ejemplo n.º 12
0
def _cache_image_x(context, target, image_id, user_id, project_id):
    if not os.path.exists(target):
        libvirt_utils.fetch_image(context, target, image_id, user_id,
                                  project_id)
Ejemplo n.º 13
0
def cache_image(context, target, image_id, user_id, project_id, clean=False):
    if clean and os.path.exists(target):
        os.unlink(target)
    if not os.path.exists(target):
        libvirt_utils.fetch_image(context, target, image_id,
                                  user_id, project_id)
Ejemplo n.º 14
0
def cache_image(context, target, image_id, user_id, project_id, clean=False):
    if clean and os.path.exists(target):
        os.unlink(target)
    if not os.path.exists(target):
        libvirt_utils.fetch_image(context, target, image_id, user_id,
                                  project_id)