// DropLinuxResourcesNetworkPriorities drops one item from g.Config.Linux.Resources.Network.Priorities.
186364
func (g *Generator) DropLinuxResourcesNetworkPriorities(name string) {
	if g.Config == nil || g.Config.Linux == nil || g.Config.Linux.Resources == nil || g.Config.Linux.Resources.Network == nil {
		return
	}

	for i, netPriority := range g.Config.Linux.Resources.Network.Priorities {
		if netPriority.Name == name {
			g.Config.Linux.Resources.Network.Priorities = append(g.Config.Linux.Resources.Network.Priorities[:i], g.Config.Linux.Resources.Network.Priorities[i+1:]...)
			return
		}
	}
}
725636
func podPriorityInUse(podSpec *api.PodSpec) bool {
	if podSpec == nil {
		return false
	}
	if podSpec.Priority != nil || podSpec.PriorityClassName != "" {
		return true
	}
	return false
}
1053505
func (s *OriginationRoute) SetPriority(v int64) *OriginationRoute {
	s.Priority = &v
	return s
}
1182929
func (g *Generator) SetLinuxResourcesCPUShares(shares uint64) {
	g.InitConfigLinuxResourcesCPU()
	g.Config.Linux.Resources.CPU.Shares = &shares
}
1214854
func (g *Generator) SetLinuxResourcesCPUCpus(cpus string) {
	g.InitConfigLinuxResourcesCPU()
	g.Config.Linux.Resources.CPU.Cpus = cpus
}
364839
func (g *GroupComposer) SetPriority(l level.Priority) error {
	if l == level.Invalid {
		return fmt.Errorf("cannot set priority to an invalid setting")
	}

	for _, m := range g.messages {
		if m == nil {
			continue
		}

		if m.Priority() == level.Invalid {
			_ = m.SetPriority(l)
		}
	}

	return nil
}
978554
func (g *Generator) DropLinuxResourcesHugepageLimit(pageSize string) {
	if g.Config == nil || g.Config.Linux == nil || g.Config.Linux.Resources == nil {
		return
	}

	for i, pageLimit := range g.Config.Linux.Resources.HugepageLimits {
		if pageLimit.Pagesize == pageSize {
			g.Config.Linux.Resources.HugepageLimits = append(g.Config.Linux.Resources.HugepageLimits[:i], g.Config.Linux.Resources.HugepageLimits[i+1:]...)
			return
		}
	}
}
726772
func (g *Generator) SetLinuxResourcesCPURealtimeRuntime(time int64) {
	g.InitConfigLinuxResourcesCPU()
	g.Config.Linux.Resources.CPU.RealtimeRuntime = &time
}
582603
func (r Network_Storage_Group_Nfs) GetServiceResource() (resp datatypes.Network_Service_Resource, err error) {
	err = r.Session.DoRequest("SoftLayer_Network_Storage_Group_Nfs", "getServiceResource", nil, &r.Options, &resp)
	return
}
1262244
func ComputeTaintTolerationPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedulernodeinfo.NodeInfo) (schedulerapi.HostPriority, error) {
	node := nodeInfo.Node()
	if node == nil {
		return schedulerapi.HostPriority{}, fmt.Errorf("node not found")
	}
	// To hold all the tolerations with Effect PreferNoSchedule
	var tolerationsPreferNoSchedule []v1.Toleration
	if priorityMeta, ok := meta.(*priorityMetadata); ok {
		tolerationsPreferNoSchedule = priorityMeta.podTolerations

	} else {
		tolerationsPreferNoSchedule = getAllTolerationPreferNoSchedule(pod.Spec.Tolerations)
	}

	return schedulerapi.HostPriority{
		Host:  node.Name,
		Score: countIntolerableTaintsPreferNoSchedule(node.Spec.Taints, tolerationsPreferNoSchedule),
	}, nil
}
1177695
func (me *PriorityBitmap) GetPriority(bit int) (prio int, ok bool) {
	prio, ok = me.priorities[bit]
	return
}
124093
func (s *Rule) SetPriority(v string) *Rule {
	s.Priority = &v
	return s
}
1098354
func ValidateLinuxResourcesNetwork(config *rspec.Spec, t *tap.T, state *rspec.State) error {
	cg, err := cgroups.FindCgroup()
	t.Ok((err == nil), "find network cgroup")
	if err != nil {
		t.Diagnostic(err.Error())
		return nil
	}

	lnd, err := cg.GetNetworkData(state.Pid, config.Linux.CgroupsPath)
	t.Ok((err == nil), "get network cgroup data")
	if err != nil {
		t.Diagnostic(err.Error())
		return nil
	}

	t.Ok(*lnd.ClassID == *config.Linux.Resources.Network.ClassID, "network ID set correctly")
	t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Network.ClassID, *lnd.ClassID)

	for _, priority := range config.Linux.Resources.Network.Priorities {
		found := false
		for _, lip := range lnd.Priorities {
			if lip.Name == priority.Name {
				found = true
				t.Ok(lip.Priority == priority.Priority, fmt.Sprintf("network priority for %s is set correctly", priority.Name))
				t.Diagnosticf("expect: %d, actual: %d", priority.Priority, lip.Priority)
			}
		}
		t.Ok(found, fmt.Sprintf("network priority for %s found", priority.Name))
	}

	return nil
}
428448
func (g *Generator) SetLinuxResourcesMemoryReservation(reservation int64) {
	g.initConfigLinuxResourcesMemory()
	g.Config.Linux.Resources.Memory.Reservation = &reservation
}
622811
func NormalizeReduce(maxPriority int, reverse bool) PriorityReduceFunction {
	return func(
		_ *v1.Pod,
		_ interface{},
		_ map[string]*schedulernodeinfo.NodeInfo,
		result schedulerapi.HostPriorityList) error {

		var maxCount int
		for i := range result {
			if result[i].Score > maxCount {
				maxCount = result[i].Score
			}
		}

		if maxCount == 0 {
			if reverse {
				for i := range result {
					result[i].Score = maxPriority
				}
			}
			return nil
		}

		for i := range result {
			score := result[i].Score

			score = maxPriority * score / maxCount
			if reverse {
				score = maxPriority - score
			}

			result[i].Score = score
		}
		return nil
	}
}
1019579
func (svc *Service) SetPriority(priority int) error {
	if priority < -20 || priority > 19 {
		return fmt.Errorf("Invalid priority %d - must be between -20 and 19", priority)
	}
	svc.priority = priority
	return nil
}
179772
func ParsePriority(pr string) (Priority, error) {
	for k, v := range priorities {
		if v == pr {
			return k, nil
		}
	}

	e := errors.New("can not parse priority: do not recognize " + pr)
	return DefaultPriority, e
}