Using CLI to update many server profiles in HP Virtual Connect Enterprise Manager


Some of you already know that working with the HP Virtual Connect Enterprise Manager may be simply tedious. The web-based GUI and unwieldy database make you find HP VCEM rather slow and hardly responsive. Of course HP VCEM provides some advantages, which compensate many drawbacks. For example you can define a new VLAN and assign it to existing shared uplink in a specific Virtual Connect module and such change will be automatically replicated to all Virtual Connect modules in the same domain group. You would love such feature if you had 30 C7000 chassis and 240 BL685c blade servers in a single Virtual Connect domain group. Nevertheless there are some management operations which take a lot of time.

A few days ago I had to add a new VLAN to specific network interfaces on all blade servers with ESXi 5.0 U1 onboard. The usual way you would do it is editing server profiles assigned to all ESXi blade servers one by one. A few minutes per profile and you end up with a day or two of donkey work.

Fortunately I recalled that the HP provides the HP Virtual Connect Enterprise Manager Command Line Interface (VCEMCLI) – a command line interface that provides the facilities necessary for the most frequently used management operations for the HP VCEM infrastructure.

The VCEMCLI is automatically installed from the Insight Management DVD when the HP VCEM is installed on the host and it can be executed from the Windows command line or from scripts written in any Windows-supported scripting language.

In my case the network configuration was the same in all altered server profiles:
The network configuration of edited server profiles

The network interfaces presented as multiple networks are nothing more than VLAN trunks. I had to add VLAN ID 96 to network ports no. 9, 10, 13 and 14. The VLAN 96 has been registered in 2 available shared uplinks as network Public_VLAN_A_96 and Public_VLAN_B_96 respectively.

Here is the Windows script I created for that:

set CLI=vcemcli.exe

set PROFILE_NAMES=^
 Full_Blade_A1R2_ESX_1 Full_Blade_A1R2_ESX_2 ^
 Full_Blade_A1R2_ESX_3 Full_Blade_A1R2_ESX_4 ^
 Full_Blade_A1R2_ESX_5 Full_Blade_A2R1_ESX_1 ^
 Full_Blade_A2R1_ESX_2 Full_Blade_A2R1_ESX_3 ^
 Full_Blade_A2R1_ESX_4 Full_Blade_A2R2_ESX_1 ^
 Full_Blade_A2R2_ESX_2 Full_Blade_A2R2_ESX_3 ^
 Full_Blade_A2R2_ESX_4 Full_Blade_A3R1_ESX_1 ^
 Full_Blade_A3R1_ESX_2 Full_Blade_A3R1_ESX_3 ^
 Full_Blade_A3R1_ESX_4 Full_Blade_A3R2_ESX_1 ^
 Full_Blade_A3R2_ESX_2 Full_Blade_A3R2_ESX_3 ^
 Full_Blade_A3R2_ESX_4 Full_Blade_A4R1_ESX_1 ^
 Full_Blade_A4R1_ESX_2 Full_Blade_A4R1_ESX_3 ^
 Full_Blade_A4R1_ESX_4 Full_Blade_A4R2_ESX_1 ^
 Full_Blade_A4R2_ESX_3 Full_Blade_A4R2_ESX_4 ^
 Full_Blade_A5R1_ESX_1 Full_Blade_A5R1_ESX_2 ^
 Full_Blade_A5R2_ESX_1 Full_Blade_A5R2_ESX_2 ^
 Full_Blade_A6R1_ESX_1 Full_Blade_A6R1_ESX_2 ^
 Full_Blade_A6R2_ESX_1 Full_Blade_A6R2_ESX_2 ^
 Full_Blade_A17R1_ESX_3 Full_Blade_A17R1_ESX_5 ^
 Full_Blade_A17R1_ESX_5 Full_Blade_A17R2_ESX_7 ^
 Full_Blade_A17R2_ESX_8

FOR %%I IN (%PROFILE_NAMES%) DO (
  %CLI% -add server-port-map -profileName %%I -portNumber 9 -network Public_VLAN_A_96 -vlanid 96
  %CLI% -add server-port-map -profileName %%I -portNumber 10 -network Public_VLAN_B_96 -vlanid 96
  %CLI% -add server-port-map -profileName %%I -portNumber 13 -network Public_VLAN_A_96 -vlanid 96
  %CLI% -add server-port-map -profileName %%I -portNumber 14 -network Public_VLAN_B_96 -vlanid 96
  if ERRORLEVEL 1 goto ERRORHANDLER
)

goto END

:ERRORHANDLER
echo Error processing last command. ERRORLEVEL = %ERRORLEVEL%

:END
pause
exit /b %ERRORLEVEL%

The above script is based on the command-line interface for VCEM version 7.0. The variable PROFILE_NAMES contains the names of server profiles, which should be edited by the script. The network interfaces are reconfigured by the VCEMCLI commands submitted in lines 27-30.

The output of the script shows that each VCEMCLI command creates a new VCEM task:
The output of the VCEM script

All created tasks are always shown on the VCEM task history page:
The VCEM job history

Regarding the performance of this approach, in my environment the presented script was able to update 1 server profile per minute. This isn’t a roaring result but the point is the VCEMCLI automates a lot of time-consuming VCEM operations.

IMHO the VCEMCLI is extremely easy to learn. The best way to start the VCEM scripting is read the manual, available right here.

, ,

  1. #1 by shanedawg on April 3, 2013 - 19:03

    This was so helpful. You saved me hours of work man. Thank you!!

    I only have two c7000 chassis and do not have vcem but I found the command that worked when you are just ssh’s into the vc module itself. Here it is:

    add server-port-map esx12:2 inet2_bay2 Uplinkset=esx_bay2_uplink

    and the results
    ->show server-port-map esx12:2
    Profile Name : esx12
    Server Port ID : 2

    =================================================
    Network VLanID Uplink Set Untagged
    =================================================
    mgmt_bay2 — — esx_bay2_uplink true
    default_bay2 1 esx_bay2_uplink false
    inet_bay2 80 esx_bay2_uplink false
    inet2_bay2 81 esx_bay2_uplink false

(will not be published)