Joey
The setup_networks/modified_network_attachments methods took care of my
issue.
Thanks
Don
On Wed, Jul 3, 2019 at 8:15 AM Don Dupuis <dondster(a)gmail.com> wrote:
Thanks, I will check it out.
On Wed, Jul 3, 2019 at 12:06 AM Joey Ma <majunjiev(a)gmail.com> wrote:
> Hi Don,
>
> One feasible way to manipulate host networks/nics is using
> `host_service.setup_networks()` function. You could refer to [1] and [2]
> for the official directive details. Hopefully it will be useful.
>
> Regards,
> Joey
>
> [1]:
>
https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/examples/add_bo...
> [2]:
>
http://ovirt.github.io/ovirt-engine-api-model/4.4/#services/host/methods/...
>
> On Wed, Jul 3, 2019 at 2:42 AM Don Dupuis <dondster(a)gmail.com> wrote:
>
>> 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():
>> if n.name == 'bond0.96':
>> n_id = n.id
>> 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]
>> print ("Network name is %s" % network.name)
>> print ("Network id is %s" % network.id)
>> net_attachments_service = host_service.network_attachments_service()
>> net_attachment = net_attachments_service.add(
>> types.NetworkAttachment(
>> network=types.Network(id=network.id),
>> 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
>> _______________________________________________
>> Users mailing list -- users(a)ovirt.org
>> To unsubscribe send an email to users-leave(a)ovirt.org
>> Privacy Statement:
https://www.ovirt.org/site/privacy-policy/
>> oVirt Code of Conduct:
>>
https://www.ovirt.org/community/about/community-guidelines/
>> List Archives:
>>
https://lists.ovirt.org/archives/list/users@ovirt.org/message/VJ4VY5XLXZJ...
>>
>