本文整理匯總了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
}