Open prydin opened 3 years ago
+1
From: Pontus Rydin notifications@github.com Sent: Monday, December 14, 2020 1:31 PM To: prydin/vrealize-automation-plugin-for-jenkins vrealize-automation-plugin-for-jenkins@noreply.github.com Cc: Allen, John John.Allen@compuware.com; Mention mention@noreply.github.com Subject: [prydin/vrealize-automation-plugin-for-jenkins] Reverting a snapshot is too difficult (#11)
It's too difficult to revert a snapshot, as it requires direct API calls to get the snapshot ID. There should be a way of doing this through pipeline steps only.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fprydin%2Fvrealize-automation-plugin-for-jenkins%2Fissues%2F11&data=04%7C01%7Cjohn.allen%40compuware.com%7C49dfc0523cf84e24c81508d8a05e690c%7C893e9ba31b7844d8aca9105fab957fed%7C0%7C0%7C637435674672785027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=g%2BkRzLcvyXR5JOI5OVT8wm28OEqz2%2FTHccubktMOy%2BQ%3D&reserved=0, or unsubscribehttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAUSAKQZSLI3Q6MFEWOXY63SUZKWLANCNFSM4U3E3G2A&data=04%7C01%7Cjohn.allen%40compuware.com%7C49dfc0523cf84e24c81508d8a05e690c%7C893e9ba31b7844d8aca9105fab957fed%7C0%7C0%7C637435674672795026%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=duiRCGMJiUkpWj%2BzM3h4JNaFhg5tvWrkxPPuD3Rp%2FgA%3D&reserved=0.
The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it
So here is what I'm going to have to do: I will implement a new step called "getActionDetails" where you can get things like what inputs are needed for an action, as well as the possible values for drop-downs. From this you should be able to pull out the snapshot IDs. Might take me a day or two.
@theuntested I just cut a new release (1.2). It will probably take a few hours before it's pushed to the main Jenkins repo. I've added steps that can get the metadata for resource action. That way, you can look up the snapshot ID for a name. It looks like this:
node {
// Create a snapshot
vraRunAction(
actionId: 'Cloud.vSphere.Machine.Snapshot.Create',
deploymentName: 'snapshot target',
reason: 'Because I can',
inputMap: [
name: "demo snapshot",
memorySnapshot: true ],
resourceName: 'Cloud_vSphere_Machine_1')
// Get the resource action metadata
def ra = vraGetResourceActionDetails(
deploymentName: 'snapshot target',
resourceName: 'Cloud_vSphere_Machine_1',
actionId: 'Cloud.vSphere.Machine.Snapshot.Revert'
)
// Find the "demo snapshot" label and get the snapshot ID for it
def snap = ra[0].schema.properties.snapshotId.oneOf.find {
it.title.startsWith("demo snapshot") }
def snapId = snap.const
print "Snapshot id is: " + snapId
// Revert it!
vraRunAction(
actionId: 'Cloud.vSphere.Machine.Snapshot.Revert',
deploymentName: 'snapshot target',
reason: 'Because I can',
inputMap: [
snapshotId: snapId ],
resourceName: 'Cloud_vSphere_Machine_1')
}
@prydin Looking forward to trying it. Waiting for it to get deployed.
Hello @prydin I have had partial success. I see you are using resourceName. Where are you getting that value? Would you consider some time to do a walk thru? Thank you. John
update; I figured it out. Thanks again for the plugin. More to come... 👍
Filing on behalf of @theuntested.
It's too difficult to revert a snapshot, as it requires direct API calls to get the snapshot ID. There should be a way of doing this through pipeline steps only.