Esempio n. 1
0
func lbInterface(ncc client.NCC) client.LBInterface {
	iface := *testIface
	nodeIP := net.ParseIP(*nodeIPStr)
	nodeIPv6 := net.ParseIP(*nodeIPv6Str)
	if nodeIP == nil && nodeIPv6 == nil {
		log.Fatalf("Invalid node IP/IPv6 - %q/%q", *nodeIPStr, *nodeIPv6Str)
	}

	unicastVIP := net.ParseIP(*unicastVIPStr)
	if unicastVIP == nil {
		log.Fatalf("Invalid unicast VIP - %q", *unicastVIPStr)
	}
	vip := net.ParseIP(*clusterVIPStr)
	if vip == nil {
		log.Fatalf("Invalid cluster VIP - %q", *clusterVIPStr)
	}
	if *vrID < 1 || *vrID > 255 {
		log.Fatalf("Invalid VRID - %q", *vrID)
	}
	rtID := uint8(*routingTableID)
	// TODO(jsing): Change this to allow both IPv4 and IPv6 addresses.
	lbCfg := &types.LBConfig{
		ClusterVIP:     seesaw.Host{IPv4Addr: vip},
		Node:           seesaw.Host{IPv4Addr: nodeIP, IPv6Addr: nodeIPv6},
		DummyInterface: "dummy0",
		NodeInterface:  "eth0",
		RoutingTableID: rtID,
		VRID:           uint8(*vrID),
	}
	lb := ncc.NewLBInterface(iface, lbCfg)
	if err := lb.Init(); err != nil {
		log.Fatalf("Failed to initialise the LB interface: %v", err)
	}
	return lb
}