summaryrefslogtreecommitdiffstats
path: root/ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_vm.py
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_vm.py')
-rw-r--r--ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_vm.py649
1 files changed, 436 insertions, 213 deletions
diff --git a/ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_vm.py b/ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_vm.py
index c71e80be0..af858bac2 100644
--- a/ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_vm.py
+++ b/ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_vm.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"""
@@ -19,43 +16,51 @@ options:
description:
- 128-bit SMBIOS UUID of a virtual machine represented as a hexadecimal string
in "12345678-abcd-1234-cdef-123456789abc" format.
+ - If unset, will be generated.
type: str
boot:
description:
- Boot configuration.
+ - If unset, guest-specific default values will be used.
- 'Valid attributes are:'
- - ' - C(type) (str): The C(type) defines the valid firmware types for a virtual
+ - ' - C(type) (str): This option defines the valid firmware types for a virtual
machine. ([''present''])'
- ' - Accepted values:'
- ' - BIOS'
- ' - EFI'
- ' - C(efi_legacy_boot) (bool): Flag indicating whether to use EFI legacy
- boot mode. ([''present''])'
- - ' - C(network_protocol) (str): The C(network_protocol) defines the valid
- network boot protocols supported when booting a virtual machine with {@link
- Type#EFI} firmware over the network. ([''present''])'
+ boot mode.'
+ - If unset, defaults to value that is recommended for the guest OS and is
+ supported for the virtual hardware version. (['present'])
+ - ' - C(network_protocol) (str): This option defines the valid network boot
+ protocols supported when booting a virtual machine with EFI firmware over
+ the network. ([''present''])'
- ' - Accepted values:'
- ' - IPV4'
- ' - IPV6'
- ' - C(delay) (int): Delay in milliseconds before beginning the firmware
- boot process when the virtual machine is powered on. This delay may be
+ boot process when the virtual machine is powered on. This delay may be
used to provide a time window for users to connect to the virtual machine
- console and enter BIOS setup mode. ([''present''])'
+ console and enter BIOS setup mode.'
+ - If unset, default value is 0. (['present'])
- ' - C(retry) (bool): Flag indicating whether the virtual machine should
- automatically retry the boot process after a failure. ([''present''])'
+ automatically retry the boot process after a failure.'
+ - If unset, default value is false. (['present'])
- ' - C(retry_delay) (int): Delay in milliseconds before retrying the boot
- process after a failure; applicable only when {@link Info#retry} is true.
- ([''present''])'
+ process after a failure; applicable only when I(retry) is true.'
+ - If unset, default value is 10000. (['present'])
- ' - C(enter_setup_mode) (bool): Flag indicating whether the firmware boot
process should automatically enter setup mode the next time the virtual
- machine boots. Note that this flag will automatically be reset to false
- once the virtual machine enters setup mode. ([''present''])'
+ machine boots. Note that this flag will automatically be reset to false
+ once the virtual machine enters setup mode.'
+ - If unset, the value is unchanged. (['present'])
type: dict
boot_devices:
description:
- Boot device configuration.
+ - If unset, a server-specific boot sequence will be used.
- 'Valid attributes are:'
- - ' - C(type) (str): The C(type) defines the valid device types that may be
+ - ' - C(type) (str): This option defines the valid device types that may be
used as bootable devices. ([''present''])'
- ' This key is required with [''present''].'
- ' - Accepted values:'
@@ -68,168 +73,254 @@ options:
cdroms:
description:
- List of CD-ROMs.
+ - If unset, no CD-ROM devices will be created.
- 'Valid attributes are:'
- - ' - C(type) (str): The C(host_bus_adapter_type) defines the valid types
- of host bus adapters that may be used for attaching a Cdrom to a virtual
- machine. ([''present''])'
+ - ' - C(type) (str): This option defines the valid types of host bus adapters
+ that may be used for attaching a Cdrom to a virtual machine. ([''present''])'
- ' - Accepted values:'
- ' - IDE'
- ' - SATA'
- - ' - C(ide) (dict): Address for attaching the device to a virtual IDE adapter.
- ([''present''])'
+ - ' - C(ide) (dict): Address for attaching the device to a virtual IDE adapter.'
+ - If unset, the server will choose an available address; if none is available,
+ the request will fail. (['present'])
- ' - Accepted keys:'
- ' - primary (boolean): Flag specifying whether the device should be
attached to the primary or secondary IDE adapter of the virtual machine.'
+ - If unset, the server will choose a adapter with an available connection.
+ If no IDE connections are available, the request will be rejected.
- ' - master (boolean): Flag specifying whether the device should be the
master or slave device on the IDE adapter.'
- - ' - C(sata) (dict): Address for attaching the device to a virtual SATA adapter.
- ([''present''])'
+ - If unset, the server will choose an available connection type. If no IDE
+ connections are available, the request will be rejected.
+ - ' - C(sata) (dict): Address for attaching the device to a virtual SATA adapter.'
+ - If unset, the server will choose an available address; if none is available,
+ the request will fail. (['present'])
- ' - Accepted keys:'
- ' - bus (integer): Bus number of the adapter to which the device should
be attached.'
- ' - unit (integer): Unit number of the device.'
+ - If unset, the server will choose an available unit number on the specified
+ adapter. If there are no available connections on the adapter, the request
+ will be rejected.
- ' - C(backing) (dict): Physical resource backing for the virtual CD-ROM
- device. ([''present''])'
+ device.'
+ - If unset, defaults to automatic detection of a suitable host device. (['present'])
- ' - Accepted keys:'
- - ' - type (string): The C(backing_type) defines the valid backing types
- for a virtual CD-ROM device.'
+ - ' - type (string): This option defines the valid backing types for a
+ virtual CD-ROM device.'
- 'Accepted value for this field:'
- ' - C(CLIENT_DEVICE)'
- ' - C(HOST_DEVICE)'
- ' - C(ISO_FILE)'
- ' - iso_file (string): Path of the image file that should be used as
the virtual CD-ROM device backing.'
+ - This field is optional and it is only relevant when the value of I(type)
+ is ISO_FILE.
- ' - host_device (string): Name of the device that should be used as
the virtual CD-ROM device backing.'
- - ' - device_access_type (string): The C(device_access_type) defines the
- valid device access types for a physical device packing of a virtual CD-ROM
- device.'
+ - If unset, the virtual CD-ROM device will be configured to automatically
+ detect a suitable host device.
+ - ' - device_access_type (string): This option defines the valid device
+ access types for a physical device packing of a virtual CD-ROM device.'
- 'Accepted value for this field:'
- ' - C(EMULATION)'
- ' - C(PASSTHRU)'
- ' - C(PASSTHRU_EXCLUSIVE)'
- ' - C(start_connected) (bool): Flag indicating whether the virtual device
- should be connected whenever the virtual machine is powered on. ([''present''])'
+ should be connected whenever the virtual machine is powered on.'
+ - Defaults to false if unset. (['present'])
- ' - C(allow_guest_control) (bool): Flag indicating whether the guest can
- connect and disconnect the device. ([''present''])'
+ connect and disconnect the device.'
+ - Defaults to false if unset. (['present'])
elements: dict
type: list
cpu:
description:
- CPU configuration.
+ - If unset, guest-specific default values will be used.
- 'Valid attributes are:'
- - ' - C(count) (int): New number of CPU cores. The number of CPU cores in
- the virtual machine must be a multiple of the number of cores per socket.
- The supported range of CPU counts is constrained by the configured guest
- operating system and virtual hardware version of the virtual machine.
- If the virtual machine is running, the number of CPU cores may only be
- increased if {@link Info#hotAddEnabled} is true, and may only be decreased
- if {@link Info#hotRemoveEnabled} is true. ([''present''])'
- - ' - C(cores_per_socket) (int): New number of CPU cores per socket. The
- number of CPU cores in the virtual machine must be a multiple of the number
- of cores per socket. ([''present''])'
+ - ' - C(count) (int): New number of CPU cores. The number of CPU cores in
+ the virtual machine must be a multiple of the number of cores per socket. '
+ - ' The supported range of CPU counts is constrained by the configured guest
+ operating system and virtual hardware version of the virtual machine. '
+ - ''
+ - ' If the virtual machine is running, the number of CPU cores may only be
+ increased if I(hot_add_enabled) is true, and may only be decreased if
+ I(hot_remove_enabled) is true.'
+ - ''
+ - If unset, the value is unchanged. (['present'])
+ - ' - C(cores_per_socket) (int): New number of CPU cores per socket. The number
+ of CPU cores in the virtual machine must be a multiple of the number of
+ cores per socket.'
+ - If unset, the value is unchanged. (['present'])
- ' - C(hot_add_enabled) (bool): Flag indicating whether adding CPUs while
- the virtual machine is running is enabled. This field may only be modified
- if the virtual machine is powered off. ([''present''])'
+ the virtual machine is running is enabled. '
+ - ' This field may only be modified if the virtual machine is powered off.'
+ - ''
+ - If unset, the value is unchanged. (['present'])
- ' - C(hot_remove_enabled) (bool): Flag indicating whether removing CPUs
- while the virtual machine is running is enabled. This field may only be
- modified if the virtual machine is powered off. ([''present''])'
+ while the virtual machine is running is enabled. '
+ - ' This field may only be modified if the virtual machine is powered off.'
+ - ''
+ - If unset, the value is unchanged. (['present'])
type: dict
datastore:
description:
- Identifier of the datastore on which the virtual machine's configuration
state is stored.
+ - If unset, I(path) must also be unset and I(datastore_path) must be set.
+ - '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_datastore_info). '
type: str
datastore_path:
description:
- Datastore path for the virtual machine's configuration file in the format
- "[datastore name] path". For example "[storage1] Test-VM/Test-VM.vmx".
+ "[datastore name] path". For example "[storage1] Test-VM/Test-VM.vmx".
+ - If unset, both I(datastore) and I(path) must be set.
type: str
disconnect_all_nics:
description:
- Indicates whether all NICs on the destination virtual machine should be
disconnected from the newtwork
+ - If unset, connection status of all NICs on the destination virtual machine
+ will be the same as on the source virtual machine.
type: bool
disks:
description:
- Individual disk relocation map.
+ - If unset, all disks will migrate to the datastore specified in the I(datastore)
+ field of I()
+ - 'When clients pass a value of this structure as a parameter, the key in
+ the field map must be the id of a resource returned by M(vmware.vmware_rest.vcenter_vm_hardware_disk). '
- 'Valid attributes are:'
- - ' - C(type) (str): The C(host_bus_adapter_type) defines the valid types
- of host bus adapters that may be used for attaching a virtual storage
- device to a virtual machine. ([''present''])'
+ - ' - C(type) (str): This option defines the valid types of host bus adapters
+ that may be used for attaching a virtual storage device to a virtual machine.
+ ([''present''])'
- ' - Accepted values:'
- ' - IDE'
+ - ' - NVME'
- ' - SATA'
- ' - SCSI'
- - ' - C(ide) (dict): Address for attaching the device to a virtual IDE adapter.
- ([''present''])'
+ - ' - C(ide) (dict): Address for attaching the device to a virtual IDE adapter.'
+ - If unset, the server will choose an available address; if none is available,
+ the request will fail. (['present'])
- ' - Accepted keys:'
- ' - primary (boolean): Flag specifying whether the device should be
attached to the primary or secondary IDE adapter of the virtual machine.'
+ - If unset, the server will choose a adapter with an available connection.
+ If no IDE connections are available, the request will be rejected.
- ' - master (boolean): Flag specifying whether the device should be the
master or slave device on the IDE adapter.'
- - ' - C(scsi) (dict): Address for attaching the device to a virtual SCSI adapter.
- ([''present''])'
+ - If unset, the server will choose an available connection type. If no IDE
+ connections are available, the request will be rejected.
+ - ' - C(scsi) (dict): Address for attaching the device to a virtual SCSI adapter.'
+ - If unset, the server will choose an available address; if none is available,
+ the request will fail. (['present'])
- ' - Accepted keys:'
- ' - bus (integer): Bus number of the adapter to which the device should
be attached.'
- ' - unit (integer): Unit number of the device.'
- - ' - C(sata) (dict): Address for attaching the device to a virtual SATA adapter.
- ([''present''])'
+ - If unset, the server will choose an available unit number on the specified
+ adapter. If there are no available connections on the adapter, the request
+ will be rejected.
+ - ' - C(sata) (dict): Address for attaching the device to a virtual SATA adapter.'
+ - If unset, the server will choose an available address; if none is available,
+ the request will fail. (['present'])
+ - ' - Accepted keys:'
+ - ' - bus (integer): Bus number of the adapter to which the device should
+ be attached.'
+ - ' - unit (integer): Unit number of the device.'
+ - If unset, the server will choose an available unit number on the specified
+ adapter. If there are no available connections on the adapter, the request
+ will be rejected.
+ - ' - C(nvme) (dict): Address for attaching the device to a virtual NVMe adapter.'
+ - If unset, the server will choose an available address; if none is available,
+ the request will fail. (['present'])
- ' - Accepted keys:'
- ' - bus (integer): Bus number of the adapter to which the device should
be attached.'
- ' - unit (integer): Unit number of the device.'
+ - If unset, the server will choose an available unit number on the specified
+ adapter. If there are no available connections on the adapter, the request
+ will be rejected.
- ' - C(backing) (dict): Existing physical resource backing for the virtual
- disk. Exactly one of C(#backing) or C(#new_vmdk) must be specified. ([''present''])'
+ disk. Exactly one of I(backing) or I(new_vmdk) must be specified.'
+ - If unset, the virtual disk will not be connected to an existing backing.
+ (['present'])
- ' - Accepted keys:'
- - ' - type (string): The C(backing_type) defines the valid backing types
- for a virtual disk.'
+ - ' - type (string): This option defines the valid backing types for a
+ virtual disk.'
- 'Accepted value for this field:'
- ' - C(VMDK_FILE)'
- ' - vmdk_file (string): Path of the VMDK file backing the virtual disk.'
+ - This field is optional and it is only relevant when the value of I(type)
+ is VMDK_FILE.
- ' - C(new_vmdk) (dict): Specification for creating a new VMDK backing for
- the virtual disk. Exactly one of C(#backing) or C(#new_vmdk) must be
- specified. ([''present''])'
+ the virtual disk. Exactly one of I(backing) or I(new_vmdk) must be specified.'
+ - If unset, a new VMDK backing will not be created. (['present'])
- ' - Accepted keys:'
- - ' - name (string): Base name of the VMDK file. The name should not
- include the ''.vmdk'' file extension.'
+ - ' - name (string): Base name of the VMDK file. The name should not include
+ the ''.vmdk'' file extension.'
+ - If unset, a name (derived from the name of the virtual machine) will be
+ chosen by the server.
- ' - capacity (integer): Capacity of the virtual disk backing in bytes.'
- - ' - storage_policy (object): The C(storage_policy_spec) {@term structure}
- contains information about the storage policy that is to be associated
- the with VMDK file.'
+ - If unset, defaults to a guest-specific capacity.
+ - ' - storage_policy (object): The I(storage_policy_spec) structure contains
+ information about the storage policy that is to be associated the with
+ VMDK file.'
+ - 'If unset the default storage policy of the target datastore (if applicable)
+ is applied. Currently a default storage policy is only supported by object
+ based datastores : VVol & vSAN. For non- object datastores, if unset then
+ no storage policy would be associated with the VMDK file.'
elements: dict
type: list
disks_to_remove:
description:
- Set of Disks to Remove.
+ - If unset, all disks will be copied. If the same identifier is in I(disks_to_update)
+ InvalidArgument fault will be returned.
+ - When clients pass a value of this structure as a parameter, the field must
+ contain the id of resources returned by M(vmware.vmware_rest.vcenter_vm_hardware_disk).
elements: str
type: list
disks_to_update:
description:
- Map of Disks to Update.
+ - If unset, all disks will copied to the datastore specified in the I(datastore)
+ field of I() If the same identifier is in I(disks_to_remove) InvalidArgument
+ fault will be thrown.
+ - 'When clients pass a value of this structure as a parameter, the key in
+ the field map must be the id of a resource returned by M(vmware.vmware_rest.vcenter_vm_hardware_disk). '
type: dict
floppies:
description:
- List of floppy drives.
+ - If unset, no floppy drives will be created.
- 'Valid attributes are:'
- ' - C(backing) (dict): Physical resource backing for the virtual floppy
- drive. ([''present''])'
+ drive.'
+ - If unset, defaults to automatic detection of a suitable host device. (['present'])
- ' - Accepted keys:'
- - ' - type (string): The C(backing_type) defines the valid backing types
- for a virtual floppy drive.'
+ - ' - type (string): This option defines the valid backing types for a
+ virtual floppy drive.'
- 'Accepted value for this field:'
- ' - C(CLIENT_DEVICE)'
- ' - C(HOST_DEVICE)'
- ' - C(IMAGE_FILE)'
- ' - image_file (string): Path of the image file that should be used
as the virtual floppy drive backing.'
+ - This field is optional and it is only relevant when the value of I(type)
+ is IMAGE_FILE.
- ' - host_device (string): Name of the device that should be used as
the virtual floppy drive backing.'
+ - If unset, the virtual floppy drive will be configured to automatically detect
+ a suitable host device.
- ' - C(start_connected) (bool): Flag indicating whether the virtual device
- should be connected whenever the virtual machine is powered on. ([''present''])'
+ should be connected whenever the virtual machine is powered on.'
+ - Defaults to false if unset. (['present'])
- ' - C(allow_guest_control) (bool): Flag indicating whether the guest can
- connect and disconnect the device. ([''present''])'
+ connect and disconnect the device.'
+ - Defaults to false if unset. (['present'])
elements: dict
type: list
guest_OS:
@@ -416,15 +507,17 @@ options:
- WIN_XP_PRO
- WIN_XP_PRO_64
description:
- - The C(guest_o_s) defines the valid guest operating system types used for
- configuring a virtual machine. Required with I(state=['present'])
+ - The GuestOS enumerated type defines the valid guest operating system types
+ used for configuring a virtual machine. Required with I(state=['present'])
type: str
guest_customization_spec:
description:
- Guest customization spec to apply to the virtual machine after the virtual
machine is deployed.
+ - If unset, the guest operating system is not customized after clone.
- 'Valid attributes are:'
- - ' - C(name) (str): Name of the customization specification. ([''clone''])'
+ - ' - C(name) (str): Name of the customization specification.'
+ - If unset, no guest customization is performed. (['clone'])
type: dict
hardware_version:
choices:
@@ -445,38 +538,48 @@ options:
- VMX_18
- VMX_19
description:
- - The C(version) defines the valid virtual hardware versions for a virtual
- machine. See https://kb.vmware.com/s/article/1003746 (Virtual machine
- hardware versions (1003746)).
+ - The I(version) enumerated type defines the valid virtual hardware versions
+ for a virtual machine. See https://kb.vmware.com/s/article/1003746 (Virtual
+ machine hardware versions (1003746)).
type: str
memory:
description:
- Memory configuration.
+ - If unset, guest-specific default values will be used.
- 'Valid attributes are:'
- - ' - C(size_MiB) (int): New memory size in mebibytes. The supported range
- of memory sizes is constrained by the configured guest operating system
- and virtual hardware version of the virtual machine. If the virtual machine
- is running, this value may only be changed if {@link Info#hotAddEnabled}
+ - ' - C(size_MiB) (int): New memory size in mebibytes. '
+ - ' The supported range of memory sizes is constrained by the configured guest
+ operating system and virtual hardware version of the virtual machine. '
+ - ''
+ - ' If the virtual machine is running, this value may only be changed if I(hot_add_enabled)
is true, and the new memory size must satisfy the constraints specified
- by {@link Info#hotAddIncrementSizeMiB} and {@link Info#hotAddLimitMiB}.
- ([''present''])'
+ by I(hot_add_increment_size_mib) and I()'
+ - ''
+ - If unset, the value is unchanged. (['present'])
- ' - C(hot_add_enabled) (bool): Flag indicating whether adding memory while
- the virtual machine is running should be enabled. Some guest operating
- systems may consume more resources or perform less efficiently when they
- run on hardware that supports adding memory while the machine is running.
- This field may only be modified if the virtual machine is not powered
- on. ([''present''])'
+ the virtual machine is running should be enabled. '
+ - ' Some guest operating systems may consume more resources or perform less
+ efficiently when they run on hardware that supports adding memory while
+ the machine is running. '
+ - ''
+ - ' This field may only be modified if the virtual machine is not powered
+ on.'
+ - ''
+ - If unset, the value is unchanged. (['present'])
type: dict
name:
description:
- - Name of the new virtual machine.
+ - Virtual machine name.
+ - If unset, the display name from the virtual machine's configuration file
+ will be used.
type: str
nics:
description:
- List of Ethernet adapters.
+ - If unset, no Ethernet adapters will be created.
- 'Valid attributes are:'
- - ' - C(type) (str): The C(emulation_type) defines the valid emulation types
- for a virtual Ethernet adapter. ([''present''])'
+ - ' - C(type) (str): This option defines the valid emulation types for a virtual
+ Ethernet adapter. ([''present''])'
- ' - Accepted values:'
- ' - E1000'
- ' - E1000E'
@@ -485,25 +588,31 @@ options:
- ' - VMXNET2'
- ' - VMXNET3'
- ' - C(upt_compatibility_enabled) (bool): Flag indicating whether Universal
- Pass-Through (UPT) compatibility is enabled on this virtual Ethernet adapter.
- ([''present''])'
- - ' - C(mac_type) (str): The C(mac_address_type) defines the valid MAC address
- origins for a virtual Ethernet adapter. ([''present''])'
+ Pass-Through (UPT) compatibility is enabled on this virtual Ethernet adapter.'
+ - If unset, defaults to false. (['present'])
+ - ' - C(mac_type) (str): This option defines the valid MAC address origins
+ for a virtual Ethernet adapter. ([''present''])'
- ' - Accepted values:'
- ' - ASSIGNED'
- ' - GENERATED'
- ' - MANUAL'
- - ' - C(mac_address) (str): MAC address. ([''present''])'
+ - ' - C(mac_address) (str): MAC address.'
+ - Workaround for PR1459647 (['present'])
- ' - C(pci_slot_number) (int): 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. ([''present''])'
+ 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. (['present'])
- ' - C(wake_on_lan_enabled) (bool): Flag indicating whether wake-on-LAN is
- enabled on this virtual Ethernet adapter. ([''present''])'
+ enabled on this virtual Ethernet adapter.'
+ - Defaults to false if unset. (['present'])
- ' - C(backing) (dict): Physical resource backing for the virtual Ethernet
- adapter. ([''present''])'
+ adapter.'
+ - If unset, the system may try to find an appropriate backing. If one is not
+ found, the request will fail. (['present'])
- ' - Accepted keys:'
- - ' - type (string): The C(backing_type) defines the valid backing types
- for a virtual Ethernet adapter.'
+ - ' - type (string): This option defines the valid backing types for a
+ virtual Ethernet adapter.'
- 'Accepted value for this field:'
- ' - C(DISTRIBUTED_PORTGROUP)'
- ' - C(HOST_DEVICE)'
@@ -511,115 +620,208 @@ options:
- ' - C(STANDARD_PORTGROUP)'
- ' - network (string): Identifier of the network that backs the virtual
Ethernet 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). '
- ' - distributed_port (string): 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
+ 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.
- ' - C(start_connected) (bool): Flag indicating whether the virtual device
- should be connected whenever the virtual machine is powered on. ([''present''])'
+ should be connected whenever the virtual machine is powered on.'
+ - Defaults to false if unset. (['present'])
- ' - C(allow_guest_control) (bool): Flag indicating whether the guest can
- connect and disconnect the device. ([''present''])'
+ connect and disconnect the device.'
+ - Defaults to false if unset. (['present'])
elements: dict
type: list
nics_to_update:
description:
- Map of NICs to update.
+ - If unset, no NICs will be updated.
+ - 'When clients pass a value of this structure as a parameter, the key in
+ the field map must be the id of a resource returned by M(vmware.vmware_rest.vcenter_vm_hardware_ethernet). '
type: dict
+ nvme_adapters:
+ description:
+ - List of NVMe adapters.
+ - If unset, any adapters necessary to connect the virtual machine's storage
+ devices will be created; this includes any devices that explicitly specify
+ a NVMe host bus adapter, as well as any devices that do not specify a
+ host bus adapter if the guest's preferred adapter type is NVMe.
+ - 'Valid attributes are:'
+ - ' - C(bus) (int): NVMe bus number.'
+ - If unset, the server will choose an available bus number; if none is available,
+ the request will fail. (['present'])
+ - ' - C(pci_slot_number) (int): Address of the NVMe adapter on the PCI bus.'
+ - If unset, the server will choose an available address when the virtual machine
+ is powered on. (['present'])
+ elements: dict
+ type: list
parallel_ports:
description:
- List of parallel ports.
+ - If unset, no parallel ports will be created.
- 'Valid attributes are:'
- ' - C(backing) (dict): Physical resource backing for the virtual parallel
- port. ([''present''])'
+ port.'
+ - If unset, defaults to automatic detection of a suitable host device. (['present'])
- ' - Accepted keys:'
- - ' - type (string): The C(backing_type) defines the valid backing types
- for a virtual parallel port.'
+ - ' - type (string): This option defines the valid backing types for a
+ virtual parallel port.'
- 'Accepted value for this field:'
- ' - C(FILE)'
- ' - C(HOST_DEVICE)'
- ' - file (string): Path of the file that should be used as the virtual
parallel port backing.'
+ - This field is optional and it is only relevant when the value of I(type)
+ is FILE.
- ' - host_device (string): Name of the device that should be used as
the virtual parallel port backing.'
+ - If unset, the virtual parallel port will be configured to automatically
+ detect a suitable host device.
- ' - C(start_connected) (bool): Flag indicating whether the virtual device
- should be connected whenever the virtual machine is powered on. ([''present''])'
+ should be connected whenever the virtual machine is powered on.'
+ - Defaults to false if unset. (['present'])
- ' - C(allow_guest_control) (bool): Flag indicating whether the guest can
- connect and disconnect the device. ([''present''])'
+ connect and disconnect the device.'
+ - Defaults to false if unset. (['present'])
elements: dict
type: list
parallel_ports_to_update:
description:
- Map of parallel ports to Update.
+ - If unset, no parallel ports will be updated.
+ - 'When clients pass a value of this structure as a parameter, the key in
+ the field map must be the id of a resource returned by M(vmware.vmware_rest.vcenter_vm_hardware_parallel). '
type: dict
path:
description:
- 'Path to the virtual machine''s configuration file on the datastore corresponding
to {@link #datastore).'
+ - If unset, I(datastore) must also be unset and I(datastore_path) must be
+ set.
type: str
placement:
description:
- Virtual machine placement information.
+ - If this field is unset, the system will use the values from the source virtual
+ machine. If specified, each field will be used for placement. If the fields
+ result in disjoint placement the operation will fail. If the fields along
+ with the other existing placement of the virtual machine result in disjoint
+ placement the operation will fail.
- 'Valid attributes are:'
- ' - C(folder) (str): Virtual machine folder into which the virtual machine
- should be placed. ([''clone'', ''instant_clone'', ''present'', ''register'',
- ''relocate''])'
+ should be placed.'
+ - If this field is unset, the virtual machine will stay in the current folder.
+ - 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_folder_info).
+ (['clone', 'instant_clone', 'present', 'register', 'relocate'])
- ' - C(resource_pool) (str): Resource pool into which the virtual machine
- should be placed. ([''clone'', ''instant_clone'', ''present'', ''register'',
- ''relocate''])'
- - ' - C(host) (str): Host onto which the virtual machine should be placed.
- If C(#host) and C(#resource_pool) are both specified, C(#resource_pool)
- must belong to C(#host). If C(#host) and C(#cluster) are both specified,
- C(#host) must be a member of C(#cluster). ([''clone'', ''present'', ''register'',
- ''relocate''])'
- - ' - C(cluster) (str): Cluster into which the virtual machine should be placed.
- If C(#cluster) and C(#resource_pool) are both specified, C(#resource_pool)
- must belong to C(#cluster). If C(#cluster) and C(#host) are both specified,
- C(#host) must be a member of C(#cluster). ([''clone'', ''present'', ''register'',
- ''relocate''])'
+ should be placed.'
+ - If this field is unset, the virtual machine will stay in the current resource
+ pool.
+ - 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_resourcepool_info).
+ (['clone', 'instant_clone', 'present', 'register', 'relocate'])
+ - ' - C(host) (str): Host onto which the virtual machine should be placed. '
+ - ' If I(host) and I(resource_pool) are both specified, I(resource_pool) must
+ belong to I(host). '
+ - ''
+ - ' If I(host) and I(cluster) are both specified, I(host) must be a member
+ of I(cluster).'
+ - ''
+ - If this field is unset, if I(resource_pool) is unset, the virtual machine
+ will remain on the current host. if I(resource_pool) is set, and the target
+ is a standalone host, the host is used. if I(resource_pool) is set, and
+ the target is a DRS cluster, a host will be picked by DRS. if I(resource_pool)
+ is set, and the target is a cluster without DRS, InvalidArgument will
+ be thrown.
+ - 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_host_info).
+ (['clone', 'present', 'register', 'relocate'])
+ - ' - C(cluster) (str): Cluster into which the virtual machine should be placed. '
+ - ' If I(cluster) and I(resource_pool) are both specified, I(resource_pool)
+ must belong to I(cluster). '
+ - ''
+ - ' If I(cluster) and I(host) are both specified, I(host) must be a member
+ of I(cluster).'
+ - ''
+ - If I(resource_pool) or I(host) is specified, it is recommended that this
+ field be unset.
+ - 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_cluster_info).
+ (['clone', 'present', 'register', 'relocate'])
- ' - C(datastore) (str): Datastore on which the virtual machine''s configuration
- state should be stored. This datastore will also be used for any virtual
+ state should be stored. This datastore will also be used for any virtual
disks that are associated with the virtual machine, unless individually
- overridden. ([''clone'', ''instant_clone'', ''present'', ''relocate''])'
+ overridden.'
+ - If this field is unset, the virtual machine will remain on the current datastore.
+ - 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_datastore_info).
+ (['clone', 'instant_clone', 'present', 'relocate'])
type: dict
power_on:
description:
- - 'Attempt to perform a {@link #powerOn} after clone.'
+ - Attempt to perform a I(power_on) after clone.
+ - If unset, the virtual machine will not be powered on.
type: bool
sata_adapters:
description:
- List of SATA adapters.
+ - If unset, any adapters necessary to connect the virtual machine's storage
+ devices will be created; this includes any devices that explicitly specify
+ a SATA host bus adapter, as well as any devices that do not specify a
+ host bus adapter if the guest's preferred adapter type is SATA.
- 'Valid attributes are:'
- - ' - C(type) (str): The C(type) defines the valid emulation types for a virtual
+ - ' - C(type) (str): This option defines the valid emulation types for a virtual
SATA adapter. ([''present''])'
- ' - Accepted values:'
- ' - AHCI'
- - ' - C(bus) (int): SATA bus number. ([''present''])'
- - ' - C(pci_slot_number) (int): Address of the SATA adapter on the PCI bus.
- ([''present''])'
+ - ' - C(bus) (int): SATA bus number.'
+ - If unset, the server will choose an available bus number; if none is available,
+ the request will fail. (['present'])
+ - ' - C(pci_slot_number) (int): Address of the SATA adapter on the PCI bus.'
+ - If unset, the server will choose an available address when the virtual machine
+ is powered on. (['present'])
elements: dict
type: list
scsi_adapters:
description:
- List of SCSI adapters.
+ - If unset, any adapters necessary to connect the virtual machine's storage
+ devices will be created; this includes any devices that explicitly specify
+ a SCSI host bus adapter, as well as any devices that do not specify a
+ host bus adapter if the guest's preferred adapter type is SCSI. The type
+ of the SCSI adapter will be a guest-specific default type.
- 'Valid attributes are:'
- - ' - C(type) (str): The C(type) defines the valid emulation types for a virtual
+ - ' - C(type) (str): This option defines the valid emulation types for a virtual
SCSI adapter. ([''present''])'
- ' - Accepted values:'
- ' - BUSLOGIC'
- ' - LSILOGIC'
- ' - LSILOGICSAS'
- ' - PVSCSI'
- - ' - C(bus) (int): SCSI bus number. ([''present''])'
- - ' - C(pci_slot_number) (int): Address of the SCSI adapter on the PCI bus. If
- the PCI address is invalid, the server will change it when the VM is started
- or as the device is hot added. ([''present''])'
- - ' - C(sharing) (str): The C(sharing) defines the valid bus sharing modes
- for a virtual SCSI adapter. ([''present''])'
+ - ' - C(bus) (int): SCSI bus number.'
+ - If unset, the server will choose an available bus number; if none is available,
+ the request will fail. (['present'])
+ - ' - C(pci_slot_number) (int): Address of the SCSI adapter on the PCI bus.
+ If the PCI address is invalid, the server will change it when 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. (['present'])
+ - ' - C(sharing) (str): This option defines the valid bus sharing modes for
+ a virtual SCSI adapter. ([''present''])'
- ' - Accepted values:'
- ' - NONE'
- ' - PHYSICAL'
@@ -629,17 +831,20 @@ options:
serial_ports:
description:
- List of serial ports.
+ - If unset, no serial ports will be created.
- 'Valid attributes are:'
- ' - C(yield_on_poll) (bool): CPU yield behavior. If set to true, the virtual
machine will periodically relinquish the processor if its sole task is
polling the virtual serial port. The amount of time it takes to regain
the processor will depend on the degree of other virtual machine activity
- on the host. ([''present''])'
+ on the host.'
+ - If unset, defaults to false. (['present'])
- ' - C(backing) (dict): Physical resource backing for the virtual serial
- port. ([''present''])'
+ port.'
+ - If unset, defaults to automatic detection of a suitable host device. (['present'])
- ' - Accepted keys:'
- - ' - type (string): The C(backing_type) defines the valid backing types
- for a virtual serial port.'
+ - ' - type (string): This option defines the valid backing types for a
+ virtual serial port.'
- 'Accepted value for this field:'
- ' - C(FILE)'
- ' - C(HOST_DEVICE)'
@@ -648,33 +853,51 @@ options:
- ' - C(PIPE_CLIENT)'
- ' - C(PIPE_SERVER)'
- ' - file (string): Path of the file backing the virtual serial port.'
+ - This field is optional and it is only relevant when the value of I(type)
+ is FILE.
- ' - host_device (string): Name of the device backing the virtual serial
- port. <p>'
+ port. '
+ - ''
+ - ''
+ - If unset, the virtual serial port will be configured to automatically detect
+ a suitable host device.
- ' - pipe (string): Name of the pipe backing the virtual serial port.'
+ - This field is optional and it is only relevant when the value of I(type)
+ is one of PIPE_SERVER or PIPE_CLIENT.
- ' - no_rx_loss (boolean): Flag that enables optimized data transfer
over the pipe. When the value is true, the host buffers data to prevent
- data overrun. This allows the virtual machine to read all of the data
+ data overrun. This allows the virtual machine to read all of the data
transferred over the pipe with no data loss.'
+ - If unset, defaults to false.
- ' - network_location (string): URI specifying the location of the network
- service backing the virtual serial port. <ul> <li>If {@link #type} is
- {@link BackingType#NETWORK_SERVER}, this field is the location used by
- clients to connect to this server. The hostname part of the URI should
- either be empty or should specify the address of the host on which the
- virtual machine is running.</li> <li>If {@link #type} is {@link BackingType#NETWORK_CLIENT},
- this field is the location used by the virtual machine to connect to the
- remote server.</li> </ul>'
+ service backing the virtual serial port. '
+ - ' - If I(type) is NETWORK_SERVER, this field is the location used by clients
+ to connect to this server. The hostname part of the URI should either
+ be empty or should specify the address of the host on which the virtual
+ machine is running.'
+ - ' - If I(type) is NETWORK_CLIENT, this field is the location used by the
+ virtual machine to connect to the remote server.'
+ - ' '
+ - This field is optional and it is only relevant when the value of I(type)
+ is one of NETWORK_SERVER or NETWORK_CLIENT.
- ' - proxy (string): Proxy service that provides network access to the
- network backing. If set, the virtual machine initiates a connection with
+ network backing. If set, the virtual machine initiates a connection with
the proxy service and forwards the traffic to the proxy.'
+ - If unset, no proxy service should be used.
- ' - C(start_connected) (bool): Flag indicating whether the virtual device
- should be connected whenever the virtual machine is powered on. ([''present''])'
+ should be connected whenever the virtual machine is powered on.'
+ - Defaults to false if unset. (['present'])
- ' - C(allow_guest_control) (bool): Flag indicating whether the guest can
- connect and disconnect the device. ([''present''])'
+ connect and disconnect the device.'
+ - Defaults to false if unset. (['present'])
elements: dict
type: list
serial_ports_to_update:
description:
- Map of serial ports to Update.
+ - If unset, no serial ports will be updated.
+ - 'When clients pass a value of this structure as a parameter, the key in
+ the field map must be the id of a resource returned by M(vmware.vmware_rest.vcenter_vm_hardware_serial). '
type: dict
session_timeout:
description:
@@ -686,7 +909,10 @@ options:
version_added: 2.1.0
source:
description:
- - Virtual machine to InstantClone from. Required with I(state=['clone', 'instant_clone'])
+ - Virtual machine to InstantClone from.
+ - 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_vm_info).
+ Required with I(state=['clone', 'instant_clone'])
type: str
state:
choices:
@@ -702,12 +928,19 @@ options:
type: str
storage_policy:
description:
- - The C(storage_policy_spec) {@term structure} contains information about
- the storage policy that is to be associated with the virtual machine home
- (which contains the configuration and log files). Required with I(state=['present'])
+ - The I(storage_policy_spec) structure contains information about the storage
+ policy that is to be associated with the virtual machine home (which contains
+ the configuration and log files).
+ - 'If unset the datastore default storage policy (if applicable) is applied.
+ Currently a default storage policy is only supported by object datastores
+ : VVol and vSAN. For non-object datastores, if unset then no storage policy
+ would be associated with the virtual machine home. Required with I(state=[''present''])'
- 'Valid attributes are:'
- ' - C(policy) (str): Identifier of the storage policy which should be associated
- with the virtual machine. ([''present''])'
+ with the virtual machine.'
+ - 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_storage_policies).
+ (['present'])
- ' This key is required with [''present''].'
type: dict
vcenter_hostname:
@@ -749,18 +982,19 @@ options:
type: bool
vm:
description:
- - Identifier of the virtual machine to be unregistered. Required with I(state=['absent',
- 'relocate', 'unregister'])
+ - Identifier of the virtual machine to be unregistered.
+ - The parameter must be the id of a resource returned by M(vmware.vmware_rest.vcenter_vm_info).
+ Required with I(state=['absent', 'relocate', 'unregister'])
type: str
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"""
@@ -1016,6 +1250,24 @@ value:
# This structure describes the format of the data expected by the end-points
PAYLOAD_FORMAT = {
+ "clone": {
+ "query": {},
+ "body": {
+ "disks_to_remove": "disks_to_remove",
+ "disks_to_update": "disks_to_update",
+ "guest_customization_spec": "guest_customization_spec",
+ "name": "name",
+ "placement": "placement",
+ "power_on": "power_on",
+ "source": "source",
+ },
+ "path": {},
+ },
+ "relocate": {
+ "query": {},
+ "body": {"disks": "disks", "placement": "placement"},
+ "path": {"vm": "vm"},
+ },
"register": {
"query": {},
"body": {
@@ -1027,6 +1279,7 @@ PAYLOAD_FORMAT = {
},
"path": {},
},
+ "unregister": {"query": {}, "body": {}, "path": {"vm": "vm"}},
"create": {
"query": {},
"body": {
@@ -1041,6 +1294,7 @@ PAYLOAD_FORMAT = {
"memory": "memory",
"name": "name",
"nics": "nics",
+ "nvme_adapters": "nvme_adapters",
"parallel_ports": "parallel_ports",
"placement": "placement",
"sata_adapters": "sata_adapters",
@@ -1050,25 +1304,7 @@ PAYLOAD_FORMAT = {
},
"path": {},
},
- "relocate": {
- "query": {},
- "body": {"disks": "disks", "placement": "placement"},
- "path": {"vm": "vm"},
- },
"delete": {"query": {}, "body": {}, "path": {"vm": "vm"}},
- "clone": {
- "query": {},
- "body": {
- "disks_to_remove": "disks_to_remove",
- "disks_to_update": "disks_to_update",
- "guest_customization_spec": "guest_customization_spec",
- "name": "name",
- "placement": "placement",
- "power_on": "power_on",
- "source": "source",
- },
- "path": {},
- },
"instant_clone": {
"query": {},
"body": {
@@ -1083,11 +1319,8 @@ PAYLOAD_FORMAT = {
},
"path": {},
},
- "unregister": {"query": {}, "body": {}, "path": {"vm": "vm"}},
} # pylint: disable=line-too-long
-import json
-import socket
from ansible.module_utils.basic import env_fallback
try:
@@ -1102,26 +1335,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",
@@ -1371,6 +1606,7 @@ def prepare_argument_spec():
argument_spec["name"] = {"type": "str"}
argument_spec["nics"] = {"type": "list", "elements": "dict"}
argument_spec["nics_to_update"] = {"type": "dict"}
+ argument_spec["nvme_adapters"] = {"type": "list", "elements": "dict"}
argument_spec["parallel_ports"] = {"type": "list", "elements": "dict"}
argument_spec["parallel_ports_to_update"] = {"type": "dict"}
argument_spec["path"] = {"type": "str"}
@@ -1433,7 +1669,6 @@ def build_url(params):
async def entry_point(module, session):
-
if module.params["state"] == "present":
if "_create" in globals():
operation = "create"
@@ -1450,20 +1685,16 @@ async def entry_point(module, session):
async def _clone(params, session):
-
lookup_url = per_id_url = build_url(params)
uniquity_keys = ["vm"]
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]["vm"])
@@ -1526,20 +1757,16 @@ async def _clone(params, session):
async def _create(params, session):
-
lookup_url = per_id_url = build_url(params)
uniquity_keys = ["vm"]
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]["vm"])
@@ -1620,20 +1847,16 @@ async def _delete(params, session):
async def _instant_clone(params, session):
-
lookup_url = per_id_url = build_url(params)
uniquity_keys = ["vm"]
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]["vm"])