|
|
@ -47,6 +47,7 @@ options:
|
|
|
|
profile:
|
|
|
|
profile:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Virtual network interface profile to be attached to VM network interface.
|
|
|
|
- Virtual network interface profile to be attached to VM network interface.
|
|
|
|
|
|
|
|
- When not specified and network has only single profile it will be auto-selected, otherwise you must specify profile.
|
|
|
|
interface:
|
|
|
|
interface:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- "Type of the network interface. For example e1000, pci_passthrough, rtl8139, rtl8139_virtio, spapr_vlan or virtio."
|
|
|
|
- "Type of the network interface. For example e1000, pci_passthrough, rtl8139, rtl8139_virtio, spapr_vlan or virtio."
|
|
|
@ -183,6 +184,15 @@ class EntityNicsModule(BaseModule):
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_vnics(networks_service, network, connection):
|
|
|
|
|
|
|
|
resp = []
|
|
|
|
|
|
|
|
vnic_services = connection.system_service().vnic_profiles_service()
|
|
|
|
|
|
|
|
for vnic in vnic_services.list():
|
|
|
|
|
|
|
|
if vnic.network.id == network.id:
|
|
|
|
|
|
|
|
resp.append(vnic)
|
|
|
|
|
|
|
|
return resp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
argument_spec = ovirt_full_argument_spec(
|
|
|
|
argument_spec = ovirt_full_argument_spec(
|
|
|
|
state=dict(type='str', default='present', choices=['absent', 'plugged', 'present', 'unplugged']),
|
|
|
|
state=dict(type='str', default='present', choices=['absent', 'plugged', 'present', 'unplugged']),
|
|
|
@ -234,8 +244,8 @@ def main():
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Find vNIC id of the network interface (if any):
|
|
|
|
# Find vNIC id of the network interface (if any):
|
|
|
|
|
|
|
|
if module.params['network']:
|
|
|
|
profile = module.params.get('profile')
|
|
|
|
profile = module.params.get('profile')
|
|
|
|
if profile and module.params['network']:
|
|
|
|
|
|
|
|
cluster_name = get_link_name(connection, cluster_id)
|
|
|
|
cluster_name = get_link_name(connection, cluster_id)
|
|
|
|
dcs_service = connection.system_service().data_centers_service()
|
|
|
|
dcs_service = connection.system_service().data_centers_service()
|
|
|
|
dc = dcs_service.list(search='Clusters.name=%s' % cluster_name)[0]
|
|
|
|
dc = dcs_service.list(search='Clusters.name=%s' % cluster_name)[0]
|
|
|
@ -252,10 +262,20 @@ def main():
|
|
|
|
dc.name
|
|
|
|
dc.name
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
if profile:
|
|
|
|
for vnic in connection.system_service().vnic_profiles_service().list():
|
|
|
|
for vnic in connection.system_service().vnic_profiles_service().list():
|
|
|
|
if vnic.name == profile and vnic.network.id == network.id:
|
|
|
|
if vnic.name == profile and vnic.network.id == network.id:
|
|
|
|
entitynics_module.vnic_id = vnic.id
|
|
|
|
entitynics_module.vnic_id = vnic.id
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
# When not specified which vnic use ovirtmgmt/ovirtmgmt
|
|
|
|
|
|
|
|
vnics = get_vnics(networks_service, network, connection)
|
|
|
|
|
|
|
|
if len(vnics) == 1:
|
|
|
|
|
|
|
|
entitynics_module.vnic_id = vnics[0].id
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
raise Exception(
|
|
|
|
|
|
|
|
"You didn't specify any vnic profile. "
|
|
|
|
|
|
|
|
"Following vnic profiles are in system: '%s', please specify one of them" % ([vnic.name for vnic in vnics])
|
|
|
|
|
|
|
|
)
|
|
|
|
# Handle appropriate action:
|
|
|
|
# Handle appropriate action:
|
|
|
|
state = module.params['state']
|
|
|
|
state = module.params['state']
|
|
|
|
if state == 'present':
|
|
|
|
if state == 'present':
|
|
|
|