aci

package
v0.0.0-...-c11f831 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ErrAlreadyDiscovered - Can't remove node identity policy - Node TEP-1-102 is already discovered. Please decommission first.
	ErrAlreadyDiscovered = "107"
)

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present.

A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

Types

type AAA

type AAA struct {
	// contains filtered or unexported fields
}

AAA is part of the authentication process that holds authentication attributes

type Building

type Building struct {
	// contains filtered or unexported fields
}

Building ...

func (*Building) AddFloor

func (building *Building) AddFloor(floor *Floor)

AddFloor ...

func (*Building) DeleteFloor

func (building *Building) DeleteFloor(floor *Floor)

DeleteFloor ...

func (*Building) Description

func (l *Building) Description() string

Description resturns a location description.

func (*Building) Floors

func (building *Building) Floors() []*Floor

Floors ...

func (*Building) Name

func (l *Building) Name() string

Name returns the name of a location.

func (*Building) SetCreated

func (l *Building) SetCreated() string

SetCreated sets the status of the location to "created,modified".

func (*Building) SetDeleted

func (l *Building) SetDeleted() string

SetDeleted sets the status of the location to "deleted".

func (*Building) SetDescription

func (l *Building) SetDescription(description string) error

SetDescription validates and sets the description of a location

A site description can be up to 128 characters. It can only contain alphanumeric characters and the following symbols: !#$%()*,-.:;@_{|}~?&+

func (*Building) SetName

func (l *Building) SetName(name string) error

SetName validates and sets the name of a location

A site name can be up to 64 characters and must begin with an alphanumeric character. It can only contain alphanumeric characters and the following symbols: -.:_

func (*Building) Status

func (l *Building) Status() string

Status returns the status of the location.

func (*Building) String

func (l *Building) String() string

type Client

type Client struct {
	BaseURL *url.URL

	Config Config

	// Services used for talking to different parts of the APIC API
	FabricMembership *FabricMembershipService
	Geolocation      *GeolocationService
	// contains filtered or unexported fields
}

Client manages communication with the APIC API

func NewClient

func NewClient(cfg Config) (*Client, error)

NewClient instantiates a new APIC client

func (*Client) Cookie

func (c *Client) Cookie() string

Cookie returns the APIC authentication cookie. Returns an empty string if it has not been set.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)

Do performs APIC client http requests

func (*Client) Login

func (c *Client) Login(ctx context.Context) error

Login authenticates a new APIC session, setting the authentication cookie

func (*Client) NewRequest

func (c *Client) NewRequest(method string, path string, body interface{}) (*http.Request, error)

NewRequest forms an http request for use with an APIC client

func (*Client) Password

func (c *Client) Password() string

Password returns the authentication password of the APIC client

func (*Client) SetCookie

func (c *Client) SetCookie(r *http.Response)

SetCookie sets the value of the APIC authentication cookie It requires the response received from a login request.

func (*Client) SetPassword

func (c *Client) SetPassword(s string)

SetPassword sets the authentication password of the APIC client

func (*Client) SetUsername

func (c *Client) SetUsername(s string)

SetUsername set the authentication username of the APIC client

func (*Client) Username

func (c *Client) Username() string

Username returns the authentication username of the APIC client

type Config

type Config struct {
	Host     string
	Username string
	Password string
}

Config specifies the client connection options

type DecommissionAttributes

type DecommissionAttributes struct {
	TDN                  string `json:"tDn"`                  // "topology/pod-<pod>/node-<nodeID>"
	Status               string `json:"status"`               // createModify
	RemoveFromController string `json:"removeFromController"` // "true"
}

DecommissionAttributes are the attributes of the node to be decomissioned

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is the error response from the APIC server

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response // HTTP response that caused this error
	Errors   []Error        `json:"imdata"` // APIC details on errors
}

ErrorResponse reports any errors caused by an API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type FabricInstance

type FabricInstance struct {
	GeoAttrs `json:"attributes"`
	GeoSites []GeoSiteContainer `json:"children"`
}

FabricInstance ...

type FabricInstanceContainer

type FabricInstanceContainer struct {
	FabricInstance `json:"fabricInst"`
}

FabricInstanceContainer ...

type FabricMembershipService

type FabricMembershipService service

FabricMembershipService handles communication with the fabric membership related methods of the APIC API.

func (*FabricMembershipService) DecommissionNode

func (s *FabricMembershipService) DecommissionNode(ctx context.Context, node *Node) (NodesResponse, error)

DecommissionNode decommisions a fabric membership node

func (*FabricMembershipService) List

func (s *FabricMembershipService) List(ctx context.Context) ([]*Node, error)

List lists all node members of the ACI fabric

func (*FabricMembershipService) NewNode

func (s *FabricMembershipService) NewNode(name, ID, pod, serial, role string) (*Node, error)

NewNode instanstatiates a valid ACI fabric membership node

func (*FabricMembershipService) Update

func (s *FabricMembershipService) Update(ctx context.Context, nodes ...*Node) (NodesResponse, error)

Update ...

type FabricNode

type FabricNode struct {
	NodeResponseAttrs `json:"attributes"`
}

FabricNode is the node identity profile

type FabricNodeContainer

type FabricNodeContainer struct {
	FabricNodeIdentP `json:"fabricNodeIdentP"`
}

FabricNodeContainer is a container for a Fabric Node Identity Profile

type FabricNodeIdentP

type FabricNodeIdentP struct {
	NodeRequestAttrs `json:"attributes"`
}

FabricNodeIdentP is the node identity profile

type Floor

type Floor struct {
	// contains filtered or unexported fields
}

Floor ...

func (*Floor) AddRoom

func (floor *Floor) AddRoom(room *Room)

AddRoom ...

func (*Floor) DeleteRoom

func (floor *Floor) DeleteRoom(room *Room)

DeleteRoom ...

func (*Floor) Description

func (l *Floor) Description() string

Description resturns a location description.

func (*Floor) Name

func (l *Floor) Name() string

Name returns the name of a location.

func (*Floor) Rooms

func (floor *Floor) Rooms() []*Room

Rooms ...

func (*Floor) SetCreated

func (l *Floor) SetCreated() string

SetCreated sets the status of the location to "created,modified".

func (*Floor) SetDeleted

func (l *Floor) SetDeleted() string

SetDeleted sets the status of the location to "deleted".

func (*Floor) SetDescription

func (l *Floor) SetDescription(description string) error

SetDescription validates and sets the description of a location

A site description can be up to 128 characters. It can only contain alphanumeric characters and the following symbols: !#$%()*,-.:;@_{|}~?&+

func (*Floor) SetName

func (l *Floor) SetName(name string) error

SetName validates and sets the name of a location

A site name can be up to 64 characters and must begin with an alphanumeric character. It can only contain alphanumeric characters and the following symbols: -.:_

func (*Floor) Status

func (l *Floor) Status() string

Status returns the status of the location.

func (*Floor) String

func (l *Floor) String() string

type GeoAttrs

type GeoAttrs struct {
	Descr  string `json:"descr,omitempty"`
	DN     string `json:"dn,omitempty"`
	Name   string `json:"name,omitempty"`
	RN     string `json:"rn,omitempty"`
	Status string `json:"status,omitempty"`
}

GeoAttrs ...

type GeoBuilding

type GeoBuilding struct {
	GeoAttrs  `json:"attributes,omitempty"`
	GeoFloors []GeoFloorContainer `json:"children,omitempty"`
}

GeoBuilding ...

type GeoBuildingContainer

type GeoBuildingContainer struct {
	GeoBuilding `json:"geoBuilding,omitempty"`
}

GeoBuildingContainer ...

type GeoFloor

type GeoFloor struct {
	GeoAttrs `json:"attributes,omitempty"`
	GeoRooms []GeoRoomContainer `json:"children,omitempty"`
}

GeoFloor ...

type GeoFloorContainer

type GeoFloorContainer struct {
	GeoFloor `json:"geoFloor,omitempty"`
}

GeoFloorContainer ...

type GeoRack

type GeoRack struct {
	GeoAttrs `json:"attributes,omitempty"`
	GeoNodes []interface{} `json:"children,omitempty"`
}

GeoRack ...

type GeoRackContainer

type GeoRackContainer struct {
	GeoRack `json:"geoRack,omitempty"`
}

GeoRackContainer ...

type GeoRoom

type GeoRoom struct {
	GeoAttrs `json:"attributes,omitempty"`
	GeoRows  []GeoRowContainer `json:"children,omitempty"`
}

GeoRoom ...

type GeoRoomContainer

type GeoRoomContainer struct {
	GeoRoom `json:"geoRoom,omitempty"`
}

GeoRoomContainer ...

type GeoRow

type GeoRow struct {
	GeoAttrs `json:"attributes,omitempty"`
	GeoRacks []GeoRackContainer `json:"children,omitempty"`
}

GeoRow ...

type GeoRowContainer

type GeoRowContainer struct {
	GeoRow `json:"geoRow,omitempty"`
}

GeoRowContainer ...

type GeoSite

type GeoSite struct {
	GeoAttrs     `json:"attributes,omitempty"`
	GeoBuildings []GeoBuildingContainer `json:"children,omitempty"`
}

GeoSite ...

type GeoSiteContainer

type GeoSiteContainer struct {
	GeoSite `json:"geoSite,omitempty"`
}

GeoSiteContainer ...

type GeolocationResponse

type GeolocationResponse struct {
	TotalCount string        `json:"totalCount"`
	Imdata     []interface{} `json:"imdata"`
}

GeolocationResponse ...

type GeolocationService

type GeolocationService service

GeolocationService handles communication with the geolocation related methods of the APIC API.

func (*GeolocationService) ListSites

func (s *GeolocationService) ListSites(ctx context.Context) ([]*Site, error)

ListSites ...

func (*GeolocationService) NewBuilding

func (s *GeolocationService) NewBuilding(name, description string) (*Building, error)

NewBuilding instantiates a Building.

func (*GeolocationService) NewFloor

func (s *GeolocationService) NewFloor(name, description string) (*Floor, error)

NewFloor instantiates a Floor.

func (*GeolocationService) NewRack

func (s *GeolocationService) NewRack(name, description string) (*Rack, error)

NewRack instantiates a Rack.

func (*GeolocationService) NewRoom

func (s *GeolocationService) NewRoom(name, description string) (*Room, error)

NewRoom instantiates a Room.

func (*GeolocationService) NewRow

func (s *GeolocationService) NewRow(name, description string) (*Row, error)

NewRow instantiates a Row.

func (*GeolocationService) NewSite

func (s *GeolocationService) NewSite(name, description string) (*Site, error)

NewSite instantiates a Site.

func (*GeolocationService) UpdateSite

func (s *GeolocationService) UpdateSite(ctx context.Context, site *Site) (GeolocationResponse, error)

UpdateSite ...

type Mapper

type Mapper interface {
	Key() string
	Value() Mapper
}

Mapper wraps basic key/value methods. This is useful for building hashmaps of ACI objects.

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node is an ACI fabric membership node

func (*Node) Equal

func (n *Node) Equal(o *Node) bool

Equal compares n & o and returns whether they are equal or not.

func (*Node) ID

func (n *Node) ID() string

ID returns the node ID

func (*Node) Name

func (n *Node) Name() string

Name returns the node name.

func (*Node) Pod

func (n *Node) Pod() string

Pod returns the id of the pod the node is attached to.

func (*Node) Role

func (n *Node) Role() string

Role returns the role of the node.

func (*Node) Serial

func (n *Node) Serial() string

Serial returns the node's serial number.

func (*Node) SetCreated

func (n *Node) SetCreated() string

SetCreated sets the status of the node to "created,modified".

func (*Node) SetDeleted

func (n *Node) SetDeleted() string

SetDeleted sets the status of the node to "deleted".

func (*Node) SetID

func (n *Node) SetID(id string) error

SetID validates and sets the node ID.

A node ID must be a number between 101 and 4000 inclusive.

func (*Node) SetName

func (n *Node) SetName(name string) error

SetName validates and sets the node name.

A node name can be up to 64 characters and can only contain alphanumeric, hyphen and underscore characters. It must begin and end with an alphanumeric character.

func (*Node) SetPod

func (n *Node) SetPod(id string) error

SetPod validates and sets the id of the pod the node is attached to.

A pod id must be a number between 0 and 255.

func (*Node) SetRole

func (n *Node) SetRole(role string) error

SetRole sets the role of the node. Can only be "leaf" or "spine"

func (*Node) SetSerial

func (n *Node) SetSerial(serial string) error

SetSerial validates and sets the node serial number.

A valid serial number has a maximum length of 16 and contains only letters and numbers.

func (*Node) Status

func (n *Node) Status() string

Status returns the status of the node.

func (*Node) String

func (n *Node) String() string

String returns the string representation of an ACI node

type NodeDecommission

type NodeDecommission struct {
	DecommissionAttributes `json:"attributes"`
}

NodeDecommission describes the node to decommission

type NodeDecommissionContainer

type NodeDecommissionContainer struct {
	NodeDecommission `json:"fabricRsDecommissionNode"`
}

NodeDecommissionContainer is a container for the request to decommission a fabric membership node

type NodeIdentProfContainer

type NodeIdentProfContainer struct {
	NodeIdentityProfile `json:"fabricNodeIdentPol"`
}

NodeIdentProfContainer is a container for a NodeIdentityProfile

type NodeIdentityProfile

type NodeIdentityProfile struct {
	NodeResponseAttrs `json:"attributes"`
	Children          []FabricNodeContainer `json:"children"`
}

NodeIdentityProfile describes the node identity profile

type NodeRequestAttrs

type NodeRequestAttrs struct {
	DN     string `json:"dn,omitempty"`
	Serial string `json:"serial,omitempty"`
	NodeID string `json:"nodeId,omitempty"`
	Name   string `json:"name,omitempty"`
	Role   string `json:"role,omitempty"`
	RN     string `json:"rn,omitempty"`
	Status string `json:"status,omitempty"`
}

NodeRequestAttrs contains all the attributes of an ACI fabric node API request

type NodeResponseAttrs

type NodeResponseAttrs struct {
	DN       string `json:"dn,omitempty"`
	FabricSt string `json:"fabricSt,omitempty"`
	ID       string `json:"id,omitempty"`
	Model    string `json:"model,omitempty"`
	Name     string `json:"name,omitempty"`
	Role     string `json:"role,omitempty"`
	Serial   string `json:"serial,omitempty"`
	Status   string `json:"status,omitempty"`
	UID      string `json:"uid,omitempty"`
	Vendor   string `json:"vendor,omitempty"`
	Version  string `json:"version,omitempty"`
}

NodeResponseAttrs contains all the attributes of an ACI fabric node API response

type NodesImdata

type NodesImdata struct {
	FabricNode `json:"fabricNode"`
}

NodesImdata contains the node in the nodes response structure

type NodesResponse

type NodesResponse struct {
	NodesImdata []NodesImdata `json:"imdata"`
}

NodesResponse contains the response for ACI fabric nodes requests

type Rack

type Rack struct {
	// contains filtered or unexported fields
}

Rack ...

func (*Rack) Description

func (l *Rack) Description() string

Description resturns a location description.

func (*Rack) Name

func (l *Rack) Name() string

Name returns the name of a location.

func (*Rack) SetCreated

func (l *Rack) SetCreated() string

SetCreated sets the status of the location to "created,modified".

func (*Rack) SetDeleted

func (l *Rack) SetDeleted() string

SetDeleted sets the status of the location to "deleted".

func (*Rack) SetDescription

func (l *Rack) SetDescription(description string) error

SetDescription validates and sets the description of a location

A site description can be up to 128 characters. It can only contain alphanumeric characters and the following symbols: !#$%()*,-.:;@_{|}~?&+

func (*Rack) SetName

func (l *Rack) SetName(name string) error

SetName validates and sets the name of a location

A site name can be up to 64 characters and must begin with an alphanumeric character. It can only contain alphanumeric characters and the following symbols: -.:_

func (*Rack) Status

func (l *Rack) Status() string

Status returns the status of the location.

func (*Rack) String

func (l *Rack) String() string

type Room

type Room struct {
	// contains filtered or unexported fields
}

Room ...

func (*Room) AddRow

func (room *Room) AddRow(row *Row)

AddRow ...

func (*Room) DeleteRow

func (room *Room) DeleteRow(row *Row)

DeleteRow ...

func (*Room) Description

func (l *Room) Description() string

Description resturns a location description.

func (*Room) Name

func (l *Room) Name() string

Name returns the name of a location.

func (*Room) Rows

func (room *Room) Rows() []*Row

Rows ...

func (*Room) SetCreated

func (l *Room) SetCreated() string

SetCreated sets the status of the location to "created,modified".

func (*Room) SetDeleted

func (l *Room) SetDeleted() string

SetDeleted sets the status of the location to "deleted".

func (*Room) SetDescription

func (l *Room) SetDescription(description string) error

SetDescription validates and sets the description of a location

A site description can be up to 128 characters. It can only contain alphanumeric characters and the following symbols: !#$%()*,-.:;@_{|}~?&+

func (*Room) SetName

func (l *Room) SetName(name string) error

SetName validates and sets the name of a location

A site name can be up to 64 characters and must begin with an alphanumeric character. It can only contain alphanumeric characters and the following symbols: -.:_

func (*Room) Status

func (l *Room) Status() string

Status returns the status of the location.

func (*Room) String

func (l *Room) String() string

type Row

type Row struct {
	// contains filtered or unexported fields
}

Row ...

func (*Row) AddRack

func (row *Row) AddRack(rack *Rack)

AddRack ...

func (*Row) DeleteRack

func (row *Row) DeleteRack(rack *Rack)

DeleteRack ...

func (*Row) Description

func (l *Row) Description() string

Description resturns a location description.

func (*Row) Name

func (l *Row) Name() string

Name returns the name of a location.

func (*Row) Racks

func (row *Row) Racks() []*Rack

Racks ...

func (*Row) SetCreated

func (l *Row) SetCreated() string

SetCreated sets the status of the location to "created,modified".

func (*Row) SetDeleted

func (l *Row) SetDeleted() string

SetDeleted sets the status of the location to "deleted".

func (*Row) SetDescription

func (l *Row) SetDescription(description string) error

SetDescription validates and sets the description of a location

A site description can be up to 128 characters. It can only contain alphanumeric characters and the following symbols: !#$%()*,-.:;@_{|}~?&+

func (*Row) SetName

func (l *Row) SetName(name string) error

SetName validates and sets the name of a location

A site name can be up to 64 characters and must begin with an alphanumeric character. It can only contain alphanumeric characters and the following symbols: -.:_

func (*Row) Status

func (l *Row) Status() string

Status returns the status of the location.

func (*Row) String

func (l *Row) String() string

type Site

type Site struct {
	// contains filtered or unexported fields
}

Site ...

func (*Site) AddBuilding

func (site *Site) AddBuilding(building *Building)

AddBuilding ...

func (*Site) Buildings

func (site *Site) Buildings() []*Building

Buildings ...

func (*Site) DeleteBuilding

func (site *Site) DeleteBuilding(building *Building)

DeleteBuilding ...

func (*Site) Description

func (l *Site) Description() string

Description resturns a location description.

func (*Site) Name

func (l *Site) Name() string

Name returns the name of a location.

func (*Site) SetCreated

func (l *Site) SetCreated() string

SetCreated sets the status of the location to "created,modified".

func (*Site) SetDeleted

func (l *Site) SetDeleted() string

SetDeleted sets the status of the location to "deleted".

func (*Site) SetDescription

func (l *Site) SetDescription(description string) error

SetDescription validates and sets the description of a location

A site description can be up to 128 characters. It can only contain alphanumeric characters and the following symbols: !#$%()*,-.:;@_{|}~?&+

func (*Site) SetName

func (l *Site) SetName(name string) error

SetName validates and sets the name of a location

A site name can be up to 64 characters and must begin with an alphanumeric character. It can only contain alphanumeric characters and the following symbols: -.:_

func (*Site) Status

func (l *Site) Status() string

Status returns the status of the location.

func (*Site) String

func (l *Site) String() string

Jump to

Keyboard shortcuts

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