def get_instance_type_by_name(name):
    """Retrieves single instance type by name."""
    if name is None:
        return get_default_instance_type()
    try:
        ctxt = context.get_admin_context()
        return db.instance_type_get_by_name(ctxt, name)
    except exception.DBError:
        raise exception.ApiError(_("Unknown instance type: %s") % name)


# TODO(termie): flavor-specific code should probably be in the API that uses
#               flavors.
dataset/ETHPy150Open nii-cloud/dodai-compute/nova/compute/instance_types.py/get_instance_type_by_name/original