%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/thread-self/root/lib/python2.7/site-packages/salt/cloud/clouds/
Upload File :
Create Path :
Current File : //proc/thread-self/root/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pyo

�
���^c@@s~dZddlmZmZmZddlZddlZddlZddl	j
Z
ddlmZddl
mZyddlZeZWnek
r�eZnXeje�ZdZd�Zd�Zd	�Zd
�Zdd�Zed
�Zed�Zed�Z ed�Z!ed�Z"d�Z#ded�Z$ed�Z%ed�Z&ed�Z'ed�Z(ed�Z)dS(u�
SoftLayer Cloud Module
======================

The SoftLayer cloud module is used to control access to the SoftLayer VPS
system.

Use of this module only requires the ``apikey`` parameter. Set up the cloud
configuration at:

``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/softlayer.conf``:

.. code-block:: yaml

    my-softlayer-config:
      # SoftLayer account api key
      user: MYLOGIN
      apikey: JVkbSJDGHSDKUKSDJfhsdklfjgsjdkflhjlsdfffhgdgjkenrtuinv
      driver: softlayer

The SoftLayer Python Library needs to be installed in order to use the
SoftLayer salt.cloud modules. See: https://pypi.python.org/pypi/SoftLayer

:depends: softlayer
i(tabsolute_importtprint_functiontunicode_literalsN(tSaltCloudSystemExit(tsixu	softlayercC@s*t�tkrtSt�tkr&tStS(u-
    Check for SoftLayer configurations.
    (tget_configured_providertFalsetget_dependenciest__virtualname__(((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pyt__virtual__7s
cC@stjttptd�S(u/
    Return the first configured instance.
    uapikey(uapikey(tconfigtis_provider_configuredt__opts__t__active_provider_name__R(((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pyRDs	cC@stjtitd6�S(u*
    Warn if dependencies aren't met.
    u	softlayer(R
tcheck_driver_dependenciesRt
HAS_SLLIBS(((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pyROscC@sRtjjjtjd|t�|ttjjjtjjjt|���}|S(u-
    Return the script deployment object
    uscript(	tsalttutilstcloudt	os_scriptR
tget_cloud_config_valueRtsalt_config_to_yamlt
minion_config(tvm_t
deploy_script((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pytscriptYsuSoftLayer_Virtual_Guestc
C@sPtjdtjdt�tdt�dtjdt�tdt��}||S(u5
    Return a conn object for the passed VM data
    tusernameuusert
search_globaltapi_keyuapikey(t	SoftLayertClientR
RRRR(tservicetclient((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pytget_connhs	cC@sx|dkrtd��ni}t�}|j�}x;|dD]/}i|dddd6||ddd<qAW|S(u&
    List all available locations
    uactionufThe avail_locations function must be called with -f or --function, or with the --list-locations optionudatacentersutemplateu
datacenteruname(RR!tgetCreateObjectOptions(tcalltrettconntresponset
datacenter((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pytavail_locationsws	*cC@sN|dkrtd��niid6id6id6}t�}|j�}xZ|dD]N}i|ddd	d
6|dddd
dd6|d|ddd	<qVWxN|dD]B}i|ddd	d
6|ddd6|d|ddd	<q�WxN|dD]B}i|ddd	d
6|ddd6|d|ddd	<qW|S(u�
    Return a dict of all available VM sizes on the cloud provider with
    relevant data. This data is provided in three dicts.
    uactionu^The avail_sizes function must be called with -f or --function, or with the --list-sizes optionu
block devicesumemoryu
processorsublockDevicesu	itemPriceuitemudescriptionunameutemplateiu	diskImageucapacityu	maxMemoryu	startCpusu
start cpus(RR!R"(R#R$R%R&tdevicetmemoryt
processors((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pytavail_sizes�s,
	6**cC@s�|dkrtd��ni}t�}|j�}xJ|dD]>}i|dddd6|dd	d6||ddd<qAW|S(
uI
    Return a dict of all available VM images on the cloud provider.
    uactionu`The avail_images function must be called with -f or --function, or with the --list-images optionuoperatingSystemsu	itemPriceuitemudescriptionunameutemplateuoperatingSystemReferenceCode(RR!R"(R#R$R%R&timage((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pytavail_images�s	&cC@s�|dkrtd��ni}td�}|j�}xt|D]l}d|krXq@ni|dd6|dd6|dd6||d<d|kr@|d||dd<q@q@W|S(uF
    Return a dict of all custom VM images on the cloud provider.
    ufunctionu=The list_vlans function must be called with -f or --function.uSoftLayer_AccountuglobalIdentifieruidunameunote(RR!tgetBlockDeviceTemplateGroups(R#R$R%R&R-((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pytlist_custom_images�s 
c	C@s.tjdtjd|pt�tdt��S(u�
    Return the location to use, in this order:
        - CLI parameter
        - VM parameter
        - Cloud profile setting
    ulocationR(RtgetR
RRR(R((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pytget_location�sc'@s�y=|dr<tjttpd|dd|�tkr<tSWntk
rPnX|d}|�tjd|tddq�}|dqkr�td�n|j	d�r�d	j
||g�}||d<ntd
ddd
j|�dtdd|ddddg�dtddtd�t
jd|�t�}i�d6|d6|dd6|dd6|dd6}tjd|tdt�}||d <d!|kr�|d!|d"<g|d#<|d$}t|t�r�tj|�g}n=t|tj�rg|jd%�D]}|j�^q}nd&}x�|D]�}	|d'krG|d'7}nitj|�d(6itj|	�d)6d*6}
|d#j|
�|d'7}|d+kr(t
jd,|�Pq(q(Wn$d-|kr�i|d-d.6|d/<nt|�}|ri|d6|d0<ntjd1|tdt�}|r<ii|d26d36|d4<ntjd5|tdt�}
t|
�tkrvd6|d7<ntjd8|tdt�}|r�ii|d26d36|d9<ntjd:|tdt�}|r3g|D] }iit|�d26d;6^q�}|j	d9i�}||d<<|ji|d96�ntjd=|tdt�}|r�g|D] }iit|�d26d;6^q[}|j	d4i�}||d<<|ji|d46�ntjd>|tdd?�}|r�it|�d@6g|dA<ntjdB|tddq�}|r ||dC<ntjdD|tddq�}|rUi|d26|dE<ntd
ddFdGj|�ditddH|t|��dI6dtddtd�y|j|��Wn0tk
r�}t
j dJ||dKt!j"�tSXdL�tjdM|tdt�}tjdN|tdt�}|sC|sC|dqkrLdO�n��fdP�}t#j$j%j&|dQtjdR|tddr��}tjdU|t�tk	r�t'�dVdW�SdX}dY}|}tjdZ|t�s�tjd[|t�r�|}ntjd\|tds�} tjd]|t| �}!t#j$j%j(|d^|dQ|!�s^td_��ntd`da��iidbdc6idbdd6de6df6����fdg�}"t#j$j%j&|"dQtjdR|tddt��\}#}$|#�dh<|$�di<|�dj<tjdk|td|#�}%||dl<|$|di<tdm|t�}&|&j��td
ddndoj|�dtddp|ddddg�dtddtd�|&S(uu-
    Create a single VM from a data dict
    uprofileu	softlayerRunameudomaintdefaultu3A domain name is required for the SoftLayer driver.uuse_fqdnu.ucloud.fire_eventueventustarting createusalt/cloud/{0}/creatingtargsucloud.filter_eventucreatinguproviderudrivertsock_dirusock_dirt	transportu	transportuCreating Cloud VM %suhostnameu
cpu_numberu	startCpusuramu	maxMemoryuhourly_billinguhourlyBillingFlagu
local_disku
localDiskFlaguimageuoperatingSystemReferenceCodeublockDevicesu	disk_sizeu,iiudeviceucapacityu	diskImageiu�More that 5 disks were specified for %s .The first 5 disks will be applied to the VM, but the remaining disks will be ignored.
Please adjust your cloud configuration to only specify a maximum of 5 disks.uglobal_identifieruglobalIdentifierublockDeviceTemplateGroupu
datacenteruprivate_vlanuidunetworkVlanuprimaryBackendNetworkComponentuprivate_networkuTrueuprivateNetworkOnlyFlagupublic_vlanuprimaryNetworkComponentupublic_security_groupsu
securityGroupusecurityGroupBindingsuprivate_security_groupsu
max_net_speedi
umaxSpeedunetworkComponentsupost_uriupostInstallScriptUriudedicated_host_idu
dedicatedHosturequesting instanceusalt/cloud/{0}/requestingu
requestingukwargsuqError creating %s on SoftLayer

The following exception was thrown when trying to run the initial deployment: 
%stexc_info_on_logleveluprimaryIpAddressuprivate_sshuprivate_windowsuprimaryBackendIpAddressc@s6t�}�|�kr%|��Stjd�tS(u=
        Wait for the IP address to become available
        i(tlist_nodes_fullttimetsleepR(tnodes(thostnametip_type(s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pytwait_for_ip�s
	
ttimeoutuwait_for_fun_timeoutii<udeployR#uactionii�uwindowsu
win_installerussh_connect_timeoutuconnect_timeouttportu)Failed to authenticate against remote sshRuSoftLayer_Accountuu
powerStateu	passwordsuoperatingSystemu
virtualGuestsc@s��jd�dd��}xj|D]b}|d�dkr#d|dkr#|ddr#|dddd|ddddfSq#Wtjd	�tS(
u;
        Wait for the password to become available
        tiduidtmasku	passwordsuoperatingSystemiuusernameupasswordi(tgetVirtualGuestsR9R:R(t	node_infotnode(RBt	pass_connR&(s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pytget_credentials�s
.
uusernameupasswordu	public_ipussh_usernameussh_hostucloud.bootstrapucreated instanceusalt/cloud/{0}/createducreatedNi�i�i�()R
tis_profile_configuredRR
RtAttributeErrorRtNoneRR1tjoint	__utils__tformattlogtinfoR!t
isinstancetintRt	text_typetstring_typestsplittstriptappendtwarningR2tbooltTruetupdatetlisttcreateObjectt	ExceptionterrortloggingtDEBUGRRRtwait_for_funt
show_instancet
wait_for_port('RtnametdomainR%tkwargstlocal_disk_flagtdiskstsizetcounttdisktblock_devicetlocationtprivate_vlantprivate_networktpublic_vlantpublic_security_groupstsgt	secgroupstpnctprivate_security_groupstpbnct
max_net_speedtpost_uritdedicated_host_idtexctprivate_sshtprivate_wdsR>t
ip_addresstSSH_PORTtWINDOWS_DS_PORTt
managing_porttssh_connect_timeouttconnect_timeoutRGRtpasswdtssh_usernameR$((R<R=RBRFR&s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pytcreate�sh	




"
	


+


	
*
*

 
	
	
		






"
umask[id]cC@s�|dkrtd��ni}tdd�}|j�}x"|D]}|d}|||<qCWtd|tjd�dt�|S(	u;
    Return a list of the VMs that are on the provider
    uactionuBThe list_nodes_full function must be called with -f or --function.RuSoftLayer_Accountuhostnameucloud.cache_node_listu:i(RR!RCRLR
RTR(RBR#R$R%R&tnode_idR<((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pyR8s

!cC@s2|dkrtd��ni}t�}d|kr^tdj|dddd���nx�|D]�}i||dd	6||d
d6||dd
6||<d||kr�||d||d<nd||kr�||d||d<nd||kretj||dd�||d<qeqeW|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.uerroru*An error occurred while listing nodes: {0}uErrorsuErroruMessageuhostnameuidu	maxMemoryuramumaxCpuucpusuprimaryIpAddressu
public_ipsuprimaryBackendIpAddressuprivate_ipsustatusunameustate(RR8RMRRR(R#R$R;RE((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pyt
list_nodes!s*	
*cC@s tjjjt�td|�S(uO
    Return a list of the VMs that are on the provider, with select fields
    uquery.selection(RRRtlist_nodes_selectR8R(R#((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pyR�AscC@sD|dkrtd��nt�}td||tt�||S(u<
    Show the details from SoftLayer concerning a guest
    uactionu<The show_instance action must be called with -a or --action.ucloud.cache_node(RR8RLR
R(RdR#R;((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pyRbJs	cC@s|dkrtd��ntddddj|�di|d6d	td
dtd�t|d
d�}t�}|jd|d�}tddddj|�di|d6d	td
dtd�tjdt�t	krtd|t
jd�dt�n|S(um
    Destroy a node.

    CLI Example:

    .. code-block:: bash

        salt-cloud --destroy mymachine
    ufunctionuEThe destroy action must be called with -d, --destroy, -a or --action.ucloud.fire_eventueventudestroying instanceusalt/cloud/{0}/destroyingR4unameR5usock_dirR6u	transportR#uactionRAuidudestroyed instanceusalt/cloud/{0}/destroyeduupdate_cachedirucloud.delete_minion_cachediru:i(RRLRMRRbR!tdeleteObjectR1RRYR
RT(RdR#RER%R&((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pytdestroyXs.


	

$cC@s4|dkrtd��ntdd�}|j�S(u4
    List all VLANs associated with the account
    ufunctionu=The list_vlans function must be called with -f or --function.RuSoftLayer_Account(RR!tgetNetworkVlans(R#R%((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pyt
list_vlans�s
(*t__doc__t
__future__RRRR_R9tsalt.utils.cloudRtsalt.configR
tsalt.exceptionsRtsalt.extRRRYRtImportErrorRt	getLoggert__name__RNRR	RRRR!RJR(R,R.R0R2R�R8R�R�RbR�R�(((s?/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer.pyt<module>s@


	
		
	&	� 	+

Zerion Mini Shell 1.0