Exemplo n.º 1
0
func (cli *LBClient) SVCGet(feL3n4 types.L3n4Addr) (*types.LBSVC, error) {
	key := lbmap.L3n4Addr2ServiceKey(feL3n4)
	svc, err := lbmap.LookupService(key)
	if err != nil {
		return nil, err
	}
	besLen := 0
	if key.IsIPv6() {
		besLen = int(svc.(*lbmap.Service6Value).Count)
	} else {
		besLen = int(svc.(*lbmap.Service4Value).Count)
	}
	bes := []types.L3n4Addr{}
	svcID := types.ServiceID(0)
	for i := 1; i <= besLen; i++ {
		key.SetBackend(i)
		svc, err := lbmap.LookupService(key)
		if err != nil {
			return nil, err
		}
		sv, err := lbmap.ServiceValue2L3n4Addr(key, svc)
		if err != nil {
			return nil, err
		}
		bes = append(bes, *sv)
		if i == 1 {
			svcID = types.ServiceID(svc.RevNatKey().GetKey())
		}
	}
	return &types.LBSVC{
		FE: types.L3n4AddrID{
			ID:       svcID,
			L3n4Addr: feL3n4,
		},
		BES: bes,
	}, nil
}
Exemplo n.º 2
0
func (cli *LBClient) SVCDelete(feL3n4 types.L3n4Addr) error {
	return lbmap.DeleteService(lbmap.L3n4Addr2ServiceKey(feL3n4))
}