%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddl	m
Z
ddlmZ
eje�ZdZy�ddlZddlmZddlmZmZeed	�r�e
ej�e
e�kr�e��nejd
�jej�eZWnek
reZnXd�Z d�Z!d
�Z"d�Z#d�Z$d�Z%ddd�Z'd�Z(d�Z)d�Z*d�Z+dd�Z,d�Z-d�Z.d�Z/d�Z0d�Z1dS(u
Apache Libcloud Load Balancer Management
========================================

Connection module for Apache Libcloud Storage load balancer management for a full list
of supported clouds, see http://libcloud.readthedocs.io/en/latest/loadbalancer/supported_providers.html

Clouds include Amazon ELB, ALB, Google, Aliyun, CloudStack, Softlayer

.. versionadded:: 2018.3.0

:configuration:
    This module uses a configuration profile for one or multiple Storage providers

    .. code-block:: yaml

        libcloud_loadbalancer:
            profile_test1:
              driver: gce
              key: GOOG0123456789ABCXYZ
              secret: mysecret
            profile_test2:
              driver: alb
              key: 12345
              secret: mysecret

:depends: apache-libcloud
i(tabsolute_importtunicode_literalstprint_functionN(tsix(tLooseVersionu1.5.0(t
get_driver(tMembert	Algorithmu__version__ulibcloudcC@s#tsdjt�}t|fStS(u0
    Only load if libcloud libraries exist.
    uAA apache-libcloud library with version at least {0} was not found(tHAS_LIBCLOUDtformattREQUIRED_LIBCLOUD_VERSIONtFalsetTrue(tmsg((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pyt__virtual__>s
	
cC@stjjjt�dS(N(tsalttutilstcompattpack_dundert__name__(topts((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pyt__init__IscC@sJitjd6tjd6tjd6tjd6tjd6tjd6tjd6S(NuRANDOMuROUND_ROBINuLEAST_CONNECTIONSuWEIGHTED_ROUND_ROBINuWEIGHTED_LEAST_CONNECTIONSuSHORTEST_RESPONSEu
PERSISTENT_IP(RtRANDOMtROUND_ROBINtLEAST_CONNECTIONStWEIGHTED_ROUND_ROBINtWEIGHTED_LEAST_CONNECTIONStSHORTEST_RESPONSEt
PERSISTENT_IP(((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pyt_algorithm_mapsMs





cC@s�tdd�|}t|d�}|j�}|d=|jd�|d<|jdd�|d<|ddkrz|d=n|jdt�|d<|jdd�|d<|jdd�|d<||�S(	Nu
config.optionulibcloud_loadbalancerudriverukeyusecretusecureuhostuport(t__salt__RtcopytgettNoneR(tprofiletconfigtclstargs((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pyt_get_driverYs
cK@satd|�}tjjj|�}|j|�}g}x!|D]}|jt|��q@W|S(uP
    Return a list of load balancers.

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's list_balancers method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_storage.list_balancers profile1
    R"(R&RRR%tclean_kwargstlist_balancerstappendt_simple_balancer(R"tlibcloud_kwargstconnt	balancerstrettbalancer((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pyR(hs
cK@s1td|�}tjjj|�}|j|�S(u�
    Return a list of supported protocols.

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's list_protocols method
    :type  libcloud_kwargs: ``dict``

    :return: a list of supported protocols
    :rtype: ``list`` of ``str``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_storage.list_protocols profile1
    R"(R&RRR%R'tlist_protocols(R"R+R,((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pyR0�sc
K@s�|dkrtj}n"t|tj�r:t�|}ng}|dk	r�t|t�r�xG|D]0}|jt	ddd|dd|d��qbWq�t
d��ntjj
j|�}td|�}	|	j||||||�}
t|
�S(	uZ
    Create a new load balancer instance

    :param name: Name of the new load balancer (required)
    :type  name: ``str``

    :param port: Port the load balancer should listen on, defaults to 80
    :type  port: ``str``

    :param protocol: Loadbalancer protocol, defaults to http.
    :type  protocol: ``str``

    :param algorithm: Load balancing algorithm, defaults to ROUND_ROBIN. See Algorithm type
        in Libcloud documentation for a full listing.
    :type algorithm: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's create_balancer method
    :type  libcloud_kwargs: ``dict``

    :return: The details of the new balancer

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_storage.create_balancer my_balancer 80 http profile1
    tidtipuiptportuportumembers must be of type listR"N(R!RRt
isinstanceRtstring_typesRtlistR)Rt
ValueErrorRRR%R'R&tcreate_balancerR*(tnameR3tprotocolR"t	algorithmtmembersR+tstarting_memberstmR,R/((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pyR8�s
1cK@sCtd|�}tjjj|�}|j|�}|j||�S(u
    Destroy a load balancer

    :param balancer_id: LoadBalancer ID which should be used
    :type  balancer_id: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's destroy_balancer method
    :type  libcloud_kwargs: ``dict``

    :return: ``True`` if the destroy was successful, otherwise ``False``.
    :rtype: ``bool``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_storage.destroy_balancer balancer_1 profile1
    R"(R&RRR%R'tget_balancertdestroy_balancer(tbalancer_idR"R+R,R/((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pyR@�scK@s�td|�}tjjj|�}|j|�}g|D]}|j|kr:|^q:}t|�dkr{t|d�St|�dkr�t	d��nt	d��dS(u�
    Get the details for a load balancer by name

    :param name: Name of a load balancer you want to fetch
    :type  name: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's list_balancers method
    :type  libcloud_kwargs: ``dict``

    :return: the load balancer details

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_storage.get_balancer_by_name my_balancer profile1
    R"iiu*Ambiguous argument, found mulitple recordsuBad argument, found no recordsN(
R&RRR%R'R(R9tlenR*R7(R9R"R+R,R-tbtmatch((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pytget_balancer_by_name�s(cK@s@td|�}tjjj|�}|j||�}t|�S(u�
    Get the details for a load balancer by ID

    :param balancer_id: id of a load balancer you want to fetch
    :type  balancer_id: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's get_balancer method
    :type  libcloud_kwargs: ``dict``

    :return: the load balancer details

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_storage.get_balancer balancer123 profile1
    R"(R&RRR%R'R?R*(RAR"R+R,R/((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pyR?scK@s1td|�}tjjj|�}|j|�S(u�
    Get the supported algorithms for a profile

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's list_supported_algorithms method
    :type  libcloud_kwargs: ``dict``

    :return: The supported algorithms

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_storage.list_supported_algorithms profile1
    R"(R&RRR%R'tlist_supported_algorithms(R"R+R,((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pyRF#sc
K@sytd|�}tjjj|�}tddd|d|ddd|�}|j|�}|j|||�}	t	|	�S(ue
    Add a new member to the load balancer

    :param balancer_id: id of a load balancer you want to fetch
    :type  balancer_id: ``str``

    :param ip: IP address for the new member
    :type  ip: ``str``

    :param port: Port for the new member
    :type  port: ``int``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's balancer_attach_member method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_storage.balancer_attach_member balancer123 1.2.3.4 80 profile1
    R"R1R2R3R/textraN(
R&RRR%R'RR!R?tbalancer_attach_membert_simple_member(
RAR2R3R"RGR+R,tmemberR/tmember_saved((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pyRH:s'c	K@s�td|�}|j|�}|jd|�}g|D]}|j|kr7|^q7}t|�dkrytd��n+t|�dkr�td��n
|d}tjjj	|�}|j
d|d||�S(ud
    Add a new member to the load balancer

    :param balancer_id: id of a load balancer you want to fetch
    :type  balancer_id: ``str``

    :param ip: IP address for the new member
    :type  ip: ``str``

    :param port: Port for the new member
    :type  port: ``int``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's balancer_detach_member method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_storage.balancer_detach_member balancer123 member123 profile1
    R"R/iu*Ambiguous argument, found mulitple recordsiuBad argument, found no recordsRJ(R&R?tbalancer_list_membersR1RBR7RRR%R'tbalancer_detach_member(	RAt	member_idR"R+R,R/R<RJRD((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pyRM[s(
cK@setd|�}|j|�}tjjj|�}|jd||�}g|D]}t|�^qOS(u�
    List the members of a load balancer

    :param balancer_id: id of a load balancer you want to fetch
    :type  balancer_id: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's list_balancer_members method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_storage.list_balancer_members balancer123 profile1
    R"R/(R&R?RRR%R'RLRI(RAR"R+R,R/R<RJ((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pytlist_balancer_members�s
cK@s=tjjj|�}td|�}t||�}||�S(u�
    Call an extended method on the driver

    :param method: Driver's method name
    :type  method: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_loadbalancer.extra ex_get_permissions google container_name=my_container object_name=me.jpg --out=yaml
    R"(RRR%R'R&tgetattr(tmethodR"R+R,tconnection_method((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pyRG�scC@s@i|jd6|jd6|jd6|jd6|jd6|jd6S(Nuidunameustateuipuportuextra(R1R9tstateR2R3RG(R/((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pyR*�s




cC@s<i|jd6|jd6|jd6t|j�d6|jd6S(Nuiduipuportubalanceruextra(R1R2R3R*R/RG(RJ((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pyRI�s


(2t__doc__t
__future__RRRtloggingtsalt.utils.argsRtsalt.utils.compattsalt.extRtsalt.utils.versionsRt
_LooseVersiont	getLoggerRtlogR
tlibcloudtlibcloud.loadbalancer.providersRtlibcloud.loadbalancer.baseRRthasattrt__version__tImportErrortsetLeveltCRITICALRRRRRRR&R(R0R!R8R@RER?RFRHRMRORGR*RI(((sF/usr/lib/python2.7/site-packages/salt/modules/libcloud_loadbalancer.pyt<module>sF*


						2		!		!	'			

Zerion Mini Shell 1.0