The IBM SmartCloud Enterprise provides on demand development and test infrastructure services for enterprises. This environment enables reduced costs and time savings on development and test efforts by eliminating the need for organizations to set up and run project infrastructure. It also provides capabilities that make it easy to engage administrative features such as provisioning an instance, creating an image, creating storage volumes, and adding IP addresses.
The graphical user interface (GUI), HTTP REST API, and the command line tool are the three methods available to interface with the IBM Cloud:
- The GUI is the most commonly used method.
- The HTTP REST API provides a programming language that lets users create calls from their own applications or third-party apps to interact with the cloud.
- The command line tool is an efficient way to help users perform some administrative tasks, especially repetitive tasks.
This article addresses the use of the command line (CL) tool in Windows (the CL tool supports both Windows and Linux®). See the article for using the command line on Linux. This article shows how to configure an instance to use the CL tool, how to install the CL tool, and how to use the CL tool to manage other instances and resources. Scripts can be created based on the CL tool commands to perform repetitive command execution. An example script for creating multiple instances is illustrated.
Configuring an instance to use the command line tool
To configure an instance:
- Download CMD line package from the Support tab on the IBM public cloud website and copy in your instance.
In your Windows instance, open Internet Explorer (your browser) to login to the IBM Cloud. Go to the Support tab, click Command Line Tool Reference. After it opens, click Content in the left menu, download the DeveloperCloud_CMD_Tool.zip file and save it in your instance. - Unzip the packages into a new folder and set execute permission to scripts files (in other words, give it a .cmd extension).
- Install the IBM Java™ version from the Java website.
- Find the exact path of the Java code and export that path to run script commands that work properly:
SetJAVA _HOMEpath:C:\> set JAVA_HOME=C:\Program Files\Java\jre
Set thePATHenvironment variable to include the Java bin directory:C:\> set PATH=%PATH%;%JAVA_HOME%\bin
This procedure lets you create an instance with manual processing using batch script commands.
To create an instance using the command line, you need to:
- Create a password file on the client system where you use the command line tool.
- Find the data center ID.
- Find the instance type.
- Create the instance.
Before you use the command line tool, create a password file to prevent your password from being stolen when you type it in a command line.
Enter in the command line:
#./ic-create-password.cmd -u <user name> -p <password> -w unlock -g C:\keys\pass.txt |
You should see:
Executing action: CreatePassword ... Password File created successfully! Path : C:\keys\pass.txt File Name : pass.txt Please do not edit this file! Created password successfully. Executing CreatePassword finished |
The data center is where images and instances are located.
Enter in the command line:
#./ic-describe-locations.cmd -u <username> -w <passphrase> -g <password file> |
You should see:
Executing action: Describe Locations ... 4 locations! ---------------------------------- ID : 41 Location : RTP Name : RTP State : ONLINE Description : RTP usrdtsa0a1ccxra ---------------------------------- ---------------------------------- ID : 61 Location : EHN Name : EHN State : ONLINE Description : ---------------------------------- ---------------------------------- ID : 82 Location : us-co-dc1 Name : us-co-dc1 State : ONLINE Description : BLD main DC ---------------------------------- Executing Describe Locations finished |
From this command you'll get both the ID and the instance type ID. Enter in the command line:
#./ic-describe-images.cmd -u <username> -w <passphrase> -g <password file path> |
You should see:
ID : 20003155
InstanceType ID : BRZ32.1/2048/60*175
InstanceType ID : COP32.1/2048/60
InstanceType ID : GLD32.4/4096/60*350
InstanceType ID : SLV32.2/4096/60*350
ID : 20007821
InstanceType ID : BRZ32.1/2048/60*175
InstanceType ID : COP32.1/2048/60
InstanceType ID : GLD32.4/4096/60*350
InstanceType ID : SLV32.2/4096/60*350
|
The following parameters are used with the command to create the instance. Be sure to have this information available.
-ufor username-wfor passphrase-gfor password file-tfor instance type-kfor image id-Lfor datacenter id-nfor Instance name-dfor Instance description-mfor UserName and Password
Enter in the command line:
#./ic-create-instance.cmd -u <username> -w <passphrase> -g <password file path>
-t <instance type> (for example, COP32.1/2048/60) -k <image id> (for example, 20010002)
-L <datacenter ID> (for example, 61)
-n <instance name> (for example, Windows_2003_R2_32bi) -d "CMD line instance"
-m <configuration> (for example, {UserName:user,Password:password})
|
Creating multiple instances with your own script file
The example script below lets you create multiple instances on the IBM Cloud without the use of the GUI.
This script uses a while loop and lets you create two instances, but you can alter it to create more.
for /L %%A in (0, 1, 1) do ic-create-instance -u user@ibm.com -w unlock
-g C:\keys\mykey.txt -t COP32.1/2048/60 -n Windows2003R2NEW%%A -k 20013858
-d CMD_Instance -m {UserName:Name,Password:Password} -L 61
|
To change the number of instances, alter this bit of the code:
(0,1,1).
As is, this creates two instances: instance 0 and instance 1:
- To create three instances (i0-i2):
(0,1,2). - To create three instances (i1-i3):
(1,1,3). - To create four instances (i0-i3):
(0,1,3). - To create four instances (i1-i4):
(1,1,4). - To create five instances (i0-i4):
(0,1,4).
And so on.
Save this script in a file with the extension .cmd and keep it in the command line tool folder. You need to provide execute permission for the file.
Two things to note about using this script:
- The script file has to be saved in the script command folder.
- Before you create this script, you should know all the required parameters needed to create an instance using the
ic-create-instancecommand.
Creating a private image with this instance
After you successfully configured the command line tool in your instance, you can save it as a private image which will have all the configurations you have built for this command line tool. Whenever you want to create instances with the command line tool, you can use this image to create an instance and the command line tool will be automatically attached.
Enter on the command line:
#./ic-save-instance.cmd -u <username> -w <passphrase> -g <password file path> -l <instance id> (for example, 42828) -n <image name> (for example, "Windows with Command Line Tool") -d <description> (for example, "A Windows image installed command line tool") |
Using the command line tool to administer your instances is very efficient and quite easy; it saves you from many of the "clicking" steps you encounter when using the graphical user interface.
For a Linux client system, see Create an IBM Cloud instance with the Linux command line.
Learn
- Find more information about the commands and parameters on the Support tab of
the Cloud Development and Test page.
See "Command Line Tool Reference Card" and "Command Line Tool Reference"
in the Documentation library list.
-
For more on Release 1.2, listen to the Brian Snitzer podcast.
-
In the developerWorks cloud developer resources, discover and share knowledge and experience of application and services developers building their projects for cloud deployment.
-
The next steps: Find out how to access IBM SmartCloud Enterprise.
Get products and technologies
-
See the product images available on the IBM SmartCloud Enterprise.
Discuss
-
Join a cloud computing group on developerWorks.
-
Read all the great cloud blogs on developerWorks.
-
Join the developerWorks community, a professional network and unified set of community tools for connecting, sharing, and collaborating.
Boas Betzler is a senior technical staff member and member of the IBM Academy of Technology. He has worldwide responsibility for the image center of both the public IBM Compute Cloud and the IBM Shared Private Production Cloud.
Du Li Juan joined IBM as the L3 team lead for IBM GTS Platform Integration and Deployment Services and assumed responsibility of development and support for the service automation solutions based on Lotus Domino technologies. In her current role, she works on best practices for the IBM Smart Business Development and Test Cloud.




