Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/storage/glusterfs/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pyo

�
�Udac@`sgddlmZmZmZeZidd6dgd6dd6ZdZd	Zdd
l	Z	dd
l
Z
dd
lZdd
lZddl
mZddlmZd
ad�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d �Z$e%d!krce$�nd
S("i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bysj
module: gluster_volume
short_description: Manage GlusterFS volumes
description:
  - Create, remove, start, stop and tune GlusterFS volumes
version_added: '1.9'
options:
  name:
    description:
      - The volume name.
    required: true
    aliases: ['volume']
  state:
    description:
      - Use present/absent ensure if a volume exists or not.
        Use started/stopped to control its availability.
    required: true
    choices: ['absent', 'present', 'started', 'stopped']
  cluster:
    description:
      - List of hosts to use for probing and brick setup.
  host:
    description:
      - Override local hostname (for peer probing purposes).
  replicas:
    description:
      - Replica count for volume.
  arbiters:
    description:
      - Arbiter count for volume.
    version_added: '2.3'
  stripes:
    description:
      - Stripe count for volume.
  disperses:
    description:
      - Disperse count for volume.
    version_added: '2.2'
  redundancies:
    description:
      - Redundancy count for volume.
    version_added: '2.2'
  transport:
    description:
      - Transport type for volume.
    default: tcp
    choices: [ tcp, rdma, 'tcp,rdma' ]
  bricks:
    description:
      - Brick paths on servers. Multiple brick paths can be separated by commas.
    aliases: [ brick ]
  start_on_create:
    description:
      - Controls whether the volume is started after creation or not.
    type: bool
    default: 'yes'
  rebalance:
    description:
      - Controls whether the cluster is rebalanced after changes.
    type: bool
    default: 'no'
  directory:
    description:
      - Directory for limit-usage.
  options:
    description:
      - A dictionary/hash with options/settings for the volume.
  quota:
    description:
      - Quota value for limit-usage (be sure to use 10.0MB instead of 10MB, see quota list).
  force:
    description:
      - If brick is being created in the root partition, module will fail.
        Set force to true to override this behaviour.
    type: bool
notes:
  - Requires cli tools for GlusterFS on servers.
  - Will add new bricks, but not remove them.
author:
- Taneli Leppä (@rosmo)
s
- name: create gluster volume
  gluster_volume:
    state: present
    name: test1
    bricks: /bricks/brick1/g1
    rebalance: yes
    cluster:
      - 192.0.2.10
      - 192.0.2.11
  run_once: true

- name: tune
  gluster_volume:
    state: present
    name: test1
    options:
      performance.cache-size: 256MB

- name: Set multiple options on GlusterFS volume
  gluster_volume:
    state: present
    name: test1
    options:
      { performance.cache-size: 128MB,
        write-behind: 'off',
        quick-read: 'on'
      }

- name: start gluster volume
  gluster_volume:
    state: started
    name: test1

- name: limit usage
  gluster_volume:
    state: present
    name: test1
    directory: /foo
    quota: 20.0MB

- name: stop gluster volume
  gluster_volume:
    state: stopped
    name: test1

- name: remove gluster volume
  gluster_volume:
    state: absent
    name: test1

- name: create gluster volume with multiple bricks
  gluster_volume:
    state: present
    name: test2
    bricks: /bricks/brick1/g2,/bricks/brick2/g2
    cluster:
      - 192.0.2.10
      - 192.0.2.11
  run_once: true

- name: Remove the bricks from gluster volume
  gluster_volume:
    state: present
    name: testvol
    bricks: /bricks/brick1/b1,/bricks/brick2/b2
    cluster:
      - 10.70.42.85
    force: true
  run_once: true

- name: Reduce cluster configuration
  gluster_volume:
    state: present
    name: testvol
    bricks: /bricks/brick3/b1,/bricks/brick4/b2
    replicas: 2
    cluster:
      - 10.70.42.85
    force: true
  run_once: true
N(t
AnsibleModule(t	to_nativetcK`s�tdg}|j|�yftj||�\}}}|dkr~tjdddj|�||pg|fdtj��nWnHtk
r�}tjdddj|�t	|�fdtj��nX|S(Ns
--mode=scriptitmsgs.error running gluster (%s) command (rc=%d): %st t	exceptions&error running gluster (%s) command: %s(
t
glusterbintextendtmoduletrun_commandt	fail_jsontjoint	tracebackt
format_exct	ExceptionR	(tgargstkwargstargstrctoutterrte((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pytrun_gluster�s
3!cK`sEtg}|j|�tj||�\}}}|dkrAdS|S(Ni(RRRRtNone(RRRRRR((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pytrun_gluster_nofail�s	
c	C`s4tddg�}i}d}d}d}t}x�|jd�D]�}d|kr�|jd�\}}|j�dkr�|}t}n|j�dkr�|}n|j�dkr,|}||g||<q,q@|j�dkr�t}q@|d	kr|tkr||g||<q@|d	kr@t}q@q@W|S(
NtpeerRs
s: thostnametuuidtstatesother names:R
(RRtFalsetsplittlowertTrue(	RtpeersR"R#R$t
shortNamestrowtkeytvalue((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pyt	get_peers�s0			
cC`s_tddg�}i}i}x:|jd�D])}d|kr|jd�\}}|j�dkr�||d<i|d<t|d<n|j�d	kr�||d
<n|j�dkr�||d<n|j�dkr�||d
<n|j�jd�r1d|krg|d<n|d }|dj|�n#|j�dkrT|d|d<n|j�dkr�|j�d dkr�d|kr�g|d<n|dj|�nd|krWd|kr�i|d<n||d|<|dkr|dkrt|d<qqWq.|j�dkr.|j�dkr.t|�dkrN|||d<ni}q.q.W|S(Ntvolumetinfos
s: svolume nametnametoptionstquotas	volume idtidRstransport-typet	transports
 (arbiter)tarbitersi����snumber of bricksi����treplicastbricksitbrickt.sfeatures.quotatonsbricks:soptions reconfigured:i(RR&R'R%tendswithtappendR(tlen(RtvolumesR/R+R,R-((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pytget_volumes�sL







(

$
cC`s�i}|r1tdd|dg�}|sI|Sntdd|dg�}xN|jd�D]=}|d dkrYtjd|�}|d||d<qYqYW|S(	NR/R3tlists
it/s\s+i(R RR&tre(R1tnofailtquotasRR+tq((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pyt
get_quotas scC`sgx`tdd�D]O}t�}||krR||dj�jd�dkrRtStjd�qWtS(Niiispeer in clusteri����(trangeR.R'tfindR(ttimetsleepR%(thosttxR)((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pyt
wait_for_peer/s	/cC`sXtdd|g�}|jd�dkrTt|�rTtjdd||f�ndS(NR!tprobet	localhosti����Rsfailed to probe peer %s on %s(RRIRNRR(RLt
myhostnameR((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pyRO8s"cC`s=x6|D].}|j�}||krt||�qqWdS(N(tstripRO(thostsR)RQRL((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pytprobe_all_peers?s
c

C`s]ddg}
|
j|�|rB|
jd�|
jt|��n|rk|
jd�|
jt|��n|r�|
jd�|
jt|��n|r�|
jd�|
jt|��n|r�|
jd�|
jt|��n|
jd�|
j|�x6|D].}x%|D]}|
jd	||f�qWqW|	rO|
jd
�nt|
�dS(NR/tcreatetstripetreplicatarbitertdisperset
redundancyR5s%s:%stforce(R=tstrR(
R1RVRWRXRYRZR5RSR8R[RR9RL((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pyt
create_volumeFs2









cC`stdd|g�dS(NR/tstart(R(R1((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pytstart_volumebscC`stdd|g�dS(NR/tstop(R(R1((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pytstop_volumefscC`stdd|||g�dS(NR/tset(R(R1toptiont	parameter((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pytset_volume_optionjscC`s�dd|g}|r8|jd�|jt|��n|ra|jd�|jt|��n|j|�|r�|jd�nt|�dS(NR/s	add-brickRVRWR[(R=R\RR(R1t
new_bricksRVRWR[R((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pyt
add_bricksns


cC`s(d}d}t}dd|g}|j|�|}|jd�t|�|setjdd�n�x�||kr
|d}tdd||d	g�}	xW|	jd
�dD]B}
d|
kr�|jd
�t|�}	t}Pq�tj	d�q�W|r�Pn|d7}qhW|s$tjdd�ndS(NiiR/sremove-brickR^RsForce option is mandatory.i����Rs
it	completedtcommiti
s[Exceeded number of tries, check remove-brick status.
Commit operation needs to be followed.(
R%RR=RRRR&R(RJRK(R1tremoved_bricksR[t	max_triestretriestsuccessRtargs_ct
last_brickRR+((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pyt
remove_bricks|s2




cC`s�tdd|dg�}|jd�}xR|D]J}d|kr.t|jd�dj��dkr.tjd	d
�q.q.Wdd|d|g}|j|�|r�|jd
�ntjd	d�t|�dS(NR/thealR0s
tNumbert:iiRs)Operation aborted, self-heal in progress.sremove-brickRWR[sForce option is mandatory(RR&tintRRRRRR=(R1RjR7R[RtsummarytlineR((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pyt
reduce_config�s
1
cC`stdd|dg�dS(NR/t	rebalanceR^(R(R1((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pytdo_rebalance�scC`stdd|dg�dS(NR/R3tenable(R(R1((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pytenable_quota�scC`s tdd|d||g�dS(NR/R3slimit-usage(R(R1t	directoryR-((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pyt	set_quota�sc)C`s�tdtdtdddtddg�dtdddtd	d
ddd
g�dtdd�dtdd�dtdd�dtdd�dtdd�dtdd�dtdd�dtddddd	dddg�dtddddg�dtdddt�d tdddt�d!tdd"di�d#tdd�d$tdd�d%tdddt���atjd&t�at}tjd}tjd}tjd}tjd}tjd}tjd}tjd}tjd}tjd}	tjd}
tjd}tjtjd�}tjtjd �}
tjtjd%�}|slt	j
�}n|dk	r�t|�d'kr�|d(d)kr�|d*d(!}n|dkr�g}n|dk	r�d+|kr�|j
d+�}n	|g}tjd!}tjd#}tjd$}t�}t�}i}||krw||d#rw||d,j�dkrwt|t�}n|d
kr�||kr�||d,j�dkr�t|�ntdd-|g�t}q�n|d
kr�t|||�||kr4t||||||	|
|||�
t�}t}n||kr�||d,j�dkrs|rst|�t}ng}g}g}||d}xX|D]P}xG|D]?}d.||f}|j|�||kr�|j|�q�q�Wq�W|rOt|�d*krOt|�t|�krOx-|D]"}||kr&|j|�q&q&Wn|rtt|||||�t}n|r�|r�t|�t||d�kr�t||t|�|�nt|||�t}n|r=||d#s�t|�nt|t�}||ks!|||kr=t|||�t}q=nxx|j�D]S}|||d!ks�||d!|||krJt ||||�t}qJqJWq�tj!d/d0|�n|d
kr�||kr�tj!d/d1|�n|dkr&||d,j�dkr&t|�t}q&n|dkrb||d,j�dkrbt|�t}qbn|r�t�}|
r�t"|�q�ni}i|d26|d36|d46|d5<tj#d6|d7|�dS(8Nt
argument_specR1ttypeR\trequiredtaliasesR/R$tchoicestabsenttstartedtstoppedtpresenttclusterRARLtstripesRtR7R6t	dispersestredundanciesR5tdefaultttcptrdmastcp,rdmaR8R9tstart_on_createtboolRxR2tdictR3R|R[tglusterii����R
it,Rtdeletes%s:%sRsfailed to create volume %ssvolume not found %sR)R?REt	glusterfstchangedt
ansible_facts($RR�R(R%Rtget_bin_pathRtparamstbooleantsockettgethostnameRR>R&R.R@R'RGRaRRTR]R_R=RgRtRwR\RpR{R}tkeysReRRyt	exit_json(R�tactiontvolume_nameR�tbrick_pathsR�R7R6R�R�R5RQR�RxR[R2R3R|R)R?RERfRjt
all_brickstbricks_in_volumetnodet
brick_pathR9Rctfacts((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pytmain�s�'$










.		


		4
%		 
	



	&	
0

	t__main__(&t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLESRCR�RJRtansible.module_utils.basicRtansible.module_utils._textR	RRR R.R@RGRNRORTR]R_RaReRgRpRwRyR{R}R�t__name__(((sT/usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_volume.pyt<module>sD


RS				,											$					�

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