Documentation ¶
Overview ¶
The arista package contains several methods which allow an application to easily send requests to an Arista switch which is configured with its HTTPs API enabled.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arista_api ¶
type Arista_api struct {
// contains filtered or unexported fields
}
func Mk_aristaif ¶
func Mk_aristaif(usr *string, pw *string, host *string, port *string) (aif *Arista_api)
Mk_aristaif creates a small object which is then used for all requests to a specific switch.
func (*Arista_api) Get_interfaces ¶
func (aif *Arista_api) Get_interfaces(ifstate string) (ifmap map[string]*Swif, err error)
Get_interfaces sends a request to the switch and generate a map of single interface structs that is indexed by the interface name. The single interface struct contains very limited information compared to what is returned by the switch.
func (*Arista_api) Submit_req ¶
func (aif *Arista_api) Submit_req(cmds *string, text_req bool) (raw_json []byte, err error)
Submit_req sends a command set to the switch and returns the raw result. If text request is true, we change the format to text in the request. (There are some Arista commands that do not support returning json output and thus the text_req parameter must be set to true in order for the command to work. Err will be non-nil if any error was detected.
The cmds parameter is a chain of commands to be executed by the switch API. Each command must be supplied as a quoted substring, and if multiple substrings are contained in the string they must be comma separated. For example, the following command string makes a query to enable openflow:
`"configure", "openstack", "no shutdown"`
Which has the effect of entering all three of those commands on the Arista command line.
type Swif ¶
type Swif struct { Name string // all fields are exposed since caller will likely be using them directly State string Addr string Mtu float64 Bandwidth float64 }
Single switch interface data. This struct contains a very limited amount of information that is returned by the switch for a single interface (port). All fields are available directly to the user.