'Test create snapshot from bootable volume.'

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

    volume = self._create_volume_from_image()
    volume_id = volume['id']
    self.assertEqual('available', volume['status'])
    self.assertTrue(volume['bootable'])
    image_info = imageutils.QemuImgInfo()
    image_info.virtual_size = '1073741824'
    mock_qemu_info.return_value = image_info
    ctxt = context.get_admin_context()
    vol_glance_meta = db.volume_glance_metadata_get(ctxt, volume_id)
    self.assertTrue(vol_glance_meta)
    snap = create_snapshot(volume_id)
    self.volume.create_snapshot(ctxt, snap)
    snap_glance_meta = db.volume_snapshot_glance_metadata_get(ctxt, snap.id)
    self.assertTrue(snap_glance_meta)
    self.assertEqual(len(vol_glance_meta), len(snap_glance_meta))
    vol_glance_dict = {x.key: x.value for x in vol_glance_meta}
    snap_glance_dict = {x.key: x.value for x in snap_glance_meta}
    self.assertDictEqual(vol_glance_dict, snap_glance_dict)
    self.assertEqual(fields.SnapshotStatus.AVAILABLE, snap.status)
    snap.destroy()
    db.volume_destroy(ctxt, volume_id)
