VMware Cloud Community
abassoonkid
Contributor
Contributor

No VM Vim Reference

An odd problem is cropping up when I try to migrate my application (that uses the vCloud Java SDK) from one network to another. As far as I can tell, I've set up everything the same on each network, from the vCloud Director settings to the templates used, and yet the code returns NULL when I try to run the getVMVimRef() function (off a VM, of course). Any ideas as to what could cause a VM to not have a Vim reference?

0 Kudos
20 Replies
abassoonkid
Contributor
Contributor

Anyone have any useful information on this or at least seen something like this occur?

0 Kudos
rkamal
VMware Employee
VMware Employee

Hi,

Are you trying to VappTemplate VM's - getVMVimRef();

And it throws "Vim Object Reference Not Found"

Regards,
Rajesh Kamal.     

0 Kudos
abassoonkid
Contributor
Contributor

Sorry to get back to you so late. I'm getting a Null Pointer Exception.

This is the top line of the stacktrace:
com.vmware.vcloud.sdk.VM.getVMVimRef(VM.java:1090)

0 Kudos
rkamal
VMware Employee
VMware Employee

Hi,

Are you doing this operation as a System Admin/Organization Admin/User??

This information is only available to Sytem Admins. Even using as an Organization Admin/User should not throw a null pointer. It should be data not found or something.

Regards,

Rajesh Kamal.

0 Kudos
abassoonkid
Contributor
Contributor

I'm using a System Admin account

0 Kudos
rkamal
VMware Employee
VMware Employee

Hi,

Is this SDK 1.5 against vCD 1.5.

Can you post the SDK logs.

Regards,

Rajesh Kamal.

0 Kudos
rkamal
VMware Employee
VMware Employee

Hi,

Looks like a bug. I was referring to he Vapp VM's instead of the VappTemplate VM's.

As a workaround you can get that info like this.

Cose Snippet:

--------------------

VappTemplate vappTemp = VappTemplate.getVappTemplateById(vcloudClient,
"urn:vcloud:vapptemplate:9673a092-8ed0-4331-a764-812448285397");
List<VappTemplate> vappVms = vappTemp.getChildren();
for (VappTemplate vappVm : vappVms) {
for (VCloudExtensionType vcloudExtension : vappVm.getResource()
.getVCloudExtension()) {
for (Object jaxbObject : vcloudExtension.getAny()) {
if (((JAXBElement) jaxbObject).getValue() instanceof VmVimInfoType) {
VmVimInfoType vmVimInfoType = (((JAXBElement<VmVimInfoType>) jaxbObject))
.getValue();
System.out.println(vmVimInfoType.getVmVimObjectRef()
.getMoRef());
}
}
}
}

Regards,

Rajesh Kamal.

abassoonkid
Contributor
Contributor

I am using both the SDK 1.5 and vCD 1.5.

I've looked through the logs (request, debug, etc.) and I don't see any errors. Is there a different path that the SDK log is at?

0 Kudos
abassoonkid
Contributor
Contributor

I'm refering to a Vapp's VMs as well. Can I use the same sort of code for a Vapp's VMs as opposed to a VAppTemplate's?

0 Kudos
rkamal
VMware Employee
VMware Employee

Hi,

For Vapp's VM,

    You should be able use the VM -> getVMVimRef() - This should work fine.

For VappTemplate's VM,

    VappTemplate -> getVMVimRef() - This looks like a bug. For this you can use the above code snippet only for this.

Regards,

Rajesh Kamal.

0 Kudos
abassoonkid
Contributor
Contributor

I'm getting this bug for while using that call on the Vapp's VMs...

0 Kudos
rkamal
VMware Employee
VMware Employee

Hi,

I was able to get the Vapp vm's vim object reference.

Vapp vapp = Vapp.getVappById(vcloudClient, "urn:vcloud:vapp:2f93cc90-d787-4dcf-9e1a-ec47a780056b");
VM vm = vapp.getChildrenVms().get(0);
System.out.println(vm.getVMVimRef().getMoRef());

Regards,

Rajesh Kamal.

0 Kudos
abassoonkid
Contributor
Contributor

I understand that, and I stated in my first post that I can get it to work on my first network, but when deploying it on a different network, this problem crops up.

0 Kudos
rkamal
VMware Employee
VMware Employee

Hi,

Can you post the Vapp xml logs which gets logged on the console.

Setting this would spit all the XML logs from the SDK.

VcloudClient.setLogLevel(Level.All);

Regards,

Rajesh Kamal.

0 Kudos
abassoonkid
Contributor
Contributor

I'll work on that.

I tried your other code for the VApp's Vms, and I'm getting an empty list on the first call (vm.getResource().getVCloudExtension())

0 Kudos
abassoonkid
Contributor
Contributor

I figured out the problem. It seems like vCD couldn't communicate with vCenter correctly and thus wasn't giving back the reference to vCenter. I turned of a firewall in vCenter and everything worked.

0 Kudos
anuragvr
Enthusiast
Enthusiast

Hi Rajesh,

I am facing similar issue in orchestrator workflow, when I am  trying to convert VCD vApps vm to vCenter vm .  When I try to run the getVMVimRef() function (off a VM) it throw error “Vim Object Reference Not Found”.

Any ideas as to what could cause a VM to not have a Vim reference?


My workflow code is as listed below


var vcVms = new Array();


System.log("Vms passed in: " + vms.length);


for (var i in vms) {

    var moref = vms[i].getVMVimRef().moRef;

    var XPath = "xpath:id='"+ moref +"'";

    var VMs  = VcPlugin.getAllVirtualMachines(null, XPath);

    var vm = VMs[0];

    var vmName = vm.name;

    vcVms[i] = vm;

}

--AVR

0 Kudos
iceman76
Enthusiast
Enthusiast

The vCloud VM always has a moRef. Are you sure that the array contains vCloud VM Objects ? ? Have you tried your script with a single vCloud:VM object ?

I am using exactly the same script to get a vCenter VM from vCloud VM.

var vmmoref = vCloudVM.getVMVimRef().moRef;
var xpath = "xpath:id='"+ vmmoref +"'";

var vms = VcPlugin.getAllVirtualMachines(null , xpath);

vm=vms[0];

0 Kudos
anuragvr
Enthusiast
Enthusiast

Yes, array contains the VM objects as when I print following

System.log("Vms passed in: " + vms.length);

System.log("vCloud VM: " + vms[i].name);

System.log(vms[i]);

var moref = vms[i].getVMVimRef().moRef;

It prints arrays actual length 2 and VM name. this scriptable task taking vm array as input from action “getVms FromVApp”

Log subtracts for reference

[2013-04-15 09:15:08.494] [I] Vms passed in: 2

[2013-04-15 09:15:08.498] [I] vCloud VM: test1

[2013-04-15 09:15:08.501] [I] DynamicWrapper (Instance) : [VclVM]-[class com.vmware.vmo.plugin.vcloud.model.VM] -- VALUE : com.vmware.vmo.plugin.vcloud.model.VM@c36c4a9a

[2013-04-15 09:15:09.112] [I] Vim Object Reference Not Found (Workflow:SetAffinityRule / Change vCloud:VM(s) to VC:VM(s) (item4)#7)

In my environment

vCenter Orchestrator's vCloud Director plug-in version is 5.1.538

-AVR

0 Kudos