Documentation ¶
Overview ¶
Package client provides helper functions for OpenConfig CLI tools.
Index ¶
Constants ¶
const (
// HostnameArg is the value to be replaced by the actual hostname
HostnameArg = "HOSTNAME"
)
Variables ¶
This section is empty.
Functions ¶
func ParseFlags ¶
func ParseFlags() (username string, password string, subscriptions, addrs []string, opts []grpc.DialOption)
ParseFlags registers some additional common flags, parses the flags, and returns the resulting gRPC options, and other settings to connect to the gRPC interface.
func ParseHostnames ¶
ParseHostnames parses a comma-separated list of names and replaces HOSTNAME with the current hostname in it
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a connected gRPC client
func New ¶
func New(username, password, addr string, opts []grpc.DialOption) *Client
New creates a new gRPC client and connects it
func (*Client) Get ¶
func (c *Client) Get(path string) []*openconfig.Notification
Get sends a get request and returns the responses
func (*Client) Subscribe ¶
func (c *Client) Subscribe(wg *sync.WaitGroup, subscriptions []string, publish PublishFunc)
Subscribe sends subscriptions, and consumes responses. The given publish function is used to publish SubscribeResponses received for the given subscriptions, when connected to the given host, with the given user/pass pair, or the client-side cert specified in the gRPC opts. This function does not normally return so it should probably be run in its own goroutine. When this function returns, the given WaitGroup is marked as done.
type PublishFunc ¶
PublishFunc is the method to publish responses