I have a problem when I want to use vRO to change a XaaS object in vRA inventory.
My goal is to modify descriptions informations in a virtual machine provisionned by XaaS (vRO) and add to vRA's elements.
I think I'm not on the good way. I can find my inventory element, put it in a variable and modify informations in this variable. But I can't return this to modify original item.
Here is my scriptable task :
// Create client var service = vCACHost.createCatalogClient().getCatalogConsumerResourceService(); // Create my filter on VM's name var filter = new Array(); filter = vCACCAFEFilterParam.equal("name", vCACCAFEFilterParam.string(vm.name)); // create Odata request var query = vCACCAFEOdataQuery.query().addFilter(filter); // run request and get elements from vRA's inventory var items = service.getResourcesList(new vCACCAFEPageOdataRequest(query)); // working on the first element // get ResourceData var oldResourceDatas = items.getResourceData(); // create new resource data var newResourceDatas = oldResourceDatas; // print original resourceData System.log(oldResourceDatas); // create new value in format StringLiteral (newdesc = input) var myNewValue = new vCACCAFEStringLiteral(newDesc); // delete old ressource data newResourceDatas.remove("description"); // create new resource data with new value newResourceDatas.put("description",myNewValue); // Print new resourceData System.log(newResourceDatas); // Modify vCACCAFECatalogResource items.setResourceData(newResourceDatas); // Validation var items = service.getResourcesListWithData(true, true, new vCACCAFEPageOdataRequest(query)); System.log(items.getResourceData());
Script works fine bu never modify the vCACCAFECatalogResource.
If someone as a tips, or a way to search, thanks
The basic issue here is that you're doing the following
1- load resource from server into a LOCAL var
2- modify the content of the LOCAL var
3- re-load resource from the server into the LOCAL var
LOCAL there means that the object you have access to only exists in the vRO workflow context - updating fields on that instance value does not change the value stored in the vRA database / server.
What you need to do is put an update back to the server between 2 & 3 here but sadly there's no API for that operation AFAIK
For the resource description field, you might need to udpate the value via the Infrastructure branch of the vRA plugin for an already provisioned VM. If you can though, it might be best to set the custom description during the Request phase in XaaS? You can more or less modify anything you want on the Request data for the IaaS VM
Thank you for your message eoinbyrne.
In fact, my objectives are to modify any fields of ResourceData. Description is an example.
My difficulty is to send back my local data to vRA.
I haven't found the way to do that.
Thanks for your help
Can I ask which fields you'd like to update? The thing is that the CatalogResource entry is just
an overlay to the actual data stored in the IaaS system, and therefore on the vCACVirtualMachine / vCACEntity.
vRA has TWO databases, the CAFE database (postgres on the vApp) and the IaaS database (usually MSSQL on the IaaS host).
CAFE hosts all info related to the user portals etc.
IaaS hosts all data related to the Infrastructure (VMs, Networks, Reservations, etc)
Most of the resource data presented in the user portals is sourced by the CAFE system from the IaaS DB. CAFE does keep some 'cloned' data
of it's own so quite possibly for each field you wanted to update you'd actually have to update both places..
Note, I'm assuming that you are referring to VMs only here, other types visible in the CatalogResource views will be stored in different places depending on where they originated, e.g., ADUser entry originates at the vRO AD plugin and so source data for the resource view would be modified there....
If you wanted to modify the CPU count of a VM then simply changing the value on the CatalogResource
would not change the 'physical' value of the CPU allocated to that VM... You would normally call the Reconfigure
action on the VM to accomplish this for a standing VM. You can do that with vRO if you have a look at the CatalogResourceAction and search for examples of it.
If you were absolutely hell-bent on updating resources directly then since there is no API to permit that,
then you'd be forced to update the postgres DB and MSSQL db directly, but this is a complete hack and so would
likely not be supported for production use.
The Virtual Machine Object came from XaaS and not IaaS. Not sure IaaS server manage this object.
I'm trying to do two different actions:
First: add Description post-deployment
This action's goal is to send back to my user some informations (ex : backup ok, software installed, etc.) about is VM in vRA's portal.
Second: relink orphaned IaaS VMs
This occur when there is a restore of a VM and IDs are not kept. The link is break in vRA which try to find old VM. I want to change those IDs and hope this help. Not sure.
My goal is to do those operations without playing with vRA's databases.
It seems impossible.
Trying to do something similar: adding imported VMs into multi-node deployments. I think this is not an extraordinary idea, normally used for bring existing VMs under cloud management (as a set, and not individual deployments/VMs). Other cloud management tools allows this (that I used before) and I see no reason to forbid this. Of course, one has to be careful to match properties but we're careful anyway
So tried with vCACCAFECatalogResource.setParentResourceRef() without luck and could not get setName working either (just for testing purposes). Probably due to beging local variable I cannot "commit back" my changes. Did you get any further?