JLI script with no arguments in the input
In the following example, the JLI command does not require any input arguments. This example JLI script fetches a list of all the servers and returns the output list of servers as a string, separated by the new line character.
BLCLI command | blcli -v <profile> Server listAllServers |
Input | None |
Output | All servers as a single string, delimited by the newline character (\n) |
JLI command | ./bljythonexe "<location of jli script file>" |
Sample script
import re
import sys
import string as s
import bladelogic.cli.CLI as blcli
jli = blcli.CLI()
jli.setServiceProfileName("<profile>")
jli.setRoleName("<Role>")
jli.connect()
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 str(propertyKey)
def split(result):
#Using regular expression to split the result on new line
arr = re.split('\n',result)
counter = 0
#looping the array elements to remove newline.
for element in arr:
#Strips newlines from right end of the string.
arr[counter]=s.rstrip(element)
counter+=1
return arr
#declaring the command array to hold commands to be executed
cmd =[]
#Appending namespace
cmd.append('Server')
#Appending command
cmd.append('listAllServers')
#Result is returned as an array.
servers = split(execute(cmd))
print servers
#Iterating over the list of servers
for server in servers:
if(server != ''):
print server
sys.exit(0)
import sys
import string as s
import bladelogic.cli.CLI as blcli
jli = blcli.CLI()
jli.setServiceProfileName("<profile>")
jli.setRoleName("<Role>")
jli.connect()
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 str(propertyKey)
def split(result):
#Using regular expression to split the result on new line
arr = re.split('\n',result)
counter = 0
#looping the array elements to remove newline.
for element in arr:
#Strips newlines from right end of the string.
arr[counter]=s.rstrip(element)
counter+=1
return arr
#declaring the command array to hold commands to be executed
cmd =[]
#Appending namespace
cmd.append('Server')
#Appending command
cmd.append('listAllServers')
#Result is returned as an array.
servers = split(execute(cmd))
print servers
#Iterating over the list of servers
for server in servers:
if(server != ''):
print server
sys.exit(0)
For an alternative example of a script that returns a list of servers, see .
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*