示例#1
0
func (s *ipAddressesStateSuite) TestUpdateAddressFailsToChangeProviderID(c *gc.C) {
	s.addNamedDevice(c, "eth0")
	addrArgs := state.LinkLayerDeviceAddress{
		DeviceName:   "eth0",
		ConfigMethod: state.ManualAddress,
		CIDRAddress:  "0.1.2.3/24",
		ProviderID:   "id-0123",
	}
	err := s.machine.SetDevicesAddresses(addrArgs)
	c.Assert(err, jc.ErrorIsNil)
	addrArgs.ProviderID = "id-0124"
	err = s.machine.SetDevicesAddresses(addrArgs)
	c.Assert(err, gc.ErrorMatches, `.*cannot change ProviderID of link address "0.1.2.3"`)
}
示例#2
0
func (s *ipAddressesStateSuite) TestUpdateAddressPreventsDuplicateProviderID(c *gc.C) {
	s.addNamedDevice(c, "eth0")
	addrArgs := state.LinkLayerDeviceAddress{
		DeviceName:   "eth0",
		ConfigMethod: state.ManualAddress,
		CIDRAddress:  "0.1.2.3/24",
	}
	err := s.machine.SetDevicesAddresses(addrArgs)
	c.Assert(err, jc.ErrorIsNil)

	// Set the provider id through an update.
	addrArgs.ProviderID = "id-0123"
	err = s.machine.SetDevicesAddresses(addrArgs)
	c.Assert(err, jc.ErrorIsNil)

	// Adding a new address with the same provider id should now fail.
	addrArgs.CIDRAddress = "0.1.2.4/24"
	err = s.machine.SetDevicesAddresses(addrArgs)
	c.Assert(err, gc.ErrorMatches, `.*invalid address "0.1.2.4/24": ProviderID\(s\) not unique: id-0123`)
}