Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) AddTrunkVlan(ifName string, allowed string, native string) error
- func (c *Client) AddVlan(vlanId string, vni string) error
- func (c *Client) DeleteVlan(id string) error
- func (c *Client) GetInterface(ifName string) ([]map[string]interface{}, error)
- func (c *Client) GetVlan(id string) ([]map[string]interface{}, error)
- func (c *Client) Login() error
- func (c *Client) Logout()
- func (c *Client) Refresh() error
- func (c *Client) RefreshTimeout() time.Duration
- func (c *Client) SplitInterfaceName(ifName string) (string, string, error)
- type ClientOptions
Constants ¶
const ( // Single URI Definition for Add, Replace, interface Delete attributes ConfigRootURI = "/api/mo.json" // Body definitions Start TopBegin = `{"topSystem": { "children": [ ` TopEnd = `]}}` // URI Definition for Get // Where %s is 'l1PhysIf' for Enet and 'pcAggrIf' for Port Channel InterfaceAll = "/api/mo/sys/intf.json?query-target=subtree&target-subtree-class=%s" // Where %s is interface id. Ex: 1/12 for ethernet or 55 for port-channel InterfaceEnetURI = "/api/mo/sys/intf/phys-[eth%s].json" InterfacePcURI = "/api/mo/sys/intf/aggr-[po%s].json" // switchport mode <which-mode> Where id is interface-id ex: po5 eth1/3 // modes are trunk, access, or edge SwitchPortMode = `` /* 194-byte string literal not displayed */ TrunkMode = "trunk" AccessMode = "access" EdgeMode = "edge" // switchport trunk native vlan 129 // switchport trunk allowed vlan 129,136 // 1st %s is pcAggrIf for Port channel and l1PhysIf for ethernet // 2nd&3rd %s is interface-id ex: po5 eth1/3 // 4th %s is TrunkMode (above) // 5th %s is trunkVlans and nativeVlan config (below) IfEntity = `{ "interfaceEntity": { "children": [ { "%s": { "attributes": { "id": "%s%s", "mode": "%s", %s } } } ] } }` PcTag = "pcAggrIf" EnetTag = "l1PhysIf" PcPfx = "po" EnetPfx = "eth" NativeVlan = `"nativeVlan": "vlan-%s"` NoNativeVlan = `"nativeVlan": ""` TrunkVlans = `"trunkVlans": "%s"` // URI Definition for Get, Delete VlanURI = `/api/mo/sys/bd/bd-[vlan-%s].json` AllVlanURI = `/api/mo/sys/bd/.json?query-target=subtree&target-subtree-class=l2BD` )
const ( NexusHosts = "NEXUS_HOSTS" // Env var. List of Nexus hostnames or ip addresses. // Example: "1.1.1.1" or "1.1.1.1,2.2.2.2,3.3.3.3" or // "hostnamea,4.4.4.4" NexusUser = "NEXUS_USER" // Env var. Username. Example: "joe" NexusPass = "NEXUS_PASS" // Env var. Password. Example: "joesecret" NexusDebug = "NEXUS_DEBUG" // Env var. Debug. )
Environment variables used as default parameters.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Opt ClientOptions // Options for the Nexus client // contains filtered or unexported fields }
Client is an instance for interacting with Nexus switch using API calls.
func New ¶
func New(o ClientOptions) (*Client, error)
New creates a new Client instance for interacting with Nexus switch using API calls.
func (*Client) AddTrunkVlan ¶
AddTrunkVlan - Adds trunk/native Vlan to interface
func (*Client) DeleteVlan ¶
func (*Client) GetInterface ¶
func (*Client) Logout ¶
func (c *Client) Logout()
Logout closes a session to Nexus Switch using the API aaaLogout.
func (*Client) Refresh ¶
Refresh resets the session timer on Nexus Switch using the API aaaRefresh. In order to keep the session active, Refresh() must be called at a period lower than the timeout reported by RefreshTimeout().
func (*Client) RefreshTimeout ¶
RefreshTimeout gets the session timeout reported by last API call to Nexus Switch. In order to keep the session active, Refresh() must be called at a period lower than the timeout reported by RefreshTimeout().
type ClientOptions ¶
type ClientOptions struct { Hosts []string // List of apic hostnames. If unspecified, env var NEXUS_HOSTS is used. User string // Username. If unspecified, env var NEXUS_USER is used. Pass string // Password. If unspecified, env var NEXUS_PASS is used. Debug bool // Debug enables verbose debugging messages to console. }
ClientOptions is used to specify options for the Client.