Command Line client scripting

The Command Line client can be scripted.
This can be useful for those wanting to manage their RAID configurations through scripts or their favorite automation tools.

To run the command line client in:
Interactive mode: FlexRAIDClient [Host] [Port] [Timeout]
Non-Interactive mode: FlexRAIDClient Host Port Timeout Command

For those wanting to script the Command Line client, you will be using it in non-interactive mode.

The Host/Port/Timeout parameters are optional in interactive mode, but required in non-interactive mode.

To use the default values for the Port and Timeout parameter, use a ‘-’ as value.
Ex: FlexRAIDClient localhost - - run C:\cmds\create.txt

For the non-interactive mode, the “Command” parameter represents the command you would normally type in interactive mode.
In the previous example, the bolded text is the command.

In non-interactive mode, the client will return an exit-code that you can make use of in your script.

Exit-Codes:

SUCCESS = 0

STATE_PROCESSING = 100
STATE_RESUMING = 101
STATE_PAUSING = 102
STATE_RESUMING_TO_ABORT = 103
STATE_ABORTING = 104
STATE_PAUSED = 105
STATE_ABORTED = 106

MISSING_COMMAND_FILE_TO_RUN = -100
MISSING_COMMAND_FILE_TO_UPLOAD = -101

COMMAND_NOT_SUPPORTED_IN_INTERACTIVE_MODE_PREFIX = -200
COMMAND_NOT_SUPPORTED_IN_INTERACTIVE_MODE_POSTFIX = -201
COMMAND_NOT_SUPPORTED_IN_INTERACTIVE_MODE_CONNECT = -202

VALIDATE_ALERT_HAS_CORRUPTED_CHANGED_DELETED = -300
VALIDATE_ALERT_HAS_CORRUPTED_CHANGED = -301
VALIDATE_ALERT_HAS_CORRUPTED_DELETED = -302
VALIDATE_ALERT_HAS_CHANGED_DELETED = -303
VALIDATE_ALERT_HAS_CORRUPTED = -304
VALIDATE_ALERT_HAS_CHANGED = -305
VALIDATE_ALERT_HAS_DELETED = -306

NO_RESPONSE_RECEIVED = -400

ERROR_AN_ERROR_HAS_OCCURRED = -500
ERROR_AN_EXCEPTION_HAS_OCCURRED = -501
ERROR_INVALID_TASK = -510
ERROR_INVALID_COMMAND = -520
ERROR_INVALID_PARAMETERS = -530
ERROR_INVALID_PARAMETERS_FOR_UPLOAD_COMMAND = -531
ERROR_INVALID_PARAMETERS_FOR_RUN_COMMAND = -532
ERROR_INVALID_PARAMETERS_FOR_MAX_COMMAND = -533
ERROR_NOT_YET_IMPLEMENTED = -540
ERROR_NOT_YET_SUPPORTED = -550
ERROR_NON_EXISTENT_ELEMENT = -560
ERROR_NO_SUCH_PROCESS_ID = -561
ERROR_NO_COMMAND_SPECIFIED = -570
ERROR_CONCURRENT_PROCESS_NOT_ALLOWED_ON_THE_SAME_CONFIG = -580
ERROR_VALIDATION_ERROR = -590

Sample script 1:

FlexRAIDClient myhost - - run C:\cmds\create.txt

Sample script 2:

rem Here we start the host
cd "C:\Program Files\OpenEgg.org\FlexRAID Basic Host Service 1.0"
C:
start /min FlexRAID

rem This here is to wait for the host to finish starting - waiting 3 seconds
@ping 127.0.0.1 -n 3 -w 1000> nul

rem Now we switch to the command-line client
cd "C:\Program Files\OpenEgg.org\FlexRAID Basic CMD Client 1.0"
C:

set myhost=localhost
rem '-' means use the default value (9595)
set myPort=-
rem '-' means use the default value (2000 - [in milliseconds])
set myTimeOut=-
set configFile=C:\cmds\config.txt
set create=%configFile% create
set update=%configFile% rsynch
set validate=%configFile% validate
set quick-validate=%configFile% quick-validate
set verify=%configFile% verify
set cmdStart=FlexRAIDClient %myhost% %myPort% %myTimeOut%
set logFile=C:\logs\myLog.txt

%cmdStart% run %update% >> %logFile%
IF %ERRORLEVEL% GTR 0 goto report

rem This will block until the task has completed
%cmdStart% monitor >> %logFile%

:report
rem IF %ERRORLEVEL% GTR 0 (
rem call sendEmail "me@email.com" "my ERROR message" %ERRORLEVEL%
rem goto done
rem )

rem IF %ERRORLEVEL% EQU 0 (
rem call sendEmail "me@email.com" "my SUCCESS message"
rem )

:done
%cmdStart% shutdown-server >> %logFile%

Where config.txt would contain something like (see command templates package for more info):

metadata=D:\Data\P

data=DRU1{D:\Data\D1}|DRU2{D:\Data\D2}|DRU3{D:\Data\D3}
parity=PPU1{D:\Data\P}
Be Sociable, Share!

Revisions

One Response to “Command Line client scripting”

  1. vletroye February 4, 2013 at 3:34 PM #

    For Windows users, the command in “FlexRaidCmd” instead of “FlexRaidClient”. It can be downloaded as an Optional pack from here : http://www.flexraid.com/download/#download

    E.g.: To start/stop the first pool (id=0) using the new driver(class1), one can use the Command “view”

    FlexRAIDCMD localhost – - view class1_0 start
    FlexRAIDCMD localhost – - view class1_0 stop

Leave a Reply

8 + four =