Having a little trouble updating a business group in a script using builtin methods. I am able to get both custom properties into the business group object, but when I send back the updated business group... the getInfrastructureBusinessGroupsService().update(#businessGroup) method only sets the FIRST custom property no matter which one is first.
I do know that Sid put out a Custom Property Toolkit (written by Dan Lindsey: http://dailyhypervisor.com/vrealize-automation-vcac-6-1-custom-property-toolkit-for-vco/) that would handle this activity easily, but I am trying these updates directly for learning purposes.
Can anybody take a look at the below and at least tell me if I am just doing it wrong... and that is why it isn't working?
//setup a couple custom properties
owner = new vCACCAFECustomProperty;
owner.setName("businessGroupOwner");
owner.setValue(businessGroupOwner);
owner.setIsEncrypted(false);
owner.setIsRuntime(false); //this is Prompt User
costCentre = new vCACCAFECustomProperty;
costCentre.setName("costCenter");
costCentre.setValue(costCenter);
costCentre.setIsEncrypted(false);
costCentre.setIsRuntime(false); //this is Prompt User
var myArray = new Array();
myArray.push(costCentre);
myArray.push(owner);
/*Reversed
myArray.push(owner);
myArray.push(costCentre);
*/
System.log(myArray.length); // this ends up being 2 as expected
businessGroup.setCustomProperties(myArray);
checkProps = businessGroup.getCustomProperties();
for each (prop in checkProps){
System.log(prop.getName());
} // BOTH PROPERTIES ARE IN THE LOCAL BUSINESS GROUP OBJECT AS EXPECTED
// Send updated Business Group back into Cafe through host service
// Behaves as an overwrite
myService = host.createInfrastructureClient().getInfrastructureBusinessGroupsService();
myService.update(businessGroup); // Only sends in FIRST custom Property no matter which is first
The custom property toolkit is updating the VCAC CAFE Business Group through the IAAS ProvisioningGroups link using the Model Entity methods. This of course works... but will this always be the way for VCAC into future versions? What is the future of IaaS?
I don't think it is foolish to expect a "see object, update object" concept. This shouldn't need to be done across IAAS programmatic links to VCAC. I mean... I get it: we do what is possible, what we are capable of doing to meet the requirements we face based on what the developers have provided for us to use. Occam's razor applies however: how many hoops do we need to jump through to update a property that should be directly accessible in the API?
This is likely because the Business Group entity exists both in the vRA Appliance and the IaaS SQL DB. In 6.2 we can modify the BG directly through the API (I recently wrote about this here - though the lack of IaaS means this isn't actually a supported config). Interestingly, when I perform a GET against a Business Group, I don't see the custom properties in the response. Very weird.
I'll need to dig a bit further on this.
Grant
>>>though the lack of IaaS means this isn't actually a supported config
So the reference key between the IaaS "Provisioning Group" and the Café "Business Group" is groupID ⋈ ID. As long as the key doesn't change, row updates should be allowed I would think.
The strange thing about the method is that it DOES work. I can update anything in the Business Group by using the method directly against the CAFE Host after updating the business group object pulled into the execution space.
So for example, this works:
businessGroup.setUsers(["tom","dick","harry"]);
myService = host.createInfrastructureClient().getInfrastructureBusinessGroupsService();
myService.update(businessGroup);
You can add many custom properties while the Business Group object is in the execution space. When it is pushed back to the host for update, all of the properties are lost except the first one. No matter how you shake it... that cannot be the desired state.
I am going to go ahead and put in a support ticket on this one. I would like to see this work right.
>> Interestingly, when I perform a GET against a Business Group, I don't see the custom properties in the response. Very weird.
Join on another table?
Edit: You are doing a REST GET? It should be in the Properties list for the CAFE item. It isn't in IaaS item. Though the values seem to be some sort of ID reference.
Ticket in...
Issue description:
The issue is defined in this Communities Post.
https://communities.vmware.com/message/2481037#2481037
Using the Business Group update method through the VCAC plugin to the VCAC Café... example...
myService = host.createInfrastructureClient().getInfrastructureBusinessGroupsService();
myService.update(businessGroup);
... ends up dropping/not-updating any custom properties after the first one. The update method does update everything else within the business group.
Additional notes:
This may be resolved already in the 6.2 vRA plugin version
but we CANNOT go to the 6.2 plugin version because we are on vCO 5.5.2. People who have upgraded vRO to 6 and vRA plugin to 6.2 are having issues with ASD external actions and vRO OGNL as seen here:
https://communities.vmware.com/thread/502331
We leverage these capabilities heavily and cannot have a failure in our Resource Actions due to upgrade.
I was doing the REST call against CAFE. Now you're making me wonder what BG info is stored where....
Grant
So maybe these three images will solidify the picture...
In the GUI...
(Edit: The lower case G in the first custom property emphasizes to me why I need to do it programmatically. )
In the VCO plugin Inventory CAFE (my desired update TARGET)
In the VCO plugin Inventory IAAS (Dan Lindsey's Custom Property Toolkit update TARGET, which updates Café BG item across entity link)
Yeah, you're not going crazy. Custom Properties are showing under CAFE for me. But they don't come out as part of the GET 😕