%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/states/boto_elb.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlZ	ddlm
Z
ddlmZeje�Zd�Zddddddddddd	dd
dddddedddd�Zddddd�Zd
Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"ddddd�Z#d�Z$dS(u<
Manage ELBs

.. versionadded:: 2014.7.0

Create and destroy ELBs. Be aware that this interacts with Amazon's
services, and so may incur charges.

This module uses ``boto``, which can be installed via package, or pip.

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 `here
<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 file or
in the minion's config file:

.. code-block:: yaml

    elb.keyid: GKTADJGHEIQSXMKKRBJ08H
    elb.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

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

.. code-block:: yaml

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

.. code-block:: yaml

    Ensure myelb ELB exists:
        boto_elb.present:
            - name: myelb
            - region: us-east-1
            - availability_zones:
                - us-east-1a
                - us-east-1c
                - us-east-1d
            - keyid: GKTADJGHEIQSXMKKRBJ08H
            - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
            - listeners:
                - elb_port: 443
                  instance_port: 80
                  elb_protocol: HTTPS
                  instance_protocol: HTTP
                  certificate: 'arn:aws:iam::1111111:server-certificate/mycert'
                  policies:
                      - my-ssl-policy
                      - cookie-policy
                - elb_port: 8210
                  instance_port: 8210
                  elb_protocol: TCP
            - backends:
                - instance_port: 80
                  policies:
                      - enable-proxy-protocol
            - health_check:
                target: 'HTTP:80/'
            - attributes:
                cross_zone_load_balancing:
                  enabled: true
                access_log:
                  enabled: true
                  s3_bucket_name: 'mybucket'
                  s3_bucket_prefix: 'my-logs'
                  emit_interval: 5
                connecting_settings:
                  idle_timeout: 60
            - cnames:
                - name: mycname.example.com.
                  zone: example.com.
                  ttl: 60
                - name: myothercname.example.com.
                  zone: example.com.
            - security_groups:
                - my-security-group
            - policies:
                - policy_name: my-ssl-policy
                  policy_type: SSLNegotiationPolicyType
                  policy:
                    Protocol-TLSv1.2: true
                    Protocol-SSLv3: false
                    Server-Defined-Cipher-Order: true
                    ECDHE-ECDSA-AES128-GCM-SHA256: true
                - policy_name: cookie-policy
                  policy_type: LBCookieStickinessPolicyType
                  policy: {}  # no policy means this is a session cookie
                - policy_name: enable-proxy-protocol
                  policy_type: ProxyProtocolPolicyType
                  policy:
                    ProxyProtocol: true

    # Using a profile from pillars
    Ensure myelb ELB exists:
        boto_elb.present:
            - name: myelb
            - region: us-east-1
            - profile: myelbprofile

    # Passing in a profile
    Ensure myelb ELB exists:
        boto_elb.present:
            - name: myelb
            - region: us-east-1
            - profile:
                keyid: GKTADJGHEIQSXMKKRBJ08H
                key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

It's possible to specify attributes from pillars by specifying a pillar. You
can override the values defined in the pillard by setting the attributes on the
resource. The module will use the default pillar key 'boto_elb_attributes',
which allows you to set default attributes for all ELB resources.

Setting the attributes pillar:

.. code-block:: yaml

    my_elb_attributes:
      cross_zone_load_balancing:
        enabled: true
      connection_draining:
        enabled: true
        timeout: 20
      access_log:
        enabled: true
        s3_bucket_name: 'mybucket'
        s3_bucket_prefix: 'my-logs'
        emit_interval: 5

Overriding the attribute values on the resource:

.. code-block:: yaml

    Ensure myelb ELB exists:
        boto_elb.present:
            - name: myelb
            - region: us-east-1
            - attributes_from_pillar: my_elb_attributes
            # override cross_zone_load_balancing:enabled
            - attributes:
                cross_zone_load_balancing:
                  enabled: false
            - profile: myelbprofile

It's possible to specify cloudwatch alarms that will be setup along with the
ELB. Note the alarm name will be defined by the name attribute provided, plus
the ELB resource name.

.. code-block:: yaml

    Ensure myelb ELB exists:
        boto_elb.present:
            - name: myelb
            - region: us-east-1
            - profile: myelbprofile
            - alarms:
                UnHealthyHostCount:
                  name: 'ELB UnHealthyHostCount **MANAGED BY SALT**'
                  attributes:
                    metric: UnHealthyHostCount
                    namespace: AWS/ELB
                    statistic: Average
                    comparison: '>='
                    threshold: 1.0
                    period: 600
                    evaluation_periods: 6
                    unit: null
                    description: ELB UnHealthyHostCount
                    alarm_actions: ['arn:aws:sns:us-east-1:12345:myalarm']
                    insufficient_data_actions: []
                    ok_actions: ['arn:aws:sns:us-east-1:12345:myalarm']

You can also use alarms from pillars, and override values from the pillar
alarms by setting overrides on the resource. Note that 'boto_elb_alarms'
will be used as a default value for all resources, if defined and can be
used to ensure alarms are always set for a resource.

Setting the alarms in a pillar:

.. code-block:: yaml

    my_elb_alarm:
      UnHealthyHostCount:
        name: 'ELB UnHealthyHostCount **MANAGED BY SALT**'
        attributes:
          metric: UnHealthyHostCount
          namespace: AWS/ELB
          statistic: Average
          comparison: '>='
          threshold: 1.0
          period: 600
          evaluation_periods: 6
          unit: null
          description: ELB UnHealthyHostCount
          alarm_actions: ['arn:aws:sns:us-east-1:12345:myalarm']
          insufficient_data_actions: []
          ok_actions: ['arn:aws:sns:us-east-1:12345:myalarm']

Overriding the alarm values on the resource:

.. code-block:: yaml

    Ensure myelb ELB exists:
        boto_elb.present:
            - name: myelb
            - region: us-east-1
            - profile: myelbprofile
            - alarms_from_pillar: my_elb_alarm
            # override UnHealthyHostCount:attributes:threshold
            - alarms:
                UnHealthyHostCount:
                  attributes:
                    threshold: 2.0

Tags can also be set:

.. versionadded:: 2016.3.0

.. code-block:: yaml

    Ensure myelb ELB exists:
        boto_elb.present:
            - name: myelb
            - region: us-east-1
            - profile: myelbprofile
            - tags:
                MyTag: 'My Tag Value'
                OtherTag: 'My Other Value'
i(tabsolute_importtprint_functiontunicode_literalsN(tSaltInvocationError(tsixcC@sdtkrdStS(u)
    Only load if boto is available.
    uboto_elb.existsuboto_elb(t__salt__tFalse(((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pyt__virtual__�suinternet-facinguboto_elb_attributesuboto_elb_alarmsuboto_elb_policiesc$C@s.td|	i�}|r1tjjj||�n|}i|d6td6dd6id6}t|tjt	t
d(�f�s�d}tj
|�|ji|d6td6�|St|tj�r�|jd�}nt|||||||||||�}|ji|dd6d	j|d|dg�d6�|drD|dn|d|d<|dtkrf|Std
|||||�}|r�tdr�|S|r=t||||||�}|jitjjj|d|d�d6d	j|d|dg�d6�|dr|dn|d|d<|dtkr=|Snt||||||�}|jitjjj|d|d�d6d	j|d|dg�d6�|dr�|dn|d|d<|dtkr�|S|
r@td|||||�}|r@x8|
D]-}d(}d
}|jidd6|dd6�d|krX|jd�}n|d
kr�x=d)D]2} | |kr�t�j| �n|| || <qkWntd|�}|jitjjj|d|d�d6d	j|d|dg�d6�|dr|dn|d|d<|dtkr	|Sq	Wq@nt|||||||�}|jitjjj|d|d�d6d	j|d|dg�d6�|dr�|dn|d|d<|dtkr�|St||
|||||||�	}|jitjjj|d|d�d6d	j|d|dg�d6�|drd|dn|d|d<|dtkr�|St||||||�}|jitjjj|d|d�d6d	j|d|dg�d6�|dr|dn|d|d<|dtkr#|S|s2g}n|r�d*}!xF|D];}"|tdd|"d |d!|d"|d#|d$|!�7}qEWn|r*tdr�td%||t||||�r'|dcd&j|�7<d(|d<q'q*td%||t||||�}#|#s*|dcd'7<t|d<q*n|S(+uB

    Ensure the ELB exists.

    name
        Name of the ELB.

    availability_zones
        A list of availability zones for this ELB.

    listeners
        A list of listener lists; example::

            [
                ['443', 'HTTPS', 'arn:aws:iam::1111111:server-certificate/mycert'],
                ['8443', '80', 'HTTPS', 'HTTP', 'arn:aws:iam::1111111:server-certificate/mycert']
            ]

    subnets
        A list of subnet IDs in your VPC to attach to your LoadBalancer.

    subnet_names
        A list of subnet names in your VPC to attach to your LoadBalancer.

    security_groups
        The security groups assigned to your LoadBalancer within your VPC. Must
        be passed either as a list or a comma-separated string.

        For example, a list:

        .. code-block:: yaml

            - security_groups:
              - secgroup-one
              - secgroup-two

        Or as a comma-separated string:

        .. code-block:: yaml

            - security_groups: secgroup-one,secgroup-two

    scheme
        The type of a LoadBalancer, ``internet-facing`` or ``internal``. Once
        set, can not be modified.

    health_check
        A dict defining the health check for this ELB.

    attributes
        A dict defining the attributes to set on this ELB.
        Unknown keys will be silently ignored.

        See the :mod:`salt.modules.boto_elb.set_attributes` function for
        recognized attributes.

    attributes_from_pillar
        name of pillar dict that contains attributes.   Attributes defined for this specific
        state will override those from pillar.

    cnames
        A list of cname dicts with attributes needed for the DNS add_record state.
        By default the boto_route53.add_record state will be used, which requires: name, zone, ttl, and identifier.
        See the boto_route53 state for information about these attributes.
        Other DNS modules can be called by specifying the provider keyword.
        the cnames dict will be passed to the state as kwargs.

        See the :mod:`salt.states.boto_route53` state for information about
        these attributes.

    alarms:
        a dictionary of name->boto_cloudwatch_alarm sections to be associated with this ELB.
        All attributes should be specified except for dimension which will be
        automatically set to this ELB.

        See the :mod:`salt.states.boto_cloudwatch_alarm` state for information
        about these attributes.

    alarms_from_pillar:
        name of pillar dict that contains alarm settings.   Alarms defined for this specific
        state will override those from pillar.

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used.

    profile
        A dict with region, key and keyid, or a pillar key (string)
        that contains a dict with region, key and keyid.

    wait_for_sync
        Wait for an INSYNC change status from Route53.

    tags
        dict of tags

    instance_ids
        list of instance ids.  The state will ensure that these, and ONLY these, instances
        are registered with the ELB.  This is additive with instance_names.

    instance_names
        list of instance names.  The state will ensure that these, and ONLY these, instances
        are registered with the ELB.  This is additive with instance_ids.
    u
config.optionunameuresultuucommentuchangesuQThe 'security_group' parameter must be either a list or a comma-separated string.u,u  uboto_elb.existsutestuboto_elb.get_elb_configuboto_route53uCNAMEurecord_typeudns_nameuvalueuprovideruprofileukeyukeyiduregionu
wait_for_syncuboto_route53.presentupendingu	rebootingurunningustoppingustoppeduboto_ec2.find_instancestnametregiontkeytkeyidtprofilet	in_statesuboto_elb.set_instancesu$ ELB {0} instances would be updated.u"Failed to set requested instances.N(uprofileukeyukeyiduregionu
wait_for_sync(upendingu	rebootingurunningustoppingustopped(Rtsalttutilst
dictupdatetupdatetTruet
isinstanceRtstring_typestlistttypetNonetlogterrorRtsplitt_elb_presenttjoint__opts__t_attributes_presentt_health_check_presenttpoptlocalstgett
__states__t_alarms_presentt_policies_presentt
_tags_presenttformat($Rt	listenerstavailability_zonestsubnetstsubnet_namestsecurity_groupstschemethealth_checkt
attributestattributes_from_pillartcnamestalarmstalarms_from_pillartpoliciestpolicies_from_pillartbackendsR	R
RRt
wait_for_syncttagstinstance_idstinstance_namesttmptrettmsgt_rettexiststlbtcnametdns_providertptrunning_statestntsuccess((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pytpresents�v$"!
""*""	*""	

3*""*""*""*""	


cC@sBi|d6td6dd6id6}td|||||�}|sdj|�}tj|�|ji|d6td6�|Std|||||�}	g|	D] }
|
d	d
kr�|
d^q�}g|D]}
|
|kr�|
^q�}t|�s?djtj	|�j
d
��}tj|�|ji|d6�|Stdrmdj||�|d<d|d<|Std||||||�}
|
rdj|�}tj|�t�j||�}|ji|d6idj|�d6djt|��d6d6�n7dj|�}tj|�|ji|d6td6�|S(u
    Add EC2 instance(s) to an Elastic Load Balancer. Removing an instance from
    the ``instances`` list does not remove it from the ELB.

    name
        The name of the Elastic Load Balancer to add EC2 instances to.

    instances
        A list of EC2 instance IDs that this Elastic Load Balancer should
        distribute traffic to. This state will only ever append new instances
        to the ELB. EC2 instances already associated with this ELB will not be
        removed if they are not in the ``instances`` list.

    .. versionadded:: 2015.8.0

    .. code-block:: yaml

        add-instances:
          boto_elb.register_instances:
            - name: myloadbalancer
            - instances:
              - instance-id1
              - instance-id2
    unameuresultuucommentuchangesuboto_elb.existsuCould not find lb {0}uboto_elb.get_instance_healthudescriptionu.Instance deregistration currently in progress.uinstance_iduInstance/s {0} already exist.u[]utestu!ELB {0} is set to register : {1}.uboto_elb.register_instancesu"Load Balancer {0} has been changedu
uoldunewu)Load balancer {0} failed to add instancesN(RRR'RRRRtlenRt	text_typetstriptdebugRRtinfotsettunionRR(Rt	instancesR	R
RRR<R@R=thealthtvaluetnodestnewtstate((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pytregister_instances�sB"

 %!



#!
uboto_elb_listener_policiescC@sIitd6dd6id6}tjjj|||f�sHtd��n|sWg}nx/|D]'}t|�dkr�td��nd|kr�td	��nd
|kr�td��nd|kr�td
��n|dj�|d<|ddkrd|krtd��n|jdg�}
|j	dd�}|
rU|dkrUt}n|r^|
td|i�j	|dg�7}
q^q^W|rFg}x�|D]�}tddd|d|d|d|	d|
�}d|krdj
|d�|d<t|d<|Sd|kr.dj
|�|d<t|d<|S|j|d�q�Wnd}|r�td||||	|
�}|j	d �}|s�d!j
|�|d<t|d<|Std"|d#|d|d|d|	d|
�}|s�d$j
|�|d<t|d<|Sntd%||||	|
�}|s�td&rId'j
|�|d<d|d<|Std(d|d)|d*|d+|d,|d-|d|d|d|	d|
�
}|r�idd.6|dd/<i|d.6|dd0<d1j
|�|d<qEt|d<d2j
|�|d<nMd3j
|�|d<t|||||	|
�}tjjj|d|d�|d<d4j|d|dg�|d<|ds�|d|d<|dtkr�|Snt|||||	|
�}tjjj|d|d�|d<d4j|d|dg�|d<|ds)|d|d<|dtkr)|Sn|r�t|||||	|
�}tjjj|d|d�|d<d4j|d|dg�|d<|dsE|d|d<|dtkr�|SqEn�|rEt|||||	|
�}tjjj|d|d�|d<d4j|d|dg�|d<|dsE|d|d<qEn|S(5NuresultuucommentuchangesuWExactly one of availability_zones, subnets, subnet_names must be provided as arguments.iu\Listeners must have at minimum port, instance_port and protocol values in the provided list.uelb_portu+elb_port is a required value for listeners.u
instance_portu0instance_port is a required value for listeners.uelb_protocolu/elb_protocol is a required value for listeners.uHTTPSucertificateuOcertificate is a required value for listeners if HTTPS is set for elb_protocol.upoliciesupolicies_from_pillaru
pillar.getuboto_vpc.get_resource_idusubnetRR	R
RRuerroru Error looking up subnet ids: {0}uiduSubnet {0} does not exist.uboto_vpc.get_subnet_associationuvpc_idu)Subnets {0} do not map to a valid vpc id.u"boto_secgroup.convert_to_group_idstvpc_idu;Security groups {0} do not map to valid security group ids.uboto_elb.existsutestuELB {0} is set to be created.uboto_elb.createR)R(R*R,R-uelbuoldunewuELB {0} created.uFailed to create {0} ELB.uELB {0} present.u  (RRRtdatatexactly_oneRRHtuppert
setdefaultR"Rt"DEFAULT_PILLAR_LISTENER_POLICY_KEYRR'RtappendRt_security_groups_presentRRRt_listeners_presentt_zones_presentt_subnets_present(RR)R(R*R+R,R-R	R
RRR<tlistenerR4tpolicies_pillartitrt_security_groupsRVR?tcreatedR>((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pyR,s�	
	.







$!
$!
$!

$!
cC@s�itd6dd6id6}td|||||�}|s^dj|�|d<t|d<|S|smg}ni}x(|D] }	td|	�}
|	||
<qzWi}x,|dD] }	td|	�}
|	||
<q�Wg}g}
x9tj|�D](\}}	||kr�|
j|	�q�q�Wx9tj|�D](\}}	||kr+|j|	�q+q+Wtd	r%g}|
ss|r�|jd
j|��x.|
D]&}|jdjtd|���q�Wx.|D]&}|jdjtd|���q�Wd|d<n|jd
j|��dj	|�|d<|S|r�g|D]}	|	d^q2}td||||||�}|r�dj|�|d<q�dj|�|d<t|d<n|
r6td||
||||�}|r�d}dj	|d|j|�g�|d<q6d}dj	|d|j|�g�|d<t|d<n|
sB|r�i|dd<|d|ddd<td|||||�}|d|ddd<nd
j|�|d<|S(Nuresultuucommentuchangesuboto_elb.get_elb_configu-{0} ELB configuration could not be retrieved.uboto_elb.listener_dict_to_tupleu	listenersutestu'ELB {0} set to have listeners modified:uListener {0} added.uListener {0} deleted.u!Listeners already set on ELB {0}.u  uelb_portuboto_elb.delete_listenersuDeleted listeners on {0} ELB.u&Failed to delete listeners on {0} ELB.uboto_elb.create_listenersuCreated listeners on {0} ELB.u u&Failed to create listeners on {0} ELB.uoldunew(
RRR'RRt	iteritemsR\RRR(RR(R	R
RRR<R@texpected_listeners_by_tupletltl_keytactual_listeners_by_tuplet	to_deletet	to_createttR=RatportstdeletedRf((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pyR^�s�
	





		

		)&
	c
C@siitd6dd6id6}td|||||�}|s^dj|�|d<t|d<|S|smg}nt}t|�t|d�kr�t}n|rRtdr�d	j|�|d<d|d<|Std
||||||�}	|	rdj|�|d<ndj|�|d<t|d<i|dd6|dd
<i|d6|dd<ndj|�|d<|S(Nuresultuucommentuchangesuboto_elb.get_elb_configu-{0} ELB configuration could not be retrieved.usecurity_groupsutestu-ELB {0} set to have security groups modified.uboto_elb.apply_security_groupsu$Modified security_groups on {0} ELB.u,Failed to modify security_groups on {0} ELB.uoldunewu'security_groups already set on ELB {0}.(RRR'RRMRR(
RR,R	R
RRR<R@t
change_neededtchanged((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pyR]�s4
		


c	C@s�itd6dd6id6}td|||||�}|s^t|d<dj|�|d<|Sg}d|kr�|d}	|d}
|	d|
dkr�|jd�q�nd	|kr|d	}|d	}|d|dks|jd
d�|jd
�kr|jd	�qnd|krZ|d}
|d}|
d
|d
krZ|jd�qZnd|krxWtj|d�D]B\}}tj|d|�tj|�krz|jd�qzqzWd|dkr|dd}|j	d�s�|j
d�rtd��qqn|r�tdrBdj|�|d<d|d<|Std||||||�}|r�i|d6|dd<i|d6|dd<dj|�|d<q�t|d<dj|�|d<ndj|�|d<|S(Nuresultuucommentuchangesuboto_elb.get_attributesu*Failed to retrieve attributes for ELB {0}.ucross_zone_load_balancinguenableduconnection_drainingutimeouti,uconnecting_settingsuidle_timeoutu
access_logus3_bucket_prefixu/u-s3_bucket_prefix can not start or end with /.utestu#ELB {0} set to have attributes set.uboto_elb.set_attributesu
attributesuoldunewuSet attributes on ELB {0}.u$Failed to set attributes on ELB {0}.u"Attributes already set on ELB {0}.(RRRR'R\R"RRgRIt
startswithtendswithRRR(RR/R	R
RRR<t_attributestattrs_to_settczlbt_czlbtcdt_cdtcst_cstattrtvaltsbptwas_set((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pyRs`	




!

 &


		
cC@s�itd6dd6id6}|s*i}ntd|||||�}|smt|d<dj|�|d<|St}xHtj|�D]7\}	}
tj||	�tj|
�kr�t}q�q�W|r�tdr�dj|�|d<d|d<|Std	||||||�}|rpi|d
6|dd<td|||||�}i|d
6|dd<d
j|�|d<q�t|d<dj|�|d<ndj|�|d<|S(Nuresultuucommentuchangesuboto_elb.get_health_checku,Failed to retrieve health_check for ELB {0}.utestu%ELB {0} set to have health check set.uboto_elb.set_health_checkuhealth_checkuoldunewuSet health check on ELB {0}.u&Failed to set health check on ELB {0}.u$Health check already set on ELB {0}.(	RRRR'RRgRIRR(RR.R	R
RRR<t
_health_checktneed_to_setR}R~R�((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pyRLs@	
"



		
	
cC@saitd6dd6id6}td|||||�}|s^t|d<dj|�|d<|Sg}g}	|d}
x*|D]"}||
kr{|j|�q{q{Wx*|
D]"}||kr�|	j|�q�q�W|s�|	rJtdrd	j|�|d<d|d<|S|rftd
||||||�}|rFdj|�|d<qfdj|�|d<t|d<n|	r�td
||	||||�}
|
r�d}dj|d|j|�g�|d<q�d}dj|d|j|�g�|d<t|d<ni|dd6|dd<td|||||�}i|dd6|dd<ndj|�|d<|S(Nuresultuucommentuchangesuboto_elb.get_elb_configuFailed to retrieve ELB {0}.uavailability_zonesutestu'ELB {0} to have availability zones set.u"boto_elb.enable_availability_zonesu&Enabled availability zones on {0} ELB.u/Failed to enable availability zones on {0} ELB.u#boto_elb.disable_availability_zonesu'Disabled availability zones on {0} ELB.u  u0Failed to disable availability zones on {0} ELB.uoldunewu*Availability zones already set on ELB {0}.(RRRR'R\RRR(RR)R	R
RRR<R@t	to_enablet
to_disablet_zonestzonetenabledtdisabledR=((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pyR_qsX






)&
	cC@sditd6dd6id6}|s*g}ntd|||||�}|smt|d<dj|�|d<|Sg}g}	|d}
x*|D]"}||
kr�|j|�q�q�Wx*|
D]"}||kr�|	j|�q�q�W|s�|	rMtdrd	j|�|d<d|d<|S|rutd
||||||�}|rUdj|�|d<qudj|�|d<t|d<n|	r�td
||	||||�}
|
r�dj|ddj|�g�|d<q�dj|ddj|�g�|d<t|d<ni|dd6|dd<td|||||�}i|dd6|dd<ndj|�|d<|S(Nuresultuucommentuchangesuboto_elb.get_elb_configuFailed to retrieve ELB {0}.usubnetsutestuELB {0} to have subnets set.uboto_elb.attach_subnetsuAttached subnets on {0} ELB.u$Failed to attach subnets on {0} ELB.uboto_elb.detach_subnetsu uDetached subnets on {0} ELB.u$Failed to detach subnets on {0} ELB.uoldunewuSubnets already set on ELB {0}.(RRRR'R\RRR(RR*R	R
RRR<R@R�R�t_subnetstsubnettattachedtdetached((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pyR`�s`	






		

		
	c
C@s�td|i�}|r4tjjj||�}ni|d6td6dd6id6}x%tj|�D]\}	}
|d|
d|
d<|d|
dd	|
dd	<i|gd
6|
dd<i|
dd6|
dd6|d6|d
6|d6|d6}td|�}|j	d�s&|d|d<n|j	di�ikrW|d|d|
d<nd|krf|dc|d7<qfqfW|S(uAhelper method for present.  ensure that cloudwatch_alarms are setu
config.optionunameuresultuucommentuchangesu u
attributesudescriptionuLoadBalancerNameu
dimensionsuregionukeyukeyiduprofileuboto_cloudwatch_alarm.present(
RRRRRRRRgR#R"(
RR2R3R	R
RRtcurrentR<t_RLtkwargstresults((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pyR$�s."
c	+C@s�	|d5krg}ntd|g�}	||	}|d5krGg}nt�}
x�|D]�}d|krxtd��nd|kr�td��nd|kr�td��n|d|
kr�tdj|d���n|
j|d�qWWxY|D]Q}xH|jd	g�D]4}||
krtd
j|d||���qqWq�WxY|D]Q}
xH|
jd	g�D]4}||
krktdj|
d
||���qkqkWqRWitd6dd6id6}td|||||�}|sdj|�|d<t|d<|Si}i}x2|D]*}t	|�}|||<|||d<qW|j
�}|d	}t�}i}xE|D]=}tg|jd	g�D]}||^q��||d<qrWi}xk|dD]_}t|jd	g��}|||d<x0|D](}tjd|�r�|j|�q�q�Wq�Wi}xE|D]=}
tg|
jd	g�D]}||^qP�||
d
<q4Wi}x8|dD],}
t|
jd	g��}|||
d
<q�Wg}g}x*|D]"}||kr�|j
|�q�q�Wx9|D]1}||kr�||kr'|j
|�q'q�q�Wt�}xHtj|�D]7\} }||j| t��krD|j| �qDqDWxHtj|�D]7\} }||j| t��kr�|j| �q�q�Wt�}!xHtj|�D]7\} }||j| t��kr�|!j| �q�q�WxHtj|�D]7\} }||j| t��kr.|!j| �q.q.Wtdrqg}"|s�|r�|"j
dj|��x$|D]}#|"j
dj|#��q�Wx$|D]}#|"j
dj|#��q�Wd5|d<n|"j
dj|��x$|D]}$|"j
dj|$��qWx$|!D]}%|"j
dj|%��q:Wdj|"�|d<|S|rBx�|D]�}tdd |d!|d"||dd#||dd$|d%|d&|d'|�}&|&r-||dj|i�d(<d)j||�}'dj|d|'g�|d<t|d<q~t|d<|Sq~Wnx�|D]�} td*d |d+| d,t|j| g��d$|d%|d&|d'|�}(|(r0d-j| �})it|j| g��d.6t|j| g��d(6|d|)<d/j|| || �}'dj|d|'g�|d<t|d<qIt|d<|SqIWx�|!D]�} td0d |d+| d,t|j| g��d$|d%|d&|d'|�}(|(r0	d1j| �})it|j| g��d.6t|j| g��d(6|d|)<d2j|| || �}'dj|d|'g�|d<t|d<qIt|d<|SqIW|r�	x�|D]�}td3d |d!|d$|d%|d&|d'|�}*|*r�	||dj|i�d.<d4j||�}'dj|d|'g�|d<t|d<qO	t|d<|SqO	Wn|S(6u;helper method for present. ensure that ELB policies are setu
config.optionupolicy_nameu-policy_name is a required value for policies.upolicy_typeu-policy_type is a required value for policies.upolicyu)policy is a required value for listeners.u:Policy names must be unique: policy {0} is declared twice.upoliciesu7Listener {0} on ELB {1} refers to undefined policy {2}.uelb_portu6Backend {0} on ELB {1} refers to undefined policy {2}.u
instance_porturesultuucommentuchangesuboto_elb.get_elb_configu-{0} ELB configuration could not be retrieved.u	listenersu^ELBSecurityPolicy-\d{4}-\d{2}$ubackendsutestu&ELB {0} set to have policies modified:uPolicy {0} added.uPolicy {0} deleted.u Policies already set on ELB {0}.uListener {0} policies updated.uBackend {0} policies updated.u  uboto_elb.create_policyRtpolicy_nametpolicy_typetpolicyR	R
RRunewu!Policy {0} was created on ELB {1}uboto_elb.set_listener_policytportR4ulistener_{0}_policyuoldu.Policy {0} was created on ELB {1} listener {2}uboto_elb.set_backend_policyubackend_{0}_policyu-Policy {0} was created on ELB {1} backend {2}uboto_elb.delete_policyu#Policy {0} was deleted from ELB {1}N(RRRMRR'taddR"RRt
_policy_cnametkeystretmatchR\RRgRRRZR(+RR4R5R(R6R	R
RRtpillar_policiestpolicy_namesRCRitbR<R@tpolicies_by_cnametcnames_by_nameRAtexpected_policy_namestactual_policy_namestdefault_aws_policiestexpected_policies_by_listenertactual_policies_by_listenertlistener_policiestexpected_policies_by_backendtactual_policies_by_backendtbackend_policiesRlRmR�tlisteners_to_updateR�tbackends_to_updateR=R�RatbackendRftcommentt
policy_sett
policy_keyRp((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pyR%�sd	
		
	
	!
	!



		
8

8

		







	



	$



	$



	

cC@s�|d}|d}|d}tjtttj|��dd���}tjtjj	j
t|���j�}|j
d�r�|d }ndj|||�S(	Nupolicy_nameupolicy_typeupolicyR
cS@stj|d�S(Ni(RRI(tx((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pyt<lambda>�suTypei����u{0}-{1}-{2}(RRItsortedRRgthashlibtmd5RRtstringutilstto_byteststrt	hexdigestRtR'(tpolicy_dictR�R�R�tcanonical_policy_reprtpolicy_hash((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pyR��s


-$
cC@si|d6td6dd6id6}td|||||�}|r�tdrodj|�|d<d|d<|Std	|||||�}|r�i|d
6|dd<idd
6|dd<d
j|�|d<qt|d<dj|�|d<ndj|�|d<|S(uH
    Ensure an ELB does not exist

    name
        name of the ELB
    unameuresultuucommentuchangesuboto_elb.existsutestuELB {0} is set to be removed.uboto_elb.deleteuelbuoldunewuELB {0} deleted.uFailed to delete {0} ELB.u{0} ELB does not exist.N(RRRR'RR(RR	R
RRR<R?Rp((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pytabsent�s""

	
cC@s�itd6dd6id6}|r�td|||||�}|}i}	g}
|jd�r�x||dD]m}||j�kr�||
kr�|
j|�q�qi|||d|kr�|||	|<n|j|�qiWn|
rtdrJdjt|
�d	krd
nddj	|
��}d
j	|d|g�|d<d|d<qtd||
||||�}
|
s�t|d<dj|
�}d
j	|d|g�|d<|Sd|dkr�tj
jj|diiid6d6�|d<nx/|
D]$}|d||ddd|<q�Wn|s(|	rttdr	|r�djt|j��d	kr\d
nddj	|j���}dj	|d|g�|d<d|d<n|	rqdjt|	j��d	kr�dnddj	|	j���}d
j	|d|g�|d<qqqttj
jj||	�}td||||||�}
|
swt|d<d}d
j	|d|g�|d<|Sd|dkr�tj
jj|diiid6d6�|d<nd|dkr�tj
jj|diiid6d6�|d<nxx|D]m}|||ddd|<d|kr|drm||dkrj|d||ddd|<qjqmqqWn|	r�|
r�|r�d}d
j	|d|g�|d<q�n|S(u1
    helper function to validate tags on elb
    uresultuucommentuchangesuboto_elb.get_elb_configutagsutestu,The following tag{0} set to be removed: {1}.ius areu isu, u  uboto_elb.delete_tagsu#Error attempting to delete tag {0}.uoldu*The following tag{0} set to be added: {1}.u u-The following tag {0} set to be updated: {1}.u
values areuvalue isuboto_elb.set_tagsuError attempting to set tags.unewuTags are already set.N(RRR"R�R\R RR'RHRRRRRRR(RR8R	R
RRR<R@ttags_to_addttags_to_updatettags_to_removet_tagR=R>tall_tag_changesttag((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pyR&s�
-

1
%
!
!#
11

.#(%t__doc__t
__future__RRRtloggingR�R�tsalt.utils.dataRtsalt.utils.dictupdatetsalt.utils.stringutilstsalt.exceptionsRtsalt.extRt	getLoggert__name__RRRRRGRUR[RR^R]RRR_R`R$R%R�R�R&(((s8/usr/lib/python2.7/site-packages/salt/states/boto_elb.pyt<module>�sD			�	@	z	P	 	6	%	2	8		�	

Zerion Mini Shell 1.0