cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3473
Views
3
Helpful
0
Comments
amoherek
Cisco Employee
Cisco Employee

This blog post was written by Michael Earls

While working in IT, I came across a program called Expect, Expect is a tool for automating interactive applications such as telnet, ftp, password, fsck, login, tip, etc. Expect is also useful for testing out theses same applications, I'm not a professional programer or ever played one on TV. At the time, I was looking for a way to automate route and switch backups, push out small configuration templates for SNMP and modify the backdoor passwords once a month for security. This simple program introduced me to the world of programing and how to automate boring or mundane tasks. The world of programming has changed with different languages with similar format but the tasks are still the same. In the next few sections, I will show the associated Cisco ACI (Application-Centric Infrastructure) device command line and the API with the given output.

If your new to Python or new to setting up your own environment with the ACI Toolkit associated functions, please reference this link (ACI-Toolkit).

In this Part 1 series we will cover a few basic commands to show the power of the API and associated device command line.

Accessing the CLI:

Access the secure shell (SSH) client, open an SSH connection to the out-of-band management IP address that was configured durning the initial setup.

$ ssh apic-admin@10.10.10.10

Application Policy Infrastructure Controller
apic-admin@10.10.10.10's password:

In the example below we are pulling the local physical interface stats on Leaf-101 Ethernet Slot 1 Port 18.

~> show interface brief leaf-101 physical eth1:18

# layer-1-physical-interface-configuration

interface            : eth1/18

admin-state          : up

usage                : epg,infra

bandwidth            : 0

delay                : 1

mdix                 : auto

medium               : broadcast

mtu                  : 9000

router-mac           : n/a

speed                : 10-gbps

auto-negotiation     : on

dot1q-ether-type     : 0x8100

layer                : switched

mode                 : trunk

description          :

ethpmcfgfailedbmp    :

ethpmcfgfailedts     : 00:00:00:00.000

ethpmcfgstate        : 0

name                 :

switchingstate       : enabled

cfg-access-vlan      : vlan-13

cfg-native-vlan      : unknown

bundle-index         : po3

oper-duplex          : full

oper-state           : up

oper-state-reason    : connected

backplane-mac        : 50:87:89:A2:56:04

last-link-st-change  : 2015-11-30T17:47:40.311-06:00

oper-router-mac      : 00:00:00:00:00:00

oper-mdix            : auto

oper-mode            : trunk

oper-speed           : 10-gbps

reset-counter        : 8

load-interval-1      : 30

load-interval-2      : 300

load-interval-3      : 0

eee-lat              : variable

eee-lpi              : aggressive

eee-state            : not-applicable

portcap-speed        : 1000,10000,auto

channeling-state     : channeling ~>

Here is the same command using the REST API

url: 10.10.10.10/api/node/mo/topology/pod-1/node-101/sys/phys-[eth1/18]/HDeqptEgrTotal5min-0.json

{

"bytesAvg": "244",

"bytesCum": "38591693",

"bytesMax": "3232",

"bytesMin": "0",

"bytesPer": "7321",

"bytesRate": "24.373760",

"bytesRateAvg": "26.076521",

"bytesRateMax": "355.008787",

"bytesRateMin": "0.000000",

"bytesRateSpct": "0",

"bytesRateThr": "",

"bytesRateTr": "15.957305",

"bytesSpct": "0",

"bytesThr": "",

"bytesTr": "4128",

"childAction": "",

"cnt": "30",

"dn": "topology/pod-1/node-101/sys/phys-[eth1/18]/HDeqptEgrTotal5min-0",

"index": "0",

"lastCollOffset": "300",

"modTs": "never",

"pktsAvg": "1",

"pktsCum": "316068",

"pktsMax": "35",

"pktsMin": "0",

"pktsPer": "59",

"pktsRate": "0.196428",

"pktsRateAvg": "0.212366",

"pktsRateMax": "3.844464",

"pktsRateMin": "0.000000",

"pktsRateSpct": "0",

"pktsRateThr": "",

"pktsRateTr": "0.151017",

"pktsSpct": "0",

"pktsThr": "",

"pktsTr": "40",

"repIntvEnd": "2015-12-02T09:19:45.187-06:00",

"repIntvStart": "2015-12-02T09:14:44.823-06:00",

"status": "",

"utilAvg": "0",

"utilMax": "0",

"utilMin": "0",

"utilSpct": "0",

"utilThr": "",

"utilTr": "0"

}

In this example we are issuing a show version command to find out software version, node names, node type, etc.

~> node type   node id  node name   version

----------  -------  ----------  --------------

controller  1        apic-m1-07  1.1(2h)

controller  2        apic-m1-08  1.1(2h)

controller  3        apic-m1-09  1.1(2h)

leaf        101      leaf-101    n9000-11.1(2h)

leaf        102      leaf-102    n9000-11.1(2h)

spine       111      spine-111   n9000-11.1(2h)

spine       112      spine-112   n9000-11.1(2h)

~>

Here is the same command using the REST API expect it shows a ton more relevant data on the given Leafs and Spine nodes.

url: 10.10.10.10/api/node/class/topSystem.json?query-target=subtree&target-subtree-class=topSystem,eqptCh,firmwareRunning,firmwareCtrlrRunning,maintUpgJob&_dc=1449090003070

{

  "response": {

  "totalCount": "28",

  "imdata": [{

  "topSystem": {

  "attributes": {

  "address": "10.10.10.10",

  "childAction": "",

  "configIssues": "",

  "currentTime": "2015-12-02T15:00:03.171-06:00",

  "dn": "topology/pod-1/node-101/sys",

  "fabricId": "1",

  "fabricMAC": "00:22:BD:F8:19:FF",

  "id": "101",

  "inbMgmtAddr": "0.0.0.0",

  "lcOwn": "local",

  "modTs": "2015-09-21T16:32:12.669-06:00",

  "mode": "unspecified",

  "monPolDn": "uni/fabric/monfab-default",

  "name": "leaf-101",

  "oobMgmtAddr": "172.26.30.115",

  "podId": "1",

  "role": "leaf",

  "serial": "8",

  "state": "in-service",

  "status": "",

  "systemUpTime": "71:23:34:58.000"

  }

  }

  }, {

  "maintUpgJob": {

  "attributes": {

  "childAction": "",

  "creationDate": "2015-09-21T15:26:12.188-06:00",

  "desiredVersion": "",

  "dn": "topology/pod-1/node-101/sys/fwstatuscont/upgjob",

  "endDate": "2015-09-21T15:26:12.188-06:00",

  "fwGrp": "",

  "fwPolName": "",

  "grpPriKey": "",

  "iUrl": "",

  "installId": "",

  "installStage": "InstallNotStarted",

  "instlProgPct": "0",

  "internalLabel": "",

  "lcOwn": "local",

  "maintGrp": "",

  "modTs": "2015-09-21T15:26:12.122-06:00",

  "monPolDn": "uni/fabric/monfab-default",

  "numAttempts": "0",

  "polName": "",

  "scheduler": "",

  "startDate": "2015-09-21T15:26:12.188-06:00",

  "status": "",

  "upgradeStatus": "notscheduled",

  "upgradeStatusStr": ""

  }

  }

  }, {

  "firmwareRunning": {

  "attributes": {

  "biosTs": "2014-09-09T18:00:00.000-06:00",

  "biosVer": "07.17",

  "childAction": "",

  "descr": "version 11.1(2h) [build 11.1(2h)]",

  "dn": "topology/pod-1/node-101/sys/fwstatuscont/running",

  "internalLabel": "e52826b12f28a7f77010cca46e1cdc4edf7009c4",

  "ksFile": "bootflash:aci-n9000-dk9.11.1.2h.bin",

  "modTs": "never",

  "mode": "normal",

  "peVer": "1.1(2h)",

  "status": "",

  "sysFile": "bootflash:///auto-s",

  "ts": "2015-08-16T20:21:00.000-06:00",

  "type": "switch",

  "version": "n9000-11.1(2h)"

  }

  }

  }, {

  "eqptCh": {

  "attributes": {

  "childAction": "",

  "descr": "Nexus C9396PX Chassis",

  "dn": "topology/pod-1/node-101/sys/ch",

  "id": "1",

  "mfgTm": "2014-05-18T18:00:00.000-06:00",

  "modTs": "2015-09-21T15:26:13.734-06:00",

  "model": "N9K-C9396PX",

  "monPolDn": "uni/fabric/monfab-default",

  "operSt": "online",

  "operStQual": "Chassis came online",

  "rev": "1",

  "role": "leaf",

  "ser": "",

  "status": "",

  "vendor": "Cisco Systems, Inc."

  }

  }

  }]

  }

}

For those interested in more command line options using the current device software, check out Cisco Techzone. https://techzone.cisco.com/t5/Application-Centric/Cisco-ACI-CLI-Commands-quot-Cheat-Sheet-quot/ta-p/638196

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: