here is my code to get info about the vms, then I will use to get mem, cpu etc..but getting NULL for vmname
any help is appreciated
fetchVMByName = function(vmName) {
var expression1 = new VclExpression(VclQueryVMField.NAME, vmName, VclExpressionType.EQUALS);
var expression2 = new VclExpression(VclQueryVMField.ISVAPPTEMPLATE, false, VclExpressionType.EQUALS);
var expressions = new Array(expression1,expression2);
var filter = new VclFilter(expressions,VclFilterType.AND);
var params = new VclQueryParams();
var fields = new Array();
fields.push(VclQueryVMField.NAME);
params.addSortFields(fields, VclSortType.SORT_ASC);
params.setFilter(filter);
var resultSet = vCDQueryService.queryRecords(VclQueryRecordType.VM, params);
var vms = new Array();
System.log(resultSet);
while (resultSet != null) {
var records = resultSet.getRecords(new VclQueryResultVMRecord());
for (var record in records) {
System.log(record);
var vmRef = new VclReference();
vmRef.href = record.href;
vmRef.name = record.name;
vmRef.type = record.type;
var vm = vCLOUDHost.getEntityByReference(VclFinderType.VM, vmRef);
if (vm != null){
System.log(vm.name);
return vm;
}
}
resultSet = resultSet.getNextPage();
}
};
Please provide the exact output printed by System.log() statements. Also, you may want to log the entire 'vm' variable.
BTW, is this code working? the 'for' loop doesn't look correct to me; you probably meant to use 'for each' instead?
yes Ilian Iliev
its still work in progress but I think I have it now. I was querying it improperly
thank you