Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/system/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/system/open_iscsi.pyo

�
�Udac@`sddlmZmZmZeZidd6dgd6dd6ZdZd	Zdd
l	Z	dd
l
Z
dd
lZddlm
Z
dZd
�Zd
d�Zd�Zd�Zd
d
d�Zd�Zd�Zd�Zd�Zd�Zd�Zedkre�nd
S(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: open_iscsi
author:
- Serge van Ginderachter (@srvg)
version_added: "1.4"
short_description: Manage iSCSI targets with Open-iSCSI
description:
    - Discover targets on given portal, (dis)connect targets, mark targets to
      manually or auto start, return device nodes of connected targets.
requirements:
    - open_iscsi library and tools (iscsiadm)
options:
    portal:
        description:
        - The IP address of the iSCSI target.
        type: str
        aliases: [ ip ]
    port:
        description:
        - The port on which the iSCSI target process listens.
        type: str
        default: 3260
    target:
        description:
        - The iSCSI target name.
        type: str
        aliases: [ name, targetname ]
    login:
        description:
        - Whether the target node should be connected.
        type: bool
        aliases: [ state ]
    node_auth:
        description:
        - The value for C(discovery.sendtargets.auth.authmethod).
        type: str
        default: CHAP
    node_user:
        description:
        - The value for C(discovery.sendtargets.auth.username).
        type: str
    node_pass:
        description:
        - The value for C(discovery.sendtargets.auth.password).
        type: str
    auto_node_startup:
        description:
        - Whether the target node should be automatically connected at startup.
        type: bool
        aliases: [ automatic ]
    discover:
        description:
        - Whether the list of target nodes on the portal should be
          (re)discovered and added to the persistent iSCSI database.
        - Keep in mind that C(iscsiadm) discovery resets configuration, like C(node.startup)
          to manual, hence combined with C(auto_node_startup=yes) will always return
          a changed state.
        type: bool
    show_nodes:
        description:
        - Whether the list of nodes in the persistent iSCSI database should be returned by the module.
        type: bool
s�
- name: Perform a discovery on 10.1.2.3 and show available target nodes
  open_iscsi:
    show_nodes: yes
    discover: yes
    portal: 10.1.2.3

# NOTE: Only works if exactly one target is exported to the initiator
- name: Discover targets on portal and login to the one available
  open_iscsi:
    portal: '{{ iscsi_target }}'
    login: yes
    discover: yes

- name: Connect to the named target, after updating the local persistent database (cache)
  open_iscsi:
    login: yes
    target: iqn.1986-03.com.sun:02:f8c1f9e0-c3ec-ec84-c9c9-8bfb0cd5de3d

- name: Disconnect from the cached named target
  open_iscsi:
    login: no
    target: iqn.1986-03.com.sun:02:f8c1f9e0-c3ec-ec84-c9c9-8bfb0cd5de3d
N(t
AnsibleModuletiscsiadmcC`s|j�|j�||kS(N(tsort(tl1tl2((sE/usr/lib/python2.7/site-packages/ansible/modules/system/open_iscsi.pytcompare_nodelistsqs

c	C`s'dt}|j|�\}}}|dkr�|j�}g}x�|D]�}|j�}	t|	�dkr�|jddd|�n|	d}
|	djd�}	|	d}|dks�||krG|j|
�qGqGWnI|d	ks�|d
krd|krg}n|jd|d|d|�|S(
Ns%s --mode nodeiitmsgserror parsing outputtcmdit:ii�so records foundtrc(tiscsiadm_cmdtrun_commandt
splitlinestsplittlent	fail_jsontNonetappend(tmoduletportalRRtoutterrtlinestnodestlinetpartsttargett
target_portal((sE/usr/lib/python2.7/site-packages/ansible/modules/system/open_iscsi.pytiscsi_get_cached_nodesws$



$	cC`sZdt||f}|j|�\}}}|dkrV|jd|d|d|�ndS(Ns5%s --mode discovery --type sendtargets --portal %s:%siRRR(RRR(RRtportRRRR((sE/usr/lib/python2.7/site-packages/ansible/modules/system/open_iscsi.pytiscsi_discover�scC`shdt}|j|�\}}}|dkr8||kS|dkrHtS|jd|d|d|�dS(Ns%s --mode sessioniiRRR(RRtFalseR(RR"RRRR((sE/usr/lib/python2.7/site-packages/ansible/modules/system/open_iscsi.pyttarget_loggedon�s

cC`sG|jd}|jd}|jd}|r�d|fd|fd|fg}xp|D]e\}}	dt|||	f}
|j|
�\}}}
|dkrU|jd	|
d
|d|
�qUqUWndt|f}
|dk	r|dk	r|
d
||f7}
n|j|
�\}}}
|dkrC|jd	|
d
|d|
�ndS(Nt	node_autht	node_usert	node_passsnode.session.auth.authmethodsnode.session.auth.usernamesnode.session.auth.passwords?%s --mode node --targetname %s --op=update --name %s --value %siRRRs&%s --mode node --targetname %s --logins --portal %s:%s(tparamsRRRR(RR"RR%R)R*R+R,tnametvalueRRRR((sE/usr/lib/python2.7/site-packages/ansible/modules/system/open_iscsi.pyttarget_login�s$


		&cC`sWdt|f}|j|�\}}}|dkrS|jd|d|d|�ndS(Ns'%s --mode node --targetname %s --logoutiRRR(RRR(RR"RRRR((sE/usr/lib/python2.7/site-packages/ansible/modules/system/open_iscsi.pyt
target_logout�scC`sktjd|�}g}xK|D]C}d|kr tjj|�}||krc|j|�qcq q W|S(Ns/dev/disk/by-path/*%s*s-part(tglobtostpathtrealpathR(RR"tdevicestdevdiskstdevtdevdisk((sE/usr/lib/python2.7/site-packages/ansible/modules/system/open_iscsi.pyttarget_device_node�s
cC`s�dt|f}|j|�\}}}|dkrk|j�}x$|D]}d|krGd|kSqGWtS|jd|d|d|�dS(Ns%s --mode node --targetname %sisnode.startupt	automaticRRR(RRRR'R(RR"RRRRRR ((sE/usr/lib/python2.7/site-packages/ansible/modules/system/open_iscsi.pyt
target_isauto�s
cC`sWdt|f}|j|�\}}}|dkrS|jd|d|d|�ndS(NsP%s --mode node --targetname %s --op=update --name node.startup --value automaticiRRR(RRR(RR"RRRR((sE/usr/lib/python2.7/site-packages/ansible/modules/system/open_iscsi.pyttarget_setauto�scC`sWdt|f}|j|�\}}}|dkrS|jd|d|d|�ndS(NsM%s --mode node --targetname %s --op=update --name node.startup --value manualiRRR(RRR(RR"RRRR((sE/usr/lib/python2.7/site-packages/ansible/modules/system/open_iscsi.pyttarget_setmanual�scC`s�tdtdtddddg�dtdddd	�d
tdddddg�d
tdddd�dtdd�dtdddt�dtddddg�dtddddg�dtdddt�dtdddt��
dddgddggdt�}|jddt�a|jd}|jd
}|jd}|jd}|jd}|jd}|jd}|j}t||�}	i}
t|
d<|r%|dkr�|j
d d!�n.|r�|	}nt|||�t||�}t|	|�s+|
dctO<t|
d"<q+n|	}|dk	sC|dk	r�|dkr�t
|�d#krt|j
d d$�q�|d%}q�t}x$|D]}
|
|kr�t}Pq�q�W|s�|j
d d&�q�n|r�||
d'<n|dk	r�t||�}|r|s|rA|rA|
dctO<|r�t||�|
d(<q�q�|s�|r�t||||�tjd#�t||�|
d(<n
t||�|
dctO<t|
d)<q�|
dctO<t|
d)<n|dk	rt||�}|r�|s�|r|r|
dctO<t|
d*<q|sb|r8t||�n
t||�|
dctO<t|
d*<q|
dctO<t|
d*<n|j|
�dS(+Nt
argument_specRttypetstrtaliasestipR%tdefaulti�R"R-t
targetnameR)tCHAPR*R+tno_logtlogintbooltstatetauto_node_startupR:tdiscovert
show_nodestrequired_togethert
discover_usert
discover_passtsupports_check_modeR	trequiredtchangedRs4Need to specify at least the portal (ip) to discovert
cache_updatedisNeed to specify a targetisSpecified target not foundRtdevicenodestconnection_changedtautomatic_changed(RtdicttTrueR'tget_bin_pathRR,t
check_modeR$RRR&R
RR(R9R/ttimetsleepR0R;R<R=t	exit_json(RRR"R%RGR:RKRLtchecktcachedtresultRtcheck_targettnodetloggedontisauto((sE/usr/lib/python2.7/site-packages/ansible/modules/system/open_iscsi.pytmain�s�		






	
	










t__main__(t
__future__RRRR?t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLESR1R2R[tansible.module_utils.basicRtISCSIADMR
RR$R&R(R/R0R9R;R<R=Ret__name__(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/open_iscsi.pyt<module>s0


A									u

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]