Create an IBM Cloud instance with the Windows command line

Learn how to use the command line from Windows™ to create an instance in the IBM® SmartCloud Enterprise environment. This article shows you how to configure the instance to use the Windows command line, and the steps to create the instance using the command line. The author also shows you how to create multiple instances with a simple script.

Boas Betzler, Senior Technical Staff, IBM

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 , Staff Software Engineer, IBM

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.



31 January 2011 (First published 05 January 2011)

Also available in Japanese

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:

  1. 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.
  2. Unzip the packages into a new folder and set execute permission to scripts files (in other words, give it a .cmd extension).
  3. Install the IBM Java™ version from the Java website.
  4. Find the exact path of the Java code and export that path to run script commands that work properly:

    Set JAVA _HOME path:
    C:\> set JAVA_HOME=C:\Program Files\Java\jre

    Set the PATH environment variable to include the Java bin directory:
    C:\> set PATH=%PATH%;%JAVA_HOME%\bin

Creating an instance

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:

  1. Create a password file on the client system where you use the command line tool.
  2. Find the data center ID.
  3. Find the instance type.
  4. Create the instance.

Create the password file

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

Find the data center ID

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

Find the instance type

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

Create the instance

The following parameters are used with the command to create the instance. Be sure to have this information available.

  • -u for username
  • -w for passphrase
  • -g for password file
  • -t for instance type
  • -k for image id
  • -L for datacenter id
  • -n for Instance name
  • -d for Instance description
  • -m for 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:

  1. The script file has to be saved in the script command folder.
  2. Before you create this script, you should know all the required parameters needed to create an instance using the ic-create-instance command.

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")

In conclusion

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.

Resources

Learn

Get products and technologies

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Cloud computing on developerWorks


  • Bluemix Developers Community

    Get samples, articles, product docs, and community resources to help build, deploy, and manage your cloud apps.

  • Cloud digest

    Complete cloud software, infrastructure, and platform knowledge.

  • DevOps Services

    Software development in the cloud. Register today to create a project.

  • Try SoftLayer Cloud

    Deploy public cloud instances in as few as 5 minutes. Try the SoftLayer public cloud instance for one month.

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Cloud computing
ArticleID=606130
ArticleTitle=Create an IBM Cloud instance with the Windows command line
publish-date=01312011