コード例 #1
0
func (i IpRangeToStaticIps) ReserveStaticIpsInPool(ipPool *bftinput.IpPool) {
	staticIps, ok := i[ipPool.IpRange]
	if !ok {
		return
	}

	for _, ip := range staticIps {
		ipPool.ReserveStaticIp(ip)
	}
}
コード例 #2
0
					},
				},
			},
		}

		result := networksAssigner.Assign(input, previousInput)
		Expect(len(result.Jobs[0].Networks[0].StaticIps)).To(Equal(2))
		Expect(result.Jobs[0].Networks[0].StaticIps).ToNot(ContainElement("192.168.4.209"))
		Expect(result.Jobs[0].Networks[0].StaticIps).ToNot(ContainElement("192.168.4.254"))
	})

	Context("when previous input has static IPs", func() {
		BeforeEach(func() {
			decider.IsYesYes = true

			expectedIpPool.ReserveStaticIp("192.168.0.219")
			expectedIpPool.ReserveStaticIp("192.168.0.245")
			expectedIpPool.ReserveStaticIp("192.168.0.252")
			expectedIpPool.ReserveStaticIp("192.168.0.236")
		})

		It("does not reuse those static IPs", func() {
			// our fuzzing returns ips in order
			// "192.168.0.252", "192.168.0.219", "192.168.0.234", "192.168.0.245"
			// we put "192.168.0.252" on second job to make sure it is not going to be used by first job
			// we put "192.168.0.245" on first job to make sure it is not going to be used by second job
			input := bftinput.Input{
				Jobs: []bftinput.Job{
					{
						Name:      "foo",
						Instances: 2,