The HP IMC eAPI can now also be used to directly deploy CLI commands to devices supported by the ICC (Intelligent Configuration Center).
The ICC is already very powerful due to its vendor independent approach using device adapters (ICC can manage provision, cisco, comware etc devices through CLI), so having the eAPI functions for the ICC module means these same functions can be accessed through the eAPI interface for scripting purposes.
In this post a very short demo of how a sample CLI series of commands can be pushed to IMC managed devices.
- Target device managed is by IMC
- Proper telnet/ssh configuration on device and IMC login templates have been configured
- IMC 7 E0202 was used
In this example, an HP VSR 1000 was used, SNMP and telnet server enabled and an admin account defined. The device was added to IMC and the login was verified (check access settings).
Interfaces of the VSR before the deployment
In the CLI test, a new Loopback interface will be defined. So before we run the script, a quick listing of the current interfaces on the VSR
[core]dis int brief Brief information on interface(s) under route mode: Link: ADM - administratively down; Stby - standby Protocol: (s) - spoofing Interface Link Protocol Main IP Description GE1/0 UP UP 10.0.1.1 InLoop0 UP UP(s) -- NULL0 UP UP(s) -- REG0 DOWN -- -- [core]
Use the online eAPI to find the IMC Device ID
To deploy a CLI command to a device, you will need the Device ID, so the first step is to lookup the deviceID.
Open the IMC RS site on http://imc-ip:8080/imcrs
Login with your admin account (admin/admin by default)
First you need to find the IMC Device ID of the target device, so open the /plat/res/device function, and next open the GET /plat/res/device method.
You can simply query for all devices, or enter some filter information. In this example, I know the target IP address is 10.0.1.1, so this is entered as a filter for the query:
In this resulting output, you will be able to see the IMC Device ID for the found device:
In this example the Device ID is 2.
Use the online eAPI to deploy CLI commands
Navigate to the /icc/confFile section, and open it, you will see the /icc/confiFile/executeCmd POST option:
There will be a brief description of the feature, and next there is a sample body which can be entered for a test.
In this test, a simple loopback interface with an IP Address is defined with the following code, and it will be pushed to deviceID 2:
<!--?xml version="1.0" encoding="UTF-8" standalone="yes"?> <deviceExecuteCmd> <cmdlist> <cmd>system-view</cmd> <cmd>int loop 0</cmd> <cmd>ip address 126.96.36.199 32</cmd> </cmdlist> <deviceId>2</deviceId> </deviceExecuteCmd>
Next the Try it out can beused to push the commands. You will see a progressing image on the right-hand side:
And when done, the result will be shown:
Interfaces of the VSR after the deployment
On the console of the VSR, you will see that an admin login/logout was done from 10.0.1.100 (the IMC lab server), and the new Loopback0 interface will be listed:
[core] [core]%Apr 28 17:56:47:227 2014 core SHELL/5/SHELL_LOGIN: admin logged in from 10.0.1.100. %Apr 28 17:56:48:820 2014 core SHELL/5/SHELL_LOGOUT: admin logged out from 10.0.1.100. [core] [core]dis int brief Brief information on interface(s) under route mode: Link: ADM - administratively down; Stby - standby Protocol: (s) - spoofing Interface Link Protocol Main IP Description GE1/0 UP UP 10.0.1.1 InLoop0 UP UP(s) -- Loop0 UP UP(s) 188.8.131.52 NULL0 UP UP(s) -- REG0 DOWN -- -- [core]
Network trace of the telnet session
This is the wireshark output of the telnet session:
So this summarizes a sample eAPI CLI deployment. Using the device queries, this mechanism can easily be combined to deploy specific commands to an entire site of devices (any device supported by the IMC ICC !).