Cannot instantiate vApp from VM template without network interface
Hello,
vCloud: 9.7.0.16081827 API: 32.0 python: 3.7
I am not able to instantiate a vApp where the VM has no network.
vdc.instantiate_vapp("vapp_name",
"my_catalog",
"my_template",
description="test desc.",
deploy=True,
power_on=False,
accept_all_eulas=False,
memory=1024,
cpu=1,
vm_name="test-vm",
hostname="test-host")
With pyvcloud 22.0.1:
pyvcloud/vcd/vdc.py", line 322, in instantiate_vapp
primary_index = int(vms[0].NetworkConnectionSection.
File "src/lxml/objectify.pyx", line 231, in lxml.objectify.ObjectifiedElement.__getattr__
File "src/lxml/objectify.pyx", line 450, in lxml.objectify._lookupChildOrRaise
AttributeError: no such child: {http://www.vmware.com/vcloud/v1.5}PrimaryNetworkConnectionIndex
With git revision ac8539e:
pyvcloud/vcd/vdc.py", line 368, in instantiate_vapp
primary_index = int(vms[0].NetworkConnectionSection.
File "src/lxml/objectify.pyx", line 231, in lxml.objectify.ObjectifiedElement.__getattr__
File "src/lxml/objectify.pyx", line 450, in lxml.objectify._lookupChildOrRaise
AttributeError: no such child: {http://www.vmware.com/vcloud/v1.5}PrimaryNetworkConnectionIndex
The template used was created from the web interface from a vApp where all network interfaces were removed from the VM. The vApp contains only one VM.
This works if I use a similar template with still network interfaces on the VM.
I tried has a workaround (with current git revision) to create an empty vApp and add VM from the template to it, but I get
File "pyvcloud/vcd/vapp.py", line 1025, in add_vms
params.append(self.to_sourced_item(spec))
File "pyvcloud/vcd/vapp.py", line 928, in to_sourced_item
primary_index = int(source_vm_resource.NetworkConnectionSection.
File "src/lxml/objectify.pyx", line 231, in lxml.objectify.ObjectifiedElement.__getattr__
File "src/lxml/objectify.pyx", line 450, in lxml.objectify._lookupChildOrRaise
AttributeError: no such child: {http://www.vmware.com/vcloud/v1.5}PrimaryNetworkConnectionIndex
With the following code:
vapp = vdc.create_vapp("test",
description="test desc.",
fence_mode='bridged'
)
vapp = VApp(client, href=vapp.get('href'))
catalog_item = org.get_catalog_item(catalog_name, template_name)
tmpl = client.get_resource(catalog_item.Entity.get('href'))
vm_spec = {
"vapp": tmpl,
"source_vm_name": "base",
"target_vm_name": "test-vm",
"hostname": "test-host",
"network": "admin"
}
vapp.add_vms([vm_spec],
deploy=True,
power_on=False
)
Also the same code as above, without specifying network
File "pyvcloud/vcd/vapp.py", line 1032, in add_vms
EntityType.RECOMPOSE_VAPP_PARAMS.value, params)
File "pyvcloud/vcd/client.py", line 1437, in post_linked_resource
find_link(resource, rel, media_type).href, contents,
File "pyvcloud/vcd/client.py", line 1727, in find_link
links = get_links(resource, rel, media_type, name)
File "pyvcloud/vcd/client.py", line 1754, in get_links
for link in resource.findall('{http://www.vmware.com/vcloud/v1.5}Link'):
AttributeError: 'NoneType' object has no attribute 'findall'
By the way, is it possible to manipulate object without having to reconstruct them from client and href? (eg: vapp = VApp(client, href=vapp.get('href')) )
@rmillet-rs, please confirm if the template does not have any network attached to it because if it does not have any network then execution should not have gotten inside the below code as per line. The network value has to be None for every time.
pyvcloud/vcd/vdc.py", line 322, in instantiate_vapp
primary_index = int(vms[0].NetworkConnectionSection.
Hello, I suspect the network is still attached to the vApp, but not to the VM itself because I only disconnect it from VM (not vApp) before creating the template.
But when a vApp is created from this template in the web interface, the network is not attached to the created vApp.
same, i prepare the PR for that case, just a moment
Hello, I suspect the network is still attached to the vApp, but not to the VM itself because I only disconnect it from VM (not vApp) before creating the template.
But when a vApp is created from this template in the web interface, the network is not attached to the created vApp.
i will be try to answer more objectively and try to stay out, get chill and wait. And if you can, you see... please wait my arguments below in next hour.
You must go, and read the issues and PR body information, You see can see multiple behavior math points,
- between you issues and my case.
My writed code to ansible module with fix SDK methods can do a VMs,
Time go day by day, looks nothing in total are changes, -
Looks need enjoy to develop the fixes for that
So master looks still no... github cat now regrettably crying
In my fix whic approved and merged to SDK, really nano-fix - fixes for samelless problem with self in different place.
Links on that types of issues, and read it:
https://github.com/vmware/ansible-module-vcloud-director/pull/131 https://github.com/vmware/pyvcloud/pull/696
Now i no have uses before vCloud Infrastructure, and cannot test fix. But after bootstrap platform, i do that