
    VhP                         d dl mZmZmZ eZdZdZdZ	 d dl	m
Z
mZ d dlmZ d dlmZ d dlmZ d d	lmZ  G d
 de      Zd Zedk(  r e        yy# e$ r Y ;w xY w)    )absolute_importdivisionprint_functiona  
---
module: vmware_vswitch
short_description: Manage a VMware Standard Switch to an ESXi host.
description:
- This module can be used to add, remove and update a VMware Standard Switch to an ESXi host.
author:
- Joseph Callen (@jcpowermac)
- Russell Teague (@mtnbikenc)
- Abhijeet Kasurde (@Akasurde) <akasurde@redhat.com>
options:
  switch:
    description:
    - vSwitch name to add.
    required: true
    aliases: [ switch_name ]
    type: str
  nics:
    description:
    - A list of vmnic names or vmnic name to attach to vSwitch.
    aliases: [ nic_name ]
    default: []
    type: list
    elements: str
  number_of_ports:
    description:
    - Number of port to configure on vSwitch.
    default: 128
    type: int
  mtu:
    description:
    - MTU to configure on vSwitch.
    default: 1500
    type: int
  state:
    description:
    - Add or remove the switch.
    default: present
    choices: [ absent, present ]
    type: str
  esxi_hostname:
    description:
    - Manage the vSwitch using this ESXi host system.
    aliases: [ 'host' ]
    type: str
  security:
    description:
    - Network policy specifies layer 2 security settings for a
      portgroup such as promiscuous mode, where guest adapter listens
      to all the packets, MAC address changes and forged transmits.
    - Dict which configures the different security values for portgroup.
    suboptions:
      promiscuous_mode:
        type: bool
        description: Indicates whether promiscuous mode is allowed.
      forged_transmits:
        type: bool
        description: Indicates whether forged transmits are allowed.
      mac_changes:
        type: bool
        description: Indicates whether mac changes are allowed.
    required: false
    aliases: [ 'security_policy', 'network_policy' ]
    type: dict
  teaming:
    description:
      - Dictionary which configures the different teaming values for portgroup.
    suboptions:
      load_balancing:
        type: str
        description:
        - Network adapter teaming policy.
        choices: [ loadbalance_ip, loadbalance_srcmac, loadbalance_srcid, failover_explicit ]
        aliases: [ 'load_balance_policy' ]
      network_failure_detection:
        type: str
        description: Network failure detection.
        choices: [ link_status_only, beacon_probing ]
      notify_switches:
        type: bool
        description: Indicate whether or not to notify the physical switch if a link fails.
      failback:
        type: bool
        description: Indicate whether or not to use a failback when restoring links.
      active_adapters:
        type: list
        description:
        - List of active adapters used for load balancing.
        - All vmnics are used as active adapters if O(teaming.active_adapters) and O(teaming.standby_adapters) are not defined.
        elements: str
      standby_adapters:
        type: list
        description:
        - List of standby adapters used for failover.
        - All vmnics are used as active adapters if O(teaming.active_adapters) and O(teaming.standby_adapters) are not defined.
        elements: str
    required: false
    aliases: [ 'teaming_policy' ]
    type: dict
  traffic_shaping:
    description:
      - Dictionary which configures traffic shaping for the switch.
    suboptions:
      enabled:
        type: bool
        description: Status of Traffic Shaping Policy.
      average_bandwidth:
        type: int
        description: Average bandwidth (kbit/s).
      peak_bandwidth:
        type: int
        description: Peak bandwidth (kbit/s).
      burst_size:
        type: int
        description: Burst size (KB).
    required: false
    type: dict
extends_documentation_fragment:
- community.vmware.vmware.documentation

a
  
- name: Add a VMware vSwitch
  community.vmware.vmware_vswitch:
    hostname: '{{ esxi_hostname }}'
    username: '{{ esxi_username }}'
    password: '{{ esxi_password }}'
    switch: vswitch_name
    nics: vmnic_name
    mtu: 9000
  delegate_to: localhost

- name: Add a VMware vSwitch without any physical NIC attached
  community.vmware.vmware_vswitch:
    hostname: '{{ esxi_hostname }}'
    username: '{{ esxi_username }}'
    password: '{{ esxi_password }}'
    switch: vswitch_0001
    mtu: 9000
  delegate_to: localhost

- name: Add a VMware vSwitch with multiple NICs
  community.vmware.vmware_vswitch:
    hostname: '{{ esxi_hostname }}'
    username: '{{ esxi_username }}'
    password: '{{ esxi_password }}'
    switch: vmware_vswitch_0004
    nics:
    - vmnic1
    - vmnic2
    mtu: 9000
  delegate_to: localhost

- name: Add a VMware vSwitch to a specific host system
  community.vmware.vmware_vswitch:
    hostname: '{{ esxi_hostname }}'
    username: '{{ esxi_username }}'
    password: '{{ esxi_password }}'
    esxi_hostname: DC0_H0
    switch_name: vswitch_001
    nic_name: vmnic0
    mtu: 9000
  delegate_to: localhost

- name: Add a VMware vSwitch to a specific host system with Promiscuous Mode Enabled
  community.vmware.vmware_vswitch:
    hostname: '{{ esxi_hostname }}'
    username: '{{ esxi_username }}'
    password: '{{ esxi_password }}'
    esxi_hostname: DC0_H0
    switch_name: vswitch_001
    nic_name: vmnic0
    mtu: 9000
    security:
        promiscuous_mode: true
  delegate_to: localhost

- name: Add a VMware vSwitch to a specific host system with active/standby teaming
  community.vmware.vmware_vswitch:
    hostname: '{{ esxi_hostname }}'
    username: '{{ esxi_username }}'
    password: '{{ esxi_password }}'
    esxi_hostname: DC0_H0
    switch_name: vswitch_001
    nic_name:
      - vmnic0
      - vmnic1
    teaming:
      active_adapters:
        - vmnic0
      standby_adapters:
        - vmnic1
  delegate_to: localhost

- name: Add a VMware vSwitch to a specific host system with traffic shaping
  community.vmware.vmware_vswitch:
    hostname: '{{ esxi_hostname }}'
    username: '{{ esxi_username }}'
    password: '{{ esxi_password }}'
    esxi_hostname: DC0_H0
    switch_name: vswitch_001
    nic_name:
      - vmnic0
      - vmnic1
    traffic_shaping:
        enabled: true
        average_bandwidth: 100000
        peak_bandwidth: 100000
        burst_size: 102400
  delegate_to: localhost

- name: Delete a VMware vSwitch in a specific host system
  community.vmware.vmware_vswitch:
    hostname: '{{ esxi_hostname }}'
    username: '{{ esxi_username }}'
    password: '{{ esxi_password }}'
    esxi_hostname: DC0_H0
    switch_name: vswitch_001
    state: absent
  delegate_to: localhost
z
result:
    description: information about performed operation
    returned: always
    type: str
    sample: "vSwitch 'vSwitch_1002' is created successfully"
)vimvmodl)AnsibleModule)PyVmomi)base_argument_spec)	to_nativec                   d     e Zd Z fdZd Zd Zd Zd Zd Zd Z	e
d        Zd	 Zd
 Zd Z xZS )VMwareHostVirtualSwitchc           	         t         t        |   |       d | _        d | _        |j
                  d   | _        |j
                  d   | _        |j
                  d   | _        |j
                  d   | _	        |j
                  d   | _
        |j
                  d   }| j                  |      }|r|d   | _        n| j                  j                  d	
       | j                  j                  j                  | _        | j                   s| j                  j                  d
       | j
                  j#                  d      dk(  r| j                   j$                  j&                  D cg c]  }|j(                   }}t+               | _        | j                   j$                  j.                  D ]~  }g }|j&                  D ](  }|j1                  dd      d   }|j3                  |       * t+        ||j                  |j4                  j6                        | j,                  |j8                  <    | j                  D ]  }	|	|vr7| j                  j                  d|	d| j                  j8                  d
       | j,                  D ]J  }
|	| j,                  |
   d   v s|
| j                  k7  s(| j                  j                  d|	d|
d
       L  y y c c}w )Nswitchnumber_of_portsnicsmtustateesxi_hostname)esxi_host_namer   zCFailed to get details of ESXi server. Please specify esxi_hostname.msgz/Failed to find network manager for ESXi system.present-   )pnicr   	num_portszSpecified Physical NIC 'z!' does not exists on given ESXi 'z'.r   z' is already used by vSwitch ')superr   __init__host_systemvssparamsr   r   r   r   r   get_all_host_objsmodule	fail_jsonconfigManagernetworkSystemnetwork_mgrgetnetworkInfor   devicedictavailable_vswitchesvswitchsplitappendspecnumPortsname)selfr$   r   hostsr   available_pnicavailable_vswitch	used_pnicm_pnicdesired_pnicr.   	__class__s              s/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/vmware/plugins/modules/vmware_vswitch.pyr   z VMwareHostVirtualSwitch.__init__  s   %t5f=mmH-%}}->?MM&)	==']]7+
o6&&m&D$QxDKK!! 'G! H  ++99GGKK!!&W!X;;??7#y06:6F6F6R6R6W6WXddkkXNX'+vD$%)%5%5%A%A%I%I 	J!	-22 -D!ZZQ/3F$$V,- DHYL]LaLaRcRhRhRqRqDJ(():)?)?@	J !%		 
a~5KK))O[OSO_O_OdOd/f) g  $77 aG#t'?'?'H'PPU\`d`k`kUk--IUW^3`- aa
a 1Xs   Kc                 T   | j                   | j                  d| j                  | j                  dd}	  || j                     | j                                    y# t        j                  $ r9}| j                  j                  t        |j                               Y d}~yd}~wt        j                  $ r9}| j                  j                  t        |j                               Y d}~yd}~wt        $ r/}| j                  j                  t        |             Y d}~yd}~ww xY w)z2
        Manage internal state of vSwitch
        )r   absent)r>   r   r   N)state_destroy_vswitchstate_exit_unchangedstate_update_vswitchstate_create_vswitchr   check_vswitch_configurationr   RuntimeFaultr$   r%   r   r   MethodFault	Exception)r4   vswitch_statesruntime_faultmethod_faultes        r<   process_statez%VMwareHostVirtualSwitch.process_state1  s      5533
  4433	
	4JN4::&t'G'G'IJL!! 	DKK!!i0A0A&B!CC   	CKK!!i0@0@&A!BB 	4KK!!il!33	4s/   %A D'./B""D'8/C,,D'8%D""D'c           	         t        dd      }t        j                  j                  j	                         }| j
                  |_        | j                  |_        | j                  r9t        j                  j                  j                  | j                        |_
        | j                  j                  rd| j                  z  |d<   n	 | j                  j                  | j                  |       d}| j!                  | j"                  | j                        j$                  }| j'                  ||      rd}| j)                  ||      rd}| j+                  ||      rd}|r'| j                  j-                  | j                  |       d	| j                  z  |d
<   d|d<    | j                  jD                  di | y# t        j.                  j0                  $ r2}d| j                  dt3        |j4                        |d
<   Y d}~ld}~wt        j.                  j6                  $ rI}| j                  j9                  d| j                  dt3        |j4                               Y d}~d}~wt        j.                  j:                  $ rJ}| j                  j9                  d| j                  dt3        |j4                               Y d}~5d}~wt<        j.                  j>                  $ rJ}| j                  j9                  d| j                  dt3        |j4                               Y d}~d}~wt<        j.                  j@                  $ rJ}	| j                  j9                  d| j                  dt3        |	j4                               Y d}	~	d}	~	wtB        $ r@}
| j                  j9                  d| j                  dt3        |
             Y d}
~
Fd}
~
ww xY w)z
        Create a virtual switch

        Source from
        https://github.com/rreubenur/pyvmomi-community-samples/blob/patch-1/samples/create_vswitch.py

        F changedresult	nicDevicezvSwitch '%s' would be createdr   vswitchNamer1   Tz$vSwitch '%s' is created successfullyrP   zvSwitch with name z already exists: NzFailed to add vSwitch '?' as physical network adapter being bridged is already in use: r   $' due to host configuration fault : ', this can be due to either of following : 1. vSwitch Name exceeds the maximum allowed length, 2. Number of ports specified falls out of valid range, 3. Network policy is invalid, 4. Beacon configuration is invalid : ' due to : ' due to generic exception : rO    )#r,   r   hostVirtualSwitchSpecificationr   r2   r   r   
BondBridgebridger$   
check_moder   r(   AddVirtualSwitchfind_vswitch_by_namer    r1   update_security_policyupdate_teaming_policyupdate_traffic_shaping_policyUpdateVirtualSwitchfaultAlreadyExistsr   r   ResourceInUser%   HostConfigFaultr   InvalidArgumentSystemErrorrF   	exit_json)r4   resultsvss_specrO   r1   already_existsresource_usedhost_config_faultinvalid_argumentsystem_errorgeneric_excs              r<   rB   z,VMwareHostVirtualSwitch.state_create_vswitchI  s?    uR088))779 00xx99!hh44??$))?THO;;!!<t{{JGEN0`  11dkk7? 2 A  001A1A4;;OTT ..tW="G --dG<"G 55dGD"G$$88T[[>B 9 D %KT[[$X!6 "	((9 99** pQUQ\Q\QZ[i[m[mQn%p!99** s%%TXT_T_T]^k^o^oTp+r% s s 99,, l%%IMIRSdShShIi+k% l l ;;.. z%% Y]XcXcXabrbvbvXw+y% z z ;;** t%%VZVaVaV_`l`p`pVq+s% t t `%%GK{{GPQ\G]+_% ` ``sU   CF9 9O"(H O"#?I'' O"?K O",?L11 O"?NO""5OO"c                 <    | j                   j                  d       y)z0
        Declare exit without unchanged
        F)rO   N)r$   rm   r4   s    r<   r@   z,VMwareHostVirtualSwitch.state_exit_unchanged  s     	e,    c           	      J   t        dd      }| j                  j                  rd| j                  j                  z  |d<   n`	 | j
                  j                  j                  j                  | j                  j                         d| j                  j                  z  |d<   d|d<    | j                  j&                  di | y
# t        j                  j                  $ r2}d| j                  d	t        |j                        |d<   Y d
}~ld
}~wt        j                  j                  $ rI}| j                  j!                  d| j                  dt        |j                               Y d
}~d
}~wt        j                  j"                  $ rJ}| j                  j!                  d| j                  dt        |j                               Y d
}~5d
}~wt$        $ r@}| j                  j!                  d| j                  dt        |             Y d
}~|d
}~ww xY w)z4
        Remove vSwitch from configuration

        FrM   rN   zvSwitch '%s' would be removedr   z"vSwitch '%s' removed successfully.rP   z	vSwitch 'z' not available. NzFailed to remove vSwitch 'z:' as vSwitch is used by several virtual network adapters: r   rV   rY   TrO   rZ   )r,   r$   r`   r!   r3   r    r&   r'   RemoveVirtualSwitchr   rg   NotFoundr   r   r   ri   r%   rj   rF   rm   )r4   rn   vswitch_not_foundvswitch_in_userr   ru   s         r<   r?   z-VMwareHostVirtualSwitch.state_destroy_vswitch  s   
 uR0;;!!<txx}}LGENX  ..<<PPQUQYQYQ^Q^_$H488==$X!$ "	((' 99%% jHLHQRcRgRgHh%j!99** e%%EI[[EN~OaOaEb+d% e e 99,, l%%IMIRSdShShIi+k% l l  X%%?C{{?H?U+W% X XXs=   AC H" (D H"-?E11 H"?GH""5HH"c           	         d}t        dd| j                  z        }| j                  j                  }| j                  j                  | j                  k7  r| j                  |_        d}|j
                  | j                  k7  r| j                  |_        d}t        t        d | j                  j                              }|t        | j                        k7  r| j                  r:t        j                  j                  j                  | j                        |_        nd|_        d}| j                   d   s+|j"                  j$                  j&                  }|j(                  |j(                  D cg c]  }|| j                  v s| c}k7  r.|j(                  D cg c]  }|| j                  v s| c}|_        |j*                  |j*                  D cg c]  }|| j                  v s| c}k7  r.|j*                  D cg c]  }|| j                  v s| c}|_        t        | j                        |z
  r+|xj(                  t        | j                        |z
  z  c_        | j-                  ||      rd}| j/                  ||      rd}| j1                  ||      rd}|rh| j2                  j4                  rd	| j                  z  |d
<   n:	 | j6                  j9                  | j                  |       d| j                  z  |d<   d|d<    | j2                  jR                  di | yc c}w c c}w c c}w c c}w # t        j:                  j<                  $ rI}| j2                  j?                  d| j                  dtA        |jB                               Y d}~d}~wt        j:                  jD                  $ rI}| j2                  j?                  d| j                  dtA        |jB                               Y d}~d}~wt        j:                  jF                  $ rJ}	| j2                  j?                  d| j                  dtA        |	jB                               Y d}	~	`d}	~	wtH        j:                  jJ                  $ rJ}
| j2                  j?                  d| j                  dtA        |
jB                               Y d}
~
d}
~
wtH        j:                  jL                  $ rJ}| j2                  j?                  d| j                  dtA        |jB                               Y d}~*d}~wtH        j:                  jN                  $ rJ}| j2                  j?                  d| j                  dtA        |jB                               Y d}~d}~wtP        $ r@}| j2                  j?                  d| j                  dtA        |             Y d}~d}~ww xY w)z!
        Update vSwitch

        FzNo change in vSwitch '%s'rN   Tc                 ,    | j                  dd      d   S )Nr      )rsplit)ns    r<   <lambda>z>VMwareHostVirtualSwitch.state_update_vswitch.<locals>.<lambda>  s    #q)9!)< rx   rQ   NteamingzvSwitch '%s' would be updatedr   rS   z$vSwitch '%s' is updated successfullyrP   zFailed to update vSwitch 'rU   r   z$Failed to update vSwitch with name 'z' as it does not exists: rV   rW   rX   zB' as network adapter teaming policy is set but is not supported : rY   rO   rZ   )*r,   r   r!   r1   r   r2   r   setmapr   r   r   r[   r\   r^   r_   r"   policy
nicTeamingnicOrder	activeNic
standbyNicrc   rd   re   r$   r`   r(   rf   rg   ri   r%   r   r   r{   rj   r   rk   rl   NotSupportedrF   rm   )r4   rO   rn   r1   nics_currentr   irq   	not_foundrr   rs   rt   not_supportedru   s                 r<   rA   z,VMwareHostVirtualSwitch.state_update_vswitch  s   
 u-H4;;-VWxx}} 88<<488#xxDHG ==D000 00DMG 3<dhhmmLM3tyy>)yy!hh44??$))?T"G ;;y);;11::%%X5G5G)Z1PTPYPY>!)ZZ5=5G5G)Z1PTPYPY>!)ZH&&&h6I6I*\QRVR[R[^1*\\6>6I6I*\QRVR[R[^1*\H'tyy>L0&&#dii.<*GG& &&tW5G %%dG4G --dG<G{{%%!@4;;!N"d$$88T[[>B 9 D(NQUQ\Q\(\GH%B "&GI((} *[)Z*\*\2 yy.. wKK))X\XcXcXabobsbsXt/v) w w yy)) iKK))NRkkNWXaXeXeNf/h) i i yy00 pKK))MQ[[MVWhWlWlMm/o) p p {{22 ~KK)) ]a\g\g\efvfzfz\{/}) ~ ~ {{.. {KK))]a]h]h]fgsgwgw]x/z) { {{{// tKK))UYU`U`U^_l_p_pUq/s) t t ! dKK))KO;;KTU`Ka/c) d dds   0L%L%L*/L*L/(L/?L4L4
9L9 9W?N W:?O>> W?Q## W?S W(?T-- W?VW5WWc                 t    | j                  | j                  | j                        | _        | j                  yy)zj
        Check if vSwitch exists
        Returns: 'present' if vSwitch exists or 'absent' if not

        r>   r   )rb   r    r   r!   rw   s    r<   rC   z3VMwareHostVirtualSwitch.check_vswitch_configuration  s2     ,,T-=-=t{{K88rx   c                     | j                   j                  j                  j                  D ]  }|j                  |k(  s|c S  y)z
        Find and return vSwitch managed object
        Args:
            host: Host system managed object
            vswitch_name: Name of vSwitch to find

        Returns: vSwitch managed object if found, else None

        N)r&   r'   r*   r.   r3   )r[   vswitch_namer!   s      r<   rb   z,VMwareHostVirtualSwitch.find_vswitch_by_name&  sA     %%33??GG 	Cxx<'
	 rx   c                 D   | j                   d   r|j                  j                  sy|j                  j                  }d}| j                   d   j                  d      }| j                   d   j                  d      }| j                   d   j                  d      }|+||d<   |j                  |ur|j                  |d<   ||_        d}|+||d	<   |j
                  |ur|j
                  |d
<   ||_        d}|+||d<   |j                  |ur|j                  |d<   ||_        d}|S )z
        Update the security policy according to the parameters
        Args:
            spec: The vSwitch spec
            results: The results dict

        Returns: True if changes have been made, else false
        securityFpromiscuous_modeforged_transmitsmac_changessec_promiscuous_modesec_promiscuous_mode_previousTsec_mac_changessec_mac_changes_previoussec_forged_transmitssec_forged_transmits_previous)r"   r   r   r)   allowPromiscuous
macChangesforgedTransmits)r4   r1   rn   security_policyrO   r   r   r   s           r<   rc   z.VMwareHostVirtualSwitch.update_security_policy6  s@    {{:&dkk.B.B++..#{{:6::;MN#{{:6::;MN++j155mD+.BG*+//7KK;J;[;[783G0&)8G%&))@6E6P6P23-<*+.BG*+..6JJ;J;Z;Z782F/rx   c                    | j                   d   r|j                  j                  sy|j                  j                  }d}| j                   d   j                  d      }| j                   d   j                  d      }| j                   d   j                  d      }| j                   d   j                  d      }| j                   d   j                  d      }	| j                   d   j                  d      }
|,||d<   |j                  |k7  r|j                  |d	<   ||_        d
}|+||d<   |j                  |ur|j                  |d<   ||_        d
}|&||d<   |j
                   }||k7  r||d<   | |_        d
}|	J|	|d<   |j                  j                  |	k7  r,|j                  j                  |d<   |	|j                  _        d
}|
J|
|d<   |j                  j                  |
k7  r,|j                  j                  |d<   |
|j                  _        d
}|q||d<   |dk(  r2|j                  j                  d
u rd|d<   d|j                  _
        d
}|S |dk(  r0|j                  j                  du rd|d<   d
|j                  _
        d
}|S )z
        Update the teaming policy according to the parameters
        Args:
            spec: The vSwitch spec
            results: The results dict

        Returns: True if changes have been made, else false
        r   Fload_balancingnetwork_failure_detectionnotify_switchesfailbackactive_adaptersstandby_adaptersload_balancing_previousTnotify_switches_previousfailback_previousfailover_activefailover_active_previousfailover_standbyfailover_standby_previousfailure_detectionlink_status_onlybeacon_probingfailure_detection_previous)r"   r   r   r)   notifySwitchesrollingOrderr   r   r   failureCriteriacheckBeacon)r4   r1   rn   teaming_policyrO   teaming_load_balancingteaming_failure_detectionteaming_notify_switchesteaming_failbackteaming_failover_order_activeteaming_failover_order_standbycurrent_failbacks               r<   rd   z-VMwareHostVirtualSwitch.update_teaming_policy_  s    {{9%T[[-C-C//!%Y!7!;!;<L!M$(KK	$:$>$>?Z$[!"&++i"8"<"<=N"O;;y155jA(,I(>(B(BCT(U%)-Y)?)C)CDV)W& "-(>G$%$$(>>5C5J5J12(>% #.)@G%&,,4KK6D6S6S230G- '"2GJ#1#>#>>#33/?+,2B.B+ )4)FG%&&&004QQ6D6M6M6W6W234Q''1)5*HG&'&&115SS7E7N7N7Y7Y345S''2 %0+DG'((,>>!11==E<LG89AFN22>"G  +.>>!11==F<NG89AEN22>"Grx   c                 r   | j                   d   r|j                  j                  sy|j                  j                  }d}| j                   d   j	                  d      }|s|j
                  r	d|_        d}|S dD ]@  }| j                   d   j	                  |      r"| j                  j                  d|z         B | j                   d   j	                  d      d	z  }| j                   d   j	                  d
      d	z  }| j                   d   j	                  d      dz  }	|j
                  s	d|_        d}|j                  |k7  r||d<   |j                  |d<   ||_        d}|j                  |k7  r||d<   |j                  |d<   ||_	        d}|j                  |	k7  r|	|d<   |j                  |d<   |	|_
        d}|S )z
        Update the traffic shaping policy according to the parameters
        Args:
            spec: The vSwitch spec
            results: The results dict

        Returns: True if changes have been made, else false
        traffic_shapingFenabledT)average_bandwidthpeak_bandwidth
burst_sizezItraffic_shaping.%s is a required parameter if traffic_shaping is enabled.r   r   i  r   r   i   traffic_shaping_avg_bandw"traffic_shaping_avg_bandw_previoustraffic_shaping_peak_bandw#traffic_shaping_peak_bandw_previoustraffic_shaping_bursttraffic_shaping_burst_previous)r"   r   r   shapingPolicyr)   r   r$   r%   averageBandwidthpeakBandwidth	burstSize)
r4   r1   rn   	ts_policyrO   
ts_enabledvaluets_average_bandwidthts_peak_bandwidthts_burst_sizes
             r<   re   z5VMwareHostVirtualSwitch.update_traffic_shaping_policy  s    {{,-T[[5K5KKK--	[[!2377	B
   $)	!NJ 	E;;0155e<%%*ux}*}%~	  ${{+<=AABUVY]] KK(9:>>?OPSWW$56::<H4O   $IG%%)==3GG/0<E<V<VG89)=I&G""&774EG01=F=T=TG9:&7I#G-//<G+,8A8K8KG45"/IGrx   )__name__
__module____qualname__r   rK   rB   r@   r?   rA   rC   staticmethodrb   rc   rd   re   __classcell__)r;   s   @r<   r   r      sS    .a`40G)R- )D^)@
  'RJX4rx   r   c                     t               } | j                  t        t        dddg      t        ddgg d      t        dd	
      t        dd
      t        ddddg      t        ddg      t        dt        t        d      t        d      t        d            ddg      t        dt        t        dg ddg      t        dddg      t        d      t        d      t        dd      t        dd            d g      t        dt        t        d      t        d      t        d      t        d      !      "      #	             t        | d$      }t	        |      }|j                          y )%NstrTswitch_name)typerequiredaliaseslistnic_name)r   r   defaultelementsint   )r   r   i  r   r>   )r   r   choicesr[   )r   r   r,   bool)r   )r   r   r   r   network_policy)r   optionsr   )loadbalance_iploadbalance_srcmacloadbalance_srcidfailover_explicitload_balance_policy)r   r   r   r   r   )r   r   )r   r   )r   r   r   r   r   r   r   )r   r   r   r   )r   r   )	r   r   r   r   r   r   r   r   r   )argument_specsupports_check_mode)r
   updater,   r   r   rK   )r   r$   host_virtual_switchs      r<   mainr     sv   &(MGv
|R%P%5eT*y8Y:OPx8!%6!2!%6!2 f-
 '(89
 # 33	  +//1AB+ !%& 16* $&5 A!%6E!B%( &&-
0 &)"&E"2#/U+	
Q1 1f /35F 2&9%%'rx   __main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNpyVmomir   r   ImportErroransible.module_utils.basicr   @ansible_collections.community.vmware.plugins.module_utils.vmwarer	   Hansible_collections.community.vmware.plugins.module_utils._argument_specr
   ansible.module_utils._textr   r   r   r   rZ   rx   r<   <module>r     s    A @xtcJ
	" 5 T g 0_g _D9(x zF O  		s   A AA