VMware Cloud Community
BWinchell
Enthusiast
Enthusiast

Add extra disks to VM - Part 2

Hello,

Hopefully this can be attached to the existing discussion "add extra disks to VM".  This is how to add multiple disk to an existing VM.

Thanks

B

0 Kudos
6 Replies
Burke-
VMware Employee
VMware Employee

Hiya B - I haven't had a chance to import this, but thanks for sharing back to the community :smileygrin:

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
rubberduck70
Contributor
Contributor

Hi guys

this is just a bump on this thread that was created a while back. I've looked at the workflow and it works as intended, I do however have some issues whereas I'm trying to provide the option of adding the additional disk(s) to the VM that has just been provisioned (meaning I clone a server, customize it and then would like the option to add additional disks in the same workflow). Now the attribute in the adding of disk to existing workflow, "vm", is the one that points to the server that must have the disk added - in my case, this attribute refers to the one being cloned and my "output" for the new VM is "tempnewvm". when I amend the parameters to point to 'tempnewvm', I get the following error:

ReferenceError: "vm" is not defined. (Workflow:addVirtualDiskToExistingVm / FindDiskIndexAndBusNumber (item4)#1)

Would you be able to point out where I should amend the code?

Also, because 'vm' points to the existing vm to clone, should I just add the workflow into my provisioning one, it actually adds disk to the newly created and template vm's

0 Kudos
BWinchell
Enthusiast
Enthusiast

@rubberduck70

If it was me, I would just call this workflow after your initial clone workflow.  The main reason is you want workflows to relevantly module. 

Since I have stared to work with Orchestrator, I created some initial workflows that did what they were designed to do but, quickly found they were not flexible.  Now, I try to figure out "is the purpose of this action/s something I will use in other scenarios?"  If yes, then I will make a separate workflow (more initial work but, easier down the road).  This is my newbie opinion.

0 Kudos
rubberduck70
Contributor
Contributor

Hi BWinchell,

With regards to calling the workflow post the clone task - that is what I'm currently doing. The new VM is created and sysprep'd etc, then as a final step, the disk is added. And as I mentioned, even if I use the workflow attached, it actually adds the disk on both the source VM (template) I cloned from, as well as adding it to the new target VM. So I just need some guidance where it will only add it to the newly created VM. My attempts has not worked thus far Smiley Sad

0 Kudos
BWinchell
Enthusiast
Enthusiast

I misunderstood the original problem  (lack of sleep). Smiley Happy

Can you post your entire workflow?  That way I can see where it is going wrong?  I am sure I know what the issue is but need to confirm and figure a way around it.

Problem (assumption at this point):

The "vm" variable is used to indicate the clone template but then kept when passed to the additional disk workflow.  So essentially to both workflows, the "vm" variable = clone & new vm

Thanks

B

0 Kudos
BWinchell
Enthusiast
Enthusiast

So here is I handled this situation in the past.  (not saying this is correct way as I am not a programmer but, works well).

Basically I keep the local variable the same "vm" but, substitute the variable's source to a new variable "newvm".

FindNewVm

IN=name (string)

OUT=newVM (VC:VirtualMachine)

script:

//Set the regexp striing

var regexp = name;

// Get all Virtual Machines for all vCenter connections defined for this plugin

var allVms = VcPlugin.getAllVirtualMachines();

var vms = new Array();

// Check if the VM match the regexp

for (var i in allVms) {

  if (allVms[i].name.match(regexp)) {

  vms.push(allVms[i]);

  }

}

System.log("==================================LOG-BEGIN============================");

System.log("Module=FindNewVm");

System.log("Array results: " + vms);

System.log("==================================LOG-END==============================");

//Convert the array to an object (should only find one VM, hopefully)

var newVM = vms[0];

System.log("==================================LOG-BEGIN============================");

System.log("Module=FindNewVm");

System.log("New VM object: " + newVM);

System.log("==================================LOG-END==============================");

In your next (additional disk) workflow:

IN=vm     Source paramter=newVM

At the end, it will be something like this:

CloneWorkflow - FindNewVm - AddDiskWorkflow

0 Kudos