�
�Udac @` s d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d
Z d d l
m Z d d l m
Z
m Z d
Z d Z d Z d � Z e d � Z e d � Z d � Z d � Z e d � Z e d � Z d � Z d � Z d � Z d � Z d � Z e d k re � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bys�
---
module: purefa_host
version_added: '2.4'
short_description: Manage hosts on Pure Storage FlashArrays
description:
- Create, delete or modify hosts on Pure Storage FlashArrays.
author:
- Pure Storage Ansible Team (@sdodsley) <[email protected]>
notes:
- If specifying C(lun) option ensure host support requested value
options:
host:
description:
- The name of the host.
type: str
required: true
state:
description:
- Define whether the host should exist or not.
- When removing host all connected volumes will be disconnected.
type: str
default: present
choices: [ absent, present ]
protocol:
description:
- Defines the host connection protocol for volumes.
type: str
default: iscsi
choices: [ fc, iscsi, nvme, mixed ]
wwns:
type: list
description:
- List of wwns of the host if protocol is fc or mixed.
iqn:
type: list
description:
- List of IQNs of the host if protocol is iscsi or mixed.
nqn:
type: list
description:
- List of NQNs of the host if protocol is nvme or mixed.
version_added: '2.8'
volume:
type: str
description:
- Volume name to map to the host.
lun:
description:
- LUN ID to assign to volume for host. Must be unique.
- If not provided the ID will be automatically assigned.
- Range for LUN ID is 1 to 4095.
type: int
version_added: '2.8'
personality:
type: str
description:
- Define which operating system the host is. Recommended for
ActiveCluster integration.
default: ''
choices: ['hpux', 'vms', 'aix', 'esxi', 'solaris', 'hitachi-vsp', 'oracle-vm-server', 'delete', '']
version_added: '2.7'
preferred_array:
type: list
description:
- List of preferred arrays in an ActiveCluster environment.
- To remove existing preferred arrays from the host, specify I(delete).
version_added: '2.9'
extends_documentation_fragment:
- purestorage.fa
s@
- name: Create new AIX host
purefa_host:
host: foo
personaility: aix
fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592
- name: Delete host
purefa_host:
host: foo
fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592
state: absent
- name: Make host bar with wwn ports
purefa_host:
host: bar
protocol: fc
wwns:
- 00:00:00:00:00:00:00
- 11:11:11:11:11:11:11
fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592
- name: Make host bar with iSCSI ports
purefa_host:
host: bar
protocol: iscsi
iqn:
- iqn.1994-05.com.redhat:7d366003913
fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592
- name: Make host bar with NVMe ports
purefa_host:
host: bar
protocol: nvme
nqn:
- nqn.2014-08.com.vendor:nvme:nvm-subsystem-sn-d78432
fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592
- name: Make mixed protocol host
purefa_host:
host: bar
protocol: mixed
nqn:
- nqn.2014-08.com.vendor:nvme:nvm-subsystem-sn-d78432
iqn:
- iqn.1994-05.com.redhat:7d366003914
wwns:
- 00:00:00:00:00:00:01
- 11:11:11:11:11:11:12
fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592
- name: Map host foo to volume bar as LUN ID 12
purefa_host:
host: foo
volume: bar
lun: 12
fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592
- name: Add preferred arrays to host foo
purefa_host:
host: foo
preferred_array:
- array1
- array2
fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592
- name: Delete preferred arrays from host foo
purefa_host:
host: foo
preferred_array: delete
fa_url: 10.10.10.2
api_token: e31060a7-21fc-e277-6240-25983c6c4592
t
( t
AnsibleModule( t
get_systemt purefa_argument_specs 1.14s 1.15s 1.16c C` sQ | j d d k ro | j d ro y% | j | j d d | j d �Wql t k
rh | j d d � ql Xqo n | j d d k r� | j d
r� y% | j | j d d | j d
�Wq� t k
r� | j d d � q� Xq� n | j d d k rM| j d rMy% | j | j d d | j d �WqJt k
rF| j d d � qJXqMn d S( s Set host initiators.t protocolt nvmet mixedt nqnt hostt nqnlistt msgs Setting of NVMe NQN failed.t iscsit iqnt iqnlists Setting of iSCSI IQN failed.t fct wwnst wwnlists Setting of FC WWNs failed.N( R
R ( R R ( s fcR ( t paramst set_hostt Exceptiont fail_json( t modulet array( ( sS /usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_host.pyt _set_host_initiators� s*
c C` sS | j d d k r� | j d r� | j | j d � d } | | j d k r� y+ | j | j d d | j d �t } Wq� t k
r� | j d d � q� Xq� q� n | j d d k rJ| j d
rJ| j | j d � d
} | | j d
k rGy+ | j | j d d | j d
�t } WqDt k
r@| j d d � qDXqGqJn | j d d k rO| j d rOg | j d D] } | j d d � ^ qx| j d <g | j d D] } | j � ^ q�| j d <| j | j d � d } | | j d k rLy+ | j | j d d | j d �t } WqIt k
rE| j d d � qIXqLqOn | S( s9 Change host initiator if iscsi or nvme or add new FC WWNsR R
R R R R R s Change of NVMe NQN failed.R R R s Change of iSCSI IQN failed.R R t :t t wwnR s FC WWN change failed.( s nvmes mixed( s iscsis mixed( s fcs mixed( R t get_hostR t TrueR R t replacet upper( R R t answert current_nqnt current_iqnR"