當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。