Open Telekom Cloud for Business Customers

How to use the API to control your Cloud

The services offered by the Open Telekom Cloud (OTC) can be controlled via APIs. Because the OTC APIs are based on OpenStack, you can simply use one of the many OpenStack clients available. In the interest of speed, we are using the otc shell script from the github project otc-tools in this tutorial. It is a handy tool which simplifies the handling of all the different APIs.

Preparation


1. Create an API key on your credentials page in the OTC console:

Creation of an API key

2. Download the shell script OTC.

wget https://raw.githubusercontent.com/OpenTelekomCloud/otc-tools/master/otc

3. Make it runnable.

chmod +x otc

4. Place the configuration file .otc_env.sh in your home directory.

wget -O ~/.otc_env.sh https://raw.githubusercontent.com/OpenTelekomCloud/otc-tools/master/.otc_env.sh

5. Enter your credentials into ~/.otc_env.sh (lines 27 & 28).

You will find the username on your credentials page as the first row of the account information. The password is the API key we created in step 1.

export OS_USERNAME="12345678 OTC00000000001000000123"
 export OS_PASSWORD="your API key generated in step 1" 

6. Install the dependencies jq and libs3.

For the current Ubuntu image (14.04.4) this would be:

sudo apt-get install jq libs3-2

Usage

Now we have set up our system to use the otc command line tool. For example, this command lists the current ECS instances:

$ ./otc ecs list
 abcdefgh-ijkl-mnop-qrst-uvwxyz012345 application1-webserver
 6789abcd-efgh-ijkl-mnop-qrstuvwxyz01 application1-database

If you just call ./otc with no arguments, different options are shown for creating and deleting ECS instances, VPCs, subnets and so on.

That's it for most of the functionality: if you want to see the list of your buckets in your object storage, you will get the following message:

$ ./otc s3 list

Missing environment variable: S3_ACCESS_KEY_ID

We need a little extra configuration to make the object storage accessible via API.

Let's talk about the Object Storage Service

There is one member of the OTC API family which is special: The Object Storage Service (OBS) is not compatible with the OpenStack Object Storage called Swift. It is only accessible with S3 clients. Therefore, it expects another type of credentials: the combination of access key and secret key. These have nothing to do with the API key generated above, but can also be generated on the credentials page:

Object Storage Service: access key and secret key

You get a csv file with exactly two lines containing the secret access key and its id:

User Name,Access Key Id,Secret Access Key
 "12345678 OTC00000000001000000123",IDABCDEFGHIJKLMNOPQR,SECRETKEYABCDEFGHIJKLMNOPQRSTUVWXYZ01234

These values must be entered into ~/.otc_env.sh (lines 32 & 33):

export S3_ACCESS_KEY_ID=IDABCDEFGHIJKLMNOPQR
 export S3_SECRET_ACCESS_KEY=SECRETKEYABCDEFGHIJKLMNOPQRSTUVWXYZ01234

Now, we are able to retrieve the list of buckets via the otc command line tool:

$ ./otc s3 list
BucketCreated
My first bucket2016-07-14T15:21:09Z
My second bucket
 

2016-08-31T13:45:42Z

The command ./otc s3 help prints the options available to perform the all the OBS functions like creating and deleting buckets or objects.

Book now and claim starting credit of EUR 250* (code: 4UOTC250)
24/7 Service
Take advantage of our consulting services!

Our experts will be happy to help you.

We will answer any questions you have regarding testing, booking and usage – free and tailored to your needs. Try it out today!

Hotline: 24 hours a day, seven days a week 

0800 33 04477 from Germany
00800 44 556 600 from abroad

* Voucher can be redeemed until June 30, 2020. Please contact us when using the voucher for booking. The discount is only valid for customers with a billing address in Germany and expires two months after conclusion of the contract. The credit is deducted according to the valid list prices as per the service description. Payment of the credit in cash is excluded.


  • Test it today – with no obligation and free of charge

    Book now and claim starting credit of EUR 250*
    Code: 4UOTC250

    Book now

  • Telefon

    Free expert hotline

    Our certified cloud experts provide you with personal service free of charge.

    0800 33 04477 (from Germany)

    24 hours a day, seven days a week

  • E-Mail

    Our customer service is available free of charge via E-Mail

    Write an E-Mail

  • Arrange an appointment

    Our Open Telekom Cloud experts provide you with free, non-binding and idividual support

    Arrange an appointment