HPE Morpheus Enterprise
1832648 Members
3419 Online
110043 Solutions
New Discussion

Triggering a snapshot during a workflow?

 
SOLVED
Go to solution
Not applicable

Triggering a snapshot during a workflow?

I’m developing a provisioning workflow to run in our vmware cloud. I want to trigger a snapshot of the VM once it’s booted. What’s the easiest way to set up a task I can drop in the workflow?

6 REPLIES 6
Not applicable

Re: Triggering a snapshot during a workflow?

That worked! Thanks!

cbunge
HPE Pro

Re: Triggering a snapshot during a workflow?

Hey @malberg! The easiest way will be calling the API via a post task to call to snapshot. Give me 2 minutes and I’ll whip something up!

cbunge
HPE Pro

Re: Triggering a snapshot during a workflow?

Damn… took me 6 minutes. I have failed you :frowning:

cbunge
HPE Pro
Solution

Re: Triggering a snapshot during a workflow?

So per the API docs here you can do a task like the local executed shell script below.

Optionally you can send a body payload to configure a name/description as well :slight_smile:

URL='<%=morpheus.applianceUrl%>'
INSTANCE='<%=instance.id%>'
TOKEN='<%=morpheus.apiAccessToken%>'

curl -X PUT "$URL/api/instances/$INSTANCE/snapshot" \
  -H "Authorization: BEARER $TOKEN" \
  -H "Content-Type: application/json"
Not applicable

Re: Triggering a snapshot during a workflow?

Followup… I need to revert to that snapshot later on in the workflow.

I guess I can use GET $serverUrl/api/instances/:id/snapshots to get the snapshot listing for the instance, then PUT $serverUrl/api/instances/:id/revert-snapshot/:snapshotId to revert. The list of snapshots is returned as json. is there a best practice for parsing JSON inside a bash task?

cbunge
HPE Pro

Re: Triggering a snapshot during a workflow?

You can make the API calls in really any language. If you are utilizing bash, probably best bet is to use jquery or something to easily manipulate JSON returns.