'Choose kernel and ramdisk appropriate for the instance.
The kernel and ramdisk can be chosen in one of three ways:
1. Passed in with create-instance request.
2. Inherited from image.
3. Forced to None by using `null_kernel` FLAG.'

def _handle_kernel_and_ramdisk(self, context, kernel_id, ramdisk_id, image):

    image_properties = image.get('properties', {})
    if (kernel_id is None):
        kernel_id = image_properties.get('kernel_id')
    if (ramdisk_id is None):
        ramdisk_id = image_properties.get('ramdisk_id')
    if (kernel_id == str(CONF.null_kernel)):
        kernel_id = None
        ramdisk_id = None
    if (kernel_id is not None):
        kernel_image = self.image_api.get(context, kernel_id)
        kernel_id = kernel_image['id']
    if (ramdisk_id is not None):
        ramdisk_image = self.image_api.get(context, ramdisk_id)
        ramdisk_id = ramdisk_image['id']
    return (kernel_id, ramdisk_id)
