本文整理汇总了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
}
示例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
}
示例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
}
示例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
}