VMware Cloud Community
antonioaraujo
Enthusiast
Enthusiast

Are nested array supported in Automation Assembler version 8.14?

Dear All,

I hope you are doing well.

Are nested array supported in Automation Assembler version 8.14?

I am trying to create a cloud template that deploys a dynamic infrastructure with VMs and disks. The cloud template is using an input array to get VM’s parameters:

antonioaraujo_0-1706002077367.png

 

Additionally, an input array is used to get information about attached disks to the VM within the previous array:

antonioaraujo_1-1706002105570.png

 

antonioaraujo_2-1706002125824.png

 

antonioaraujo_3-1706002147583.png

 

antonioaraujo_4-1706002179739.png

 

Are nested arrays supported in case disks array has more than 1 item?

Thanks for your comments and support.

Best regards

 

Antonio

 

 

 

 

 

 

 

 

 

 

0 Kudos
2 Replies
RoMaKa
Enthusiast
Enthusiast

Hi,

as long as you can create it in the design it should be supported. But please keep in mind: the more complex your design is, the longer will a supporter or someone else be able to understand, what you do in your template and where an error may be...

Regards
Robert

0 Kudos
antonioaraujo
Enthusiast
Enthusiast

Dear @RoMaKa ,

I hope you are doing well.

Thanks for your comments and excuse me for the late reply.

What I want to achieve is creating a dynamic array of VMs, and for each VM, you can also add one or several disks (array). That is why I was asking if nested input arrays were supported. 

As you said, if the the design was created within the designer, then it should be supported.

So, below is listed the code I have been testing:

 

formatVersion: 1
inputs:
  virtualMachines:
    type: array
    title: Define your infrastructure adding VMs
    description: Enter VMs input parameters
    minItems: 0
    maxItems: 2
    items:
      type: object
      properties:
        hostname:
          type: string
          title: Hostname
          maxLength: 25
          populateRequiredForNestedProperties: true
        description:
          type: string
          title: Description
          maxLength: 500
          populateRequiredForNestedProperties: true
        cpuCount:
          type: integer
          title: CPU count
          default: 2
          minimum: 2
          maximum: 16
          description: CPU count
        memory:
          type: integer
          title: Memory
          default: 2048
          minimum: 2048
          maximum: 16384
          description: Memory in MB
        network:
          type: string
          title: Network
          description: Select a network
          oneOf:
            - title: test-backup-segment
              const: test-backup-segment:network
        disks:
          type: array
          title: Disks
          description: Enter disks (optional and maximum 2)
          minItems: 0
          maxItems: 2
          items:
            type: object
            properties:
              size:
                type: integer
                title: Size
                default: 10
                minimum: 10
                maximum: 300
                description: Size in GB
              label:
                type: string
                title: Label
                maxLength: 25
                populateRequiredForNestedProperties: true
              storage:
                type: string
                title: Storage type
                default: Silver
                populateRequiredForNestedProperties: true
                enum:
                  - Silver
resources:
  VirtualMachine:
    type: Cloud.vSphere.Machine
    allocatePerInstance: true
    properties:
      image: MYIMAGE
      cpuCount: ${input.virtualMachines[count.index].cpuCount}
      totalMemoryMB: ${input.virtualMachines[count.index].memory}
      capacityGb: ${input.virtualMachines[count.index].size}
      name: ${input.virtualMachines[count.index].hostname}
      description: ${input.virtualMachines[count.index].description}
      count: ${length(input.virtualMachines)}
      attachedDisks: ${map_to_object(resource.Disk[*].id, "source")}
      networks:
        - name: ${resource.Cloud_vSphere_Network_1
          assignment: dynamic
          network: ${resource.TestBackupNetwork.id}
  TestBackupNetwork:
    type: Cloud.vSphere.Network
    properties:
      networkType: existing
      constraints:
        - tag: ${input.virtualMachines[count.index].network}
  Disk:
    type: Cloud.vSphere.Disk
    allocatePerInstance: true
    properties:
      count: ${length(input.virtualMachines.disks)}
      capacityGb: ${input.virtualMachines[count.index].disks[count.index].size}
      name: ${input.virtualMachines[count.index].disks[count.index].label}

 

 

The fields I need to calculate are: Disk.count, Disk.name, Disk.capacityGB and VirtualMachine.attachedDisks

In words, Disk.count could be calculated as sum() of length of the array of disks for each VM.

I can get the number of disk for a specific VM using:

 

input.virtualMachines[0].disks #example for first VM

 

 

But I do not find the way to get an array with the number of disks per VM to then apply sum() function.

 

Then, for each VM I need to attach the disks added by the user.

I thought that this could work:

 

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

 

 

But it is not the proper way. I suppose I have to create an array.

 

I would appreciate any comments or ideas.

Best regards

Antonio

0 Kudos