HP IMC eAPI: deploying CLI commands part 1

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.

Prerequisites/assumptions

  • 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.

20140428_174134_imc-eapi-deploycli-000056

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:

20140428_174244_imc-eapi-deploycli-000058

 

In this resulting output, you will be able to see the IMC Device ID for the found device:

20140428_174311_imc-eapi-deploycli-000059

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:

20140428_153502_imc-eapi-deploycli-000049

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 1.1.1.9 32</cmd>
  </cmdlist>
  <deviceId>2</deviceId>
 </deviceExecuteCmd>

20140428_153529_imc-eapi-deploycli-000050

Next the Try it out can beused to push the commands. You will see a progressing image on the right-hand side:

20140428_180538_imc-eapi-deploycli-000060

And when done, the result will be shown:

20140428_153550_imc-eapi-deploycli-000051

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)    1.1.1.9
NULL0                UP   UP(s)    --
REG0                 DOWN --       --

[core]

Network trace of the telnet session

This is the wireshark output of the telnet session:

20140428_153620_imc-eapi-deploycli-000052

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

This entry was posted in IMC Platform and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s