當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Input.FindJobByName方法代碼示例

本文整理匯總了Golang中github.com/cloudfoundry-incubator/bosh-fuzz-tests/input.Input.FindJobByName方法的典型用法代碼示例。如果您正苦於以下問題:Golang Input.FindJobByName方法的具體用法?Golang Input.FindJobByName怎麽用?Golang Input.FindJobByName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cloudfoundry-incubator/bosh-fuzz-tests/input.Input的用法示例。


在下文中一共展示了Input.FindJobByName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: getJobStaticIpsToReuse

func (n *assigner) getJobStaticIpsToReuse(previousInput bftinput.Input, jobName string, networkName string) []string {
	staticIps := []string{}

	previousJob, found := previousInput.FindJobByName(jobName)
	if !found {
		return staticIps
	}

	for _, jobNetwork := range previousJob.Networks {
		if jobNetwork.Name == networkName {
			for _, ip := range jobNetwork.StaticIps {
				staticIps = append(staticIps, ip)
			}
		}
	}

	if len(staticIps) == 0 {
		return staticIps
	}

	shuffledStaticIPsIdsx := rand.Perm(len(staticIps))
	ipsToReuse := rand.Intn(len(staticIps))

	shuffledStaticIps := []string{}

	for i := 0; i < ipsToReuse; i++ {
		shuffledStaticIps = append(shuffledStaticIps, staticIps[shuffledStaticIPsIdsx[i]])
	}

	return shuffledStaticIps
}
開發者ID:cloudfoundry-incubator,項目名稱:bosh-fuzz-tests,代碼行數:31,代碼來源:assigner.go

示例2: jobStemcellChanged

func (s *stemcellComparator) jobStemcellChanged(job bftinput.Job, currentInput bftinput.Input, mostRecentInput bftinput.Input) bool {
	prevJob, found := mostRecentInput.FindJobByName(job.Name)
	if !found {
		return false
	}

	var currentStemcell bftinput.StemcellConfig
	if job.Stemcell != "" {
		currentStemcell = s.findStemcellByAlias(job.Stemcell, currentInput)
	} else {
		currentStemcell = s.findResourcePoolStemcell(job.ResourcePool, currentInput)
	}

	if prevJob.Stemcell != "" {
		prevStemcell := s.findStemcellByAlias(prevJob.Stemcell, mostRecentInput)
		if prevStemcell.Version != currentStemcell.Version {
			s.logger.Debug("stemcell_comparator", "Stemcell versions don't match. Previous input: %#v, new input: %#v", mostRecentInput, currentInput)
			return true
		}
	} else {
		prevStemcell := s.findResourcePoolStemcell(prevJob.ResourcePool, mostRecentInput)
		if prevStemcell.Version != currentStemcell.Version {
			s.logger.Debug("stemcell_comparator", "Stemcell versions don't match. Previous input: %#v, new input: %#v", mostRecentInput, currentInput)
			return true
		}
	}

	return false
}
開發者ID:cloudfoundry-incubator,項目名稱:bosh-fuzz-tests,代碼行數:29,代碼來源:stemcell_comparator.go

示例3: Apply

func (f *fixedMigratedFrom) Apply(input bftinput.Input, previousInput bftinput.Input) bftinput.Input {
	for foundJobIdx, job := range input.Jobs {
		previousJob, found := previousInput.FindJobByName(job.Name)
		if found {
			if len(previousJob.AvailabilityZones) == 0 && len(job.AvailabilityZones) > 0 {
				staticIPs := f.sameStaticIps(job, previousJob, input)
				for _, ip := range staticIPs {
					f.assignMigratedFromBasedOnIp(ip, &input.Jobs[foundJobIdx])
				}
			}
		}
	}

	return input
}
開發者ID:cloudfoundry-incubator,項目名稱:bosh-fuzz-tests,代碼行數:15,代碼來源:fixed_migrated_from.go

示例4: isMigratingFromAzsToNoAzsAndReusingStaticIps

func (a *analyzer) isMigratingFromAzsToNoAzsAndReusingStaticIps(previousInput bftinput.Input, currentInput bftinput.Input) bool {
	for _, job := range currentInput.Jobs {
		previousJob, found := previousInput.FindJobByName(job.Name)
		if found && (len(previousJob.AvailabilityZones) > 0 && len(job.AvailabilityZones) == 0) {
			for _, network := range job.Networks {
				previousNetwork, networkFound := previousJob.FindNetworkByName(network.Name)
				if networkFound {
					for _, currentIP := range network.StaticIps {
						for _, prevIP := range previousNetwork.StaticIps {
							if prevIP == currentIP {
								return true
							}
						}
					}
				}
			}
		}
	}

	return false
}
開發者ID:cloudfoundry-incubator,項目名稱:bosh-fuzz-tests,代碼行數:21,代碼來源:analyzer.go


注:本文中的github.com/cloudfoundry-incubator/bosh-fuzz-tests/input.Input.FindJobByName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。