**Updated**
I would like to be able to provision a cloud.vsphere.machine with 3 or more disks. The disks will have different sizes that should come from a property group. I would also like to offer multiple VMs (count) in this deployment.
I can get 3 or more disk to deploy successfully, but only when requesting a single VM. If I request 2 or more VMs, this fails with "Shared disk are not supported" message.
Any examples would be appreciated.
Thanks
Tried the below-mentioned cloud template in my lab and I could see consistent deployment for Multi-machine and multiple static disks. I have used both property-group as well as capacity defined in cloud template.
inputs:
machines:
type: integer
minimum: 1
resources:
Cloud_Machine_1:
type: Cloud.Machine
allocatePerInstance: true
properties:
image: CentOS7-CloudInit
flavor: cs360-medium
count: ${input.machines}
attachedDisks: ${map_to_object(slice(resource.diskA[*].id, count.index, count.index + 1) + slice(resource.diskB[*].id, count.index, count.index + 1) + slice(resource.diskC[*].id, count.index, count.index + 1) + slice(resource.diskD[*].id, count.index, count.index + 1), "source")}
diskA:
type: Cloud.Volume
allocatePerInstance: true
properties:
count: ${input.machines}
capacityGb: ${propgroup.propertyGroup.disk1Size}
diskB:
type: Cloud.Volume
allocatePerInstance: true
properties:
count: ${input.machines}
capacityGb: ${propgroup.propertyGroup.disk2Size}
diskC:
type: Cloud.Volume
allocatePerInstance: true
properties:
count: ${input.machines}
capacityGb: ${propgroup.propertyGroup.disk3Size}
diskD:
type: Cloud.Volume
allocatePerInstance: true
properties:
count: ${input.machines}
capacityGb: 5
Let me know how it works for you.
You can use "allocatePerInstance: true" for all the 3 VMs and use the below mentioned property
attachedDisks: '${map_to_object(slice(resource.disk[*].id, 2*count.index, 2*(count.index + 1)), "source")}'
(this is an example in the doc where each machine will have two disks)
Reference doc: https://docs.vmware.com/en/vRealize-Automation/8.11/Using-and-Managing-Cloud-Assembly/GUID-3DBE3DFF-...
You can use the below-mentioned example as well
inputs:
disks:
type: array
minItems: 0
maxItems: 12
items:
type: object
properties:
size:
type: integer
title: Size (GB)
minSize: 1
maxSize: 2048
default:
- size: 1
- size: 2
VMcount:
type: integer
default: 1
resources:
Cloud_Machine_1:
type: Cloud.Machine
allocatePerInstance: true
properties:
image: ubuntu
flavor: small
count: ${input.VMcount}
attachedDisks: ${map_to_object(slice(resource.Cloud_vSphere_Disk_1[*].id, (length(input.disks))*count.index, (length(input.disks))*(count.index + 1)), "source")}
Cloud_vSphere_Disk_1:
type: Cloud.Volume
allocatePerInstance: true
properties:
capacityGb: ${input.disks[count.index%(length(input.disks))].size}
count: ${(length(input.disks))*(input.VMcount)}
Hi, thank you for the reply. I should have been more descriptive in my request as what you have posted does work. What I would like is 3 disks with 3 different sizes, where the sizes come from a property group. For simplicity, we can use the hardcoded values below.
resources:
Cloud_vSphere_Disk_1:
type: Cloud.vSphere.Disk
allocatePerInstance: true
properties:
capacityGb: 1
count: 2
Cloud_vSphere_Disk_2:
type: Cloud.vSphere.Disk
allocatePerInstance: true
properties:
capacityGb: 2
count: 2
Cloud_vSphere_Disk_3:
type: Cloud.vSphere.Disk
allocatePerInstance: true
properties:
capacityGb: 3
count: 2
###Machine###
Cloud_vSphere_Machine_1:
type: Cloud.vSphere.Machine
allocatePerInstance: true
properties:
imageRef: myTemplate
cpuCount: 1
totalMemoryMB: 1024
attachedDisks: ${map_to_object(slice(resource.Cloud_vSphere_Disk_1[*].id+resource.Cloud_vSphere_Disk_2[*].id+resource.Cloud_vSphere_Disk_3[*].id, 2*count.index, 2*(count.index + 1)), "source")}
count: 2
In the above example, when I apply the same logic for the attachedDisks field as in the example, I end up with the below.
VM1 has 3 total disks (osTemplate+1GB+1GB)
VM2 has 3 total disks (osTemplate+2GB+2GB)
The goal is:
VM1 has 4 total disks (osTemplate+1GB+2GB+3GB)
VM2 has 4 total disks (osTemplate+1GB+2GB+3GB)
Thanks in advance
Tried the below-mentioned cloud template in my lab and I could see consistent deployment for Multi-machine and multiple static disks. I have used both property-group as well as capacity defined in cloud template.
inputs:
machines:
type: integer
minimum: 1
resources:
Cloud_Machine_1:
type: Cloud.Machine
allocatePerInstance: true
properties:
image: CentOS7-CloudInit
flavor: cs360-medium
count: ${input.machines}
attachedDisks: ${map_to_object(slice(resource.diskA[*].id, count.index, count.index + 1) + slice(resource.diskB[*].id, count.index, count.index + 1) + slice(resource.diskC[*].id, count.index, count.index + 1) + slice(resource.diskD[*].id, count.index, count.index + 1), "source")}
diskA:
type: Cloud.Volume
allocatePerInstance: true
properties:
count: ${input.machines}
capacityGb: ${propgroup.propertyGroup.disk1Size}
diskB:
type: Cloud.Volume
allocatePerInstance: true
properties:
count: ${input.machines}
capacityGb: ${propgroup.propertyGroup.disk2Size}
diskC:
type: Cloud.Volume
allocatePerInstance: true
properties:
count: ${input.machines}
capacityGb: ${propgroup.propertyGroup.disk3Size}
diskD:
type: Cloud.Volume
allocatePerInstance: true
properties:
count: ${input.machines}
capacityGb: 5
Let me know how it works for you.
Hi, this is the correct solution. The attachedDisk string that you have provided attaches the disk, as required.
Many thanks!
Glad to hear that it worked for you.