VMware Cloud Community
Czernobog
Expert
Expert

vRA 8.1 - add multiple disks to vm via blueprint - array iteration issue with count.index

I am having an issue with adding multiple disks do a vm in a blueprint. What I want to achieve is, that a user can add mutliple disks of various sizes, when requesting a new vsphere vm. I am almost there, however all of the disks added have the same size. I suspect the issue lies in the iteration of the disk configuration, whis is input as an array. Here are the relevant code snippets.

Disk configuration as input:

formatVersion: 1

inputs:

    disks:

    type: array

    title: Add disk

    description: Add new disks

    minItems: 0

    maxItems: 12

    items:

      type: object

      properties:

        size:

          type: integer

          title: Size in GB

          maxSize: 2048

          minSize: 1

Disk resource:

  Cloud_vSphere_Disk_1:

    type: Cloud.vSphere.Disk

    properties:

      count: '${length(input.disks)}'

      capacityGb: '${input.disks[count.index].size}'

VM resource:

  Cloud_vSphere_Machine_1:

    type: Cloud.vSphere.Machine

    properties:

      attachedDisks: '${map_to_object(resource.Cloud_vSphere_Disk_1[*].id, "source")}'

When a vm is deployed, the user can add an array of disks sizes. The number of disks added to the vm is correct as a result, but the size of all of them is equal to the size of the first disk added, example: user adds 3 disks in sizes 1GB, 2GB, 3GB. The resulting vm has the boot disk and 3 additional disks, all of size 1GB.

The blueprint documentation sadly only provides information about creating a new array, not iterating over value of an existing one. In most examples only the first element of an array is loaded.

I assume the issue is in Cloud_vSphere_Disk_1, where the size is improperly read from the array by index.count.

Could anyone give me a tip on how to resolve the issue?

edit: a word

edit2: added count.index to title

Tags (2)
26 Replies
nhlpens87
VMware Employee
VMware Employee

Krishna,

What information are you looking for?

--Jim
Reply
0 Kudos
j_dubs
Enthusiast
Enthusiast

Please see my post is this thread - it will address the disks all having the same size instead of different sizes from the array.

You will need allocatePerInsance: true

https://communities.vmware.com/t5/vRealize-Automation-Tools/vRA-8-5-Define-Machine-Properties-by-Inp...

 

Tags (1)
Reply
0 Kudos
Commens
Enthusiast
Enthusiast

Is there any update to this at all? 

https://developer.vmware.com/samples?id=7490#

 

I saw the link above, but it doesn't seem to work for me.  Drives don't come in the right order and drive letters aren't being passed as well.  

 

 

Reply
0 Kudos
Commens
Enthusiast
Enthusiast

I'm not sure this works for 8.6.  I've had to update the workflow "Get ordered mountpoints/drive letters" to authenticate and get the bearer token as that was not working.  However I'm still having issues grabbing the deployment info. 

Reply
0 Kudos
jspatz
Contributor
Contributor

So .. I had to play with this workflow a lot to get it working.  Because we have something set in vcenter that changes the names of the files to match the hostname, so the canned workflow doesn't work as it apparently splits the filename it is expecting.  So I am taking advantage of the other bug that a form can't accept the same disk size for any attached disk. in the "Get Ordered disk name" script I added

dsize = dev.CapacityInBytes/1024/1024/1024
 
and I switched 
            //diskNames.push(rhs)
            diskNames.push(dsize)
 
so now it loads the array with the disk size instead of the split name.
 
Then in the Get ordered mountpoint/drive letters I had to do as commens said and modify that script to grab the bearer token as well.
Also in there I switched this
 
                //resourceNames.push(resource.properties.resourceName)
                resourceNames.push(resource.properties.capacityGb) 
 
so again I am putting the file size from my form into that array. so in the next step Order mountpoint/Drive Letters like vCenter it compares resourceName == diskName  and when the file sizes match up it it sets the labels variable properly and goes on it's way.
Reply
0 Kudos
stratoCumulus
Enthusiast
Enthusiast

Is the disk ordering issue detailed here still an issue in vRA/vRO 8.8.1?

https://developer.vmware.com/samples?id=7490

Seeing issue where attached disks are not showing up on OS in the same order specified in the cloud template.

Thanks

Reply
0 Kudos
jspatz
Contributor
Contributor

to my knowledge it still is.. I am still using the workaround and have been checking the release notes of all new versions hoping this gets fixed.

Reply
0 Kudos