Пример #1
0
func (s *lxcBrokerSuite) checkDiscoverIPv4InterfaceAddressesFails(c *gc.C, ifaceName, expectedError string, fakeAddrs ...string) {
	s.patchNetInterfaceByName(c, ifaceName)
	s.patchNetInterfaceByNameAddrs(c, ifaceName, fakeAddrs...)
	addr, err := provisioner.DiscoverIPv4InterfaceAddress(ifaceName)
	c.Assert(err, gc.ErrorMatches, expectedError)
	c.Assert(addr, gc.IsNil)
}
Пример #2
0
func (s *lxcBrokerSuite) checkDiscoverIPv4InterfaceAddress(c *gc.C, ifaceName, expectedAddress string, fakeAddrs ...string) {
	s.patchNetInterfaceByName(c, ifaceName)
	s.patchNetInterfaceByNameAddrs(c, ifaceName, fakeAddrs...)
	addr, err := provisioner.DiscoverIPv4InterfaceAddress(ifaceName)
	c.Assert(err, gc.IsNil)
	c.Assert(addr, gc.Not(gc.IsNil))
	c.Assert(*addr, gc.Equals, network.NewAddress(expectedAddress))
}
Пример #3
0
func (s *lxcBrokerSuite) TestDiscoverIPv4InterfaceByNameAddressError(c *gc.C) {
	s.patchNetInterfaceByName(c, "fake")
	s.PatchValue(provisioner.InterfaceAddrs, func(i *net.Interface) ([]net.Addr, error) {
		c.Assert(i.Name, gc.Matches, "fake")
		return nil, errors.New("boom!")
	})
	addr, err := provisioner.DiscoverIPv4InterfaceAddress("fake")
	c.Assert(err, gc.ErrorMatches, `cannot get network addresses for interface "fake": boom!`)
	c.Assert(addr, gc.IsNil)
}
Пример #4
0
func (s *lxcBrokerSuite) TestDiscoverIPv4InterfaceByNameUnknownInterfaceNameError(c *gc.C) {
	s.patchNetInterfaceByName(c, "fake")
	addr, err := provisioner.DiscoverIPv4InterfaceAddress("missing")
	c.Assert(err, gc.ErrorMatches, `cannot get interface "missing": no such network interface`)
	c.Assert(addr, gc.IsNil)
}