Wednesday, 11 September 2019

OAC - Starting and stopping instances using the REST API (Autonomous/Oracle Managed)

We waited a while to be able to start and stop OAC Oracle Managed (autonomous) instances through the OAC console but there isn't a way to schedule the starting and stopping of instances in the console. This is of course very important if you want to keep costs down by automatically shutting down your instances overnight for example.


Thankfully there are now REST API calls available for Oracle Managed OAC instances which allow you to stop and start your instances. You can schedule these commands from a scripting tool of your choice to automate this process e.g. create a batch script and schedule the start/stop using the Windows scheduler.

OAC Start Instance REST API Call

The call to start the instance is a follows:

curl -v -i -X POST -u username:password -H
"Content-Type:application/vnd.com.oracle.oracloud.provisioning.Service+json"
-H "X-ID-TENANT-NAME:idcs-<IDCS-Account-Name>"
"https://psm-cacct-<PSM-Account-Name>.console.oraclecloud.com/paas/api/v1.1/instancemgmt/idcs-<IDCS-Account-Name>/services/AUTOANALYTICSINST/instances/<Instance-Name>/start"

<IDCS-Account-Name>: You can get this by logging into your Oracle MyServices homepage and clicking on the Oracle Identity Cloud Service icon:




Your IDCS account name can be found in the URL of the new tab: 
https://idcs-ef1234567fds1234567df123456.identity.oraclecloud.com/ui/v1/adminconsole


<PSM-Account-Name>: You can get this by logging into your Oracle MyServices homepage and clicking on the Oracle Analytics Cloud icon


Your PSM account name can be found in the URL of the new tab:

https://psm-cacct-ef123456gh123456hi456.console.oraclecloud.com/psmui/faces/paasRunner.jspx?serviceType=AUTOANALYTICSINST

<Instance-Name>: You can find your instance names by clicking on the Oracle Analytics Cloud icon:


Notice in the above screenshot we have both a BI instance and an Essbase instance. These commands can be used to start/stop any of your OAC instances.

So in this example the command would be:

curl -v -i -X POST -u username:password -H
"Content-Type:application/vnd.com.oracle.oracloud.provisioning.Service+json"
-H "X-ID-TENANT-NAME:idcs-ef1234567fds1234567df123456"
"https://psm-cacct-ef123456gh123456hi456.console.oraclecloud.com/paas/api/v1.1/instancemgmt/idcs-ef1234567fds1234567df123456/services/AUTOANALYTICSINST/instances/PrdOBI/start"

Once you have launched the command you will recieve this output if the command is successful:


You should also see the message in the console saying that the startup is in progress:


Everything gets logged in the OAC activity log as you would expect:



OAC Stop Instance REST API Call

The call to start the instance is a follows:

curl -v -i -X POST -u username:password -H
"Content-Type:application/vnd.com.oracle.oracloud.provisioning.Service+json"
-H "X-ID-TENANT-NAME:idcs-<IDCS-Account-Name>"
"https://psm-cacct-<PSM-Account-Name>.console.oraclecloud.com/paas/api/v1.1/instancemgmt/idcs-<IDCS-Account-Name>/services/AUTOANALYTICSINST/instances/<Instance-Name>/stop"


Spare Oracle Credits!

You can now schedule your instances to stop when they are not being used saving you valuable Oracle Universal Credits which you could use to spin up other Oracle cloud services or add more OCPU during heavy usage periods!

3 comments: