%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/cloud/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pyo

�
���^c@@s\dZddlmZmZmZddlZddlZddlmZddl	m
Z
y�ddlZddlZddl
mZddlmZddlmZmZeZegejjd	d
�jdd
�jd
�d D]Zee�^q��ZWnek
reZd!ZnXddlZ ddl!Z ddl"Z ddl#Z ddl$j%Z%ddl&m'Z'm(Z(ej)e*�Z+d"Z,d�Z-e,dd�Z/d�Z0ddd�Z1ddd�Z2ddd�Z3d�Z4d�Z5d�Z6d�Z7ddd�Z8dd�Z9ddd�Z:ddd�Z;ddd�Z<dd�Z=d �Z>dS(#ud
The generic libcloud template used to create the connections and deploy the
cloud virtual machines
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tzip(tProvider(t
get_driver(tMultiStepDeploymenttScriptDeploymentu-u.urcii�(tSaltCloudNotFoundtSaltCloudSystemExiticC@s�i	dd6dd6dd6dd6d	d
6dd6d
d6dd6dd6}idd6dd6dd6dd6dd6d	d6dd6dd6d
d6dd6dd6d d!6}t|tj�r�||S||S("u(
    Libcloud supported node states
    uRUNNINGiu	REBOOTINGiu
TERMINATEDiuPENDINGiuUNKNOWNiuSTOPPEDiu	SUSPENDEDiuERRORiuPAUSEDiurunningu	rebootinguSTARTINGustartingu
terminatedupendinguunknownuSTOPPINGustoppingustoppedu	suspendeduerrorupausedu
RECONFIGURINGu
reconfiguring(t
isinstanceRtstring_types(tid_t
states_intt
states_str((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pyt
node_state6s0

cC@sts
tSt|ttf�s.td��nyddl}WnKtk
r�tdjdj	g|D]}t
j|�^qd����nXt|kr�|j
Sdj|j
�}|djdj	g|D]}t
j|�^q���7}|r|dj|�7}n|d	7}t|��dS(
u-
    Compare different libcloud versions
    u='reqver' needs to passed as a tuple or list, i.e., (0, 14, 0)iNu:salt-cloud requires >= libcloud {0} which is not installedu.u!Your version of libcloud is {0}. u#salt-cloud requires >= libcloud {0}u for {0}u. Please upgrade.(tHAS_LIBCLOUDtFalseRtlistttupletRuntimeErrortlibcloudtImportErrortformattjoinRt	text_typetLIBCLOUD_VERSION_INFOt__version__(treqvertwhyRtnumterrormsg((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pytcheck_libcloud_versionUs(
5	/
cC@sZ|j�}xG|D]?}|j|krtdtjjj|j�tt	�|SqWdS(u1
    Return a libcloud node for the named VM
    ucloud.cache_nodeN(
t
list_nodestnamet	__utils__tsalttutilstdatatsimple_types_filtert__dict__t__active_provider_name__t__opts__(tconnR#tnodestnode((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pytget_nodevs

&cC@s*|dkrtd��n|s-t�}n|j�}i}x�|D]�}t|jtj�r�tjr�|jjdd�}nt	|j�}i||<x�t
|�D]u}|jd�s�|dkr�q�nt||�}t|tj�rtjr|jdd�}n||||<q�WqFW|S(ub
    Return a dict of all available VM locations on the cloud provider with
    relevant data
    uactionufThe avail_locations function must be called with -f or --function, or with the --list-locations optionuasciiusalt-cloud-force-asciiu_udriver(
R
tget_conntlist_locationsRR#RRtPY3tencodetstrtdirt
startswithtgetattr(R,tcallt	locationstrettimgtimg_nametattrt
attr_value((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pytavail_locations�s*

cC@s*|dkrtd��n|s-t�}n|j�}i}x�|D]�}t|jtj�r�tjr�|jjdd�}nt	|j�}i||<x�t
|�D]u}|jd�s�|dkr�q�nt||�}t|tj�rtjr|jdd�}n||||<q�WqFW|S(	u_
    Return a dict of all available VM images on the cloud provider with
    relevant data
    uactionu`The avail_images function must be called with -f or --function, or with the --list-images optionuasciiusalt-cloud-force-asciiu_udriveruget_uuid(udriveruget_uuid(
R
R0tlist_imagesRR#RRR2R3R4R5R6R7(R,R8timagesR:R;R<R=R>((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pytavail_images�s*

c	C@sB|dkrtd��n|s-t�}n|j�}i}x�|D]�}t|jtj�r�tjr�|jjdd�}nt	|j�}i||<x�t
|�D]�}|jd�s�|dkr�q�nyt||�}Wnt
k
r�nXt|tj�r(tjr(|jdd�}n||||<q�WqFW|S(	u_
    Return a dict of all available VM images on the cloud provider with
    relevant data
    uactionu^The avail_sizes function must be called with -f or --function, or with the --list-sizes optionuasciiusalt-cloud-force-asciiu_udriveruget_uuid(udriveruget_uuid(R
R0t
list_sizesRR#RRR2R3R4R5R6R7t	Exception(R,R8tsizesR:tsizet	size_nameR=R>((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pytavail_sizes�s0


cC@s|j�}tjd|t�}tjs?|jdd�}nx�|D]�}t|jtj	�r�tjr�|jjdd�}nt
|j�}t|jtj	�r�tjr�|jjdd�}nt
|j�}|rF|||fkrF|SqFWtdj
|���dS(u+
    Return the location object to use
    ulocationuasciiusalt-cloud-force-asciiu2The specified location, '{0}', could not be found.N(R1tconfigtget_cloud_config_valueR+RR2R3RtidRR4R#R	R(R,tvm_R9tvm_locationR;timg_idR<((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pytget_location�s"	
cC@s|j�}tjd|t�}tjs?|jdd�}nx�|D]�}t|jtj	�r�tjr�|jjdd�}nt
|j�}t|jtj	�r�tjr�|jjdd�}nt
|j�}|rF|||fkrF|SqFWtdj
|���dS(u(
    Return the image object to use
    uimageuasciiusalt-cloud-force-asciiu/The specified image, '{0}', could not be found.N(R@RIRJR+RR2R3RRKRR4R#R	R(R,RLRAtvm_imageR;RNR<((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pyt	get_images	
cC@s�|j�}tjd|t�}|s/|dSxB|D]:}|r6t|�t|j�t|j�fkr6|Sq6Wtdj|���dS(u%
    Return the VM's size object
    usizeiu.The specified size, '{0}', could not be found.N(	RCRIRJR+R4RKR#R	R(R,RLREtvm_sizeRF((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pytget_size.s
0c	C@sRttjjjtjd|t�|ttjjjtjjj	t|����S(u-
    Return the script deployment object
    uos(
RR%R&tcloudt	os_scriptRIRJR+tsalt_config_to_yamlt
minion_config(RL((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pytscript?scC@s|dkrtd��ntddddj|�di|d6d	td
dtd�|skt�}nt||�}t�d
}|d&kr�tj	d|�nd&}d|j
kr�d|j
dkr�|j
dd}nt}|r||krd||kr||d}n|r�tjd|�t
jj}djtdjd�d �}|jt
jjtjj|d���t
jj|�}	|	j|d�}
ntjd||�tjd|�|j|�}|r�tjd|�tddddj|�di|d6d	td
dtd�tdtkr�t|tjdd��}|r}t
jjj|d �nt|tjdd!��}
|
r�t
jjj|
d �q�ntjd"t�tkr�td#|t jd$�d t�ntStj	d%|�tS('u
    Delete a single VM
    ufunctionuEThe destroy action must be called with -d, --destroy, -a or --action.ucloud.fire_eventueventudestroying instanceusalt/cloud/{0}/destroyingtargsunametsock_dirusock_dirt	transportu	transportuprofilesuUnable to find the VM %sumetadatauprofileuflush_mine_on_destroyuClearing Salt Mine: %su/u	conf_filei����uminionu
mine.flushuClearing Salt Mine: %s, %suDestroying VM: %suDestroyed VM: %sudestroyed instanceusalt/cloud/{0}/destroyedudelete_sshkeysu
ssh_interfaceu
public_ipsiuprivate_ipsuupdate_cachedirucloud.delete_minion_cachediru:uFailed to Destroy VM: %sN(!R
R$RR+R0R/tget_configured_providertNonetlogterrortextraRtinfoR%RItDEFAULT_MINION_OPTSRtsplittupdateRWtostpathtclienttget_local_clienttcmdtdestroy_nodetTrueR7tgetR&RTt
remove_sshkeyR*(R#R,R8R.tprofilestprofiletflush_mine_on_destroytmopts_t	conf_pathRgtminionsR:t
public_ipstprivate_ips((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pytdestroyOsl


"" "

$cC@s�|st�}nt||�}|dkr@tjd|�ntjd|�|j|�}|r�tjd|�tdddj|�dj|�di|d	6d
t	ddt	d
�t
Stjd|�tS(u
    Reboot a single VM
    uUnable to find the VM %suRebooting VM: %suRebooted VM: %sucloud.fire_eventueventu{0} has been rebootedu"salt-cloudsalt/cloud/{0}/rebootingRYunameRZusock_dirR[u	transportuFailed to reboot VM: %sN(R0R/R]R^R_Ratreboot_nodeR$RR+RkR(R#R,R.R:((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pytreboot�s&	

cC@s�|dkrtd��n|s-t�}n|j�}i}xg|D]_}i|jd6|jd6|jd6|jd6|jd6|jd6t	|j
�d	6||j<qFW|S(
u;
    Return a list of the VMs that are on the provider
    uactionu=The list_nodes function must be called with -f or --function.uiduimageunameuprivate_ipsu
public_ipsusizeustate(R
R0R"RKtimageR#RuRtRFRtstate(R,R8R-R:R.((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pyR"�s"






cC@s�|dkrtd��n|s-t�}n|j�}i}xh|D]`}i}x6t|jtj|j��D]\}}|||<qqW|||j<||jd=qFWtd|t	j
d�dt�|S(uL
    Return a list of the VMs that are on the provider, with all fields
    uactionuBThe list_nodes_full function must be called with -f or --function.udriverucloud.cache_node_listu:i(R
R0R"RR)Rt
itervaluesR#R$R*RcR+(R,R8R-R:R.tpairstkeytvalue((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pytlist_nodes_full�s
+
!cC@s8|st�}ntjjjt|d�td|�S(uO
    Return a list of the VMs that are on the provider, with select fields
    ufunctionuquery.selection(R0R%R&RTtlist_nodes_selectRR+(R,R8((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pyR��scC@sD|dkrtd��nt�}td||tt�||S(uC
    Show the details from the provider concerning an instance
    uactionu<The show_instance action must be called with -a or --action.ucloud.cache_node(R
RR$R*R+(R#R8R-((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pyt
show_instance�s	cC@s*|t|�krtStjd|�tS(uF
    Find if the provided connection object has a specific method
    uMethod '%s' not yet supported!(R5RkR^R_R(R,tmethod_name((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pytconn_has_methods(i�(iii(?t__doc__t
__future__RRRRetloggingtsalt.extRtsalt.ext.six.movesRRtretlibcloud.compute.typesRtlibcloud.compute.providersRtlibcloud.compute.deploymentRRRkRRRtreplaceRctparttintRRRtsalt.utils.eventR%tsalt.clienttsalt.utils.cloudtsalt.utils.datatsalt.configRItsalt.exceptionsR	R
t	getLoggert__name__R^tLIBCLOUD_MINIMAL_VERSIONRR]R!R/R?RBRHRORQRSRXRvRxR"RR�R�R�(((s</usr/lib/python2.7/site-packages/salt/cloud/libcloudfuncs.pyt<module>sTN

	!	%#(	 			M

Zerion Mini Shell 1.0