'Test glance metadata can be correctly copied to new volume.'

@mock.patch('cinder.image.image_utils.qemu_img_info')
def test_create_volume_from_sourcevol_with_glance_metadata(self, mock_qemu_info):

    def fake_create_cloned_volume(volume, src_vref):
        pass
    self.mock_object(self.volume.driver, 'create_cloned_volume', fake_create_cloned_volume)
    image_info = imageutils.QemuImgInfo()
    image_info.virtual_size = '1073741824'
    mock_qemu_info.return_value = image_info
    volume_src = self._create_volume_from_image()
    self.volume.create_volume(self.context, volume_src)
    volume_dst = tests_utils.create_volume(self.context, source_volid=volume_src['id'], **self.volume_params)
    self.volume.create_volume(self.context, volume_dst)
    self.assertEqual('available', db.volume_get(context.get_admin_context(), volume_dst['id']).status)
    src_glancemeta = db.volume_get(context.get_admin_context(), volume_src['id']).volume_glance_metadata
    dst_glancemeta = db.volume_get(context.get_admin_context(), volume_dst['id']).volume_glance_metadata
    for meta_src in src_glancemeta:
        for meta_dst in dst_glancemeta:
            if (meta_dst.key == meta_src.key):
                self.assertEqual(meta_src.value, meta_dst.value)
    self.volume.delete_volume(self.context, volume_src)
    self.volume.delete_volume(self.context, volume_dst)
