BluemixUtility scripts
The script library provides BluemixUtility scripts that enable you to configure IBM Cloud® services. You can run a script individually or combine many procedures to create custom automation scripts for your environment.
The BluemixUtility scripts are located in the app_server_root/scriptLibraries/bluemixutility directory.
bind
The script binds an IBM Cloud service
configuration to a product server . The configuration for a
service might provide default values for an option, such as the jndiName
of a
dataSource
element. In some cases, the default values do not match what the
application expects. Use the variables option to override a default value with
the value that your application expects.
Argument | Required or Optional | Description |
---|---|---|
scope | Required | Specifies a server scope to bind to an IBM Cloud service configuration. |
serviceName | Required | Specifies the name of the imported service configuration. |
variables | Optional | Specifies a map of variable names to override variables in the imported service configuration. You can get a variable name from the showImport script. |
acceptLicense | Optional | Automatically indicates acceptance of license terms and conditions. |
Syntax
BluemixUtility.bind("acceptLicense=true", "scope=Node=node_name:Server=server_name", "serviceName=service_name", "variables=[v1Name=v1Value, v2Name=v2Value, …]")
Example usage
BluemixUtility.bind("acceptLicense=true", "scope=Node=myNode:Server=myServer", "serviceName=myDiscoveryService")
BMUX0206I: Bind successfully on service myDiscoveryService.
BluemixUtility.bind("acceptLicense=true", "scope=Node=myNode:Server=myServer", "serviceName=dashDB1", "variables=[jndiName=dashDB1]")
BMUX0206I: Bind successfully on service dashDB1.
BluemixUtility.bind("acceptLicense=true", "scope=Node=myNode:Server=myServer", "serviceName=dashDB1", "variables=[proxyUser=user1, proxyHost=myHost.com.ibm, proxyPort=3199, proxyPassword=abcd]")
BMUX0206I: Bind successfully on service dashDB1.
configureProxy
The script configures a proxy server to connect to a service.
Argument | Required or Optional | Description |
---|---|---|
proxyHost | Required | Specifies the host name of a proxy server. |
proxyPort | Required | Specifies the port of a proxy server. |
proxyUser | Optional | Specifies the user name to log in to a proxy server. |
proxyUserPassword | Optional | Specifies the password to log in to a proxy server. |
Syntax
BluemixUtility BluemixUtility.configureProxy("proxyHost=host_name", "proxyPort=port_number", "proxyUser=user_name", "proxyUserPassword=user_password")
Example usage
BluemixUtility BluemixUtility.configureProxy("proxyHost=host1.ibm.com", "proxyPort=3128", "proxyUser=user1", "proxyUserPassword=password")
BMUX0200I: Configure proxy server successfully.
createService
The script creates a service instance from the catalog.
Argument | Required or Optional | Description |
---|---|---|
serviceType | Required | Specifies the type of service to create. |
servicePlan | Required | Specifies the plan of the service to create. |
serviceName | Required | Specifies the name of the service to create. You can specify a unique serviceName for your service instance. |
credentialName | Optional | Specifies the name of the service credential. The default value is
credential-1 . |
Syntax
service = BluemixUtility.createService("serviceType=service_type", "servicePlan=service_plan", "serviceName=service_name", "credentialName=credential-1")
Example usage
service = BluemixUtility.createService("credentialName=credential-1", "serviceType=dashDB", "servicePlan=Entry", "serviceName=dashDB1")
BMUX0203I: Service dashDB2 successfully created. com.ibm.ws.bluemix.utility.cloudfoundry.CloudFoundryServiceInstance@54fc8cc1
service = BluemixUtility.createService("serviceType=discovery", "servicePlan=free", "serviceName=myDiscoveryService")
BMUX0203I: Service myDiscoveryService successfully created. com.ibm.ws.bluemix.utility.cloudfoundry.CloudFoundryServiceInstance@58cf9cd1
BluemixUtility.createServiceToString(service)
Name: dashDB1 Type: dashDB Plan: Entry Description: A flexible and powerful data warehouse for enterprise-level analytics. Documentation: https://console.ng.bluemix.net/docs/services/dashDB/dashDB.html Service keys: credential-1
print service2
BMUX0203I: Service myDiscoveryService successfully created. Name: myDiscoveryService Type: discovery Plan: free Description: Add a cognitive search and content analytics engine to applications. Documentation: https://www.ibm.com/watson/developercloud/discovery.html Service keys:
service = BluemixUtility.createService("credentialName=credential-1", "serviceType=dashDB", "servicePlan=Entry", "serviceName=dashDB1")
name = service.getName()
type = service.getService().getLabel()
plan = service.getPlan().getName()
desc = service.getService().getDescription()
docUrl = service.getService().getDocumentationUrl()
keys = service.getServiceKeys()
for k in keys:
key = k.getName()
deleteService
The script deletes a service instance.
Argument | Required or Optional | Description |
---|---|---|
serviceName | Required | Specifies the name of the service to delete. |
Syntax
BluemixUtility.deleteService("serviceName=service_name")
Example usage
BluemixUtility.deleteService("serviceName=dashDB1")
BMUX0208I: Service key credential-1 successfully deleted. BMUX0209I: Service dashDB1 successfully deleted.
getSSOURL
The script obtains the SSO passcode URL string from the service. You can get the one-time passcode for a user from a web browser open on this URL and provide the passcode in the login script.
Argument | Required or Optional | Description |
---|---|---|
api | Required | Specifies the API endpoint. |
Syntax
URL = BluemixUtility.getSSOURL("api=API_endpoint")
Example usage
BluemixUtility.getSSOURL("api=https://api.ng.bluemix.net")
Output: 'https://login.ng.bluemix.net/UAALoginServerWAR/passcode'
help
The script displays the general help for BluemixUtility or the help for a specific BluemixUtility script.
Syntax
Display the general help for BluemixUtility.
print BluemixUtility.help()
Display the help for a BluemixUtility script.
print BluemixUtility.help(action)
Example usage
print BluemixUtility.help()
BMUX2001I: The BluemixUtility script provides the script utilities to configure your WebSphere Application Server to use Bluemix cloud services. Usage: BluemixUtility.action(arguments) Actions: login Log in to IBM Bluemix. marketplace List all IBM Bluemix services that can be configured using this utility. createService Create a service instance from the IBM Bluemix catalog. listServices List all service instances. showService Show information about an IBM Bluemix service instance. importService Import a configuration for an IBM Bluemix service. showInstructions Show the instructions for a service. listImports List all imported service configuration that can be bound to a WebSphere Application Server. showImport Show information about an imported service configuration. bind Bind an IBM Bluemix service configuration to a WebSphere Application Server. unbind Unbind an IBM Bluemix service configuration from a WebSphere Application Server. deleteService Delete a service instance. switchService Switch to a different IBM Bluemix organization or space. info View IBM Bluemix connection information. logout Log out of IBM Bluemix. getSSOURL Get the login SSO URL from Bluemix. showLicenses Show the licenses for a service. configureProxy Configure a proxy server Help Print the help information for the specified action. Options: Use help(action) for detailed information of each action.
print BluemixUtility.help("login")
BUMX2002I: login Required Arguments: user, password, api Optional Arguments: org, space, passcode Description: Log in to Bluemix. If passcode is specified, user and password are not required. Usage: BluemixUtility.login("api=https://api.ng.bluemix.net", "user=user1", "password=pwd", "org=org", "space=dev") Return: None
print BluemixUtility.help("marketplace")
BUMX2003I: marketplace Arguments: None Optional Arguments: serviceTypes (separate types by space) Description: List all Bluemix services that can be configured by using the Bluemix utility. Usage: BluemixUtility.marketplace("serviceTypes=type1 type2 type3") Return: List of Bluemix CloudFoundryService objects. Note: Use marketplaceToString(services) to view all Bluemix services returned from the marketplace action
importService
The script imports a configuration for a service. The imported service script and the shared libraries are stored in the configuration tree in the /config/cells/cellName/bluemixservices/serviceName directory or in the wstemp tree in the /wstemp/session/workspace/cells/cellName/bluemixservices/serviceName directory.
Argument | Required or Optional | Description |
---|---|---|
serviceName | Required | Specifies the name of the service to import. |
acceptLicense | Optional | Specifies whether to automatically accept the license. Use true to accept
the license and false to not accept it. |
credentialName | Optional | Specifies the name of the service credential. |
encodeAlgorithm | Optional | Specifies how to encode sensitive information in the imported service. The default encoding
algorithm is xor . |
encodeKey | Optional | Specifies the key to use when encoding with AES encryption. |
parameters | Optional | Specifies other parameters to help generate and import a service configuration. For multiple parameters, separate them with a comma. |
Syntax
BluemixUtility.importService("acceptLicense=true", "serviceName=service_name", "credentialName=credential_name", "encodeAlgorithm=algorithm", "encodeKey=key", "parameters=[p1Name=p1Value, p2Name=p2Value, …]")
Example usage
BluemixUtility.importService("acceptLicense=true", "serviceName=dashDB1", "credentialName=credential-1", "encodeAlgorithm=xor", "parameters=[jndiName=test, jdbcProvider=jdbc1]")
BMUX0205I: Configuration for the dashDB1 service was successfully imported.
BluemixUtility.importService("acceptLicense=true", "serviceName=myDiscoveryService")
BBMUX0205I: Configuration for the myDiscoveryService service was successfully imported.
info
The script views the connection information.
Syntax
BluemixUtility.info()
Example usage
info = BluemixUtility.info()
Output: a TargetInfo object
BluemixUtility.infoToString(info)
API endpoint: https://api.ng.bluemix.net Organization: user1@us.ibm.com Space: devThe example uses infoToString. You can use the print command instead.
print info
info = BluemixUtility.info()
api = info.getAPI()
org = info.getOrganizationName()
space = info.getSpaceName()
listImports
The script lists all imported service configurations that can bind to a product server.
Argument | Required or Optional | Description |
---|---|---|
scope | Optional | Specifies the server scope to which the services are bound. |
Syntax
services = BluemixUtility.listImports("scope=Node=node_name:Server=server_name")
Example usage
BluemixUtility.listImports()
[dashDB1, dashDB2, myDiscoveryService]
BluemixUtility.listImports("scope=Node=myNode:Server=myServer")
[dashDB1, myDiscoveryService]
services = BluemixUtility.listImports("scope=Node=myNode:Server=myserver")
BluemixUtility.listImportsToString(services)
BMUX0210I: The following IBM Bluemix service configurations have been imported: dashDB1, myDiscoveryService
services = BluemixUtility.listImports()
for s in services:
print s
listServices
The script lists all the available service instances.
Syntax
services = BluemixUtility.listServices()
Example usage
services = BluemixUtility.listServices()
Output: list of CloudFoundryServiceInstance objects
BluemixUtility.listServicesToString(services)
Name Type Plan dashDB1 dashDB Entry dashDB2 dashDB Entry dashDB3 dashDB Entry myDiscoveryService discovery free
services = BluemixUtility.listServices()
for s in services:
name = s.getName()
type = s.getService().getLabel()
plan = s.getPlan().getName()
login
The script logs in to IBM Cloud.
Argument | Required or Optional | Description |
---|---|---|
api | Required | Specifies the API endpoint. |
user | Required (optional when you log in with the SSO passcode) | Specifies the user name of the IBM Cloud account. |
password | Required (optional when you log in with the SSO passcode) | Specifies the password of the IBM Cloud account. |
passcode | Optional | Specifies the one-time passcode value. The user and password arguments are not required when you specify the passcode value. To get the passcode value, open a web browser on the URL returned by the getSSOURL script. |
org | Optional | Specifies the organization name. |
space | Optional | Specifies the space name. |
Syntax
BluemixUtility.login("user=user_name", "password=password", "api=API_endpoint", "org=organization_name", "space=space_name", "passcode=passcode_value")
Example usage
BluemixUtility.login("user=user1@us.ibm.com", "password=password", "api=https://api.ng.bluemix.net", "org=user1@us.ibm.com", "space=dev")
BMUX0201I: Authentication successful.
BluemixUtility.login("api=https://api.ng.bluemix.net", "org=user1@us.ibm.com", "space=dev", "passcode=1234abcd")
BMUX0201I: Authentication successful.
logout
The script logs out of IBM Cloud.
Syntax
BluemixUtility.logout()
Example usage
BluemixUtility.logout()
BMUX0202I: Logout successfully.
marketplace
The script lists all the IBM Cloud services that you can configure with BluemixUtility.
Argument | Required or Optional | Description |
---|---|---|
serviceTypes | Optional | Specifies one or more service types. For multiple service types, separate them with a space. |
Syntax
services = BluemixUtility.marketplace()
services = BluemixUtility.marketplace("serviceTypes=type1 type2 type3 …")
Example usage
services = BluemixUtility.marketplace()
Output: list of CloudFoundryService objects
services = BluemixUtility.marketplace("serviceTypes=dashDB")
Output: list of CloudFoundryService instances
BluemixUtility.marketplaceToString(services)
Service: dashDB Description: A flexible and powerful data warehouse for enterprise-level analytics. Documentation: https://console.ng.bluemix.net/docs/services/dashDB/dashDB.html Plans: Enterprise, EnterpriseMPP32.244.1400forAWS, Entry, EnterpriseTransactional12.128.1400, EnterpriseTransactional2.8.500, EnterpriseTransactional2.8.500.PPU, EnterpriseTransactionalHA12.128.1400, SMP Small, SMP Large, EnterpriseTransactionalHA2.8.500, EnterpriseTransactionalHA2.8.500.PPU, SMP Medium, Enterprise256.4, Enterprise256.12, EnterpriseMPP.4, MPP Small Service: text_to_speech Description: Synthesizes natural-sounding speech from text. Documentation: https://www.ibm.com/watson/developercloud/text-to-speech.html Plans: standard, premium Service: speech_to_text Description: Low-latency, streaming transcription Documentation: https://www.ibm.com/watson/developercloud/speech-to-text.html Plans: standard, premium Service: tone_analyzer Description: Tone Analyzer uses linguistic analysis to detect three types of tones from communications: emotion, social, and language. This insight can then be used to drive high impact communications. Documentation: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/tone-analyzer.html Plans: premium, standard Service: personality_insights Description: The Watson Personality Insights derives insights from transactional and social media data to identify psychological traits Documentation: https://www.ibm.com/watson/developercloud/personality-insights.html Plans: tiered, premium Service: natural_language_classifier Description: Natural Language Classifier performs natural language classification on question texts. A user would be able to train their data and the predict the appropriate class for a input question. Documentation: https://www.ibm.com/watson/developercloud/nl-classifier.html Plans: standard Service: document_conversion Description: Converts a HTML, PDF, or Microsoft Word document into a normalized HTML, plain text, or a set of JSON-formatted Answer units. Documentation: https://www.ibm.com/watson/developercloud/document-conversion.html Plans: standard, premium Service: retrieve_and_rank Description: Add machine learning enhanced search capabilities to your application Documentation: https://www.ibm.com/watson/developercloud/retrieve-rank.html Plans: standard Service: discovery Description: Add a cognitive search and content analytics engine to applications. Documentation: https://www.ibm.com/watson/developercloud/discovery.html Plans: free, standard Service: watson_vision_combined Description: Find meaning in visual content! Analyze images for scenes, objects, faces, and other content. Choose a default model off the shelf, or create your own custom classifier. Find similar images within a collection. Develop smart applications that analyze the visual content of images or video frames to understand what is happening in a scene. Documentation: https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/visual-recognition.html Plans: free, standard Service: language_translator Description: Translate text from one language to another for specific domains. Documentation: https://www.ibm.com/watson/developercloud/language-translator.html Plans: premium, advanced, standard
services = BluemixUtility.marketplace()
for s in services:
name = s.getLabel()
desc = s.getDescription()
docUrl = s.getDocumentationUrl()
plans = s.getServicePlans()
for plan in plans:
pName = plan.getName()
showImport
The script shows information about an imported IBM Cloud service configuration such as configuration location, configuration variables, and bound servers. You can specify the variables that are returned from showImport during a bind operation to configure or override the resources or properties in the server scoped configuration.
Argument | Required or Optional | Description |
---|---|---|
serviceName | Required | Specifies the name of the imported service. |
Syntax
importInfo = BluemixUtility.showImport("serviceName=service_name")
Output: an ImportServiceDetails object
Example usage
importInfo = BluemixUtility.showImport("serviceName=dashDB1")
importInfo2 = BluemixUtility.showImport("serviceName=myDiscoveryService")
BluemixUtility.showImportToString(importInfo)
Configuration location: cells/myCell/bluemixservices/dashDB1 Configurable variables: Name: jndiName Value: jdbc/dashDB1 Bound servers: myNode/server1 myNode/server2
print importInfo2
Configuration location: cells/timmie1Cell05/bluemixservices/myDiscoveryService Configurable variables: No configurable variable Bound servers: No server/cluster bound
importInfo = BluemixUtility.showImport("serviceName=dashDB1")
configLoc = importInfo.getConfigLocation()
configVariables = importInfo.getVariables()
for var in configVariables:
vName = var.getKey()
vValue = var.getValue()
boundServers = importInfo.getBoundServers()
for server in boundServers:
print server
showInstructions
The script shows the instruction of a service.
Argument | Required or Optional | Description |
---|---|---|
serviceName | Required | Specifies the name of the service. |
Syntax
instructions = BluemixUtility.showInstructions("serviceName=service_name")
Example usage
BluemixUtility.showInstructions("serviceName=dashDB1")
Output: an instruction string
showLicenses
The script shows all software licenses that you must accept to use a service.
Argument | Required or Optional | Description |
---|---|---|
serviceName | Required | Specifies the name of the service. |
Syntax
licenses = BluemixUtility.showLicenses("serviceName=service_name")
Example usage
licenses = BluemixUtility.showLicenses("serviceName=dashDB1")
licenses2 = BluemixUtility.showLicenses("serviceName=myDiscoveryService")
Output: set of License objects
license
, a dashDB
service.
BluemixUtility.showLicensesToString(licenses)
License type: IBM IPLA License link: https://oneconnect.mybluemix.net/ds/drivers/license/jcc4jar/live Libraries: https://oneconnect.mybluemix.net/ds/drivers/download/jcc4jar/jvm/live
license2
, a discovery
service.
BluemixUtility.showLicensesToString(licenses2)
License type: Apache License link: https://www.apache.org/licenses/LICENSE-2.0.txt Libraries: https://repo1.maven.org/maven2/com/ibm/watson/developer_cloud/java-sdk/3.7.2/java-sdk-3.7.2-jar-with-dependencies.jar
licenses = BluemixUtility.showLicenses("serviceName=dashDB1")
for license in licenses:
name = license.getName()
url = license.getUrl()
libraries = license.getLibraries()
for lib in libraries:
print lib
showService
The script shows information about a service instance.
Argument | Required or Optional | Description |
---|---|---|
serviceName | Required | Specifies the name of the service to show. |
showCredentials | Optional | Specifies whether to show the service credentials. Use true to show
credentials and false to not show them. |
Syntax
service = BluemixUtility.showService("showCredentials=true", "serviceName=service_name")
Example usage
service = BluemixUtility.showService("showCredentials=true", "serviceName=dashDB1")
service2 = BluemixUtility.showService("showCredentials=true", "serviceName=myDiscoveryService")
Output: a CloudFoundryServiceInstance object
BluemixUtility.showServiceToString(service)
Name: dashDB1 Type: dashDB Plan: Entry Description: A flexible and powerful data warehouse for enterprise-level analytics. Documentation: https://console.ng.bluemix.net/docs/services/dashDB/dashDB.html Service keys: credential-1
print service2
Name: myDiscoveryService Type: discovery Plan: free Description: Add a cognitive search and content analytics engine to applications. Documentation: https://www.ibm.com/watson/developercloud/discovery.html Service keys: credential-1 password: password_value url: https://gateway.watsonplatform.net/discovery/api username: user_name_value
service = BluemixUtility.showService("showCredentials=true", "serviceName=dashDB1")
name = service.getName()
type = service.getService().getLabel()
plan = service.getPlan().getName()
desc = service.getService().getDescription()
doc = service.getService().getDocumentationUrl()
keys = service.getServiceKeys()
for k in keys:
key = k.getName()
switchService
The script switches to a different organization or space.
Argument | Required or Optional | Description |
---|---|---|
org | Optional | Specifies the organization name to switch. |
space | Optional | Specifies the space name to switch. |
Syntax
BluemixUtility.switchService("org=organization_name", "space=space_name")
Example usage
BluemixUtility.switchService("org=user1@us.ibm.com", "space=dev")
unbind
The script unbinds a service configuration from a product server.
Argument | Required or Optional | Description |
---|---|---|
scope | Required | Specifies a server scope to unbind from a service configuration. |
serviceName | Required | Specifies the name of the service configuration to unbind. |
Syntax
BluemixUtility.unbind("scope=Node=node_name:Server=server_name", "serviceName=service_name")
Example usage
BluemixUtility.unbind("scope=Node=myNode:Server=myServer", "serviceName=dashDB1")
BMUX0207I: Unbind successfully on service dashDB1.