%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/boto_elbv2.pyc

�
���^c@@sadZddlmZmZmZddlZeje�Zddl	m
Z
ddlZyKddl
Z
ddlZddlmZejd�jej�eZWnek
r�eZnXd�Zdddddd	d
dddd
d�Zddddd�Zddddd�Zdddddd�Zddddd�Zddddd�ZdS(u�
Connection module for Amazon ALB

.. versionadded:: 2017.7.0

:configuration: This module accepts explicit elb credentials but can also utilize
    IAM roles assigned to the instance through Instance Profiles. Dynamic
    credentials are then automatically obtained from AWS API and no further
    configuration is necessary. More Information available at:

    .. code-block:: text

        http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html

    If IAM roles are not used you need to specify them either in a pillar or
    in the minion's config file:

    .. code-block:: yaml

        elbv2.keyid: GKTADJGHEIQSXMKKRBJ08H
        elbv2.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
        elbv2.region: us-west-2

    If a region is not specified, the default is us-east-1.

    It's also possible to specify key, keyid and region via a profile, either
    as a passed in dict, or as a string to pull from pillars or minion config:

    .. code-block:: yaml

        myprofile:
            keyid: GKTADJGHEIQSXMKKRBJ08H
            key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
            region: us-east-1

:depends: boto3

i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tClientErroruboto3cC@s6tjjj�}|tkr2tdtd�n|S(u-
    Only load if boto3 libraries exist.
    uboto3.assign_funcsuelbv2(tsalttutilstversionstcheck_boto_reqstTruet	__utils__t__name__(t
has_boto_reqs((s;/usr/lib/python2.7/site-packages/salt/modules/boto_elbv2.pyt__virtual__EsuHTTPutraffic-portu/iiicC@std|d|d|d|�}t|||||�r=tSy�|jd|d|d|d|d	|d
|	d|
d|d
|d|
d|�}|r�tjd||ddd�tStjd|�tSWnHtk
r}tjd||j	dd|j	dddt
j�nXdS(u�
    Create target group if not present.

    name
        (string) - The name of the target group.
    protocol
        (string) - The protocol to use for routing traffic to the targets
    port
        (int) - The port on which the targets receive traffic. This port is used unless
        you specify a port override when registering the traffic.
    vpc_id
        (string) - The identifier of the virtual private cloud (VPC).
    health_check_protocol
        (string) - The protocol the load balancer uses when performing health check on
        targets. The default is the HTTP protocol.
    health_check_port
        (string) - The port the load balancer uses when performing health checks on
        targets. The default is 'traffic-port', which indicates the port on which each
        target receives traffic from the load balancer.
    health_check_path
        (string) - The ping path that is the destination on the targets for health
        checks. The default is /.
    health_check_interval_seconds
        (integer) - The approximate amount of time, in seconds, between health checks
        of an individual target. The default is 30 seconds.
    health_check_timeout_seconds
        (integer) - The amount of time, in seconds, during which no response from a
        target means a failed health check. The default is 5 seconds.
    healthy_threshold_count
        (integer) - The number of consecutive health checks successes required before
        considering an unhealthy target healthy. The default is 5.
    unhealthy_threshold_count
        (integer) - The number of consecutive health check failures required before
        considering a target unhealthy. The default is 2.

    returns
        (bool) - True on success, False on failure.

    CLI example:
    .. code-block:: bash

        salt myminion boto_elbv2.create_target_group learn1give1 protocol=HTTP port=54006 vpc_id=vpc-deadbeef
    tregiontkeytkeyidtprofiletNametProtocoltPorttVpcIdtHealthCheckProtocoltHealthCheckPorttHealthCheckPathtHealthCheckIntervalSecondstHealthCheckTimeoutSecondstHealthyThresholdCounttUnhealthyThresholdCountuCreated ALB %s: %suTargetGroupsiuTargetGroupArnuFailed to create ALB %suFailed to create ALB %s: %s: %suErroruCodeuMessagetexc_info_on_loglevelN(t	_get_connttarget_group_existsR	tcreate_target_grouptlogtinfoterrortFalseRtresponsetloggingtDEBUG(tnametprotocoltporttvpc_idRRRRthealth_check_protocolthealth_check_portthealth_check_paththealth_check_interval_secondsthealth_check_timeout_secondsthealthy_threshold_counttunhealthy_threshold_counttconntalbR#((s;/usr/lib/python2.7/site-packages/salt/modules/boto_elbv2.pyR Os.;!	c		C@std|d|d|d|�}t|||||�s=tSy�|jd�rr|jd|�tjd|�nd|jd|g�}t|d	�d
kr�t	S|d	dd}|jd|�tjd
||�tSWn-t
k
r
}tjd|dtj
�t	SXdS(up
    Delete target group.

    name
        (string) - Target Group Name or Amazon Resource Name (ARN).

    returns
        (bool) - True on success, False on failure.

    CLI example:

    .. code-block:: bash

        salt myminion boto_elbv2.delete_target_group arn:aws:elasticloadbalancing:us-west-2:644138682826:targetgroup/learn1give1-api/414788a16b5cf163
    RRRRuarn:aws:elasticloadbalancingtTargetGroupArnuDeleted target group %stNamesuTargetGroupsiiuTargetGroupArnuDeleted target group %s ARN %su Failed to delete target group %sRN(RRR	t
startswithtdelete_target_groupR!R"tdescribe_target_groupstlenR$RR#R&R'(	R(RRRRR3ttg_infotarnR#((s;/usr/lib/python2.7/site-packages/salt/modules/boto_elbv2.pyR8�s$!
c	C@s�td|d|d|d|�}y^|jd�rK|jd|g�}n|jd|g�}|rjtStjd|�tSWn'tk
r�}tjd	||�tSXd
S(u�
    Check to see if an target group exists.

    CLI example:

    .. code-block:: bash

        salt myminion boto_elbv2.target_group_exists arn:aws:elasticloadbalancing:us-west-2:644138682826:targetgroup/learn1give1-api/414788a16b5cf163
    RRRRuarn:aws:elasticloadbalancingtTargetGroupArnsR6u,The target group does not exist in region %su-target_group_exists check for %s returned: %sN(RR7R9R	R!twarningR$R(R(RRRRR3R4R#((s;/usr/lib/python2.7/site-packages/salt/modules/boto_elbv2.pyR�s!c
	C@s�td|d|d|d|�}y�|rpg}x"|D]}|ji|d6�q7W|jd|d|�}	n|jd|�}	i}
x6|	dD]*}|
ji|d	d
|dd6�q�W|
SWn!tk
r�}tj|�iSXdS(
u*
    Get the curret health check status for targets in a target group.

    CLI example:

    .. code-block:: bash

        salt myminion boto_elbv2.describe_target_health arn:aws:elasticloadbalancing:us-west-2:644138682826:targetgroup/learn1give1-api/414788a16b5cf163 targets=["i-isdf23ifjf"]
    RRRRuIdR5tTargetsuTargetHealthDescriptionsuTargetHealthuStateuTargetN(Rtappendtdescribe_target_healthtupdateRR!R>(
R(ttargetsRRRRR3ttargetsdictttargett	instancestrettinstanceR#((s;/usr/lib/python2.7/site-packages/salt/modules/boto_elbv2.pyRA�s!
(
c
C@s�g}t|tj�s*t|tj�rA|ji|d6�n%x"|D]}|ji|d6�qHWtd|d|d|d|�}y*|jd|d|�}	|	r�tStSWn!t	k
r�}
t
j|
�tSXdS(	u�
    Register targets to a target froup of an ALB. ``targets`` is either a
    instance id string or a list of instance id's.

    Returns:

    - ``True``: instance(s) registered successfully
    - ``False``: instance(s) failed to be registered

    CLI example:

    .. code-block:: bash

        salt myminion boto_elbv2.register_targets myelb instance_id
        salt myminion boto_elbv2.register_targets myelb "[instance_id,instance_id]"
    uIdRRRRR5R?N(t
isinstanceRtstring_typest	text_typeR@Rtregister_targetsR	R$RR!R>(R(RCRRRRRDRER3tregistered_targetsR#((s;/usr/lib/python2.7/site-packages/salt/modules/boto_elbv2.pyRLs$
!
c
C@s�g}t|tj�s*t|tj�rA|ji|d6�n%x"|D]}|ji|d6�qHWtd|d|d|d|�}y*|jd|d|�}	|	r�tStSWn!t	k
r�}
t
j|
�tSXdS(	u�
    Deregister targets to a target froup of an ALB. ``targets`` is either a
    instance id string or a list of instance id's.

    Returns:

    - ``True``: instance(s) deregistered successfully
    - ``False``: instance(s) failed to be deregistered

    CLI example:

    .. code-block:: bash

        salt myminion boto_elbv2.deregister_targets myelb instance_id
        salt myminion boto_elbv2.deregister_targets myelb "[instance_id,instance_id]"
    uIdRRRRR5R?N(RIRRJRKR@Rtderegister_targetsR	R$RR!R>(R(RCRRRRRDRER3RMR#((s;/usr/lib/python2.7/site-packages/salt/modules/boto_elbv2.pyRN;s$
!
(t__doc__t
__future__RRRR&t	getLoggerRR!tsalt.extRtsalt.utils.versionsRtboto3tbotocoretbotocore.exceptionsRtsetLeveltCRITICALR	tHAS_BOTOtImportErrorR$R
tNoneR R8RRARLRN(((s;/usr/lib/python2.7/site-packages/salt/modules/boto_elbv2.pyt<module>'s\


	J( %

Zerion Mini Shell 1.0