%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlj	Z	ddl
Zddlm
Z
ddlmZeje�Zy#ejd�ddlZeZWnek
r�eZnXyddlmZe�Wnek
r�nXdZd�Zd	�Zd
�Zd�Z ded�Z"ded
�Z#ded�Z$ded�Z%ded�Z&ded�Z'dd�Z(dd�Z)dd�Z*d�Z+d�Z,dd�Z-dS(u�
CenturyLink Cloud Module
===================

.. versionadded:: Oyxgen

The CLC cloud module allows you to manage CLC Via the CLC SDK.

:codeauthor: Stephan Looney <slooney@stephanlooney.com>


Dependencies
============

- clc-sdk Python Module
- flask

CLC SDK
-------

clc-sdk can be installed via pip:

.. code-block:: bash

    pip install clc-sdk

.. note::
  For sdk reference see: https://github.com/CenturyLinkCloud/clc-python-sdk

Flask
-------
flask can be installed via pip:
.. code-block:: bash
    pip install flask

Configuration
=============

To use this module: set up the clc-sdk, user, password, key in the
cloud configuration at
``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/clc.conf``:

.. code-block:: yaml

    my-clc-config:
      driver: clc
      user: 'web-user'
      password: 'verybadpass'
      token: ''
      token_pass:''
      accountalias: 'ACT'
.. note::

    The ``provider`` parameter in cloud provider configuration was renamed to ``driver``.
    This change was made to avoid confusion with the ``provider`` parameter that is
    used in cloud profile configuration. Cloud provider configuration now uses ``driver``
    to refer to the salt-cloud driver that provides the underlying functionality to
    connect to a cloud provider, while cloud profile configuration continues to use
    ``provider`` to refer to the cloud provider configuration that you define.

i(tabsolute_importtprint_functiontunicode_literalsN(tSaltCloudSystemExit(tsixuclc(tdisable_warningscC@s&t�tkst�tkr"tStS(uI
    Check for CLC configuration and if required libs are available.
    (tget_configured_providertFalsetget_dependenciest__virtualname__(((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pyt__virtual__cscC@stjttptd�S(Nutokenu
token_passuuserupassword(utokenu
token_passuuserupassword(tconfigtis_provider_configuredt__opts__t__active_provider_name__R	(((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pyRms	cC@sitd6}tjt|�S(u*
    Warn if dependencies aren't met.
    uclc(tHAS_CLCRtcheck_driver_dependenciesR	(tdeps((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pyRus

cC@s�tjdt�tdt�}tjdt�tdt�}tjdt�tdt�}tjdt�tdt�}tjdt�tdt�}i|d6|d6|d6|d6|d6}|S(Nuusert
search_globalupassworduaccountaliasutokenu
token_pass(Rtget_cloud_config_valueRR
R(tusertpasswordtaccountaliasttokent
token_passtcreds((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pyt	get_creds�s)cC@s�|dkrtd��nt�}tjj|d|d�tjjjdd�}tj	j
j|�}tj	j
j|�}|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.utokenu
token_passtlocationN(
RRtclctv1tSetCredentialstServert
GetServerstNonetsalttutilstjsontdumpstloads(tcallt
for_outputRtservers_rawtservers((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pytlist_nodes_full�s	cC@s:t�}tjj|d|d�tjjj�}|S(Nutokenu
token_pass(RRRRtQueuetList(R'R(Rtcl_queue((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pytget_queue_data�s	cC@s�t�}tjj|d|d�|dkr?td��nyhtjjjd|d�}tjj	j
|�}tjj	j|�}t|dd�}i|d	6SWnt
k
r�id
d	6SXdS(u;
    Return a list of the VMs that are on the provider
    utokenu
token_passuactionuBThe list_nodes_full function must be called with -f or --function.taliasuaccountaliasuMonthlyEstimateiuMonthly EstimateiN(RRRRRtBillingtGetAccountSummaryR"R#R$R%R&troundtRuntimeError(R'R(Rtbilling_rawtbilling((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pytget_monthly_estimate�s	
cC@s�t�}tjj|d|d�|dkr?td��nyhtjjjd|d�}tjj	j
|�}tjj	j|�}t|dd�}i|d	6SWnt
k
r�d
SXdS(u;
    Return a list of the VMs that are on the provider
    utokenu
token_passuactionuBThe list_nodes_full function must be called with -f or --function.R0uaccountaliasuMonthToDateTotaliu
Month To DateiN(RRRRRR1R2R"R#R$R%R&R3R4(R'R(RR5R6((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pytget_month_to_date�s	
cK@sxx5|j�D]'\}}d}|dkr
|}q
q
Wt�}tjj|d|d�tjj|�j�}|S(uE
    Return a list of alerts from CLC as reported by their infra
    uu
servernameuuserupassword(titemsRRtv2RRtAlerts(R'R(tkwargstkeytvaluet
servernameRtalerts((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pytget_server_alerts�s
	cK@s9xP|j�D]B\}}d}d}|dkr:|}n|dkr
|}q
q
Wt�}tjj|d|d�|dkr�td��ny�tjjjd|d	|d
d|�}tj	j
j|�}tj	j
j|�}	t
|	dd
�}
t
|	dd
�}i|
d6|d6SWntk
r4dSXdS(u�
    Return a list of the VMs that are on the provider
    usage: "salt-cloud -f get_group_estimate clc group=Dev location=VA1"
    uugroupulocationutokenu
token_passuactionuBThe list_nodes_full function must be called with -f or --function.tgroupR0uaccountaliasRuMonthlyEstimateiuMonthToDateuMonthly Estimateu
Month to DateiN(R9RRRRRR1tGetGroupEstimateR"R#R$R%R&R3R4(R'R(R<R=R>RBRRR5R6testimatet
month_to_date((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pytget_group_estimate�s*	
	(
cC@sIt�}i}x3|D]+}|dr|ji|dd6�qqW|S(u3
    returns a list of images available to you
    u
IsTemplateuNameu
Template Name(R+tupdate(R'tall_serverst	templatestserver((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pytavail_imagess	

cC@s:t�}tjj|d|d�tjjj�}|S(u6
    returns a list of locations available to you
    utokenu
token_pass(RRRRtAccounttGetLocations(R'Rt	locations((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pytavail_locationss	cC@sidd6S(u 
    use templates for this
    u;Sizes are built into templates. Choose appropriate templateuSizes((R'((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pytavail_sizesscC@s�d}tj|�}x�|dkr�tjjjd|�}|ddkr�|dd}t�}tjj|d|d�tjj	|�j
}|dd	}|S|d
}tjd|tjd|��t
jd�qWd
S(uL
    get the build status from CLC to make sure we dont return to early
    ii
t
request_iduPercentCompleteiduServersuuserupassworduinternaliu+Creating Cloud VM %s Time out in %s minutesi<N(Rt	text_typeRRt	Blueprintt	GetStatusRR:RRtip_addressestlogtinfottimetsleep(treq_idtnodenametcountertqueuetserver_nameRRUtinternal_ip_address((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pytget_build_statuss	
	cC@s�t�}tjj|d|d�tjttp6td-�}tj	d|tdt
dd.�}|d}tj	d|tdt
dd.�}tj	d|tdt
dd.�}tj	d	|tdt
dd.�}tj	d
|tdt
dd.�}tj	d|tdt
dd.�}	tj	d|tdt
dd.�}
tj	d
|tdt
dd.�}tj	d|tdt
dd.�}t|�dkr�|dd!}nt|	�dkr�d}	ntjj
jdd.d|d|d|d|
d|d|d|d|d|d|	�}
|
d}t||�|d<td d!d"d#j|�d$td%d&i|dd'6d(td)�td*|t�}i|d+6|dd,6}|j|�|S(/u$
    get the system build going
    utokenu
token_passugroupRtdefaultunameudescriptionuramubackup_levelutemplateupassworducpuunetworkulocationiii	uR0Rtnamettemplatetcputramtbackup_levelRBtnetworktdescriptionRu	RequestIDussh_hostucloud.fire_eventueventuwaiting for sshusalt/cloud/{0}/waiting_for_sshtsock_dirusock_dirtargsu
ip_addresst	transportu	transportucloud.bootstrapuServer Nameu
IP Address(utokenN(RRRRRRR
RR	RRR!tlenRtCreateR`t	__utils__tformatRG(tvm_Rt
cloud_profileRBRbRhReRfRcRRdRgRt
clc_returnRZtrettreturn_message((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pytcreate3sV			
	T


cC@sidd6S(u
    destroy the vm
    u?destroying must be done via https://control.ctl.io at this timeustatus((RbR'((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pytdestroyqs(.t__doc__t
__future__RRRt	importlibtloggingRXtsalt.configRtsalt.utils.jsonR"tsalt.exceptionsRtsalt.extRt	getLoggert__name__RVt
import_moduleRtTrueRtImportErrorRtrequests.packages.urllib3Rt	ExceptionR	R
RRRR!R+R/R7R8RARFRKRORPR`RuRv(((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/clc.pyt<module>>sJ




	
		
	
		>

Zerion Mini Shell 1.0