
    Vh                     r    d dl mZmZmZ eZddgddZdZdZdZ	d d	l
mZ d d
lmZmZ d Zedk(  r e        yy)    )absolute_importdivisionprint_functionz1.1preview	certified)metadata_versionstatussupported_byu
  
---
module: ucs_vsans
short_description: Configures VSANs on Cisco UCS Manager
description:
- Configures VSANs on Cisco UCS Manager.
extends_documentation_fragment: cisco.ucs.ucs
options:
  state:
    description:
    - If C(present), will verify VSANs are present and will create if needed.
    - If C(absent), will verify VSANs are absent and will delete if needed.
    choices: [present, absent]
    default: present
    type: str
  name:
    description:
    - The name assigned to the VSAN.
    - This name can be between 1 and 32 alphanumeric characters.
    - "You cannot use spaces or any special characters other than - (hyphen), \"_\" (underscore), : (colon), and . (period)."
    - You cannot change this name after the VSAN is created.
    required: yes
    type: str
  vsan_id:
    description:
    - The unique identifier assigned to the VSAN.
    - The ID can be a string between '1' and '4078', or between '4080' and '4093'. '4079' is a reserved VSAN ID.
    - In addition, if you plan to use FC end-host mode, the range between '3840' to '4079' is also a reserved VSAN ID range.
    - Optional if state is absent.
    type: str
  vlan_id:
    description:
    - The unique string identifier assigned to the VLAN used for Fibre Channel connections.
    - Note that Cisco UCS Manager uses VLAN '4048'.  See the UCS Manager configuration guide if you want to assign '4048' to a VLAN.
    - Optional if state is absent.
    type: str
  fc_zoning:
    description:
    - Fibre Channel zoning configuration for the Cisco UCS domain.
    - "Fibre Channel zoning can be set to one of the following values:"
    - "disabled — The upstream switch handles Fibre Channel zoning, or Fibre Channel zoning is not implemented for the Cisco UCS domain."
    - "enabled — Cisco UCS Manager configures and controls Fibre Channel zoning for the Cisco UCS domain."
    - If you enable Fibre Channel zoning, do not configure the upstream switch with any VSANs that are being used for Fibre Channel zoning.
    choices: [disabled, enabled]
    default: disabled
    type: str
  fabric:
    description:
    - "The fabric configuration of the VSAN.  This can be one of the following:"
    - "common - The VSAN maps to the same VSAN ID in all available fabrics."
    - "A - The VSAN maps to the a VSAN ID that exists only in fabric A."
    - "B - The VSAN maps to the a VSAN ID that exists only in fabric B."
    choices: [common, A, B]
    default: common
    type: str
requirements:
- ucsmsdk
author:
- David Soper (@dsoper2)
- John McDonough (@movinalot)
- CiscoUcs (@CiscoUcs)
aZ  
- name: Configure VSAN
  cisco.ucs.ucs_vsans:
    hostname: 172.16.143.150
    username: admin
    password: password
    name: vsan110
    fabric: common
    vsan_id: '110'
    vlan_id: '110'

- name: Remove VSAN
  cisco.ucs.ucs_vsans:
    hostname: 172.16.143.150
    username: admin
    password: password
    name: vsan110
    state: absent
z
#
)AnsibleModule)	UCSModuleucs_argument_specc                     t        j                         } | j                  t        dd      t        d      t        d      t        ddddg      t        ddg d	      t        dd
d
dg             t	        | d      }t        |      }d}ddlm} d}	 |j                  g}|D ]a  }d}d}	|j                  d      sd|d<   |j                  d      sd|d<   d}
|d   dk7  r|
d|d   z   z  }
|
dz   |d   z   }|j                  j                  |      }|rd}|j                  d   dk(  rG|s|j                  s5|j                  j                  |       |j                  j                          d}|r3t        |d         }|d   |d<   |d   |d<    |j                  d!i |rd}	|	r|j                  sO ||
|d   |d   |d   |d         }|j                  j!                  |d       |j                  j                          d}d 	 ||j&                  d <   |r |j(                  d!i |j&                    |j*                  d!i |j&                   y # t"        $ r'}d}dt%        |      z  |j&                  d<   Y d }~ud }~ww xY w)"NstrT)typerequired)r   disabledenabled)r   defaultchoicescommon)r   ABpresentabsent)namevsan_idvlan_id	fc_zoningfabricstate)supports_check_modeFr   )
FabricVsanr   r   z
fabric/san/z/net-r   r    r   )idr   	fcoe_vlanzoning_state)parent_mo_or_dnr   r$   r%   r&   zsetup error: %s msgchanged )r   copyupdatedictr   r    ucsmsdk.mometa.fabric.FabricVsanr"   paramsgetlogin_handlequery_dn
check_mode	remove_mocommitcheck_prop_matchadd_mo	Exceptionr   result	fail_json	exit_json)argument_specmoduleucserrr"   r)   	vsan_listvsan	mo_existsprops_matchdn_basednmokwargses                  g/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/ucs/plugins/modules/ucs_vsans.pymainrJ   h   s   %**,Mut,% % E:
I?VW:NOy9h:OP    F F
C
C;G68]]O	 /	#DIK88K($.[!88H%!)X"GH~)3h//7"T&\1B!!**2.B 	}}W%1!,,((2226((//1"G!T)_5F*.y/F;'-1+->F>*+++5f5&*"!,,',3!%f#I&*9o)-k): ((//D9((//1"G_/	#j $CJJy
&3::&F"szz"  8.Q7

58s'   BI /A;I ,A I 	J JJ__main__N)
__future__r   r   r   r   __metaclass__ANSIBLE_METADATADOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   6ansible_collections.cisco.ucs.plugins.module_utils.ucsr   r   rJ   __name__r*       rI   <module>rV      s_    A @(-(k$/1 =~(
 5 _Q#h zF rU   