I am having issue with adding network to host nic with python SDK. It works just fine using the portal GUI. I have the following:
bond0 that is setup as mode 4
bond0.120 that is attached to ovirtmgmt network
bond0.96 that I am trying to attach a new installed network called External.
Below is a code snippet of what I am trying to do:
hosts_service = connection.system_service().hosts_service()
host = hosts_service.list(search='name=%s' % HOSTNAME)[0]
host_service = hosts_service.host_service(
host.id)
hostnics_service = hosts_service.host_service(
host.id).nics_service()
n = None
for n in hostnics_service.list():
print("n is %s" % n_id)
system_service = connection.system_service()
networks_service = connection.system_service().networks_service()
network = networks_service.list(
search='name=External and datacenter=%s-local' % HOSTNAME) [0]
net_attachments_service = host_service.network_attachments_service()
net_attachment = net_attachments_service.add(
types.NetworkAttachment(
host_nic=types.HostNic(name='bond0.96')
),
),
I will end up with an error of
File "./add_host_py", line 193, in Add_External_network
host_nic=types.HostNic(name='bond0.96')
File "/usr/lib64/python2.7/site-packages/ovirtsdk4/services.py", line 15441, in add
self._check_fault(response)
File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 98, in _check_fault
Service._raise_error(response, fault)
File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 71, in _raise_error
raise Error(msg)
ovirtsdk4.Error: Fault reason is "Operation Failed". Fault detail is "[Cannot setup Networks. The attachment of network 'External' references vlan device 'bond0.96'. Network attachment cannot reference vlan device.]". HTTP response code is 400.
Can someone guide me on what I am doing wrong or not understanding with the NetworkAttachment Service?
Thanks
Don