File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/boto_route53.cpython-310.pyc
Back
o ;j� � @ s d Z ddlZddlZddlmZ ddlZddlZddlm Z e� e�Zzddl Z ddlZ ddlZ ddlmZ e� d��ej� dZW n eyM dZY nw d d � Zdd� Zd d� Zdd� Z d9dd�Zd:dd�Zd:dd�Z d;dd�Z d<dd�Z d=d!d"�Zd:d#d$�Z d%d&� Z!d'd(� Z" d>d)d*�Z#d+d,� Z$ d?d-d.�Z% d?d/d0�Z& d@d1d2�Z'd3d4� Z(dAd5d6�Z) dBd7d8�Z*dS )Ca. Connection module for Amazon Route53 .. versionadded:: 2014.7.0 :configuration: This module accepts explicit route53 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:: yaml 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 route53.keyid: GKTADJGHEIQSXMKKRBJ08H route53.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs A region may also be specified in the configuration: .. code-block:: yaml route53.region: us-east-1 If a region is not specified, the default is 'universal', which is what the boto_route53 library expects, rather than None. 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: boto � N)�OrderedDict)�SaltInvocationError)�DNSServerError�botoTFc C s t jjjddd�S )z, Only load if boto libraries exist. z2.35.0F)Zboto_verZcheck_boto3)�salt�utilsZversionsZcheck_boto_reqs� r r �M/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/boto_route53.py�__virtual__I s r c C s t r td tdtd� d S d S )Nzboto.assign_funcs�route53)�pack)�HAS_BOTO� __utils__�__name__�__salt__)�optsr r r �__init__Q s �r c C sF |� � D ]}|j| kr |jd �� dkrdnd}||kr | S qdS )a With boto route53, zones can only be matched by name or iterated over in a list. Since the name will be the same for public and private zones in a split DNS situation, iterate over the list and match the zone name and public/private status. ZPrivateZone�trueTF)Z get_zones�nameZconfig�lower)�zoneZ_conn�private_zone�_zoneZ _private_zoner r r �_get_split_zoneV s ��r c C s | j dvS )N)ZSignatureDoesNotMatch)�code)� exceptionr r r �_is_retryable_errorh s r c C sL t ||||d�}| r|rtd��d}|r�zN| r.| �d�r"| �dd�n| } t|�| �dd�}n-|r:t|�|�dd�}n!d} d}| dkr[|j| |d�} | d d }| d �dd�} | dksB|r`|W S g W S t y� } z5|r�d|j krwt�d � n d|j kr�t�d� t �d� |d8 }W Y d}~qt�d|j� g W Y d}~S d}~ww dS )as Return detailed info about one, or all, zones in the bound account. If neither zone_id nor domain_name is provided, return all zones. Note that the return format is slightly different between the 'all' and 'single' description types. zone_id The unique identifier for the Hosted Zone domain_name The FQDN of the Hosted Zone (including final period) 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. CLI Example: .. code-block:: bash salt myminion boto_route53.describe_hosted_zones domain_name=foo.bar.com. profile='{"region": "us-east-1", "keyid": "A12345678AB", "key": "xblahblahblah"}' ��region�key�keyid�profilez5At most one of zone_id or domain_name may be provided� �/hostedzone/� ZGetHostedZoneResponseN)Zstart_markerZ zone_listZListHostedZonesResponseZHostedZonesZ NextMarker� Throttling�Throttled by AWS API.�PriorRequestNotComplete�SThe request was rejected by AWS API. Route 53 was still processing a prior request.� � zCould not list zones: %s)� _get_connr � startswith�replace�getattrZget_hosted_zone�get_hosted_zone_by_nameZget_all_hosted_zones�getr r �log�debug�time�sleep�error�message)Zzone_id�domain_namer r r r! �connZretries�ret�marker�r�er r r �describe_hosted_zonesl s\ #������ � ���r= c C � t | |||d�}dd� |D �S )a� List, by their FQDNs, all hosted zones in the bound account. 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. CLI Example: .. code-block:: bash salt myminion boto_route53.list_all_zones_by_name r c S � g | ]}|d �qS )�Namer ��.0r; r r r � <listcomp>� � z*list_all_zones_by_name.<locals>.<listcomp>�r= �r r r r! r9 r r r �list_all_zones_by_name� � rG c C r>