diff options
author | Wataru Ishida <ishida.wataru@lab.ntt.co.jp> | 2017-04-01 11:10:26 -0400 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-04-02 14:17:14 +0900 |
commit | f8b9b0a7ed24744cd7e3ea7b56575ef0b428eb69 (patch) | |
tree | 57fa16b1bb41892998b4cdcc44ed798a30766842 /client/client.go | |
parent | d5be199501fdd0e3d1ee9811f38bc2bc59718594 (diff) |
cli: don't calculate # of advertised routes when not necessary
Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'client/client.go')
-rw-r--r-- | client/client.go | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/client/client.go b/client/client.go index 935a9fa1..1dddcb56 100644 --- a/client/client.go +++ b/client/client.go @@ -127,8 +127,8 @@ func (cli *Client) EnableZebra(c *config.Zebra) error { return err } -func (cli *Client) getNeighbor(name string, afi int, vrf string) ([]*config.Neighbor, error) { - ret, err := cli.cli.GetNeighbor(context.Background(), &api.GetNeighborRequest{EnableAdvertised: name != ""}) +func (cli *Client) getNeighbor(name string, afi int, vrf string, enableAdvertised bool) ([]*config.Neighbor, error) { + ret, err := cli.cli.GetNeighbor(context.Background(), &api.GetNeighborRequest{EnableAdvertised: enableAdvertised}) if err != nil { return nil, err } @@ -158,19 +158,23 @@ func (cli *Client) getNeighbor(name string, afi int, vrf string) ([]*config.Neig } func (cli *Client) ListNeighbor() ([]*config.Neighbor, error) { - return cli.getNeighbor("", 0, "") + return cli.getNeighbor("", 0, "", false) } func (cli *Client) ListNeighborByTransport(afi int) ([]*config.Neighbor, error) { - return cli.getNeighbor("", afi, "") + return cli.getNeighbor("", afi, "", false) } func (cli *Client) ListNeighborByVRF(vrf string) ([]*config.Neighbor, error) { - return cli.getNeighbor("", 0, vrf) + return cli.getNeighbor("", 0, vrf, false) } -func (cli *Client) GetNeighbor(name string) (*config.Neighbor, error) { - ns, err := cli.getNeighbor(name, 0, "") +func (cli *Client) GetNeighbor(name string, options ...bool) (*config.Neighbor, error) { + enableAdvertised := false + if len(options) > 0 && options[0] { + enableAdvertised = true + } + ns, err := cli.getNeighbor(name, 0, "", enableAdvertised) if err != nil { return nil, err } |