Hi,
I know how to convert the VM name from string to VC:VirtualMachine for vCenter and in the same way I want to convert the virtual machine name from string (input) to vCloud:VM(output) for vCD.
Please help me.
Heres an example.
Inputs:
host (vcloud:host)
vdc (vcloud:vdc)
vappname (string)
vmname (string)
Output:
vcdVM (vcloud:VM)
var queryService = host.getQueryService();
var expression = new VclExpression(VclQueryVMField.CONTAINERNAME, vappname, VclExpressionType.EQUALS);
var filter1 = new VclFilter(expression);
var filters = [filter1];
var expression2 = new VclExpression(VclQueryVMField.VDC, vdc.href, VclExpressionType.EQUALS);
var filter2 = new VclFilter(expression2);
filters.push(filter2);
var expression3 = new VclExpression(VclQueryVMField.NAME, vmname, VclExpressionType.EQUALS);
var filter3 = new VclFilter(expression3);
filters.push(filter3);
var expression4 = new VclExpression(VclQueryVMField.ISVAPPTEMPLATE, false, VclExpressionType.EQUALS);
var filter4 = new VclFilter(expression4);
filters.push(filter4);
var filter = new VclFilter(filters,VclFilterType.AND);
var params = new VclQueryParams();
params.setFilter(filter);
var resultSet = queryService.queryRecords(VclQueryRecordType.ADMINVM, params);
while (resultSet != null) {
var records = resultSet.getRecords(new VclQueryResultAdminVMRecord());
for (i = 0; i < records.length; i++) {
var vmReference = new VclReference();
vmReference.href = records[i].href;
vmReference.name = records[i].name;
vmReference.type = records[i].type;
var vm = host.getEntityByReference(VclFinderType.VM, vmReference);
vcdVM = vm;
}
resultSet = resultSet.getNextPage();
}
Hey Thanks
I am getting error as:-
TypeError: Cannot call method "getQueryService" of null (Workflow:vmConversionvCD / Scriptable task (item1)#54823)
No value in the host variable?
Again error :-
This operation is denied. (Workflow:vmConversionvCD / Scriptable task (item1)#38)
Is the VCD public rest api base url in VCD / administration / Public Addresses identical to the one you entered in the orchestrator vcloud plugin config?
frefal can you please explain this point ... I am not getting what exactly you are talking about ..
You have a HTTPS address entered in vCloud Director under administration / Public Addresses. The box is called "VCD public rest api base url".
When you configured the vCloud Director plug-in in Orchestrator, in the Orchestrator configuration page, did you enter the same address to make the connection from orchestrator to VCD?
Missmatch might be the reason for you problem. For example that you have https://vcd in one place and https://vcd.example.org in the other.
okay ...
Yeah I checked the urls and both are same, vco url is having the default port no "443"
what next we can check ..
Thanks
The account you use in the orchestrator vcloud plug-in actually have the correct permissions to perform the wanted actions in vcd?
Are you connecting against the System organization, or maybe against another, wrong organization?
I think those things are fine as I am able to run the workflows like Change the number of CPUs, Change memory capacity, power on/off VMs .. . etc etc successfully
And I am connecting against the child organization.