VMware Cloud Community
Flipper35
Contributor
Contributor
Jump to solution

inputProperties not passed properly

I am sure something on my end got missed, but the documentation isn't entirely helpful on how to troubleshoot.

 

I have two things and I am sure they are related.  In my workflow when I validate it does so properly and when I run it from the workflow I get an error performing external validation.

 

When I provision a server through the form, the workflow does not give an error but I also get null for the inputs.  When viewing the deployment the name is there with the name from the form.  The inputProperties is set as input and is in the schema as an input.

The log after provisioning:

2023-04-17 11:34:11.929 -05:00INFO__item_stack:/item0
2023-04-17 11:34:11.931 -05:00INFO------List Properties------
2023-04-17 11:34:11.932 -05:00INFOpayload.id: 5a1d0f6d-4f54-4909-90ba-833fc059586f
2023-04-17 11:34:11.933 -05:00INFOpayload.name: null
2023-04-17 11:34:11.934 -05:00INFOpayload.type: null
2023-04-17 11:34:11.935 -05:00INFOpayload.owner: null
 
The part of the script:
//COLLECT vRA INFO TO USE IN LOGGING
System.log("------List Properties------");
//System.log("payload.all: " + inputProperties, 0)
System.log("payload.id: " + inputProperties.get("id"))
System.log("payload.name: " + inputProperties.get("name"))
//System.log("payload.name: " + inputProperties.Hostname);
System.log("payload.type: " + inputProperties.get("Backup"))
System.log("payload.owner: " + inputProperties.get("owner"))

 

Blueprint:

# Created by Quickstart/Setup Cloud wizard.
formatVersion: 1
inputs:
cpuCount:
type: integer
description: Number of virtual processors
title: CPU Count
default: 1
minimum: 1
maximum: 4
totalMemoryMB:
type: integer
description: Machine virtual memory size in Megabytes
title: Memory in MB
default: 1024
inputs: null
minimum: 1024
maximum: 16385
Hostname:
type: string
title: Hostname
minLength: 6
maxLength: 15
pattern: ^[a-zA-Z0-9]*$
DiskCapacityinGB:
type: integer
description: Enter your disk requirements
default: 200
inputs: null
minimum: 200
maximum: 400
Network:
title: Network
type: string
description: Production or Dev environment
default: Development
enum:
- Development
- Production
Backup:
title: Backup
type: boolean
description: Will this server need backups
resources:
Server2022wIIS:
type: Cloud.vSphere.Machine
properties:
name: ${input.Hostname}
imageRef: TMP_W2022IIS_STD_GUI
cpuCount: ${input.cpuCount}
totalMemoryMB: ${input.totalMemoryMB}
constraints:
- tag: redacted: []
networks:
- network: ${resource.Cloud_vSphere_Network_1.id}
storage:
constraints: []
maxDiskCapacityInGB: 400
bootDiskCapacityInGB: ${input.DiskCapacityinGB}
backup:
backup: ${input.Backup}
Cloud_vSphere_Network_1:
type: Cloud.vSphere.Network
properties:
networkType: existing
constraints:
- tag: ${input.Network}

Reply
0 Kudos
1 Solution

Accepted Solutions
emacintosh
Hot Shot
Hot Shot
Jump to solution

whatever it is, it probably is something dumb.  And it's kind of hard to troubleshoot at a distance, maybe some other things i would try.

 

1) Don't set it to a new properties first, just set it to the requestInputs:  var requestInputs = inputProperties.get("requestInputs")

 

2) Maybe try to see if there are any keys in there at all?  System.log(Object.keys(requestInputs).join(","));

 

3) Try accessing the field directly instead of using get?  requestInputs["Hostname"] or requestInputs.Hostname

 

4) Maybe also just trying to convert inputProperties to json and logging it to see if everything looks the way you think it does?  System.log(JSON.stringify(inputProperties))

 

5) Take a break 🙂

 

Hope you can track it down!

View solution in original post

Reply
0 Kudos
9 Replies
Flipper35
Contributor
Contributor
Jump to solution

OK, it seems to be jus these variables I am unable to pull.  They are in the requestInputs section of inputProperties.

requestInputs     [Properties]     properties
 
DiskCapacityinGB     200     number
 
totalMemoryMB     1024      number
 
textField_33a405bc     Server 2022 with IIS     string
 
Backup     true     boolean
 
Network     Development     string
 
Hostname     Test556    string
 
textField_d7f3fd3e     ownername     string
 
cpuCount     1     number
 
This is the new code:
 
var requestInputs = new Properties();

requestInputs = inputProperties.get("requestInputs")

nodeName = requestInputs.get("hostname");

//COLLECT vRA INFO TO USE IN LOGGING
System.log("------List Properties------");
System.log("payload.id: " + inputProperties.get("blueprintId"));
System.log("payload.hostname: " + requestInputs .get("hostname"));
System.log("nodeName: " + nodeName);
System.log("payload.description: " + inputProperties.get("description"));
System.log("payload.backup: " + requestInputs.get("backup"))
System.log("payload.owner: " + inputProperties.get("deploymentOwner"));
 
Reply
0 Kudos
Flipper35
Contributor
Contributor
Jump to solution

Log results:

2023-04-18 11:25:21.902 -05:00INFO __item_stack:/item0
2023-04-18 11:25:21.905 -05:00INFO ------List Properties------
2023-04-18 11:25:21.906 -05:00INFO payload.id: 82ad8847-20a7-439a-9f69-7fdf4463aa57
2023-04-18 11:25:21.907 -05:00INFO payload.hostname: null
2023-04-18 11:25:21.908 -05:00INFO payload.description: 1122334455
2023-04-18 11:25:21.909 -05:00INFO payload.backup: null
2023-04-18 11:25:21.910 -05:00INFO payload.owner: owner
Reply
0 Kudos
Flipper35
Contributor
Contributor
Jump to solution

The subscription:

Reply
0 Kudos
emacintosh
Hot Shot
Hot Shot
Jump to solution

Might be a copy and paste thing, but it looks like you have a space between "requests" and ".get" for the hostname.

But maybe more importantly, I think the keys on an object are case sensitive in js.  So "hostname" is the not the same as "Hostname".  Based on the requestInputs you shared, that may be the problem? 

Reply
0 Kudos
Flipper35
Contributor
Contributor
Jump to solution

Yeah, it is hard to paste into the forums.  I thought they were case sensitive and I tried both.  I think it is a pathing issue in the variable/array.

Reply
0 Kudos
emacintosh
Hot Shot
Hot Shot
Jump to solution

whatever it is, it probably is something dumb.  And it's kind of hard to troubleshoot at a distance, maybe some other things i would try.

 

1) Don't set it to a new properties first, just set it to the requestInputs:  var requestInputs = inputProperties.get("requestInputs")

 

2) Maybe try to see if there are any keys in there at all?  System.log(Object.keys(requestInputs).join(","));

 

3) Try accessing the field directly instead of using get?  requestInputs["Hostname"] or requestInputs.Hostname

 

4) Maybe also just trying to convert inputProperties to json and logging it to see if everything looks the way you think it does?  System.log(JSON.stringify(inputProperties))

 

5) Take a break 🙂

 

Hope you can track it down!

Reply
0 Kudos
Flipper35
Contributor
Contributor
Jump to solution

Thanks, #1 was the answer.  requestInputs.

gregd90
VMware Employee
VMware Employee
Jump to solution

I'd recommend mapping your Inputs that you need to one of your canvas components, e.g. for backup map to custom properties on the Cloud vSphere Machine.

That way they are all in one place and more immutable as they associated with your machine object.  You can read them from the customProperties section of any Subscription that has a Topic with customProperties Parameters. Also better to use the Event Topic 'Compute Post Provision' for post build activities.

Regards,

Greg Davis, VMware

Reply
0 Kudos
Flipper35
Contributor
Contributor
Jump to solution

It is post provision as I don't want an email to go out if the deployment gets canceled or something.

 

For the mapping, I am not sure what you are saying, I have only been working with this a few weeks.

Reply
0 Kudos