Repository: ansible-collections/community.vmware

Issue:
deleting portgroup using vmware_dvs_portgroup fails with "msg: "'update'"
##### SUMMARY
When deleting an existing portgroup using the module vmware_dvs_portgroup. The task fails with "msg" containing the single word "update"

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
vmware_dvs_portgroup

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```
ansible-playbook [core 2.13.2]
  config file = /home/ansible/devs/in_progress/ansible.cfg
  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-playbook
  python version = 3.9.7 (default, Sep 13 2021, 08:18:39) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
  jinja version = 3.0.3

```

##### COLLECTION VERSION
```
community.vmware: 2.9.1
```

##### CONFIGURATION
```
default config
```

##### OS / ENVIRONMENT
Running in EE
Targeting VMware vSphere 7.0.2

##### STEPS TO REPRODUCE
Running the module with mandatory arguments and default value with `state: absent`

Playbook :
```yaml
- name: Delete PortGroup
  hosts: localhost
  gather_facts: false
  vars_files:
  - vars/vcenter_creds.yml
  vars:
    pg_name: VLAN_TEST_2222
    vds: ADMIN
    vlan_id: 2222
  tasks:
    - name: "VMWare | Delete PortGroup {{ pg_name }} from vDS {{ vds }}"
      community.vmware.vmware_dvs_portgroup:
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        validate_certs: False
        switch_name: "{{ vds }}"
        portgroup_name: "{{ pg_name }}"
        vlan_id: "{{ vlan_id }}"
        port_binding: static
        state: absent
```

##### EXPECTED RESULTS
Tasks succeed and PortGroup is deleted from vDS

##### ACTUAL RESULTS
The PortGroup is not deleted and the task return with the error "msg": "update"
The same task succeed when creating the PortGroup (state: present)
PS1: I can manually delete the PortGroup with the same vcenter user used in the module arguments, so I don't think its a privilege related issue.
PS2: When I re-run the same task (state: absent) after manually deleting the portgroup from vcenter it succeed. 

Below is the debug output (error) of the playbook above :
```
The full traceback is:
  File "/tmp/ansible_community.vmware.vmware_dvs_portgroup_payload_xdurpqmk/ansible_community.vmware.vmware_dvs_portgroup_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_dvs_portgroup.py", line 641, in process_state
fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "hostname": "vcenter.example.com",
            "in_traffic_shaping": null,
            "mac_learning": null,
            "net_flow": null,
            "network_policy": {
                "forged_transmits": false,
                "mac_changes": false,
                "promiscuous": false
            },
            "num_ports": null,
            "out_traffic_shaping": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 443,
            "port_allocation": null,
            "port_binding": "static",
            "port_policy": {
                "block_override": true,
                "ipfix_override": false,
                "live_port_move": false,
                "network_rp_override": false,
                "port_config_reset_at_disconnect": true,
                "security_override": false,
                "shaping_override": false,
                "traffic_filter_override": false,
                "uplink_teaming_override": false,
                "vendor_config_override": false,
                "vlan_override": false
            },
            "portgroup_name": "VLAN_TEST_2222",
            "proxy_host": null,
            "proxy_port": null,
            "state": "absent",
            "switch_name": "ADMIN",
            "teaming_policy": {
                "active_uplinks": null,
                "inbound_policy": null,
                "load_balance_policy": "loadbalance_srcid",
                "notify_switches": true,
                "rolling_order": false,
                "standby_uplinks": null
            },
            "username": "vcenter_user",
            "validate_certs": false,
            "vlan_id": "2222",
            "vlan_private": false,
            "vlan_trunk": false
        }
    },
    "msg": "'update'"
}
```



Discussion:

Resolving patch:
diff --git a/plugins/modules/vmware_dvs_portgroup.py b/plugins/modules/vmware_dvs_portgroup.py
--- a/plugins/modules/vmware_dvs_portgroup.py
+++ b/plugins/modules/vmware_dvs_portgroup.py
@@ -658,6 +658,7 @@ def build_config(self):
     def process_state(self):
         dvspg_states = {
             'absent': {
+                'update': self.state_destroy_dvspg,
                 'present': self.state_destroy_dvspg,
                 'absent': self.state_exit_unchanged,
             },


Test patch: