Alex Amies, Solution Architect, IBMMay 2012IBM SmartCloud EnterpriseStorage Availability Areas and Dynamic Disk Attach /De...
Agenda• Concepts and Scenarios• Demos    • UI    • Command line    • Java API2                          © 2011 IBM Corpora...
Agenda• Concepts and Scenarios• Demos    • UI    • Command line    • Java API3                          © 2011 IBM Corpora...
ConceptsThe demo illustrates the use of storage availability areas and dynamic attach / detach featuresin an end-to-end da...
Scenarios for Data BackupWhole volume backup2.Create a storage volume – choose a storage area or accept the default3.Creat...
Scenarios for Image Import / CopyImage Import2.Create a storage volume3.Create a virtual machine4.Attach the volume to the...
Agenda• Concepts and Scenarios• Demos    • UI    • Command line    • Java API7                          © 2011 IBM Corpora...
User Interface in web portalThe storage availability area options appear in the storage volume provisioning wizard, in the...
Create Storage VolumeStorage availability areas are displayed for the supported data centers in the storage volumeprovisio...
Detailed View of Storage VolumeAfter a storage volume is provisioned then the availability area that the volume is provisi...
Clone Storage VolumeWhen cloning a storage volume you will be presented the choice of availability area forsupported data ...
Agenda• Concepts and Scenarios• Demos     • UI     • Command line     • Java API12                         © 2011 IBM Corp...
Demo – backup storage volume to a different availability area1.Create a volume in a known storage availability area    a)Q...
Demo with Command line toolUse Windows for demo, Linux is similarStep 1a: create password file and list storage availabili...
Demo with Command line toolStep 1b: Find storage volume offering informationUse data found in the create volume command, s...
Demo with Command line toolStep 1c: Create storage volume on a given availability areaUse the input parameters from steps ...
Demo with Command line toolStep 1d: Check status of new volume, wait for provisioning to completeIf the status is NEW or P...
Demo with Command line toolStep 2a: Find supported sizes and check support for dynamic attach / detach for selectedvirtual...
Demo with Command line toolStep 2b: Determine SSH key to use for new virtual machine instanceUse for create instance, step...
Demo with Command line toolStep 2c: Create an instance with selected image and supported sizeThe primary purpose of the in...
Demo with Command line toolStep 2d: Check state of instance - wait for instance to be createdWe are looking for an ACTIVE ...
Demo with Command line toolStep 2e: Dynamically attach storage volume to instanceGet the volume and instance IDs from prev...
Demo with Command line toolStep 2f: Log onto the instance and use the attached volume to store dataCheck presence of volum...
Demo with Command line toolStep 3a: Detach the volumeThe volume must be detached to clone it>ic-detach-volume.cmd -u a.use...
Demo with Command line toolStep 3b: Clone the volume to another availability area to back up the dataGet the source volume...
Demo with Command line toolStep 3c: Verifying Backup1.Attach the backup volume to the virtual machine instance2.Mount the ...
Agenda• Concepts and Scenarios• Demos     • UI     • Command line     • Java API27                         © 2011 IBM Corp...
Demo with Java APIStep 1a: Query to discover existing availability areasGet sample code StorageDemo.java in RAM assetAll t...
import java.util.List;import com.ibm.cloud.api.rest.client.*;import com.ibm.cloud.api.rest.client.bean.*;// Class to list ...
Java API DemoList availability areas - program outputFound storage area id 1, Area1, gpfs1 of SONAS1Found storage area id ...
Java API DemoStep 1b: Find storage volume offering ID, available sizes, and supported formatsThis method is part of the cl...
Java API DemoList offering IDs and supported sizes - program outputFound offering for target location: 20001208, Small, 25...
Java API DemoStep 1c: Method to create a volume in a specific storage availability areaThis method is also part of the cla...
Java API DemoStep 1d: Check status, wait until provisioning is completeThis method is a simple wrapper for the DeveloperCl...
Java API DemoMethod to list storage availability area for individual volumes - program outputVolume ID: 31598Name: My Disk...
Java API DemoStep 2a: Find supported sizes and check support for dynamic attach / detach for selectedvirtual machine image...
Java API DemoStep 2b: Determine if the image supports dynamic attach and detach - program outputImage ID: 20025206Image na...
Java API DemoStep 2c: Determine SSH key to use for virtual machine instanceprivate String getDefaultKey() throws Unauthori...
Java API DemoStep 2d: Create an instance with selected image and supported sizeprivate void createInstance(String instance...
Java API DemoMethod to create virtual machine instance - program outputProvisioning a new instanceNew instance with id: 23...
Java API DemoStep 2e: Check the state of instance - wait for instance to be createdThis method is a simple wrapper for Dev...
Java API DemoMethod to check status of virtual machine instance - program outputName: Java API Test InstanceStatus: ACTIVE...
Java API DemoStep 2f: Method to dynamically attach a volumeCall it from the main() methodprivate void attachVolume(String ...
Java API DemoStatus of virtual machine instance during attaching operation – web portalThe status changes to ATTACHING for...
Java API DemoStep 3a: Log onto the instance and use the attached volume to store dataSame as step 10 of the command line t...
Java API DemoStep 3b: Detach volumeCall it from the main methodprivate void dettachVolume(String instanceID, String volume...
Java API DemoStatus of virtual machine instance during detaching operation – web portalSelect the volume in the web portal...
Java API DemoStep 3b: Status of volume during cloning operation – Java methodClone volume with ID 31598, named My Disk, fr...
Java API DemoStatus of volume during cloning operation – web portal49                                                     ...
Java API DemoStep 3c: Verifying BackupSame as step 13 of the command line tool demo50                                     ...
ResourcesInfrastructure as a service cloud development Bloghttps://www.ibm.com/developerworks/mydeveloperworks/blogs/iaas_...
Trademarks and notes©IBM Corporation 2012IBM, the IBM logo, ibm.com, Cognos, DB2, Informix, Lotus, Rational, SmartCloud, S...
Upcoming SlideShare
Loading in …5
×

IBM SmartCloud Enterprise Storage Demo

3,897 views

Published on

The demo illustrates the use of storage availability areas and dynamic attach / detach features in an end-to-end data back-up and verification scenario on SmartCloud Enterprise with the command line tool and Java API.

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
3,897
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
25
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

IBM SmartCloud Enterprise Storage Demo

  1. 1. Alex Amies, Solution Architect, IBMMay 2012IBM SmartCloud EnterpriseStorage Availability Areas and Dynamic Disk Attach /Detach Demowww.ibm.com/cloud/enterprise/ © 2011 IBM Corporation
  2. 2. Agenda• Concepts and Scenarios• Demos • UI • Command line • Java API2 © 2011 IBM Corporation
  3. 3. Agenda• Concepts and Scenarios• Demos • UI • Command line • Java API3 © 2011 IBM Corporation
  4. 4. ConceptsThe demo illustrates the use of storage availability areas and dynamic attach / detach featuresin an end-to-end data back-up and verification scenario.A storage volume in SmartCloud Enterprise is a virtualized block storage unit. It can bemounted to a virtual machine as a storage device and formatted with a file system to store data.Other terms sometimes used to refer to the same concept in SCE are storage unit or justvolume. Cloud users can use storage availability areas to store data in different areas withinthe same data center for the back-up purposes.When creating a storage volume a storage availability area can optionally be chosen for thevolume to be provisioned to. If no storage availability is chosen then one will be assigned bythe system. When cloning a storage volume it may be cloned to a different data center.A storage volume may be attached to a virtual machine instance after creation using dynamicattach. This is in contrast to static attach where a storage volume is attached to a disk duringthe virtual machine creation time. The storage volume may be detached without deleting thevirtual machine instance using dynamic detach.4 © 2011 IBM Corporation
  5. 5. Scenarios for Data BackupWhole volume backup2.Create a storage volume – choose a storage area or accept the default3.Create a virtual machine4.Attach the volume to the virtual machine (separate step, i.e. dynamically)5.Add data to the volume6.Detach the volume7.Backup the data by cloning the volume8.Re-attach the volume and continue using it9.Note: you must dynamically attach and detach for this scenario to workData backup12.Create two volumes each on different availability areas13.Create a virtual machine attaching both volumes (single step or two steps, i.e. eitherstatically or dynamically)14.Use one volume for active data storage and retrieval15.Back-up data by copying to the other volume16.Note: need to manage your own data with mounted volumes in this case5 © 2011 IBM Corporation
  6. 6. Scenarios for Image Import / CopyImage Import2.Create a storage volume3.Create a virtual machine4.Attach the volume to the virtual machine (separate step, i.e. dynamically)5.Upload a virtual machine image OVF bundle to the volume using the native tools in the virtualmachine6.Detach the volume7.Import the image to the cloud using the image import API or command lineImage Copy10.Create a storage volume11.Copy a virtual machine image OVF bundle to the volume from the cloud image repositoryusing the SCE image copy command or API12.Create a virtual machine13.Attach the volume to the virtual machine (i.e. dynamically)14.Copy the image OVF bundle from the volume to a location outside the cloud using the nativetools of the virtual machine6 © 2011 IBM Corporation
  7. 7. Agenda• Concepts and Scenarios• Demos • UI • Command line • Java API7 © 2011 IBM Corporation
  8. 8. User Interface in web portalThe storage availability area options appear in the storage volume provisioning wizard, in thestorage volume table, and in the clone storage volume dialog.Dynamic attach and detach are not available in the user interface. However, the changes instate for triggered by their use via the command line tool and API are apparent in the userinterface.8 © 2011 IBM Corporation
  9. 9. Create Storage VolumeStorage availability areas are displayed for the supported data centers in the storage volumeprovisioning wizard.9 © 2011 IBM Corporation
  10. 10. Detailed View of Storage VolumeAfter a storage volume is provisioned then the availability area that the volume is provisioned towill be displayed.10 © 2011 IBM Corporation
  11. 11. Clone Storage VolumeWhen cloning a storage volume you will be presented the choice of availability area forsupported data centers.11 © 2011 IBM Corporation
  12. 12. Agenda• Concepts and Scenarios• Demos • UI • Command line • Java API12 © 2011 IBM Corporation
  13. 13. Demo – backup storage volume to a different availability area1.Create a volume in a known storage availability area a)Query to discover existing availability areas b)Find storage volume offering ID, available sizes, and supported formats c) Create storage volume on a selected availability area d)Check status, wait until provisioning is complete2.Use the volume to store data a)Find supported sizes and check support for dynamic attach / detach for selected virtual machine image b)Determine SSH key to use for new virtual machine instance c) Create an instance with selected image and supported size d)Check state of instance - wait for instance to be created e)Dynamically attach storage volume to instance f) SSH to instance, partition, format, and mount the volume. Now that it is ready to use, save data to it.3.Back the volume up a)Detach the volume • Clone the volume to another availability area to back up the data c) Dynamically attach the cloned storage volume to the instance to verify that the data has been backed up successfully13 © 2011 IBM Corporation
  14. 14. Demo with Command line toolUse Windows for demo, Linux is similarStep 1a: create password file and list storage availability areas# Create a password file> ic-create-password.cmd -u a.user@example.com -p *** -w unlock -g mykey.ext# Find storage availability areas with the describe locations command> ic-describe-locations.cmd -u a.user@example.com -w unlock -g mykey.extID: 41Location: RTPName: Raleigh, U.S.AState: ONLINEDescription: This data center is located in Raleigh, North Carolina, U.S.A. Theservices provided are: Guest Instances, Image Capture, Persistent Storage, Reserved IP, Private VLAN/VPN.Available Storage Areas : Storage Area Id: 2 Storage Area Name: Area2 ............... Storage Area Id: 1 Storage Area Name: Area1...14 © 2011 IBM Corporation
  15. 15. Demo with Command line toolStep 1b: Find storage volume offering informationUse data found in the create volume command, step 1c>ic-describe-volume-offerings.cmd -u a.user@example.com -w unlock -g mykey.ext...ID: 20035200 ## Note for create volume commandName: StorageLabel: StorageLocation: 41 ## Data is for RTP, other locations will be listed but output is not shown hereSupported sizes in Gib: 60,256,512,1024,2048,4112,8224,10240 ## Use offering ID with list of numeric sizesPrice: $0/GHRCurrencyCode: USDCountryCode: SPTPricePerQuantity: 1UnitOfMeasure: GHRSupported Format :~~~~~~Format : EXT3Format : RAW ## In upper case, note for create volume command...15 © 2011 IBM Corporation
  16. 16. Demo with Command line toolStep 1c: Create storage volume on a given availability areaUse the input parameters from steps 1a and 1b, note the volume ID for step 2e>ic-create-volume.cmd -u a.user@example.com -w unlock -g mykey.ext -n"Storage Demo" -s 60 -f RAW -L 41 -O 20035200 -A1Executing action: CreateVolume ...The request has been submitted successfully.ID: 31854 ## Used laterName: Storage DemoOwner: a.user@example.comSize: 60Format : rawInstanceId:OfferingID: 20035200Storage Area Id: 1Storage Area Name: Area1CreatedTime: May 18, 2012 2:55:30 PM CSTExecuting CreateVolume finished16 © 2011 IBM Corporation
  17. 17. Demo with Command line toolStep 1d: Check status of new volume, wait for provisioning to completeIf the status is NEW or PROVISIONING wait for a few minutes and try again>ic-describe-volume.cmd -u a.user@example.com -w unlock -g mykey.ext -v 31854Executing action: DescribeVolume ...ID: 31854Name: Storage DemoOwner: a.user@example.comSize: 60 GibFormat : rawInstanceId:State: UNMOUNTEDLocation: 41Storage Area Id: 1Storage Area Name: Area1I/O operation price: $0.11/millionCreatedTime: May 18, 2012 2:55:30 PM CSTPlatform Version: 2Executing DescribeVolume finished17 © 2011 IBM Corporation
  18. 18. Demo with Command line toolStep 2a: Find supported sizes and check support for dynamic attach / detach for selectedvirtual machine image>ic-describe-image.cmd -u a.user@example.com -w unlock -g mykey.ext -k 20025206Executing action: DescribeImage ...ID: 20025206Name: Red Hat Enterprise Linux 6.2 (64-bit)(RTP)Visibility: PUBLICState: AVAILABLEOwner: SYSTEMPlatform: Red Hat Enterprise Linux/6Platform Version: 1.2 ## OKLocation: 41Image Size: 5.781006 Gib----------------------------------InstanceType ID: COP64.2/4096/60 ## Needed in the ic-create-instance commandLabel: Copper 64 bitDetail: Copper - 64 bit (vCPU: 2, RAM: 4 GiB, Disk: 60 GiB)Price: $0.3/UHRCurrencyCode: USDCountryCode: SPTPricePerQuantity: 1UnitOfMeasure: UHR...18 © 2011 IBM Corporation
  19. 19. Demo with Command line toolStep 2b: Determine SSH key to use for new virtual machine instanceUse for create instance, step 2c>ic-describe-keypairs.cmd -u a.user@example.com -w unlock -g mykey.extExecuting action: DescribeKeyPairs ...10 keys----------------------------------Name: july26 ## Needed in the ic-create-instance commandDefault Key: trueMaterial: ***LastModifiedTime: August 28, 2011 9:39:05 PM CST1 instances related. Instance ID: 210671...19 © 2011 IBM Corporation
  20. 20. Demo with Command line toolStep 2c: Create an instance with selected image and supported sizeThe primary purpose of the instance is to access data on the storage volume>ic-create-instance.cmd -u a.user@example.com -w unlock -g mykey.ext -t "COP64.2/4096/60" -n "Storage Demo VM" -k20025206 -c july26 -L 41Executing action: CreateInstance ...The request has been submitted successfully.1 instances!----------------------------------ID: 234165 ## Needed later in multiple commandsName: Storage Demo VMHostname:InstanceType: COP64.2/4096/60IP:KeyName: july26Owner: a.user@example.comRequestID: 234465RequestName: Storage Demo VMStatus: NEW ## Need to wait for the status to change to ACTIVEVolume IDs:----------------------------------Executing CreateInstance finished20 © 2011 IBM Corporation
  21. 21. Demo with Command line toolStep 2d: Check state of instance - wait for instance to be createdWe are looking for an ACTIVE state to move to the next step>ic-describe-instance.cmd -u a.user@example.com -w unlock -g mykey.ext -l 234165Executing action: DescribeInstance ...ID: 234165Name: Storage Demo VMImage ID: 20025206Hostname: vhost1772.site1.compute.ihost.comInstanceType: COP64.2/4096/60IP: 170.224.166.242KeyName: july26Owner: aamies@cn.ibm.comRequestID: 234465RequestName: Storage Demo VMStatus: ACTIVELocation: 41Volume IDs:Disk Size: 60Minimal local disk: falseExpiration Time: May 18, 2014 5:36:30 PM CSTExecuting DescribeInstance finished21 © 2011 IBM Corporation
  22. 22. Demo with Command line toolStep 2e: Dynamically attach storage volume to instanceGet the volume and instance IDs from previous steps 1c and 2c>ic-attach-volume.cmd -u a.user@example.com -w unlock -g mykey.ext -l 234165 -v 31854Executing action: AttachVolume ...The request has been submitted successfully.Executing AttachVolume finished## Virtual machine status will go ATTACHING. Check status as in previous step to wait for state to return to ACTIVE.>ic-describe-instance.cmd -u a.user@example.com -w unlock -g mykey.ext -l 234165...Status: ATTACHING...>ic-describe-instance.cmd -u aamies@cn.ibm.com -w unlock -g mykey.ext -l 234165...Status: ACTIVE...22 © 2011 IBM Corporation
  23. 23. Demo with Command line toolStep 2f: Log onto the instance and use the attached volume to store dataCheck presence of volume (vdc) and partition it (Bash commands)Log onto instance with SSH and change to root$ sudo /bin/bash# /sbin/fdisk -l ## List partitionsDisk /dev/vda: 64.4 GB, 64425558016 bytes...Disk /dev/vdb: 4294 MB, 4294967296 bytes...Disk /dev/vdc: 64.4 GB, 64424509440 bytes ## Newly attached partition...Disk /dev/vdc doesnt contain a valid partition table ## Not partitioned# /sbin/fdisk /dev/vdc ## Partition the new volume, follow the menu...# mkfs -t ext3 /dev/vdc1 ## Format the partition to ext3...# mkdir /volume1 ## Create mount point# /bin/mount /dev/vdc1 /volume1 ## Mount the file system# cd /volume1 ## Write data to the volume# vi my_data.txt...# umount /volume1 ## unmount file system# exit ## Log out of instance23 © 2011 IBM Corporation
  24. 24. Demo with Command line toolStep 3a: Detach the volumeThe volume must be detached to clone it>ic-detach-volume.cmd -u a.user@example.com -w unlock -g mykey.ext -l 234165 -v 31854Executing action: DetachVolume ...The request has been submitted successfully.Executing DetachVolume finished## Volume status will go ATTACHING. Check status as in previous step to wait for state to return to UNMOUNTED.>ic-describe-volume.cmd -u aamies@cn.ibm.com -w unlock -g mykey.ext -v 31854...State: DETACHING...>ic-describe-volume.cmd -u aamies@cn.ibm.com -w unlock -g mykey.ext -v 31854...State: UNMOUNTED24 © 2011 IBM Corporation
  25. 25. Demo with Command line toolStep 3b: Clone the volume to another availability area to back up the dataGet the source volume ID from step 1c>ic-clone-volume.cmd -u a.user@example.com -w unlock -g mykey.ext -n Backup -v 31854 -A 2Executing action: CloneVolume ...The request has been submitted successfully.ID: 31872Name: BackupOwner: aamies@cn.ibm.comSize: 60Format : rawInstanceId:OfferingID: 20035200Storage Area Id: 2Storage Area Name: Area2Data Center Location: 41CreatedTime: May 18, 2012 6:18:52 PM CSTExecuting CloneVolume finished25 © 2011 IBM Corporation
  26. 26. Demo with Command line toolStep 3c: Verifying Backup1.Attach the backup volume to the virtual machine instance2.Mount the volume to the file system3.List the files on the volume to make sure that they are the same as the source volume# /bin/mount /dev/vdc1 /volume1# ls -l /volume1total 20drwx------. 2 root root 16384 May 16 09:41 lost+found-rw-r--r--. 1 root root 13 May 16 09:43 my_data.txt# umount /volume1# exit26 © 2011 IBM Corporation
  27. 27. Agenda• Concepts and Scenarios• Demos • UI • Command line • Java API27 © 2011 IBM Corporation
  28. 28. Demo with Java APIStep 1a: Query to discover existing availability areasGet sample code StorageDemo.java in RAM assetAll the examples that follow are methods that are added to the main program on the next page.Classes and packages to import with the Java API examplesimport com.ibm.cloud.api.rest.client.DeveloperCloud;import com.ibm.cloud.api.rest.client.DeveloperCloudClient;import com.ibm.cloud.api.rest.client.bean.*;28 © 2011 IBM Corporation
  29. 29. import java.util.List;import com.ibm.cloud.api.rest.client.*;import com.ibm.cloud.api.rest.client.bean.*;// Class to list storage areas in a locationpublic class StorageDemo { public static final String USERNAME = "a.user@example.com"; public static final String PASSWORD = "***"; private DeveloperCloudClient client = DeveloperCloud.getClient(); public StorageDemo() { client.setRemoteCredentials(USERNAME, PASSWORD); } // Method to list storage areas private void describeStorageAreas(String locationID) throws UnknownErrorException, IOException { List<Location> locations = client.describeLocations(); for (Location l: locations) { if (locationID.equals(l.getId())) { List<StorageArea> storageAreas = l.getStorageAreas(); for (StorageArea storageArea : storageAreas) { System.out.println("Found storage area id " + storageArea.getId() + ", " + storageArea.getName() + ", " + storageArea.getDescription()); } } } } public static void main(String[] args) throws Exception { StorageDemo demo = new StorageDemo(); demo.describeStorageAreas("41"); }}29 © 2011 IBM Corporation
  30. 30. Java API DemoList availability areas - program outputFound storage area id 1, Area1, gpfs1 of SONAS1Found storage area id 2, Area2, gpfs2 of SONAS130 © 2011 IBM Corporation
  31. 31. Java API DemoStep 1b: Find storage volume offering ID, available sizes, and supported formatsThis method is part of the class in step 1aprivate void describeStorageOfferings(String locationID) throws UnknownErrorException, IOException, UnauthorizedUserException { List<VolumeOffering> volumeOfferings = client.describeVolumeOfferings(); for (VolumeOffering volumeOffering: volumeOfferings) { if (locationID.equals(volumeOffering.getLocation())) { System.out.println("Found offering for target location: " + volumeOffering.getId() + ", " + volumeOffering.getName() + ", " + volumeOffering.getLabel()); if ((volumeOffering.getSupportedSizes() != null) && (volumeOffering.getSupportedSizes().size() > 1)) { List<Long> sizes = volumeOffering.getSupportedSizes(); System.out.print("Sizes: "); for (Long size : sizes) { System.out.print(" " + size); } System.out.println(); } } }}31 © 2011 IBM Corporation
  32. 32. Java API DemoList offering IDs and supported sizes - program outputFound offering for target location: 20001208, Small, 256 GiBFound offering for target location: 20001209, Medium, 512 GiBFound offering for target location: 20001210, Large, 2048 GiBFound offering for target location: 20035200, Storage, StorageSizes: 60 256 512 1024 2048 4112 8224 1024032 © 2011 IBM Corporation
  33. 33. Java API DemoStep 1c: Method to create a volume in a specific storage availability areaThis method is also part of the class in step 1aprivate void createVolume(String name, String locationID, String offeringId, String format, String size, String areaID) throws InsufficientResourcesException, InvalidConfigurationException, PaymentRequiredException, UnauthorizedUserException, UnknownErrorException, IOException { Volume volume = client.createVolume(name, locationID, offeringId, format, size, areaID); System.out.println("Volume ID: " + volume.getID());}...// Invoke the methoddemo.createVolume("My Disk", "41", "20035200", "RAW", "60", "1");33 © 2011 IBM Corporation
  34. 34. Java API DemoStep 1d: Check status, wait until provisioning is completeThis method is a simple wrapper for the DeveloperCloudClient.describeVolumes methodthat prints out some information about the volumesprivate void describeVolumes() throws InsufficientResourcesException, InvalidConfigurationException, PaymentRequiredException, UnauthorizedUserException, UnknownErrorException, IOException, UnknownVolumeException { List<Volume> volumes = client.describeVolumes(); for (Volume volume : volumes) { System.out.println("Volume ID: " + volume.getID()); System.out.println("Name: " + volume.getName()); System.out.println("State: " + volume.getState()); System.out.println("Area: " + volume.getStorageArea().getId() + ", " + volume.getStorageArea().getName()); }}…demo.describeVolumes();34 © 2011 IBM Corporation
  35. 35. Java API DemoMethod to list storage availability area for individual volumes - program outputVolume ID: 31598Name: My DiskState: UNMOUNTEDArea: 1, Area135 © 2011 IBM Corporation
  36. 36. Java API DemoStep 2a: Find supported sizes and check support for dynamic attach / detach for selectedvirtual machine imageGiven by the platform version property, which must be at least 1.2private Image getImage(String imageID) throws UnauthorizedUserException, UnknownImageException, UnknownErrorException, IOException { Image image = client.describeImage(imageID); System.out.println("Image ID: " + image.getID()); System.out.println("Image name: " + image.getName()); System.out.println("Image Platform Version: " + image.getPlatformVersion()); List<InstanceType> supportedSizes = image.getSupportedInstanceTypes(); for (InstanceType supportedSize : supportedSizes) { System.out.println("Size: " + supportedSize.getId() + ", " + supportedSize.getLabel()); } return image;}...Image image = demo.getImage("20025206");36 © 2011 IBM Corporation
  37. 37. Java API DemoStep 2b: Determine if the image supports dynamic attach and detach - program outputImage ID: 20025206Image name: Red Hat Enterprise Linux 6.2 (64-bit)(RTP)Image Platform Version: 1.2Size: COP64.2/4096/60, Copper 64 bitSize: BRZ64.2/4096/60*500*350, Bronze 64 bitSize: SLV64.4/8192/60*500*500, Silver 64 bitSize: GLD64.8/16384/60*500*500, Gold 64 bitSize: PLT64.16/16384/60*500*500*500*500, Platinum 64 bitSize: PM264.16/32768/60*500*500*500*500, Platinum-M2 64 bit37 © 2011 IBM Corporation
  38. 38. Java API DemoStep 2c: Determine SSH key to use for virtual machine instanceprivate String getDefaultKey() throws UnauthorizedUserException, UnknownErrorException, IOException { String defaultKey = null; List<Key> keys = client.describeKeys(); for (Key key: keys) { System.out.println("Found key with name " + key.getName()); if (key.isDefaultKey()) { defaultKey = key.getName(); } } System.out.println("Found default key " + defaultKey); return defaultKey;}38 © 2011 IBM Corporation
  39. 39. Java API DemoStep 2d: Create an instance with selected image and supported sizeprivate void createInstance(String instanceName, Image image, String instanceTypeIdStr, String keyName) throws UnauthorizedUserException, UnknownErrorException, IOException, InsufficientResourcesException, InvalidConfigurationException, PaymentRequiredException { System.out.println("Provisioning a new instance"); String location = image.getLocation(); String imageID = image.getID(); Address address = null; Volume volume = null; // Create instance List<Instance> instances = client.createInstance(instanceName, location, imageID, instanceTypeIdStr, keyName, address, volume, new HashMap<String,Object>()); // Check the status of the provisioning test for (Instance instance: instances) { System.out.println("New instance with id: " + instance.getID() + " status: " + instance.getStatus()); }}...Image image = demo.getImage("20025206");String keyName = demo.getDefaultKey();demo.createInstance("Java API Test Instance", image, "COP64.2/4096/60", keyName);39 © 2011 IBM Corporation
  40. 40. Java API DemoMethod to create virtual machine instance - program outputProvisioning a new instanceNew instance with id: 232906 status: NEW40 © 2011 IBM Corporation
  41. 41. Java API DemoStep 2e: Check the state of instance - wait for instance to be createdThis method is a simple wrapper for DeveloperCloudClient.describeInstanceprivate void describeInstance(String id) throws InsufficientResourcesException, InvalidConfigurationException, PaymentRequiredException, UnauthorizedUserException, UnknownErrorException, IOException, UnknownInstanceException { Instance instances = client.describeInstance(id); System.out.println("Name: " + instances.getName()); System.out.println("Status: " + instances.getStatus()); List<String> volumeIds = instances.getVolumeIds(); System.out.println("Number of attached volumes: " + volumeIds.size()); for (String volumeId : volumeIds) { System.out.println("VolumeId: " + volumeId); }}...demo.describeInstance("232906");41 © 2011 IBM Corporation
  42. 42. Java API DemoMethod to check status of virtual machine instance - program outputName: Java API Test InstanceStatus: ACTIVENumber of attached volumes: 042 © 2011 IBM Corporation
  43. 43. Java API DemoStep 2f: Method to dynamically attach a volumeCall it from the main() methodprivate void attachVolume(String instanceID, String volumeID) throws UnauthorizedUserException, InvalidConfigurationException, InvalidStateException, UnknownErrorException, UnSupportFeatureException, IOException { client.attachStorage(instanceID, volumeID);}...demo.attachVolume("232906", "31598");// Check status as above or check in web portal as shown on the next page43 © 2011 IBM Corporation
  44. 44. Java API DemoStatus of virtual machine instance during attaching operation – web portalThe status changes to ATTACHING for a short period44 © 2011 IBM Corporation
  45. 45. Java API DemoStep 3a: Log onto the instance and use the attached volume to store dataSame as step 10 of the command line tool demo, which lists the Bash commands45 © 2011 IBM Corporation
  46. 46. Java API DemoStep 3b: Detach volumeCall it from the main methodprivate void dettachVolume(String instanceID, String volumeID) throws UnauthorizedUserException, InvalidConfigurationException, InvalidStateException, UnknownErrorException, UnSupportFeatureException, IOException { client.detachStorage(instanceID, volumeID);}...demo.dettachVolume("232906", "31598");// Check status as above or check in web portal as shown on the next page46 © 2011 IBM Corporation
  47. 47. Java API DemoStatus of virtual machine instance during detaching operation – web portalSelect the volume in the web portal to see the notifications for it47 © 2011 IBM Corporation
  48. 48. Java API DemoStep 3b: Status of volume during cloning operation – Java methodClone volume with ID 31598, named My Disk, from availability area 1 to area 2private void cloneVolume(String name, String volumeID, String targetAreaID) throws InsufficientResourcesException, InvalidConfigurationException, PaymentRequiredException, UnauthorizedUserException, UnknownErrorException, IOException { client.cloneVolume(name, volumeID, targetAreaID);}...demo.cloneVolume("Backup", "31598", "2");48 © 2011 IBM Corporation
  49. 49. Java API DemoStatus of volume during cloning operation – web portal49 © 2011 IBM Corporation
  50. 50. Java API DemoStep 3c: Verifying BackupSame as step 13 of the command line tool demo50 © 2011 IBM Corporation
  51. 51. ResourcesInfrastructure as a service cloud development Bloghttps://www.ibm.com/developerworks/mydeveloperworks/blogs/iaas_cloud/?lang=enSCE Command Line Toolkit and Referencehttps://www-147.ibm.com/cloud/enterprise/ram/assetDetail/generalDetails.faces?guid={F1466F46-A4AB-3879-D883-1A26A43BF046}SCE Java API and JavaDochttps://www-147.ibm.com/cloud/enterprise/ram/search/_rlvid.jsp.faces?_rap=!assetDetails&_rvip=/s={555C7964-F531-AECF-F8E9-F5F2D37B64D8}SCE REST User Guidehttps://www-147.ibm.com/cloud/enterprise/ram/artifact/%7B62ACBF96-CEF0-0B67-8529-14438806Red Hat Enterprise Linux Storage Administration Guidehttp://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guid51 © 2011 IBM Corporation
  52. 52. Trademarks and notes©IBM Corporation 2012IBM, the IBM logo, ibm.com, Cognos, DB2, Informix, Lotus, Rational, SmartCloud, System x, Tivoli andWebSphere are trademarks or registered trademarks of International Business Machines Corporation in theUnited States, other countries, or both. If these and other IBM trademarked terms are marked on their firstoccurrence in this information with the appropriate symbol (® or ™), these symbols indicate US registered orcommon law trademarks owned by IBM at the time this information was published. Such trademarks mayalso be registered or common law trademarks in other countries. A current list of IBM trademarks isavailable on the web at “Copyright and trademark information” at www.ibm.com/legal/copytrade.shtmlIntel is a trademark of Intel Corporation or its subsidiaries in the United States and other countries.Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both.Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other countries, orboth.Other company, product and service names may be trademarks or service marks of others.References in this publication to IBM products or services do not imply that IBM intends to make themavailable in all countries in which IBM operates.52 © 2011 IBM Corporation

×