randomname
Enthusiast
Enthusiast

VcKeyAnyValue still not working?

Prior to a recent update to the vCenter plugin, it was not possible to set any value of the value property of VcKeyAnyValue objects. Since the fix, I can now set values, however if the value is an array, it is always rejected by vCenter as being an invalid type, when it definitely *should* be valid. I have tried a dozen different ways of instantiating both the array and its members used to populate the value, but the result is always the same.

I suspect the issue is similar to what is documented at https://kb.vmware.com/s/article/1029155 and vCO is not explicitly specifying "ArrayOfString" when it is interacting with vCenter at the SOAP layer. Similar behavior is evident in PowerShell for an array of strings if the array's type is "String." However if the array's type is "String[]," it works. I have been unable to figure out any way to create a similar "strong typed" array in vCO's JavaScript which is accepted by vCenter.

Has anyone successfully modified any managed object property of type VcKeyAnyValue when the value is an array?

0 Kudos
6 Replies
iiliev
VMware Employee
VMware Employee

What do you mean by 'rejected by vCenter'? Could you show some sample code and the error it fails with?

Also, which build number of the vCenter plug-in do you have?

0 Kudos
randomname
Enthusiast
Enthusiast

vCenter returns the error "Invalid type for <whatever>" when calling the method which takes the object's hierarchy as its argument.

For example, updating a host profile in which the VcKeyAnyValue objects are members of a VcProfilePolicy's parameter array. If the VcKeyAnyValue's value is a single string, and that's what vCenter expects for the parameter with that key, it works. If the expected value is an array of one or more strings, vCenter rejects the array as an invalid type. Per the XML of the actual host profile and the previously linked article, if VcKeyAnyValue's value is an array, and only if it is an array, an explicit type must be specified when submitting to the API in addition to the actual value's data. Based on my test with PowerShell, I suspect vCO isn't sending that extra type definition when the value is an array.

vRO is 7.3. vCenter plugin in 6.5.0.7037717.

0 Kudos
randomname
Enthusiast
Enthusiast

Additional information from vpxd.log also points to my hypothesis being correct.

-->        (vmodl.KeyAnyValue) {

-->            key = "<whateverkeyname>",

-->            value = (string) [

-->                "val1",

-->                "val2"

-->            ]

-->        },

Above is what vCenter puts in vpxd.log for a VcKeyAnyValue object which has an array of strings for its value when the VcKeyAnyValue object has not been modified by vCO. That is, it is just the output from a get method which is then sent back as part of a larger object hierarchy. This works and vCenter views it as valid.

-->        (vmodl.KeyAnyValue) {

-->            key = "<whateverkeyname>",

-->            value = (anyType) [

-->                "val1",

-->                "val2"

-->            ]

-->        }

Above is what vCenter puts in vpxd.log for the same VcKeyAnyValue object which has the same array of strings for its value if the value property of the VcKeyAnyValue's object was created as an array inside vCO. This is when vCenter rejects it as an invalid type.

Despite the value property of a VcKeyAnyValue returned from a get method being listed as having the same standard array constructor as an array created in a vCO scriptable task, the returned object has no methods typical of an array. There's no push, pop, splice, slice, or anything. Nor do attempts to force new values at appropriate numerical indices have any effect on the elements of the array. So there is no way I have found to modify the values, and no way I have found to get vCenter to accept a new supposedly equivalent and valid object in its place.

0 Kudos
iiliev
VMware Employee
VMware Employee

OK, I'll open a bug report to investigate this further by vCenter plug-in developers.

0 Kudos
manuelperrot
Enthusiast
Enthusiast

Hello,

We have the same issue when updating the hostprofiles and this prevents us from using the latest plugin (and to upgrade to any vRO version > 7.2)

Did you had a chance to get this to the attention of the vCenter plug-in developers?

We have the SR 18837111606 opened to look into this as well.

I'm also trying to write a small code snipet to test this condition in the simplest form.

Thank you!

0 Kudos
iiliev
VMware Employee
VMware Employee

Hi,

Yes, we have an engineer working on the PR linked to this SR.

0 Kudos