Exemple #1
0
func (s *NetSuite) TestGetVips(c *C) {
	err := net.AddIp("192.168.0.1/32", "lo")
	c.Assert(err, IsNil)
	err = net.AddIp("192.168.0.2/32", "lo")
	c.Assert(err, IsNil)

	addrs, err := net.GetVips(s.iface)
	c.Assert(err, IsNil)

	c.Assert(len(addrs), Equals, 3)
}
Exemple #2
0
func (s *NetSuite) TestAddIp(c *C) {
	err := net.AddIp("192.168.0.1/32", "lo")
	c.Assert(err, IsNil)

	addrs, err := net.GetVips(s.iface)
	c.Assert(err, IsNil)

	found := false
	for _, a := range addrs {
		if a.IPNet.String() == "192.168.0.1/32" {
			found = true
		}
	}

	c.Assert(found, Equals, true)
}
Exemple #3
0
func (s *NetSuite) TestDelIp(c *C) {
	err := net.AddIp("192.168.0.1/32", "lo")
	c.Assert(err, IsNil)

	err = net.DelIp("192.168.0.1/32", "lo")
	c.Assert(err, IsNil)

	addrs, err := net.GetVips(s.iface)
	c.Assert(err, IsNil)

	deleted := true
	for _, a := range addrs {
		if a.IPNet.String() == "192.168.0.1/32" {
			deleted = false
		}
	}

	c.Assert(deleted, Equals, true)
}