Enthusiast
Enthusiast

Capture blueprint input array in inputProperties payload

Jump to solution

Is it possible to capture blueprint input array values and pass over to actions\workflows\external as custom properties in the inputProperies payload?

I'm requesting disk drive parametres using an array;

pastedImage_1.png

It's working OK for all inputs (strings or boolean) but not for the disk array. No errors, but the array values don't make it to customProperties.

pastedImage_2.png

Thanks.

1 Solution

Accepted Solutions
Enthusiast
Enthusiast

I thought I did post the screenshot...sorry, new to this forum, so I guess what i see isn't exactly what gets posted.  Let me see if i can just add a screenshot of the inputs, properties and workflow run variables...

inputs.png

resources.png

customProperties.png

View solution in original post

0 Kudos
10 Replies
Enthusiast
Enthusiast

What does that input look like exactly?  I created a simple input of type of array (string) and added it to my properties object like you did there.  There's more input/machine config, but this is what those two look like.

inputs:

  arrayTest:

    type: array

    title: List Things

    items:

      type: string

resources:

  vSphereVM2:

    type: Cloud.vSphere.Machine

    properties:

      listOfStuff: '${input.arrayTest}'

  

When I submitted the request, I manually populated the array with a simple list of items.  The arrayTest array was included as part of the inputProperties payload in my workflows (in customProperties).  It was also included in the requestInputs object for topics like "deployment requested".

Enthusiast
Enthusiast

Thanks for your reply.

Your example works great but I'm using an array of type object;

  disks:

    type: array

    title: Disks

    items:

      type: object

      properties:

        diskNo:

          type: integer

          title: Disk Number

          enum:

            - 2

            - 3

            - 4

        size:

          type: number

          title: Size GB

          minimum: 5

          maximum: 1024

        label:

          type: string

          title: Disk label

Maybe this is we're its going wrong, but the use of an array object is referenced in the customizing blueprints doc, How user input can customize a vRealize Automation Cloud Assembly blueprint

0 Kudos
Enthusiast
Enthusiast

Hmm...I created an input exactly as yours, leaving my other list in there too.  When I added it to the properties, I just called it "biggerList".

biggerList: '${input.disks}'

I filled out both lists manually when requesting the item in the catalog, and they are both available in the payload.  This screenshot is from a workflow run that is called during the compute.provision.pre.  The inputProperties.customProperties variable is what i have expanded...

We are currently running vRealize Automation 8.1.0.9326 (15986821) if that helps or is relevant.

0 Kudos
Enthusiast
Enthusiast

Thanks for checking.  Same version here too.  Could you post the screenshot.  I must be doing something wrong.

0 Kudos
Enthusiast
Enthusiast

I thought I did post the screenshot...sorry, new to this forum, so I guess what i see isn't exactly what gets posted.  Let me see if i can just add a screenshot of the inputs, properties and workflow run variables...

inputs.png

resources.png

customProperties.png

View solution in original post

0 Kudos
Enthusiast
Enthusiast

No problem.  Appreciate you spending time on this.

I've figured out what's going wrong, and yes, it's looking very much like pilot error!

The property name I'm using to call the input array appears to be in conflict with the input item name, both of which I'm calling disks.

inputs:

---

  disks: <==

    type: array

    title: Disks

    items:

      type: object

      properties:

        diskNo:

          type: integer

          title: Disk Number

          enum:

            - 2

            - 3

            - 4

  Cloud_vSphere_Machine_1:

    type: Cloud.vSphere.Machine

    attachedDisks: []

    properties:

      image: Windows2019Standard

      count: '${input.count}'

      cpuCount: '${input.cpu}'

      customizationSpec: 2019

      totalMemoryMB: '${input.ram}'

      customNamingEnvironment: '${input.customNamingEnvironment}'

      customnamingApplication: '${input.customnamingApplication}'

      clusterBuild: '${input.clusterBuild}'

      disks: '${input.disks}' <==

I've now named the property diskInfo and look;

I have what i need! :smileygrin:

I'll credit you with the correct answer as you've helped a great deal!

Enthusiast
Enthusiast

haha, posting the screenshot didn't work...

diskInfo.PNG

0 Kudos
Enthusiast
Enthusiast

nice, glad you got it working!  That kinda feels buggy to me, but good to know either way

0 Kudos
Enthusiast
Enthusiast

Agreed.  I've raised a SR.

0 Kudos
Enthusiast
Enthusiast

I was looking into the next steps of how to handle the diskInfo json string to initialise, partition and format the disks in guest, and happened across Vincent Riccio's post on using custom resources in the blueprint to execute scripts during deployments;

vRealize Automation 8.1 - Using Custom Resources to Execute Scripts along with Deployments - VMware ...

This is great for those who built dependencies around the guest agent in 7.6 which is now long gone in 8.x.

With help from the community, the custom resource package from VMWare and loads of hours figuring it all out, I now have a test blueprint where I can deploy vm's with a number of drives provisioned, initialised, partitioned and formatted during deployment. 

Here's the blueprint;

formatVersion: 1

name: deployWin2019

version: 1.0.4

inputs:

  cpu:

    type: integer

    description: Number of CPUs to assign to VM.

    default: 2

    title: CPUs

    minimum: 2

    maximum: 8

  ram:

    type: integer

    description: Amount of RAM to assign to VM.

    default: 4096

    title: Memory (MB)

    minimum: 4096

    maximum: 16384

  disks:

    type: array

    title: Disks

    items:

      type: object

      properties:

        diskNo:

          type: integer

          title: Disk Number

          enum:

            - 2

            - 3

            - 4

        size:

          type: number

          title: Size GB

          minimum: 5

          maximum: 1024

        label:

          type: string

          title: Disk Label

        clusterSize:

          type: integer

          title: Cluster Size (in bytes)

          enum:

            - 8

            - 16

            - 32

            - 64

            - 128

  customNamingEnvironment:

    type: string

    enum:

      - Development

      - Test

    title: NamingEnvironment

    format: ''

  customnamingApplication:

    type: string

    enum:

      - test

      - sql

      - web

      - generic

    title: namingApplication

    format: ''

  clusterBuild:

    type: boolean

    default: false

  count:

    description: No. of deployments or Cluster Nodes

    type: integer

    default: 1

    maximum: 4

    minimum: 1

resources:

  disk2:

    type: Cloud.vSphere.Disk

    properties:

      count: '${length(input.disks) >= 1 ? 1 : 0}'

      capacityGb: '${input.disks[2].size >= 5 ? input.disks[2].size : 5}'

      label: '${input.disks[2].size}'

      clusterSize: '${input.disks[2].clusterSize}'

  disk3:

    type: Cloud.vSphere.Disk

    properties:

      count: '${length(input.disks) >= 2 ? 1 : 0}'

      capacityGb: '${input.disks[1].size >= 5 ? input.disks[1].size : 5}'

      label: '${input.disks[1].size}'

      clusterSize: '${input.disks[1].clusterSize}'

  disk4:

    type: Cloud.vSphere.Disk

    properties:

      count: '${length(input.disks) >= 3 ? 1 : 0}'

      capacityGb: '${input.disks[0].size >= 5 ? input.disks[0].size : 5}'

      label: '${input.disks[0].size}'

      clusterSize: '${input.disks[0].clusterSize}'

  Cloud_vSphere_Machine_1:

    type: Cloud.vSphere.Machine

    attachedDisks: []

    properties:

      image: Windows2019Standard

      count: '${input.count}'

      cpuCount: '${input.cpu}'

      customizationSpec: 2019

      totalMemoryMB: '${input.ram}'

      customNamingEnvironment: '${input.customNamingEnvironment}'

      customnamingApplication: '${input.customnamingApplication}'

      clusterBuild: '${input.clusterBuild}'

      disksInfo: '${input.disks}'

      networks:

        - network: '${resource.Cloud_Network_1.id}'

          assignment: static

      attachedDisks: '${map_to_object(resource.disk2[*].id + resource.disk3[*].id + resource.disk4[*].id, "source")}'

  Cloud_Network_1:

    type: Cloud.Network

    properties:

      networkType: existing

      name: DsVlan1

  Format_disks:

    type: Custom.custom.executeScript

    properties:

      vcfqdn: name of vcentre

      machinename: '${resource.Cloud_vSphere_Machine_1.resourceName[0]}'

      lcmfqdn: name of vlcm

      template_locker_creds: WinRM

      vc_cred_name: vCentre

      script: |

        $json = '${input.disks}'

        $diskInfo = $json | ConvertFrom-Json

        for ($i=0; $i -lt  $diskInfo.length ; $i++){

        [int]$diskNum = [convert]::ToInt32($diskInfo.diskNo[$i], 10) -1

        [int]$clusterSize = [convert]::ToInt32($diskInfo.clusterSize[$i], 10) * 1024

        Write-Output "Cluster Size: $clusterSize"

        Initialize-Disk -Number $diskNum -PartitionStyle GPT -PassThru | New-Partition -UseMaximumSize -AssignDriveLetter | Format-Volume -FileSystem NTFS -AllocationUnitSize $clusterSize -NewFileSystemLabel $diskInfo.label[$i] -Confirm:$false

        sleep 10

        }