当前位置: 首页>>代码示例>>Golang>>正文


Golang machine.MachineState类代码示例

本文整理汇总了Golang中github.com/coreos/fleet/machine.MachineState的典型用法代码示例。如果您正苦于以下问题:Golang MachineState类的具体用法?Golang MachineState怎么用?Golang MachineState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MachineState类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: machineBootIDLegend

func machineBootIDLegend(ms machine.MachineState, full bool) string {
	legend := ms.BootID
	if !full {
		legend = fmt.Sprintf("%s...", ms.ShortBootID())
	}
	return legend
}
开发者ID:nullstyle,项目名称:fleet,代码行数:7,代码来源:cmd.go

示例2: ableToRun

// ableToRun determines if the Agent can run the provided Job based on
// the Agent's desired state. A boolean indicating whether this is the
// case or not is returned. The following criteria is used:
//   - Agent must meet the Job's machine target requirement (if any)
//   - Job must pass signature verification
//   - Agent must have all of the Job's required metadata (if any)
//   - Agent must have all required Peers of the Job scheduled locally (if any)
//   - Job must not conflict with any other Jobs scheduled to the agent
func (ar *AgentReconciler) ableToRun(as *agentState, ms *machine.MachineState, j *job.Job) (bool, string) {
	log.V(1).Infof("Attempting to determine if able to run Job(%s)", j.Name)

	if tgt, ok := j.RequiredTarget(); ok && !ms.MatchID(tgt) {
		return false, fmt.Sprintf("Agent ID %q does not match required %q", ms.ID, tgt)
	}

	if !ar.verifyJobSignature(j) {
		return false, "unable to verify signature"
	}

	log.V(1).Infof("Job(%s) has requirements: %s", j.Name, j.Requirements())

	metadata := j.RequiredTargetMetadata()
	if len(metadata) == 0 {
		log.V(1).Infof("Job(%s) has no required machine metadata", j.Name)
	} else {
		log.V(1).Infof("Job(%s) requires machine metadata: %v", j.Name, metadata)
		if !machine.HasMetadata(ms, metadata) {
			return false, "local Machine metadata insufficient"
		}
	}

	peers := j.Peers()
	if len(peers) == 0 {
		log.V(1).Infof("Job(%s) has no required peers", j.Name)
	} else {
		log.V(1).Infof("Job(%s) requires peers: %v", j.Name, peers)
		for _, peer := range peers {
			if !as.jobScheduled(peer) {
				return false, fmt.Sprintf("required peer Job(%s) is not scheduled locally", peer)
			}
		}
	}

	if cExists, cJobName := as.hasConflict(j.Name, j.Conflicts()); cExists {
		return false, fmt.Sprintf("found conflict with locally-scheduled Job(%s)", cJobName)
	}

	log.V(1).Infof("Determined local Agent is able to run Job(%s)", j.Name)
	return true, ""
}
开发者ID:JuanCarlosM,项目名称:fleet,代码行数:50,代码来源:reconcile.go

示例3: mapMachinePageToMachineStates

func mapMachinePageToMachineStates(entities []*schema.Machine) []machine.MachineState {
	machines := make([]machine.MachineState, len(entities))
	for i, _ := range entities {
		me := entities[i]

		ms := machine.MachineState{
			ID:       me.Id,
			PublicIP: me.PrimaryIP,
		}

		ms.Metadata = make(map[string]string, len(me.Metadata))
		for k, v := range me.Metadata {
			ms.Metadata[k] = v
		}

		machines[i] = ms
	}

	return machines
}
开发者ID:BillTheBest,项目名称:fleet,代码行数:20,代码来源:http.go


注:本文中的github.com/coreos/fleet/machine.MachineState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。