Important

   

This space contains documentation for TrueSight Server Automation 8.9.03 and the later service packs for 8.9. For earlier releases, see BMC Server Automation 8.9.

JLI script with multiple input arguments and list returned in output

In the following example, the JLI command requires multiple input arguments. This example JLI script adds the specifications of multiple servers in the application server. The list of added servers is then returned in the output.

BLCLI command


(all on one line)
blcli -v <profile> Server bulkAddServers
<nsh path directory of csv file>
<csv filename> <character encoding> true

Input

Values for the following variables:

  • NSH path to the .csv file that contains the descriptions of the servers to add
  • Name of the .csv file
  • Character encoding for the .csv file   

For more information about the format of the .csv file, see Server - bulkAddServers in the BLCLI documentation.

Output

List of servers added

For example:
['localhost','W-DMAZUMDE-63']

JLI command

(all on one line)
./bljythonexe "<location of jli script file>"
"/C/Users/DMAZUMDE/Desktop" "test.csv" "UTF-8"

Note

The exact JLI command depends on your operating system:

  • On Windows, use the bljythonexe command.
  • On UNIX, use the bljython command.

Sample script

import sys
import bladelogic.cli.CLI as blcli
jli = blcli.CLI()
jli.setServiceProfileName("<profile>")
jli.setRoleName("<Role>")
jli.connect()
#csv file location
serverFileLoc=sys.argv[1]
#csv file
serverFile=sys.argv[2]
#char encoding for csv
encoding=sys.argv[3]
def execute(command):
     print command
     #main CLI command execution.
     propertyObject = jli.run(cmd)
                  
     #If command executed successfully, return the result received after command execution.
     if(propertyObject.success()):
          propertyKey = propertyObject.returnValue
     return propertyKey
#declaring the command array to hold commands to be executed
cmd =[]       
#Appending namespace
cmd.append('Server')
#Appending command
cmd.append('bulkAddServers')
#Appending other parameters
cmd.append(serverFileLoc)
cmd.append(serverFile)
cmd.append(encoding)
cmd.append('true')
#Result is returned as a list of servers added.
serversAdded = execute(cmd)
#iterating over the list of servers
for server in serversAdded:
    if(server != ''):
        print server
sys.exit(0)


Was this page helpful? Yes No Submitting... Thank you

Comments