summaryrefslogtreecommitdiffstats
path: root/ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_vm_hardware_ethernet.py
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_vm_hardware_ethernet.py')
-rw-r--r--ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_vm_hardware_ethernet.py117
1 files changed, 68 insertions, 49 deletions
diff --git a/ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_vm_hardware_ethernet.py b/ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_vm_hardware_ethernet.py
index f92a0c4df..758e406fc 100644
--- a/ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_vm_hardware_ethernet.py
+++ b/ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_vm_hardware_ethernet.py
@@ -3,11 +3,8 @@
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# template: header.j2
-# This module is autogenerated by vmware_rest_code_generator.
-# See: https://github.com/ansible-collections/vmware_rest_code_generator
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+# This module is autogenerated using the ansible.content_builder.
+# See: https://github.com/ansible-community/ansible.content_builder
DOCUMENTATION = r"""
@@ -18,14 +15,16 @@ options:
allow_guest_control:
description:
- Flag indicating whether the guest can connect and disconnect the device.
+ - If unset, the value is unchanged.
type: bool
backing:
description:
- - Physical resource backing for the virtual Ethernet adapter. Required with
- I(state=['present'])
+ - Physical resource backing for the virtual Ethernet adapter.
+ - If unset, the system may try to find an appropriate backing. If one is not
+ found, the request will fail. Required with I(state=['present'])
- 'Valid attributes are:'
- - ' - C(type) (str): The C(backing_type) defines the valid backing types for
- a virtual Ethernet adapter. ([''present''])'
+ - ' - C(type) (str): This option defines the valid backing types for a virtual
+ Ethernet adapter. ([''present''])'
- ' This key is required with [''present''].'
- ' - Accepted values:'
- ' - DISTRIBUTED_PORTGROUP'
@@ -33,16 +32,25 @@ options:
- ' - OPAQUE_NETWORK'
- ' - STANDARD_PORTGROUP'
- ' - C(network) (str): Identifier of the network that backs the virtual Ethernet
- adapter. ([''present''])'
+ adapter.'
+ - This field is optional and it is only relevant when the value of I(type)
+ is one of STANDARD_PORTGROUP, DISTRIBUTED_PORTGROUP, or OPAQUE_NETWORK.
+ - When clients pass a value of this structure as a parameter, the field must
+ be the id of a resource returned by M(vmware.vmware_rest.vcenter_network_info).
+ (['present'])
- ' - C(distributed_port) (str): Key of the distributed virtual port that
- backs the virtual Ethernet adapter. Depending on the type of the Portgroup,
+ backs the virtual Ethernet adapter. Depending on the type of the Portgroup,
the port may be specified using this field. If the portgroup type is early-binding
(also known as static), a port is assigned when the Ethernet adapter is
configured to use the port. The port may be either automatically or specifically
assigned based on the value of this field. If the portgroup type is ephemeral,
the port is created and assigned to a virtual machine when it is powered
- on and the Ethernet adapter is connected. This field cannot be specified
- as no free ports exist before use. ([''present''])'
+ on and the Ethernet adapter is connected. This field cannot be specified
+ as no free ports exist before use.'
+ - May be used to specify a port when the network specified on the I(network)
+ field is a static or early binding distributed portgroup. If unset, the
+ port will be automatically assigned to the Ethernet adapter based on the
+ policy embodied by the portgroup type. (['present'])
type: dict
label:
description:
@@ -50,8 +58,12 @@ options:
type: str
mac_address:
description:
- - MAC address. This field may be modified at any time, and changes will be
- applied the next time the virtual machine is powered on.
+ - 'MAC address. '
+ - ' This field may be modified at any time, and changes will be applied the
+ next time the virtual machine is powered on.'
+ - ''
+ - If unset, the value is unchanged. Must be specified if I(mac_type) is MANUAL.
+ Must be unset if the MAC address type is not MANUAL.
type: str
mac_type:
choices:
@@ -59,19 +71,22 @@ options:
- GENERATED
- MANUAL
description:
- - The C(mac_address_type) defines the valid MAC address origins for a virtual
- Ethernet adapter.
+ - The I(mac_address_type) enumerated type defines the valid MAC address origins
+ for a virtual Ethernet adapter.
type: str
nic:
description:
- - Virtual Ethernet adapter identifier. Required with I(state=['absent', 'connect',
- 'disconnect', 'present'])
+ - Virtual Ethernet adapter identifier.
+ - The parameter must be the id of a resource returned by M(vmware.vmware_rest.vcenter_vm_hardware_ethernet).
+ Required with I(state=['absent', 'connect', 'disconnect', 'present'])
type: str
pci_slot_number:
description:
- - Address of the virtual Ethernet adapter on the PCI bus. If the PCI address
+ - Address of the virtual Ethernet adapter on the PCI bus. If the PCI address
is invalid, the server will change when it the VM is started or as the
device is hot added.
+ - If unset, the server will choose an available address when the virtual machine
+ is powered on.
type: int
session_timeout:
description:
@@ -85,6 +100,7 @@ options:
description:
- Flag indicating whether the virtual device should be connected whenever
the virtual machine is powered on.
+ - If unset, the value is unchanged.
type: bool
state:
choices:
@@ -104,15 +120,18 @@ options:
- VMXNET2
- VMXNET3
description:
- - The C(emulation_type) defines the valid emulation types for a virtual Ethernet
- adapter.
+ - The I(emulation_type) enumerated type defines the valid emulation types
+ for a virtual Ethernet adapter.
type: str
upt_compatibility_enabled:
description:
- - Flag indicating whether Universal Pass-Through (UPT) compatibility should
- be enabled on this virtual Ethernet adapter. This field may be modified
- at any time, and changes will be applied the next time the virtual machine
- is powered on.
+ - 'Flag indicating whether Universal Pass-Through (UPT) compatibility should
+ be enabled on this virtual Ethernet adapter. '
+ - ' This field may be modified at any time, and changes will be applied the
+ next time the virtual machine is powered on.'
+ - ''
+ - If unset, the value is unchanged. Must be unset if the emulation type of
+ the virtual Ethernet adapter is not VMXNET3.
type: bool
vcenter_hostname:
description:
@@ -153,24 +172,29 @@ options:
type: bool
vm:
description:
- - Virtual machine identifier. This parameter is mandatory.
+ - Virtual machine identifier.
+ - The parameter must be the id of a resource returned by M(vmware.vmware_rest.vcenter_vm_info).
+ This parameter is mandatory.
required: true
type: str
wake_on_lan_enabled:
description:
- - Flag indicating whether wake-on-LAN shoud be enabled on this virtual Ethernet
- adapter. This field may be modified at any time, and changes will be applied
- the next time the virtual machine is powered on.
+ - 'Flag indicating whether wake-on-LAN shoud be enabled on this virtual Ethernet
+ adapter. '
+ - ' This field may be modified at any time, and changes will be applied the
+ next time the virtual machine is powered on.'
+ - ''
+ - If unset, the value is unchanged.
type: bool
author:
- Ansible Cloud Team (@ansible-collections)
version_added: 0.1.0
requirements:
-- vSphere 7.0.2 or greater
+- vSphere 7.0.3 or greater
- python >= 3.6
- aiohttp
notes:
-- Tested on vSphere 7.0.2
+- Tested on vSphere 7.0.3
"""
EXAMPLES = r"""
@@ -281,6 +305,8 @@ value:
# This structure describes the format of the data expected by the end-points
PAYLOAD_FORMAT = {
+ "connect": {"query": {}, "body": {}, "path": {"nic": "nic", "vm": "vm"}},
+ "disconnect": {"query": {}, "body": {}, "path": {"nic": "nic", "vm": "vm"}},
"update": {
"query": {},
"body": {
@@ -310,12 +336,8 @@ PAYLOAD_FORMAT = {
"path": {"vm": "vm"},
},
"delete": {"query": {}, "body": {}, "path": {"nic": "nic", "vm": "vm"}},
- "disconnect": {"query": {}, "body": {}, "path": {"nic": "nic", "vm": "vm"}},
- "connect": {"query": {}, "body": {}, "path": {"nic": "nic", "vm": "vm"}},
} # pylint: disable=line-too-long
-import json
-import socket
from ansible.module_utils.basic import env_fallback
try:
@@ -330,26 +352,28 @@ try:
except ImportError:
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.vmware.vmware_rest.plugins.module_utils.vmware_rest import (
- build_full_device_list,
exists,
gen_args,
get_device_info,
get_subdevice_type,
- list_devices,
open_session,
prepare_payload,
- update_changed_flag,
session_timeout,
+ update_changed_flag,
)
def prepare_argument_spec():
argument_spec = {
"vcenter_hostname": dict(
- type="str", required=True, fallback=(env_fallback, ["VMWARE_HOST"]),
+ type="str",
+ required=True,
+ fallback=(env_fallback, ["VMWARE_HOST"]),
),
"vcenter_username": dict(
- type="str", required=True, fallback=(env_fallback, ["VMWARE_USER"]),
+ type="str",
+ required=True,
+ fallback=(env_fallback, ["VMWARE_USER"]),
),
"vcenter_password": dict(
type="str",
@@ -437,7 +461,6 @@ def build_url(params):
async def entry_point(module, session):
-
if module.params["state"] == "present":
if "_create" in globals():
operation = "create"
@@ -481,20 +504,16 @@ async def _connect(params, session):
async def _create(params, session):
-
lookup_url = per_id_url = build_url(params)
uniquity_keys = ["nic"]
comp_func = None
async def lookup_with_filters(params, session, url):
- # e.g: for the datacenter resources
- if "folder" not in params:
- return
+ search_filter = ""
+
if "name" not in params:
return
- async with session.get(
- f"{url}?names={params['name']}&folders={params['folder']}"
- ) as resp:
+ async with session.get(f"{url}?names={params['name']}{search_filter}") as resp:
_json = await resp.json()
if isinstance(_json, list) and len(_json) == 1:
return await get_device_info(session, url, _json[0]["nic"])