human
Solve the following python programming problem given the following code:
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@pick_context_manager_writer
def instance_create(context, values):
assistant
#Here is the Python program you requested.

    """Create a new Instance record in the database.
    context - request context object
    values - dict containing column values.
    """
    security_group_ensure_default(context)
    values = values.copy()
    values['metadata'] = _metadata_refs(values.get('metadata'), models.InstanceMetadata)
    values['system_metadata'] = _metadata_refs(values.get('system_metadata'), models.InstanceSystemMetadata)
    _handle_objects_related_type_conversions(values)
    instance_ref = models.Instance()
    if (not values.get('uuid')):
        values['uuid'] = uuidutils.generate_uuid()
    instance_ref['info_cache'] = models.InstanceInfoCache()
    info_cache = values.pop('info_cache', None)
    if (info_cache is not None):
        instance_ref['info_cache'].update(info_cache)
    security_groups = values.pop('security_groups', [])
    instance_ref['extra'] = models.InstanceExtra()
    instance_ref['extra'].update({'numa_topology': None, 'pci_requests': None, 'vcpu_model': None})
    instance_ref['extra'].update(values.pop('extra', {}))
    instance_ref.update(values)
    def _get_sec_group_models(security_groups):
        models = []
        default_group = _security_group_ensure_default(context)
        if ('default' in security_groups):
            models.append(default_group)
            security_groups = [x for x in security_groups if (x != 'default')]
        if security_groups:
            models.extend(_security_group_get_by_names(context, security_groups))
        return models
    if ('hostname' in values):
        _validate_unique_server_name(context, values['hostname'])
    instance_ref.security_groups = _get_sec_group_models(security_groups)
    context.session.add(instance_ref)
    ec2_instance_create(context, instance_ref['uuid'])
    return instance_ref