Skip to Main Content

Cloud Platform

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using curl to pull back instance and orchestration states

DabbsyNov 14 2017 — edited Dec 15 2017

I’m running some curl from a shell script to get the state of an instance and also an orchestration.

In the below, I’ve replaced my actual tenant and info with the oracle sample code and I’ve previously generated a cookie and passed this into the $COMPUTE_COOKIE parameter.

This cookie works fine.

When I try and run curl against the instance it returns all the information I want – but how can I just pull back the state? 

curl -X GET \

  -H "Cookie: $COMPUTE_COOKIE"   \

  -H "Accept: application/oracle-compute-v3+json" \

https://api-z999.compute.us0.oraclecloud.com/instance/Compute-acme/jack.jones@example.com/dev1/f653a677-b566-4f92-8e93-71d47b364119z999.compute.us0.oraclecloud.com/instance/Compute-acme/jack.jones@example.com/dev1/f653a677-b566-4f92-8e93-71d47b364119

The curl command pulls back dozens of fields including "state": "running" (which is the only piece of information I need) – but there’s that much date in there in one long string, so it’s difficult to easily pull out the state only – can I just ask for the state to be returned?  or how can I easily extract the state only.

when I run a similar command to the get the state of the orchestration:-

curl -X GET \

  -H "Cookie: $COMPUTE_COOKIE"   \

  -H "Accept: application/oracle-compute-v3+json" \

https://api-z999.compute.us0.oraclecloud.com/orchestrations/Compute-acme/jack.jones@example.com/dev1/

this returns

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

<html><head>

<title>403 Forbidden</title>

</head><body>

<h1>Forbidden</h1>

<p>You don't have permission to access /orchestrations/Compute-acme/jack.jones@example.com/dev1/ on this server.</p>

</body></html>

If I’ve created the orchestration and the instance myself (and I can access the instance - first command in the post) how can I not have the permissions to see the orchestration?  Is there a way of checking these permissions at the instance and the orchestration level or is there something else going on that might be stopping me?

Any assistance appreciated - this is my first venture with cloud, curl and the REST APIs.

thanks a lot

Jonathan

Comments

Kenheung-Oracle

This space is focused on Java Cloud Service, you might want to post the question in IaaS > Compute Cloud to get better response.

Q1. You will need to parse the JSON result. There is no a single specific REST API to check the state only. There are different way to paste the json, I personally use mix of awk, grep and jq ( https://stedolan.github.io/jq/ )

Q2. Even you create the orchestration, you will need Compute_Monitor or Compute_Operations role. Please check the user got the roles.  (JCS creation won't use OCI Classic orchestration, suggest you post additional question in the Compute Cloud space :-)

Kumar.Dhanagopal-Oracle
1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jan 12 2018
Added on Nov 14 2017
2 comments
473 views