Speed Up Image Imports to IBM Cloud Infrastructure

By: Rodney Rabe, Aaron Sahlin, and Mike Wurtz

IBM Cloud Object Storage now accessible from IBM Cloud infrastructure for importing and exporting images

If you’ve ever tried uploading an image to Object Storage OpenStack Swift so that you can import it to IBM Cloud infrastructure and provision virtual servers, you know that Swift’s limits on file size can create a bit of additional pain to getting your image uploaded. You have another option! IBM Cloud infrastructure now interacts with the IBM Cloud Object Storage (COS) service provisioned on the IBM Cloud console. COS offers the Aspera high-speed transfer plug-in that massively decreases the amount of time needed to upload a large image.

You can import images to IBM Cloud infrastructure from COS, and images can be exported from IBM Cloud infrastructure to COS. The IBM Cloud infrastructure customer portal or the SoftLayer API can be used to complete these tasks. This article explains how to use both the customer portal and the SoftLayer API Python Client to import and export images to IBM Cloud Object Storage.

Uploading images to IBM Cloud Object Storage with Aspera

If you have an image available locally that is compatible with the IBM Cloud infrastructure environment, you can upload it to IBM Cloud Object Storage (COS), making it available to import to the image template repository in IBM Cloud infrastructure.

The following steps describe the general flow of ordering a COS service instance, creating a bucket for storing images, and uploading images to your bucket.

  1. Make sure you have a service instance of COS available. For more information, see “Getting started with IBM Cloud Object Storage.”

  2. From the dashboard in IBM Cloud console, access your service instance of COS.

  3. Create a bucket with a unique name to store your images. For Resiliency, specify Regional. For Location, select the location that matches the region where you want to import images. (You can import images to the following regions: US-South, US-East, EU-Great Britain, EU-Germany, and JP-Tokyo.) Optionally, you can add IBM Key Protect keys to encrypt the bucket.

  4. With your bucket created, you can upload an image by clicking Add Objects. Use the Aspera high-speed transfer plug-in to realize the fastest upload speeds. Aspera is supported in all the regions that you can import images.

Creating a Service ID and API Key for import and export tasks

To limit access, we suggest that you use a service ID and associated API key to import and export images. You should create a new API key each time that you import or export an image. Then, delete the API key when your import or export task is complete.

You can complete the following steps to create a service ID and associated API key.

  1. Create a service ID.  

  2. Assign an access policy. You can assign access to an individual resource in an account, such as a bucket in IBM Cloud Object Storage.

  3. Create an API Key for the service ID.

For more information, see “Introducing IBM Cloud IAM Service IDs and API Keys.”

Using the customer portal to import images from IBM Cloud Object Storage

When your image is uploaded in IBM Cloud Object Storage (COS), you can import it to the IBM Cloud infrastructure image templates repository:

  1. In the IBM Cloud infrastructure customer portal, access the Image Templates page by selecting Devices > Manage > Images.

  2. Click the Import Image from IBM COS tab.

  3. Complete the required fields to identify the location and details of the image file in COS. You’ll also specify the API key for the Service ID described in the previous section. For more information about importing, see “Importing an image from IBM Cloud Object Storage.”

Image template

After the import completes, you can use the image to order a new virtual server instance.

Using the customer portal to export images to IBM Cloud Object Storage

If you want to export an image to IBM Cloud Object Storage (COS), you can complete the following steps:

  1. In the IBM Cloud infrastructure customer portal, access the Image Templates page by selecting Devices > Manage > Images.

  2. Right-click the image that you want to export to COS and select Export Image to IBM COS.

  3. Complete the required fields to specify the location in COS where you want to export the image. You’ll also need to include the service ID API key that gives access to COS. For more information about exporting, see “Exporting an image to IBM Cloud Object Storage.”

Export Image to IBM COS

Using the SoftLayer API Python Client to import images from IBM Cloud Object Storage

Another way to import your image template is to use the SoftLayer API Python Client (you must have version 5.6.0 or higher). You can install the Python Client via Pip by using the following command: pip install 'SoftLayer>=5.6.0'.  After the Python module is installed, create a Python file based on the following Python 3 code example:

import SoftLayer

client = SoftLayer.create_client_from_env(username='<username>',
                                         api_key='<softlayer_api_key>',
                                         endpoint_url='https://api.softlayer.com/rest/v3',
                                         timeout=30)
image_mgr = SoftLayer.ImageManager(client)

response = image_mgr.import_image_from_uri(name='<image_name>',
                                           note='<image_note>',
                                           uri='cos://<region_name>/<bucket_name>/<disk_image_file_path>',
                                           os_code='<image_os_code>',
                                           ibm_api_key='<service_id_key>',
                                           cloud_init=False,
                                           byol=False)

print(response)

Fill in the variables in the code example and save the file. Run the file by using the following terminal command: python <file_name>.py. If the file runs successfully, the newly created SoftLayer_Virtual_Guest_Block_Device_Template_Group is printed in the terminal.

For more information about the Python Client Image Manager, see SoftLayer.image.

Using the SoftLayer API Python Client to export images to IBM Cloud Object Storage

The SoftLayer API Python Client can export images from IBM Cloud Infrastructure to IBM Cloud Object Storage (again, you must have version 5.6.0 or higher). Install the Python Client via Pip by using the following command:  pip install 'SoftLayer>=5.6.0'. When the Python module is installed, create a Python file based on the following Python 3 code example:

import SoftLayer 

client = SoftLayer.create_client_from_env(username='<username>',
                                          api_key='<softlayer_api_key>',
                                          endpoint_url='https://api.softlayer.com/rest/v3',
                                          timeout=30)

image_mgr = SoftLayer.ImageManager(client)

response = image_mgr.export_image_to_uri(image_id=<image_id>,
                                         uri='cos://<region_name>/<bucket_name>/<image_file_path>',
                                         ibm_api_key='<service_id_key>')

print(response)

Fill in the variables in the code example with the proper values. When the file is saved, run the file by using the following terminal command: python <file_name>.py.  You will see “True” if the file runs successfully. A descriptive error message when the file fails.

For more information about the Python Client Image Manager, see SoftLayer.image.

Finding satisfaction in a more efficient image upload and download process

We hope you find this topic helpful in achieving much faster image uploads and downloads with IBM Cloud Object Storage. Subsequently, you can enjoy a simplified experience when importing and exporting images from IBM Cloud Infrastructure.

Be the first to hear about news, product updates, and innovation from IBM Cloud