VMware Cloud Community
Corochun
Contributor
Contributor

Regular cloning with vCO

Colleagues,

I've created two jobs to perform regular weekly cloning of the server. It consists of two separate scheduled workflows. One deletes existing clone, another one clones the protected VM 10 minutes later. The name of the deleted and newly cloned VM is the same.

Both tasks worked just once and then stopped.

Removal task failed with the follwoing error: "TypeError: Cannot read property "runtime" from undefined (Dynamic Script Module name : destroyVm#52993)". Cloning task failed because there was another vm with the name it was supposed to use for new clone (the reason is clear).

For me destroyVm#52993 looks like VCO tries to remove the VM by its VMID, which apparently changes after each cloning.

So i wonder:

- If anyone configured regular cloning with VCO and how it was done?

- If there's workflow for VM's removal by its name, not vmid?

Any feedback would be very appreciated.

Thanks.

Tags (2)
Reply
0 Kudos
7 Replies
Andreas_Diemer
Enthusiast
Enthusiast

Hi Corochun,

i'm not really sure what your worklows are doing - please put them into a package and load it up in this discussion.

Instead of using two seperate workflows, use one combining both tasks.

All activities with / against objects are done by its ID or direct by object methods, because it is bijective. A name is just a label and can change.

Of course, you can retrieve an ID (object) by searching its name (label). But you are responsible for that the found ID that it is the one you want. So you have to check for double names.

A possible workflow for your task could look like this:

input parameter:

  • VMsource (VM to be cloned / backed up)

  • VMclone (null on first run)

if VMclone != null -> destroy VMclone

Temp = clone VMclone // to store VM object in Temp, giving it an individual name to display in vcenter

schedule workflow to desired time with VMsource=VMsource VMclone=Temp

This WF will run and reschedule itself, optionally you can pass the time as parameter. No name from outside is needed.

Post your package, i will take a look and post my package back Smiley Happy

-


Regards,

don't forget: award points to helpful answers

visit &

------ for correct and / or useful answers please award points visit http://www.vcoteam.info & http://mighty-virtualization.blogspot.com
Corochun
Contributor
Contributor

Hi,

Sorry for keeping this inactive for so long - I just wasn't anywhere near to civilization. Smiley Happy Happy New Year, by the way.

I'm really new to the vCO, so your answer just produced more questions for me. The very first one is "how do i do this?". Smiley Happy

Well it would have been inhonest to ask for a detailed instruction on how to create a custom workflow (so far i've been using predefined ones), so i will take my time to dig into this with documentation.

Will post here within 2 weeks when i have (hopefully) someting.

Thank you,

Kirill.

Reply
0 Kudos
Andreas_Diemer
Enthusiast
Enthusiast

Hi Kirill,

no problem, welcome back in civilization 🙂

So you want an example with following features:

  • self scheduled workflow with weekly occurance
  • cloning a specific VM
  • deleting last clone from this VM

If so, I will build a small example and post a package for import.

Regards, Andreas

------ for correct and / or useful answers please award points visit http://www.vcoteam.info & http://mighty-virtualization.blogspot.com
Reply
0 Kudos
Andreas_Diemer
Enthusiast
Enthusiast

Hi Kirill,

attached an example workflow as package for import.

There could be a problem with the scheduled workflow, because I don't know if the ID in this is recalculated. If an error on this item occurs, just remove the scheduled item and insert again by drag and drop.

It is only an example for you to understand how to build own workflows. Do not use for production, because:

  • Next schedule is calculated on actual run time, so if there is load on vCO, it is possible that this time stamp will be later ....
  • Datastore, Folder and all VM related properties are just copied from original VM - look in the "calc value item", there you can change it
  • there is no error handling

What is this example doing:

corochun.PNG

  • calc values
    collecting parameters for clone task
    calculating next run time based on start time (7 * 24 * 60 * 60 * 1000 = 1 week in ms)
  • clone VM
    name is <VMname> + GMT clone time (calculated in previous item)
  • wait for this clone task
  • get VM
    because the result from wait task is any, we have to change it to VcVirtualMachine
  • old VM exist?
    on first (initial run) there is no old VM (an so no delete task)
  • schedule next run
    call this workflow in future with the cloned VM as old VM - so again a clone will be build and after this the old clone from last week will be destroyed

Here a snapshot from VC an vCO (running with 5min schedule - look at comment in calc value)

corochum.PNG

Regards, Andreas

------ for correct and / or useful answers please award points visit http://www.vcoteam.info & http://mighty-virtualization.blogspot.com
Reply
0 Kudos
Andreas_Diemer
Enthusiast
Enthusiast

Hi Kirill,

if you have general questions on how to edit a workflow (inserting items, using parameters, etc) just write a PM.

Regards, Andreas

------ for correct and / or useful answers please award points visit http://www.vcoteam.info & http://mighty-virtualization.blogspot.com
Reply
0 Kudos
Andreas_Diemer
Enthusiast
Enthusiast

Hi Kirill,

how far you are in digging 😉 vCO - two weeks are gone, if you need help or support, just quote or PM.

Regards, Andreas

------ for correct and / or useful answers please award points visit http://www.vcoteam.info & http://mighty-virtualization.blogspot.com
Reply
0 Kudos
Andreas_Diemer
Enthusiast
Enthusiast

Hi Kirill,

is this still open?

Do you need more?

Pls let us know or close question. Don't forget to award points for useful answers.

Regards, Andreas

------ for correct and / or useful answers please award points visit http://www.vcoteam.info & http://mighty-virtualization.blogspot.com
Reply
0 Kudos