aci

package
v0.0.0-...-def5254 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2017 License: MIT Imports: 16 Imported by: 1

Documentation

Overview

Package aci is a Go module for interacting with Cisco ACI using API calls.

Example

package main

import (
	"fmt"
	"github.com/udhos/acigo/aci"
)

func main() {

	a, errNew := aci.New(aci.ClientOptions{})
	if errNew != nil {
		fmt.Printf("login new client error: %v\n", errNew)
		return
	}

	// Since credentials have not been specified explicitly under ClientOptions,
	// Login() will use env vars: APIC_HOSTS=host, APIC_USER=username, APIC_PASS=pwd
	errLogin := a.Login()
	if errLogin != nil {
		fmt.Printf("login error: %v\n", errLogin)
		return
	}

	errAdd := a.TenantAdd("tenant-example", "")
	if errAdd != nil {
		fmt.Printf("tenant add error: %v\n", errAdd)
		return
	}

	errLogout := a.Logout()
	if errLogout != nil {
		fmt.Printf("logout error: %v\n", errLogout)
		return
	}
}

See also

Cisco APIC REST API User Guide: http://www.cisco.com/c/en/us/td/docs/switches/datacenter/aci/apic/sw/1-x/api/rest/b_APIC_RESTful_API_User_Guide.html

APIC Management Information Model Reference: https://developer.cisco.com/media/mim-ref

Index

Constants

View Source
const (
	ApicHosts = "APIC_HOSTS" // Env var. List of apic hostnames. Example: "1.1.1.1" or "1.1.1.1,2.2.2.2,3.3.3.3" or "apic1,4.4.4.4"
	ApicUser  = "APIC_USER"  // Env var. Username. Example: "joe"
	ApicPass  = "APIC_PASS"  // Env var. Password. Example: "joesecret"
)

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 APIC client
	// contains filtered or unexported fields
}

Client is an instance for interacting with ACI using API calls.

func New

func New(o ClientOptions) (*Client, error)

New creates a new Client instance for interacting with ACI using API calls.

func (*Client) ApplicationEPGAdd

func (c *Client) ApplicationEPGAdd(tenant, applicationProfile, bridgeDomain, epg, descr string) error

ApplicationEPGAdd creates a new application EPG in an application profile and attached to a bridge domain.

func (*Client) ApplicationEPGDel

func (c *Client) ApplicationEPGDel(tenant, applicationProfile, epg string) error

ApplicationEPGDel deletes an existing application EPG from an application profile.

func (*Client) ApplicationEPGList

func (c *Client) ApplicationEPGList(tenant, applicationProfile string) ([]map[string]interface{}, error)

ApplicationEPGList retrieves the list of application EPGs in an application profile.

func (*Client) ApplicationProfileAdd

func (c *Client) ApplicationProfileAdd(tenant, name, descr string) error

ApplicationProfileAdd creates a new application profile in a tenant.

func (*Client) ApplicationProfileDel

func (c *Client) ApplicationProfileDel(tenant, name string) error

ApplicationProfileDel deletes an existing application profile from a tenant.

func (*Client) ApplicationProfileList

func (c *Client) ApplicationProfileList(tenant string) ([]map[string]interface{}, error)

ApplicationProfileList retrieves application profiles from a tenant.

func (*Client) BridgeDomainAdd

func (c *Client) BridgeDomainAdd(tenant, bd, descr string) error

BridgeDomainAdd creates a new bridge domain in a tenant.

func (*Client) BridgeDomainDel

func (c *Client) BridgeDomainDel(tenant, bd string) error

BridgeDomainDel deletes an existing bridge domain from a tenant.

func (*Client) BridgeDomainL3ExtOutAdd

func (c *Client) BridgeDomainL3ExtOutAdd(tenant, bd, out string) error

BridgeDomainL3ExtOutAdd attaches a new L3 External Outside in a bridge domain.

func (*Client) BridgeDomainL3ExtOutDel

func (c *Client) BridgeDomainL3ExtOutDel(tenant, bd, out string) error

BridgeDomainL3ExtOutDel detaches an existing L3 External Outside from a bridge domain.

func (*Client) BridgeDomainL3ExtOutList

func (c *Client) BridgeDomainL3ExtOutList(tenant, bd string) ([]map[string]interface{}, error)

BridgeDomainL3ExtOutList retrieves the list of L3 External Outsides attached to a bridge domain.

func (*Client) BridgeDomainList

func (c *Client) BridgeDomainList(tenant string) ([]map[string]interface{}, error)

BridgeDomainList retrieves the list of bridge domains from a tenant.

func (*Client) BridgeDomainSubnetAdd

func (c *Client) BridgeDomainSubnetAdd(tenant, bd, subnet, descr string) error

BridgeDomainSubnetAdd creates a new subnet in a bridge domain.

func (*Client) BridgeDomainSubnetDel

func (c *Client) BridgeDomainSubnetDel(tenant, bd, subnet string) error

BridgeDomainSubnetDel deletes an existing subnet from a bridge domain.

func (*Client) BridgeDomainSubnetGet

func (c *Client) BridgeDomainSubnetGet(tenant, bd, subnet string) ([]map[string]interface{}, error)

BridgeDomainSubnetGet retrieves specific subnet from a bridge domain.

func (*Client) BridgeDomainSubnetList

func (c *Client) BridgeDomainSubnetList(tenant, bd string) ([]map[string]interface{}, error)

BridgeDomainSubnetList retrieves the list of subnets from a bridge domain.

func (*Client) BridgeDomainSubnetScopeGet

func (c *Client) BridgeDomainSubnetScopeGet(tenant, bd, subnet string) (string, error)

BridgeDomainSubnetScopeGet retrieves the scope from a bridge domain subnet.

func (*Client) BridgeDomainSubnetScopeSet

func (c *Client) BridgeDomainSubnetScopeSet(tenant, bd, subnet, scope string) error

BridgeDomainSubnetScopeSet defines the scope for a bridge domain subnet.

func (*Client) BridgeDomainVrfGet

func (c *Client) BridgeDomainVrfGet(tenant, bd string) (string, error)

BridgeDomainVrfGet retrieves the VRF for a bridge domain.

func (*Client) BridgeDomainVrfSet

func (c *Client) BridgeDomainVrfSet(tenant, bd, vrf string) error

BridgeDomainVrfSet defines the VRF for a bridge domain.

func (*Client) ExportConfigurationAdd

func (c *Client) ExportConfigurationAdd(config, scheduler, remoteLocation, descr string) error

ExportConfigurationAdd creates a new export configuration.

func (*Client) ExportConfigurationDel

func (c *Client) ExportConfigurationDel(config string) error

ExportConfigurationDel deletes an existing export configuration.

func (*Client) ExportConfigurationList

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

ExportConfigurationList retrieves the list of export configurations.

func (*Client) ExportConfigurationRemoteLocationGet

func (c *Client) ExportConfigurationRemoteLocationGet(config string) (map[string]interface{}, error)

ExportConfigurationRemoteLocationGet retrieves the remote location attached to an export configuration.

func (*Client) ExportConfigurationRun

func (c *Client) ExportConfigurationRun(config string) error

ExportConfigurationRun executes the export configuration now.

func (*Client) ExportConfigurationSchedulerGet

func (c *Client) ExportConfigurationSchedulerGet(config string) (map[string]interface{}, error)

ExportConfigurationSchedulerGet retrieves the scheduler attached to an export configuration.

func (*Client) ExternalRoutedDomainAdd

func (c *Client) ExternalRoutedDomainAdd(dom string) error

ExternalRoutedDomainAdd creates a new L3 External Domain.

func (*Client) ExternalRoutedDomainDel

func (c *Client) ExternalRoutedDomainDel(dom string) error

ExternalRoutedDomainDel deletes an existing L3 External Domain.

func (*Client) ExternalRoutedDomainList

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

ExternalRoutedDomainList retrieves the list of L3 External Domains.

func (*Client) L3ExtOutAdd

func (c *Client) L3ExtOutAdd(tenant, out, descr string) error

L3ExtOutAdd creates a new external routed network in a tenant.

func (*Client) L3ExtOutDel

func (c *Client) L3ExtOutDel(tenant, out string) error

L3ExtOutDel deletes an external routed network from a tenant.

func (*Client) L3ExtOutL3ExtDomainGet

func (c *Client) L3ExtOutL3ExtDomainGet(tenant, out string) (string, error)

L3ExtOutL3ExtDomainGet retrieves the external routed domain for an external routed network.

func (*Client) L3ExtOutL3ExtDomainSet

func (c *Client) L3ExtOutL3ExtDomainSet(tenant, out, domain string) error

L3ExtOutL3ExtDomainSet defines the external routed domain for an external routed network.

func (*Client) L3ExtOutList

func (c *Client) L3ExtOutList(tenant string) ([]map[string]interface{}, error)

L3ExtOutList retrieves the list of external routed networks from a tenant.

func (*Client) L3ExtOutVrfGet

func (c *Client) L3ExtOutVrfGet(tenant, out string) (string, error)

L3ExtOutVrfGet retrieves the VRF for an external routed network.

func (*Client) L3ExtOutVrfSet

func (c *Client) L3ExtOutVrfSet(tenant, out, vrf string) error

L3ExtOutVrfSet defines the VRF for an external routed network.

func (*Client) Login

func (c *Client) Login() error

Login opens a new session into APIC using the API aaaLogin.

func (*Client) Logout

func (c *Client) Logout() error

Logout closes a session to APIC using the API aaaLogout.

func (*Client) NodeList

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

NodeList retrieves the list of top level system elements (APICs, spines, leaves).

func (*Client) PhysicalDomainAdd

func (c *Client) PhysicalDomainAdd(name, vlanpoolName, vlanpoolMode string) error

PhysicalDomainAdd creates a new physical domain.

func (*Client) PhysicalDomainDel

func (c *Client) PhysicalDomainDel(name string) error

PhysicalDomainDel deletes an existing physical domain.

func (*Client) PhysicalDomainList

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

PhysicalDomainList retrieves the list of physical domains.

func (*Client) PhysicalDomainVlanPoolGet

func (c *Client) PhysicalDomainVlanPoolGet(name string) (string, error)

PhysicalDomainVlanPoolGet retrieves the VLAN pool for the physical domain.

func (*Client) Refresh

func (c *Client) Refresh() error

Refresh resets the session timer on APIC 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 APIC. In order to keep the session active, Refresh() must be called at a period lower than the timeout reported by RefreshTimeout().

func (*Client) RemoteLocationAdd

func (c *Client) RemoteLocationAdd(location, host, protocol, remotePort, remotePath, username, password, descr string) error

RemoteLocationAdd creates a new remote location.

func (*Client) RemoteLocationDel

func (c *Client) RemoteLocationDel(location string) error

RemoteLocationDel deletes an existing remote location.

func (*Client) RemoteLocationList

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

RemoteLocationList retrieves the list of remote locations.

func (*Client) TenantAdd

func (c *Client) TenantAdd(name, descr string) error

TenantAdd creates a new tenant.

func (*Client) TenantDel

func (c *Client) TenantDel(name string) error

TenantDel deletes an existing tenant.

func (*Client) TenantList

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

TenantList retrieves the list of tenants.

func (*Client) TenantSubscribe

func (c *Client) TenantSubscribe() (string, error)

TenantSubscribe subscribes to tenant notifications. The subscriptionId is returned.

func (*Client) TenantSubscriptionRefresh

func (c *Client) TenantSubscriptionRefresh(subscriptionId string) error

TenantSubscriptionRefresh refreshes a subscription. In order to keep the subscription active, TenantSubscriptionRefresh() must be called at a period lower than the timeout reported by TenantSubscriptionTimeout().

func (*Client) TenantSubscriptionTimeout

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

TenantSubscriptionTimeout gets the subscription timeout. In order to keep the subscription active, TenantSubscriptionRefresh() must be called at a period lower than the timeout reported by TenantSubscriptionTimeout().

func (*Client) VlanPoolAdd

func (c *Client) VlanPoolAdd(name, mode, descr string) error

VlanPoolAdd creates a new VLAN pool.

func (*Client) VlanPoolDel

func (c *Client) VlanPoolDel(name, mode string) error

VlanPoolDel deletes an existing VLAN pool.

func (*Client) VlanPoolList

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

VlanPoolList retrieves the list of VLAN pools.

func (*Client) VlanRangeAdd

func (c *Client) VlanRangeAdd(vlanpoolName, vlanpoolMode, from, to string) error

VlanRangeAdd creates a new VLAN range for a VLAN pool.

func (*Client) VlanRangeDel

func (c *Client) VlanRangeDel(vlanpoolName, vlanpoolMode, from, to string) error

VlanRangeDel deletes an existing VLAN range from a VLAN pool.

func (*Client) VlanRangeList

func (c *Client) VlanRangeList(vlanpoolName, vlanpoolMode string) ([]map[string]interface{}, error)

VlanRangeList retrieves the list of VLAN ranges from a VLAN pool.

func (*Client) VrfAdd

func (c *Client) VrfAdd(tenant, vrf, descr string) error

VrfAdd creates a new VRF in a tenant.

func (*Client) VrfDel

func (c *Client) VrfDel(tenant, vrf string) error

VrfDel deletes an existing VRF from a tenant.

func (*Client) VrfList

func (c *Client) VrfList(tenant string) ([]map[string]interface{}, error)

VrfList retrieves the list of VRFs from a tenant.

func (*Client) WebsocketOpen

func (c *Client) WebsocketOpen() error

WebsocketOpen opens websocket for receiving subscription information.

func (*Client) WebsocketReadJSON

func (c *Client) WebsocketReadJSON(v interface{}) error

WebsocketReadJSON reads subscription message from websocket.

type ClientOptions

type ClientOptions struct {
	Hosts []string // List of apic hostnames. If unspecified, env var APIC_HOSTS is used.
	User  string   // Username. If unspecified, env var APIC_USER is used.
	Pass  string   // Password. If unspecified, env var APIC_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