Ejemplo n.º 1
0
    def test_read_stored_checksum(self):
        with utils.tempdir() as tmpdir:
            self.flags(instances_path=tmpdir)
            self.flags(image_info_filename_pattern=('$instances_path/'
                                                    '%(image)s.info'),
                       group='libvirt')

            csum_input = '{"sha1": "fdghkfhkgjjksfdgjksjkghsdf"}\n'
            fname = os.path.join(tmpdir, 'aaa')
            info_fname = imagecache.get_info_filename(fname)
            f = open(info_fname, 'w')
            f.write(csum_input)
            f.close()

            csum_output = imagecache.read_stored_checksum(fname,
                                                          timestamped=False)
            self.assertEqual(csum_input.rstrip(),
                             '{"sha1": "%s"}' % csum_output)
Ejemplo n.º 2
0
    def test_read_stored_checksum(self):
        with utils.tempdir() as tmpdir:
            self.flags(instances_path=tmpdir)
            self.flags(image_info_filename_pattern=('$instances_path/'
                                                    '%(image)s.info'),
                       group='libvirt')

            csum_input = '{"sha1": "fdghkfhkgjjksfdgjksjkghsdf"}\n'
            fname = os.path.join(tmpdir, 'aaa')
            info_fname = imagecache.get_info_filename(fname)
            f = open(info_fname, 'w')
            f.write(csum_input)
            f.close()

            csum_output = imagecache.read_stored_checksum(fname,
                                                          timestamped=False)
            self.assertEqual(csum_input.rstrip(),
                             '{"sha1": "%s"}' % csum_output)
Ejemplo n.º 3
0
    def test_read_stored_checksum_legacy_essex(self):
        with utils.tempdir() as tmpdir:
            self.flags(instances_path=tmpdir)
            self.flags(image_info_filename_pattern=('$instances_path/'
                                                    '%(image)s.info'),
                       group='libvirt')

            fname = os.path.join(tmpdir, 'aaa')
            old_fname = fname + '.sha1'
            f = open(old_fname, 'w')
            f.write('fdghkfhkgjjksfdgjksjkghsdf')
            f.close()

            csum_output = imagecache.read_stored_checksum(fname,
                                                          timestamped=False)
            self.assertEqual(csum_output, 'fdghkfhkgjjksfdgjksjkghsdf')
            self.assertFalse(os.path.exists(old_fname))
            info_fname = imagecache.get_info_filename(fname)
            self.assertTrue(os.path.exists(info_fname))
Ejemplo n.º 4
0
    def test_read_stored_checksum_legacy_essex(self):
        with utils.tempdir() as tmpdir:
            self.flags(instances_path=tmpdir)
            self.flags(image_info_filename_pattern=('$instances_path/'
                                                    '%(image)s.info'),
                       group='libvirt')

            fname = os.path.join(tmpdir, 'aaa')
            old_fname = fname + '.sha1'
            f = open(old_fname, 'w')
            f.write('fdghkfhkgjjksfdgjksjkghsdf')
            f.close()

            csum_output = imagecache.read_stored_checksum(fname,
                                                          timestamped=False)
            self.assertEqual(csum_output, 'fdghkfhkgjjksfdgjksjkghsdf')
            self.assertFalse(os.path.exists(old_fname))
            info_fname = imagecache.get_info_filename(fname)
            self.assertTrue(os.path.exists(info_fname))
Ejemplo n.º 5
0
 def test_read_stored_checksum_missing(self):
     self.stubs.Set(os.path, 'exists', lambda x: False)
     csum = imagecache.read_stored_checksum('/tmp/foo', timestamped=False)
     self.assertIsNone(csum)
Ejemplo n.º 6
0
 def test_read_stored_checksum_missing(self):
     self.stubs.Set(os.path, 'exists', lambda x: False)
     csum = imagecache.read_stored_checksum('/tmp/foo', timestamped=False)
     self.assertIsNone(csum)