Automate Oracle Compute Cloud Service Management with Python Requests

Oracle Compute Cloud Service exposes a set of REST APIs for managing Compute Cloud resources programmatically. This post presents to you a sample implementation of the REST API using Python Requests package.

Inside the package,

  • OracleComputeCloud.py module is the main implementation of the REST API
  • GetComputeCloudInfo.py module demonstrates most of available retrieval operations
  • DeleteComputeCloudResources.py demonstrates delete operations
  • CreateComputeCloudInstance.py module, the most insteresting one, demonstrates automation of instance creation from ground up.

After an instance is created, you can access it via SSH using the private key provided in the package. You can use the DeleteComputeCloudResources.py module to remove all resources created by the CreateComputeCloudInstance.py module.

If you are familiar with Oracle Compute Cloud, the sample code should be self-explanatory. Otherwise, a quick read through some documentations here should help you get started.

To run the sample code, you need:

  • Oracle Compute Cloud access: authentication domain name, username, password and must be in role “Compute_Operations”
  • Available Oracle Compute Cloud resources: at least 1 OCPU, 1 External IP, some storage space
  • Python 3.5+: I use Eclipse as my IDE and run the sample code in Eclipse.

Finally, a little disclaimer here. This is my first serious Python attempt beyond hello world. There are definitely rooms for improvement in terms Python best practices. So please leave a comment so that I can learn from this exercise. Any questions are welcome too.

 

Sample code available upon request.

Add Your Comment