%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/cloud/clouds/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZ	ddl
jZddlm
Z
yddlZeZWnek
r�eZnXeje�ZdZd�Zd�Zd�Zd	�Zd
d�Zdd�Zdd
�Zdd�Zdd�Z d�Z!ddd�Z"dd�Z#dd�Z$dd�Z%dd�Z&dd�Z'ddd�Z(ddd�Z)dd�Z*dS(u�
SoftLayer HW Cloud Module
=========================

The SoftLayer HW cloud module is used to control access to the SoftLayer
hardware cloud 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_hw

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(tSaltCloudSystemExitusoftlayer_hwcC@s*t�tkrtSt�tkr&tStS(u-
    Check for SoftLayer configurations.
    (tget_configured_providertFalsetget_dependenciest__virtualname__(((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pyt__virtual__5s
cC@stjttptd�S(u/
    Return the first configured instance.
    uapikey(uapikey(tconfigtis_provider_configuredt__opts__t__active_provider_name__R(((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pyRBs	cC@stjtitd6�S(u*
    Warn if dependencies aren't met.
    u	softlayer(R	tcheck_driver_dependenciesRt
HAS_SLLIBS(((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pyRMscC@sRtjjjtjd|t�|ttjjjtjjjt|���}|S(u-
    Return the script deployment object
    uscript(	tsalttutilstcloudt	os_scriptR	tget_cloud_config_valueRtsalt_config_to_yamlt
minion_config(tvm_t
deploy_script((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pytscriptWsuSoftLayer_Hardwarec
C@sPtjdtjdt�tdt�dtjdt�tdt��}||S(u5
    Return a conn object for the passed VM data
    tusernameuusert
search_globaltapi_keyuapikey(t	SoftLayertClientR	RRRR(tservicetclient((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pytget_connfs	cC@s�|dkrtd��ni}tdd�}|jdd�}x=|D]5}i|dd6|dd6|d	d
6||d<qIW|jdd�}x>|D]6}|jdd�dkr�q�nt||d
d<q�W|S(u&
    List all available locations
    uactionufThe avail_locations function must be called with -f or --function, or with the --list-locations optionRuSoftLayer_Product_Packagetidi2uidunameulongNameulocationuisAvailableiu
locationIdu	available(RR tgetLocationstgetAvailableLocationstgettTrue(tcalltrettconnt	locationstlocationt	available((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pytavail_locationsus"

cC@s�|dkrtd��ni}tdd�}x�|jdd�D]m}|ddkr_qCnxN|d	D]B}x9|d
D]-}|dj�||d<||dd=q{WqjWqCW|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 optionRuSoftLayer_Product_PackageR!i2ucategoryCodeuserver_coreugroupsupricesuitemuid(RR t
getCategoriestcopy(R&R'R(tcategorytgrouptprice((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pytavail_sizes�scC@s�|dkrtd��ni}tdd�}x�|jdd�D]m}|ddkr_qCnxN|d	D]B}x9|d
D]-}|dj�||d<||dd=q{WqjWqCW|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 optionRuSoftLayer_Product_PackageR!i2ucategoryCodeuosugroupsupricesuitemuid(RR R-R.(R&R'R(R/R0R1((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pytavail_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(RR$R	RRR(R((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pytget_location�sc@sny=|dr<tjttpd|dd|�tkr<tSWntk
rPnX|d}|�tjd|tddV�}|dVkr�td�n|j	d�r�d	j
||g�}||d<ntd
ddd
j|�dtdd|ddddg�dtddtd�t
jd|�tdd�}idd6dd6i�d6|d6gd6d d!6i|d"d#6i|d$d#6i|d%d#6id&d#6id'd#6id(d#6id)d#6id*d#6id+d#6id,d#6g
d-6}tjd.|tdg�}x&|D]}|d-ji|d#6�qWtjd/|tdd0�}|d-ji|d#6�tjd1|tdd2�}|d-ji|d#6�tjd3|tddV�}	|	r�|d-ji|	d#6�ntjd4|tdt�}
|
rii|
d#6d56|d6<nt|�}|r#||d7<ntd
dd8d9j|�ditdd:|t|��d;6dtddtd�y|j|��Wn0tk
r�}t
jd<||d=tj�tSX�fd>�}
tjjj|
d?tjd@|tddW��}tjdC|tdD�}tjjj|d?|�s>tdE��ntddF��iidGdH6idGdI6dJ6dK6����fdL�}tjjj|d?tjd@|tddX��}|�dM<|�dN<tjdO|tddP�}||dQ<||dM<tdR|t�}|j��td
ddSdTj|�dtddU|ddddg�dtddtd�|S(Yu-
    Create a single VM from a data dict
    uprofileusoftlayer_hwRunameudomaintdefaultu3A 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 %sRuSoftLayer_Product_Orderu1SoftLayer_Container_Product_Order_Hardware_ServerucomplexTypeiuquantityuhostnameuhardwarei2u	packageIdusizeuiduhdduimageu905u21u55u57u58u420u418upricesuoptional_productsu
port_speediu	bandwidthiupost_uriuvlanunetworkVlanuprimaryNetworkComponentulocationurequesting instanceusalt/cloud/{0}/requestingu
requestingukwargsuqError creating %s on SoftLayer

The following exception was thrown when trying to run the initial deployment: 
%stexc_info_on_loglevelc@s6t�}d|�kr%|�dStjd�tS(u=
        Wait for the IP address to become available
        uprimaryIpAddressi(tlist_nodes_fullttimetsleepR(tnodes(thostname(sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pytwait_for_ip]s
	
ttimeoutuwait_for_fun_timeoutii<ussh_connect_timeouti�u)Failed to authenticate against remote sshuSoftLayer_Accountuu
powerStateu	passwordsuoperatingSystemu
virtualGuestsc@s��jd�dd��}xT|D]L}|d�dkr#d|dkr#|ddr#|ddddSq#Wtjd�tS(	u;
        Wait for the password to become available
        R!uidtmasku	passwordsuoperatingSystemiupasswordi(tgetVirtualGuestsR;R<R(t	node_infotnode(RAt	pass_conntresponse(sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pyt
get_passwd�s

upasswordu	public_ipussh_usernameurootussh_hostucloud.bootstrapucreated instanceusalt/cloud/{0}/createducreatedNi�i�(R	tis_profile_configuredRRRtAttributeErrorRtNoneRR$tjoint	__utils__tformattlogtinfoR tappendR4tlistt
placeOrdert	ExceptionterrortloggingtDEBUGRRRtwait_for_funt
wait_for_porttupdate(RtnametdomainR(tkwargstoptional_productstproductt
port_speedt	bandwidthtpost_uritvlan_idR*texcR?t
ip_addresstssh_connect_timeoutRGtpasswdtssh_usernameR'((R>RARERFsB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pytcreate�s�	




"








 
	

	





"
uomask[id, hostname, primaryIpAddress,         primaryBackendIpAddress, processorPhysicalCoreAmount, memoryCount]cC@s�|dkrtd��ni}tdd�}|jd|�}x|D]}|||d<qIWtd|tjd�d	t�|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_AccountRAuhostnameucloud.cache_node_listu:i(RR tgetHardwareRLRtsplitR(RAR&R'R(RFRD((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pyR:�s
!cC@s�|dkrtd��ni}t�}d|kr^tdj|dddd���nx�|D]�}i||dd	6||d
d6||dd
6||<d||kr�||d||d<nd||kre||d||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}uErrorsuErroruMessageuhostnameuidumemoryCounturamuprocessorPhysicalCoreAmountucpusuprimaryIpAddressu
public_ipsuprimaryBackendIpAddressuprivate_ips(RR:RM(R&R'R=RD((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.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_selectR:R(R&((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pyRl�s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(RR:RLRR(RZR&R=((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pyt
show_instance�s	cC@s.|dkrtd��ntddddj|�di|d6d	td
dtd�t|d
d�}tdd�}|ji|dd6dd6dd6td6dd6�}tddddj|�di|d6d	td
dtd�tjdt	�tkr*td|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}/destroyingR6unameR7usock_dirR8u	transportR&uactionRuSoftLayer_Ticketuidu'Salt Cloud Hardware Server CancellationureasonuPlease cancel this serverucontentucancelAssociatedItemsuHARDWAREuattachmentTypeudestroyed instanceusalt/cloud/{0}/destroyeduupdate_cachedirucloud.delete_minion_cachediru:i(RRLRMRRmR tcreateCancelServerTicketR%R$RRRj(RZR&RDR(RF((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pytdestroy�s:





$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(((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pyt
list_vlans)s
c
	C@s|tdj|di�}|s+idd6S|jdd�}|jd�}t|�dksn|d	d
kryidd6Si}i}d|d
<tdd�}xe|D]]}|dkr�q�n|jd||�}	|	||<|d
ctj|	jdd��7<q�W|d
d|d<|dd|d<|dd|d<|dd|d<|jdt�rm||d<ni||d6S(u%
    Show pricing for a particular profile. This is only an estimate, based on
    unofficial pricing sources.

    CLI Examples:

    .. code-block:: bash

        salt-cloud -f show_pricing my-softlayerhw-config profile=my-profile

    If pricing sources have not been cached, they will be downloaded. Once they
    have been cached, they will not be updated automatically. To manually update
    all prices, use the following command:

    .. code-block:: bash

        salt-cloud -f update_pricing <provider>

    .. versionadded:: 2015.8.0
    uprofilesuprofileu#The requested profile was not founduErroruprovideru0:0u:iiusoftlayer_hwu5The requested profile does not belong to Softlayer HWiuper_hourRuSoftLayer_Product_Item_PriceulocationR!uhourlyRecurringFeeiuper_dayiuper_weekiu	per_monthi4uper_yearurawu_raw(uprofileuproviderulocation(	RR$RjtlenR t	getObjecttdecimaltDecimalR(
R\R&tprofiletprovidertcompstrawR'R(titemR1((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pytshow_pricing6s0"


)
cC@s�|dkrtd��n|d
kr0i}ntdd�}d|kr[|jdd�Si}x�|jdd�D]q}|d|dkr�qtnxN|d	D]B}x9|d
D]-}|dj�||d<||dd=q�Wq�WqtW|S(u<
    Return a dict of all prices on the cloud provider.
    uactionuBThe show_all_prices function must be called with -f or --function.RuSoftLayer_Product_PackageucodeR!i2ucategoryCodeugroupsupricesuitemuidN(RRJR R-R.(R&R\R(R'R/R0R1((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pytshow_all_pricesks"	cC@si|dkrtd��ntdd�}g}x+|jdd�D]}|j|d�qCWi|d6S(	uj
    Return a dict of all available categories on the cloud provider.

    .. versionadded:: 2016.3.0
    uactionuFThe show_all_categories function must be called with -f or --function.RuSoftLayer_Product_PackageR!i2ucategoryCodeucategory_codes(RR R-RP(R&R(t
categoriesR/((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pytshow_all_categories�s(+t__doc__t
__future__RRRRUR;Rttsalt.utils.cloudRtsalt.configR	tsalt.exceptionsRRR%RtImportErrorRt	getLoggert__name__RNRRRRRR RJR,R2R3R4RhR:RkRlRmRoRqR{R|R~(((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/softlayer_hw.pyt<module>sD


	
		
		�	3
5

Zerion Mini Shell 1.0