%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlmZddlZddlZddl	Z	ddl
Zddlj
jZddlZddlZddlZddlmZmZyddlmZWnek
r�eZnXyFddlmZmZddlmZmZdd	lm Z e!Z"Wnek
r;e#Z"nXej$j%d
�Z&ej'j(e&�Z)ej*e+�Z,d�Z-d�Z.d
�Z/d�Z0d�Z1d�Z2dd�Z4dS(u�
Azure (ARM) Utilities

.. versionadded:: 2019.2.0

:maintainer: <devops@decisionlab.io>
:maturity: new
:depends:
    * `azure <https://pypi.python.org/pypi/azure>`_ >= 2.0.0rc6
    * `azure-common <https://pypi.python.org/pypi/azure-common>`_ >= 1.1.4
    * `azure-mgmt <https://pypi.python.org/pypi/azure-mgmt>`_ >= 0.30.0rc6
    * `azure-mgmt-compute <https://pypi.python.org/pypi/azure-mgmt-compute>`_ >= 0.33.0
    * `azure-mgmt-network <https://pypi.python.org/pypi/azure-mgmt-network>`_ >= 0.30.0rc6
    * `azure-mgmt-resource <https://pypi.python.org/pypi/azure-mgmt-resource>`_ >= 0.30.0
    * `azure-mgmt-storage <https://pypi.python.org/pypi/azure-mgmt-storage>`_ >= 0.30.0rc6
    * `azure-mgmt-web <https://pypi.python.org/pypi/azure-mgmt-web>`_ >= 0.30.0rc6
    * `azure-storage <https://pypi.python.org/pypi/azure-storage>`_ >= 0.32.0
    * `msrestazure <https://pypi.python.org/pypi/msrestazure>`_ >= 0.4.21
:platform: linux

i(tabsolute_importtprint_functiontunicode_literals(t
itemgetterN(tSaltInvocationErrortSaltSystemExit(trange(tUserPassCredentialstServicePrincipalCredentials(tMetadataEndpointErrort get_cloud_from_metadata_endpoint(t
CloudErroru/etc/salt/minioncC@sts
tStSdS(N(t	HAS_AZUREtFalsetTrue(((s7/usr/lib/python2.7/site-packages/salt/utils/azurearm.pyt__virtual__Asc
K@s�d|kr0td|d�}|j|�ndddg}ddg}yh|jd�r�|jd�jd	�r�t|d�}n*tjd
�}t||jdd��}Wn6tt	t
fk
r�tjdj
|d���nXt|�j|�rX|do|do|ds.td
��q�t|d|dd|dd|�}ndt|�j|�r�|do~|ds�td��q�t|d|dd|�}ntd��d|kr�td��ntjjj|d�}|||fS(u'
    Acquire Azure ARM Credentials
    uprofileu
config.optionu	client_idusecretutenantuusernameupassworducloud_environmentuhttpumsrestazure.azure_clouduAZURE_PUBLIC_CLOUDu1The Azure cloud environment {0} is not available.u_The client_id, secret, and tenant parameters must all be populated if using service principals.ttenanttcloud_environmentufThe username and password parameters must both be populated if using username/password authentication.u�Unable to determine credentials. A subscription_id with username and password, or client_id, secret, and tenant or a profile with the required parameters populatedusubscription_idu#A subscription_id must be specified(t__salt__tupdatetgett
startswithR
t	importlibt
import_moduletgetattrtAttributeErrortImportErrorR	tsystexittformattsettissubsetRRRtsalttutilststringutilstto_str(tkwargstazure_credentialstservice_principal_creds_kwargstuser_pass_creds_kwargst	cloud_envtcloud_env_moduletcredentialstsubscription_id((s7/usr/lib/python2.7/site-packages/salt/utils/azurearm.pyt_determine_authHsD' 




	cK@sjidd6dd6dd6dd6d	d
6dd6d
d6}||kr[tdj|���n||}|dks}|dkr�d
}n|}y/tjd|�}t|dj|��}Wn)tk
r�tjdj|���nXt|�\}}}	|dkr&|d|d|	j	j
�}
n!|d|d|d|	j	j
�}
|
jjdjt
jj��|
S(uT
    Dynamically load the selected client and return a management client object
    uComputeManagementucomputeuStorageManagementustorageuNetworkManagementunetworkuPolicyupolicyuResourceManagementuresourceuSubscriptionusubscriptionuWebSiteManagementuwebu9The Azure ARM client_type {0} specified can not be found.uazure.mgmt.u	{0}Clientu&The azure {0} client is not available.R*tbase_urlR+uSalt/{0}(RRRRRRRRR,t	endpointstresource_managertconfigtadd_user_agentR tversiont__version__(tclient_typeR$t
client_mapt	map_valuetmodule_namet
client_moduletClientR*R+R(tclient((s7/usr/lib/python2.7/site-packages/salt/utils/azurearm.pyt
get_client�sB


	
cK@s_ytt|jd��}Wn&ttfk
rDttd�}nX|d|j�|�dS(u/
    Log an azurearm cloud error exception
    uazurearm_log_leveluerroru*An AzureARM %s CloudError has occurred: %sN(RtlogRRt	TypeErrort
capitalize(R:tmessageR$tcloud_logger((s7/usr/lib/python2.7/site-packages/salt/utils/azurearm.pytlog_cloud_error�s	cC@sbg}xUtr]y#t|�}|j|j��Wq	tk
rH�q	tk
rYPq	Xq	W|S(uK
    Extract all pages within a paged object as a list of dictionaries
    (Rtnexttappendtas_dictRt
StopIteration(tpaged_objecttpaged_returntpage((s7/usr/lib/python2.7/site-packages/salt/utils/azurearm.pytpaged_object_to_list�s	

	c
K@sLi}y+tjdj|��}t||�}Wn,tk
r_tjdj||���nXdt|�krBx�|jj	�D]�\}}|j
|�}|r�|ddj�r�t|t
�r�t||d|�||<q;|dddkrt|t
�r|||<q;|dddkr.t|t�r.g}	x�|D]�}
|ddj�r�t|
t
�r�|	jt||d|djd�d|djd	�!|
��qC|dddkr�t|
t
�r�|	j|
�qC|ddj�rC|dddkrC|	j|
�qCqCW|	||<q;|||<q�q�Wn||�S(
u6
    Assemble an object from incoming parameters.
    uazure.mgmt.{0}.modelsu7The {0} model in the {1} Azure module is not available.u_attribute_maputypeiu{u[iu](RRRRRRRtdirt_attribute_maptitemsRtisuppert
isinstancetdicttcreate_object_modeltlistRCtindextrindex(R7tobject_nameR$t
object_kwargstmodel_moduletModeltattrRLtparamtobj_listt	list_item((s7/usr/lib/python2.7/site-packages/salt/utils/azurearm.pyRP�s>
##
#
#,
#)
cC@s�i}|sg}nt|t�s2d|d<|St|�t|�krfi|d6|d6|d<|Sy;g||fD]}t|dtd��^qv\}}Wn7tk
r�d|d<|Stk
r�d	|d<|SXx�td
t|��D]�}x�||D]�}|||}	||krT||j|i�jdd�j	d
�d}
nU||j|�}
t|	t
j�r�|	j�}	nt|
t
j�r�|
j�}
n|	|
kri|d6|d6|d<|SqWq�W|S(u
    Compare lists of dictionaries representing Azure objects. Only keys found in the "new" dictionaries are compared to
    the "old" dictionaries, since getting Azure objects from the API returns some read-only data which should not be
    used in the comparison. A list of parameter names can be passed in order to compare a bare object name to a full
    Azure ID path for brevity. If string types are found in values, comparison is case insensitive. Return comment
    should be used to trigger exit from the calling function.
    u+must be provided as a list of dictionaries!ucommentuoldunewuchangestkeyunameu:configurations must be provided as a list of dictionaries!u7configuration dictionaries must contain the "name" key!iuiduu/i����(
RNRQtlentsortedRR=tKeyErrort	six_rangeRtsplittsixtstring_typestlower(toldtnewtconvert_id_to_nametretR0t
local_configstremote_configstidxR\t	local_valt
remote_val((s7/usr/lib/python2.7/site-packages/salt/utils/azurearm.pytcompare_list_of_dicts	sF	
;



2(5t__doc__t
__future__RRRtoperatorRRtloggingRtsalt.configR tsalt.ext.sixtextRbtsalt.loadertsalt.utils.stringutilstsalt.versiontsalt.exceptionsRRtsalt.ext.six.movesRR`Rtazure.common.credentialsRRtmsrestazure.azure_cloudR	R
tmsrestazure.azure_exceptionsRRRR
R0t
minion_configt__opts__tloadertminion_modsRt	getLoggert__name__R<RR,R;RARIRPtNoneRn(((s7/usr/lib/python2.7/site-packages/salt/utils/azurearm.pyt<module>s@




		;	5			.

Zerion Mini Shell 1.0