X

@OracleIMC Partner Resources & Training: Discover your Modernization options + Reach new potential through Innovation

Using Oracle Compute API Part 2 of 3 - Creating IP Reservations and Compute storage

Allen Wangu
Cloud Consultant

Now that we have our authentication cookie, we can now begin to use the API with orchestration to create our Oracle Compute components. 

What is an Orchestration?

An orchestration defines the attributes and interdependencies of a collection of compute, networking, and storage resources in Oracle Compute Cloud Service. You can use orchestrations to automate the provisioning and lifecycle operations of an entire virtual compute topology either by using normal shell script or even a Continuous integration tool like Hudson or Jenkin which enable DevOps.

In this post we will do two things, first we'll create ip reservation where we reserve public IPs that will be used by our Oracle compute Virtual Machine then create our bootable storage volume.

Let's get started:

Create a IP reservation Orchestration

1. Using your favorite editor create a new file called "ipreservation.json"

2. Please copy and paste the code below

{
  "parentpool": "/oracle/public/ippool",
  "permanent": true,
  "name": "/Compute-{identityDomain}/{username}/ip-res-1"
}

Please replace the following:

  • identityDomain - Use the identity domain where you compute service is located.
  • username - this is the cloud account username.
  • ip-res-1 - This is the name of the ip reservation (you can change it if you want)

Create Script to execute the IP Reservation Orchestration

1. Using your favorite editor create a new file called "ipreservation.sh"

2. Please copy and paste the sample script below:

#!/bin/bash 

curl -i -X POST \
     -H "Cookie: $COMPUTE_COOKIE" \
     -H "Content-Type: application/oracle-compute-v3+json" \
     -H "Accept: application/oracle-compute-v3+json" \
     -d "@ipreservation.json" {restendpoint_url}/ip/reservation/
     

Notice the following:

$COMPUTE_COOKIE - This is our Authentication cookie. (remember it expires every 30 minutes)

restendpoint_url - this is the oracle compute rest endpoint. I showed you how to get this in part 1

@ipreservation.json - this refers to the orchestration file. This mean that it's on the same directory as the shell script. You can place this file anyway but refer to it via absolute file path

3. Execute your shell script

HTTP/1.1 201 Created

Create a Storage Volume Orchestration

1. Using your favorite editor create a new file called "storagebootable.json"

2. Please copy and paste the code below

{
  "size": "21G",
  "properties": ["/oracle/public/storage/default"],
  "name": "/Compute-{identityDomain}/{username}/bootable-vol-1",
  "bootable": true,
  "imagelist": "/oracle/public/OL_7.2_UEKR3_x86_64"
}

Please replace the following:

  • identityDomain - Use the identity domain where you compute service is located.
  • username - this is the cloud account username.
  • bootable-vol-1  - This is the name of the bootable volume (you can change it if you want)
  • imagelist - This is the image you want to use. for this example am using Oracle Linux

Create Script to execute the Storage Volume Orchestration

1. Using your favorite editor create a new file called "storagebootable.sh"

2. Please copy and paste the sample script below:

#!/bin/bash 

curl -i -X POST \
     -H "Cookie: $COMPUTE_COOKIE" \
     -H "Content-Type: application/oracle-compute-v3+json" \
     -H "Accept: application/oracle-compute-v3+json" \
     -d "@storagebootable.json" {restendpoint_url}/storage/volume/

     

Notice the following:

$COMPUTE_COOKIE - This is our Authentication cookie. (remember it expires every 30 minutes)

restendpoint_url - this is the oracle compute rest endpoint. I showed you how to get this in part 1

@storagebootable.json - this refers to the orchestration file. This mean that it's on the same directory as the shell script. You can place this file anyway but refer to it via absolute file path

3. Execute your shell script

HTTP/1.1 201 Created

Exercise 

Create a Data Storage Volume. You can use the same process to create it but there is a slight difference with the orchestration. HINT - Not bootable and no imagelist. Have a look at the documentation

As you can see this API make it easy for you to create different components in a reusable way making it easy to automate creation and management of your Oracle compute components.

In the next post will look at how to create a Oracle compute instance.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.