nx

package
v0.0.0-...-0838267 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2017 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
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`
)
View Source
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

func (c *Client) AddTrunkVlan(ifName string,
	allowed string,
	native string) error

AddTrunkVlan - Adds trunk/native Vlan to interface

func (*Client) AddVlan

func (c *Client) AddVlan(vlanId string, vni string) error

func (*Client) DeleteVlan

func (c *Client) DeleteVlan(id string) error

func (*Client) GetInterface

func (c *Client) GetInterface(ifName string) ([]map[string]interface{}, error)

func (*Client) GetVlan

func (c *Client) GetVlan(id string) ([]map[string]interface{}, error)

func (*Client) Login

func (c *Client) Login() error

Login opens a new session into Nexus Switch using the API aaaLogin.

func (*Client) Logout

func (c *Client) Logout()

Logout closes a session to Nexus Switch using the API aaaLogout.

func (*Client) Refresh

func (c *Client) Refresh() error

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

func (c *Client) RefreshTimeout() time.Duration

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().

func (*Client) SplitInterfaceName

func (c *Client) SplitInterfaceName(ifName string) (string, string, error)

SplitInterfaceName separates the interface type and id from interface name Ex: ethernet:1/12 results in two fields: ethernet 1/12

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL