Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Invalid content was found starting with element 'IpAddress' Error when trying to update existing NIC with Static IP #794

Open
mm321 opened this issue May 18, 2022 · 0 comments
Labels

Comments

@mm321
Copy link

mm321 commented May 18, 2022

Describe the bug

I have script which can successfully build a vApp, add multiple VMs in and update CPU/RAM and Guest OS Customization. However, I am unable to update the existing NIC of the VMs to Manual mode with a static IP. I receive the following error:
"HTTP 400 Bad Request - cvc-complex-type.2.4.d: Invalid content was found starting with element 'IpAddress'. No child element is expected at this point"

I have tested out adding a new NIC and then deleting the old one which does seem to work. However, it just adds extra steps in my script which begins to add up as this may end up deploying 7 or more servers at a time. I also wanted to see if I am doing something wrong or if this is a known issue before committing to that path.

My code for adding the building the vapp through updating the NIC is below:

org_resource = client.get_org_by_name('myorg-123456')
org = Org(client,resource=org_resource)
catalog_item = org.get_catalog_item("Windows Server 2019 Datacenter", "Windows Server 2019 Datacenter")
source_vapp_resource = client.get_resource(catalog_item.Entity.get('href'))
vdc_resource = org.get_vdc(vdc)
vdc = VDC(client, resource=vdc_resource)
build_vapp = vdc.create_vapp(vapp_name,description=None,network=net,fence_mode='bridged',accept_all_eulas=True)
time.sleep(5)
vapp_resource = vdc.get_vapp(vapp_name)
vapp = VApp(client, resource=vapp_resource)

specs = [{'vapp': source_vapp_resource, 'source_vm_name': "Microsoft Windows Server 2019", 'target_vm_name': 'test01', 'hostname': 'test01', 'network': 'network01', 'password_auto': False,'password_reset': False, 'password': '********','virtual_cpu': 4,'core_per_socket': 2,'memory': 8192},
        ]
        
try:
    addtovapp = vapp.add_vms(specs,power_on=False=)
except:
    pass
client.get_task_monitor().wait_for_success(addtovapp)
time.sleep(5)
vapp.reload()
vms = vapp.get_all_vms()
vms_list = list(vms)
for serv in vms_list:
    vm_resource = vapp.get_vm(serv.attrib['name'])
    vm = VM(client, resource=vm_resource)
    addsid = vm.update_guest_customization_section(change_sid=True)
    print("Enable Change SID")
    client.get_task_monitor().wait_for_success(addsid)
    time.sleep(3)
    vm.reload()
    vapp.reload()
    update_nic = vm.update_nic(network_name='network01',nic_id=0,is_primary=True,is_connected=True,ip_address_mode='MANUAL',ip_address='10.230.237.125',adapter_type='VMXNET3')
    client.get_task_monitor().wait_for_success(update_nic)

Reproduction steps

Running the above code gives me this error

Expected behavior

NIC updates successfully.

Additional context

My vCloud Director build is 10.2.2.18686238 and I am using API 35.0 when the script is run. pyvcloud version is Version: 23.0.3.

@mm321 mm321 added the bug label May 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant