def test_create_ebs_instance_snapshot(self):
        """Create snapshot of EBS-backed instance and check it."""

        instance_id = self.run_instance(ImageId=self.image_id)

        instance = self.get_instance(instance_id)
        bdt = self.get_instance_bdm(instance_id, None)
        self.assertIsNotNone(bdt)
        volume_id = bdt['Ebs'].get('VolumeId')
        self.assertIsNotNone(volume_id)

        self.client.stop_instances(InstanceIds=[instance_id])
        self.get_instance_waiter().wait_available(instance_id,
                                                  final_set=('stopped'))

        self.addResourceCleanUp(self.client.delete_volume,
                                VolumeId=volume_id)
        data = self.client.create_snapshot(VolumeId=volume_id)
        snapshot_id = data['SnapshotId']
        self.addResourceCleanUp(self.client.delete_snapshot,
                                SnapshotId=snapshot_id)
        self.get_snapshot_waiter().wait_available(snapshot_id,
                                                  final_set=('completed'))

        self.client.terminate_instances(InstanceIds=[instance_id])
        self.get_instance_waiter().wait_delete(instance_id)

        kwargs = {
            'Name': data_utils.rand_name('ebs-ami'),
            'RootDeviceName': instance['RootDeviceName'],
            'BlockDeviceMappings': [{'DeviceName': instance['RootDeviceName'],
                                     'Ebs': {'SnapshotId': snapshot_id,
                                             'DeleteOnTermination': True}}]
        }
        if 'Architecture' in instance:
            kwargs['Architecture'] = instance['Architecture']
        if 'KernelId' in instance:
            kwargs['KernelId'] = instance['KernelId']
        if 'RamdiskId' in instance:
            kwargs['RamdiskId'] = instance['RamdiskId']
        data = self.client.register_image(*[], **kwargs)
        image_id = data['ImageId']
        clean_i = self.addResourceCleanUp(self.client.deregister_image,
                                          ImageId=image_id)
        self.get_image_waiter().wait_available(image_id)

        instance_id = self.run_instance(ImageId=image_id)

        # NOTE(andrey-mp): if instance will run then test will pass

        self.client.terminate_instances(InstanceIds=[instance_id])
        self.get_instance_waiter().wait_delete(instance_id)

        self.client.deregister_image(ImageId=image_id)
        self.cancelResourceCleanUp(clean_i)
dataset/ETHPy150Open openstack/ec2-api/ec2api/tests/functional/scenario/test_ebs_instances.py/EC2_EBSInstanceSnapshot.test_create_ebs_instance_snapshot/original