HP Virtual Connect Enterprise Manager 6.3 CLI Guide

Table 1 Common options (continued)
DescriptionCLI options
When set, instructs VCEMCLI how long to wait for blocking
commands.
timeout seconds
When set, instructs VCEMCLI how often to poll VCEM for
job or power status.
-pollinginterval seconds
Using VCEMCLI in a script
The following example illustrates how VCEMCLI can be used to automate common profile
management tasks. This example:
Powers on the servers in the enclosure
Creates server profiles
Adds and edits network connections for the server profiles
Assigns server profiles to the bays containing servers
@echo off
set CLI=vcemcli.exe
set VCDG=OA-78-VCDG
set NEWNET=NET2
set MAXPROFILES=5
set MAXBAYS=16
set ENCLNAME=OA-78
set VCEMCLI=-logfile c:\demo.log
echo Turn on all servers in enclosure %ENCLNAME% --------------------------------------------
for /L %%I in (1,1,%MAXBAYS%) DO (
%CLI% -show power-status -enclosureName %ENCLNAME% -bayname %%I
if ERRORLEVEL 240 (
echo There is no server in bay %%I
) else (
if ERRORLEVEL 1 (
echo Server in bay %%I is already on
) else (
echo Turning on server in bay %%I
%CLI% -poweron devicebay -enclosureName %ENCLNAME% -bayname %%I
if ERRORLEVEL 1 goto ERRORHANDLER
)
)
)
echo Creating %MAXPROFILES% profiles -------------------------------------------------------
for /L %%I in (1,1,%MAXPROFILES%) DO (
echo Creating profile %%I of %MAXPROFILES%
%CLI% -add profile -vcdomaingroup %VCDG% -profilename PROFILE-%%I
if ERRORLEVEL 1 goto ERRORHANDLER
)
echo Profile creation complete - adding network connections --------------------------------
for /L %%I in (1,1,%MAXPROFILES%) DO (
echo Adding enet connection to PROFILE-%%I
%CLI% -add enet-connection -profilename PROFILE-%%I
if ERRORLEVEL 1 goto ERRORHANDLER
)
echo Add network connection complete - Update network connections --------------------------
for /L %%I in (1,1,%MAXPROFILES%) DO (
echo Assigning enet connection %NEWNET% to port 3 of PROFILE-%%I
%CLI% -set enet-connection -profilename PROFILE-%%I -network %NEWNET% -portnumber 3
if ERRORLEVEL 1 goto ERRORHANDLER
)
echo Assign the profiles to bays that have servers present ---------------------------------
for /L %%I in (1,1,%MAXPROFILES%) DO (
::Turn off the server in the target bay ONLY if a server is present
%CLI% -show power-status -enclosureName %ENCLNAME% -bayname %%I
if ERRORLEVEL 240 (
echo There is no server in bay %%I - skipping profile assignment
) else (
if ERRORLEVEL 1 (
echo ------------------------------------------
echo Turning off server in bay %%I
Using VCEMCLI in a script 9