cloud: ovirt: fix ovirt_nics profile search (#22684)

This commit is contained in:
Ondra Machacek 2017-03-16 13:27:30 +01:00 committed by Ryan Brown
parent 672e9a2f61
commit 7a3b6ca37c

View file

@ -212,7 +212,18 @@ def main():
dcs_service = connection.system_service().data_centers_service()
dc = dcs_service.list(search='Clusters.name=%s' % cluster_name)[0]
networks_service = dcs_service.service(dc.id).networks_service()
network = search_by_name(networks_service, module.params['network'])
network = next(
(n for n in networks_service.list()
if n.name == module.params['network']),
None
)
if network is None:
raise Exception(
"Network '%s' was not found in datacenter '%s'." % (
module.params['network'],
dc.name
)
)
for vnic in connection.system_service().vnic_profiles_service().list():
if vnic.name == profile and vnic.network.id == network.id:
vmnics_module.vnic_id = vnic.id