Beispiel #1
0
    def stash_image(self, image_id, image_data):
        image_size = len(image_data)
        image = sheepdog.SheepdogImage(sheepdog.DEFAULT_ADDR,
                                       sheepdog.DEFAULT_PORT, image_id,
                                       sheepdog.DEFAULT_CHUNKSIZE)
        image.create(image_size)
        total = left = image_size
        while left > 0:
            length = min(sheepdog.DEFAULT_CHUNKSIZE, left)
            image.write(image_data, total - left, length)
            left -= length

        return 'sheepdog://%s' % image_id
Beispiel #2
0
    def setUp(self):
        image = sheepdog.SheepdogImage(sheepdog.DEFAULT_ADDR,
                                       sheepdog.DEFAULT_PORT, "test",
                                       sheepdog.DEFAULT_CHUNKSIZE)
        try:
            image.create(512)
        except BackendException:
            msg = "Sheepdog cluster isn't set up"
            self.skipTest(msg)
        image.delete()

        self.tmp_dir = self.useFixture(fixtures.TempDir()).path

        config_file = os.path.join(self.tmp_dir, 'glance.conf')
        with open(config_file, 'w') as f:
            f.write("[DEFAULT]\n")
            f.write("default_store = sheepdog")

        oslo.config.cfg.CONF(default_config_files=[config_file], args=[])
        super(TestSheepdogStore, self).setUp()