%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s6dZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlmZddl
mZd�Zdddddd	ddddd
�
Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zddddd�ZdS(u�
Manage Data Pipelines

.. versionadded:: 2016.3.0

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

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

This module accepts explicit AWS 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

    datapipeline.keyid: GKTADJGHEIQSXMKKRBJ08H
    datapipeline.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 daily data pipeline exists:
    boto_datapipeline.present:
      - name: my-datapipeline
      - pipeline_objects:
          DefaultSchedule:
            name: Every 1 day
            fields:
              period: 1 Day
              type: Schedule
              startAt: FIRST_ACTIVATION_DATE_TIME
      - parameter_values:
          myDDBTableName: my-dynamo-table
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tzipcC@sdtkrdStS(u)
    Only load if boto is available.
    u!boto_datapipeline.create_pipelineuboto_datapipeline(t__salt__tFalse(((sA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pyt__virtual__Asu"boto_datapipeline_pipeline_objectsu#boto_datapipeline_parameter_objectsu"boto_datapipeline_parameter_valuescC@si|d6td6dd6id6}|p+i}|p7i}|pCi}t|t||�t||�t||�d|d|d|	d	|
�\}}
|r�d
j|�|d<|Stdr�dj|�|d<d|d<|Std
||d|d|d|	d	|
�}d|kr;t	|d<dj||d�|d<|S|d}td|t||�dt||�dt||�d|d|d|	d	|
�}d|krt
|�r�td|d|d|d|	d	|
�}d|krt	|d<dj||d�|d<|Std
||d|d|d|	d	|
�}d|krjt	|d<dj||d�|d<|S|d}td|t||�dt||�dt||�d|d|d|	d	|
�}nd|krt	|d<dj||d�|d<|Sntd|d|d|d|	d	|
�}d|kr\t	|d<dj||d�|d<|Std|ddd|d|d|	d	|
�}d|kr�i}nt|d�}|
s�d|dd<dj|�|d<n*t|
|�|dd<dj|�|d<|S(u�
    Ensure the data pipeline exists with matching definition.

    name
        Name of the service to ensure a data pipeline exists for.

    pipeline_objects
        Pipeline objects to use. Will override objects read from pillars.

    pipeline_objects_from_pillars
        The pillar key to use for lookup.

    parameter_objects
        Parameter objects to use. Will override objects read from pillars.

    parameter_objects_from_pillars
        The pillar key to use for lookup.

    parameter_values
        Parameter values to use. Will override values read from pillars.

    parameter_values_from_pillars
        The pillar key to use for lookup.

    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.
    unameuresultuucommentuchangestregiontkeytkeyidtprofileuAWS data pipeline {0} presentutestu1Data pipeline {0} is set to be created or updatedu!boto_datapipeline.create_pipelineuerroru'Failed to create data pipeline {0}: {1}u)boto_datapipeline.put_pipeline_definitiontparameter_objectstparameter_valuesu!boto_datapipeline.delete_pipelineu'Failed to delete data pipeline {0}: {1}u#boto_datapipeline.activate_pipelineu)boto_datapipeline.get_pipeline_definitiontversionuactiveuPipeline created.unewuData pipeline {0} createdudiffuData pipeline {0} updatedN(
tTruet!_pipeline_present_with_definitiont_pipeline_objectst_parameter_objectst_parameter_valuestformatt__opts__tNoneRRt_immutable_fields_errort_standardizet_diff(tnametpipeline_objectstpipeline_objects_from_pillarsRtparameter_objects_from_pillarsR
tparameter_values_from_pillarsRR	R
Rtrettpresenttold_pipeline_definitiontresult_create_pipelinetpipeline_idtresult_pipeline_definitiontresult_delete_pipelinetresult_activate_pipelinetpipeline_definition_resulttnew_pipeline_definition((sA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pyR Hs�-"

	

		
	


	
		cC@s>x7|dD]+}x"|dD]}d|krtSqWqWtS(uReturn true if update pipeline failed due to immutable fields

    Some fields cannot be changed after a pipeline has been activated.

    http://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-manage-pipeline-modify-console.html#dp-edit-pipeline-limits
    uerroruerrorsucan not be changed(RR(R$tete2((sA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pyR�s
cC@std|d|d|d|d|�}d|kr>tifS|d}	td|	d	d
d|d|d|d|�}
d|
kr�tifSt|
d�}|jd�}|jd�}
|jd
�}tt|�t|��o�t|
|�o�t||�}||fS(u�
    Return true if the pipeline exists and the definition matches.

    name
        The name of the pipeline.

    expected_pipeline_objects
        Pipeline objects that must match the definition.

    expected_parameter_objects
        Parameter objects that must match the definition.

    expected_parameter_values
        Parameter values that must match the definition.

    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.
    u'boto_datapipeline.pipeline_id_from_nameRR	R
Ruerroruresultu)boto_datapipeline.get_pipeline_definitionRuactiveupipelineObjectsuparameterObjectsuparameterValues(RRRtgett_recursive_comparet_cleaned(Rtexpected_pipeline_objectstexpected_parameter_objectstexpected_parameter_valuesRR	R
Rtresult_pipeline_idR#R'tpipeline_definitionRRR
R ((sA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pyRs4 	

	
cC@s�tj|�}x{|D]s}|ddkrxZ|dD]K}|ddkr7|d}tjj|d�}|jd�|d<q7q7WqqW|S(	u�Return standardized pipeline objects to be used for comparing

    Remove year, month, and day components of the startDateTime so that data
    pipelines with the same time of day but different days are considered
    equal.
    uiduDefaultScheduleufieldsukeyu
startDateTimeustringValueu%Y-%m-%dT%H:%M:%Su%H:%M:%S(tcopytdeepcopytdatetimetstrptimetstrftime(RRtpipeline_objecttfield_objecttstart_date_time_stringtstart_date_time((sA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pyR-Ns

	!cC@s-t|t�r�|dkr$g}nt|�t|�kr@tS|jdt�|jdt�x0t||�D]\}}t||�sptSqpWt	St|t
�r|dkr�i}nt
|�}t
|�}t|�t|�kr�tSx)|D]!}t||||�s�tSq�Wt	S||kSdS(u<
    Return v1 == v2. Compares list, dict, recursively.
    R	N(t
isinstancetlistRtlenRtsortt
_id_or_keyRR,Rtdicttsorted(tv1tv2txtytk((sA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pyR,as.		
cC@s>t|t�r:d|kr#|dSd|kr:|dSn|S(u0
    Return the value at key 'id' or 'key'.
    uidukey(R<RA(t	list_item((sA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pyR@scC@s�|jdd�|jdd�tjjjtjtjjj	|dd�j
t�tjjj	|dd�j
t���}dj|�S(u5
    Return string diff of pipeline definitions.
    uResponseMetadatatindentiuN(
tpopRtsalttutilstdatatdecodetdifflibtunified_difftjsontdumpst
splitlinesRtjoin(R!R(tdiff((sA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pyR�s!*c@s,�fd��tj|�}�|�|S(u�
    Return standardized format for lists/dictionaries.

    Lists of dictionaries are sorted by the value of the dictionary at
    its primary key ('id' or 'key'). OrderedDict's are converted to
    basic dictionaries.
    c@s�t|t�r=|jdt�xm|D]}�|�q&WnRt|t�r�t|�}x4tj|�D] \}}�|��|�qhWndS(NR	(R<R=R?R@RARt	iteritems(t	structureteachRGtv(tmutating_helper(sA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pyRZ�s

(R3R4(RWt
new_structure((RZsA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pyR�s
cC@satjtd|��}|j|�tt|��}x"|D]}t|d�|d<q?W|S(u�
    Return a list of pipeline objects that compose the pipeline

    pipeline_objects_from_pillars
        The pillar key to use for lookup

    pipeline_object_overrides
        Pipeline objects to use. Will override objects read from pillars.
    u
pillar.getufields(R3R4RtupdateRt_dict_to_list_idst_properties_from_dict(Rtpipeline_object_overridestfrom_pillarsRR8((sA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pyR�s


cC@satjtd|��}|j|�tt|��}x"|D]}t|d�|d<q?W|S(u
    Return a list of parameter objects that configure the pipeline

    parameter_objects_from_pillars
        The pillar key to use for lookup

    parameter_object_overrides
        Parameter objects to use. Will override objects read from pillars.
    u
pillar.getu
attributes(R3R4RR\RR]R^(Rtparameter_object_overridesR`Rtparameter_object((sA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pyR�s


cC@sBtjtd|��}|j|�t|�}t|dd�S(u
    Return a dictionary of parameter values that configure the pipeline

    parameter_values_from_pillars
        The pillar key to use for lookup

    parameter_value_overrides
        Parameter values to use. Will override values read from pillars.
    u
pillar.gettkey_nameuid(R3R4RR\RR^(Rtparameter_value_overridesR`R
((sA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pyR�s

cC@sQg}xDtj|�D]3\}}i|d6}|j|�|j|�qW|S(u�
    Convert a dictionary to a list of dictionaries, where each element has
    a key value pair {'id': key}. This makes it easy to override pillar values
    while still satisfying the boto api.
    uid(RRVR\tappend(tobjectst
list_with_idsR	tvaluetelement((sA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pyR]�s

ukeycC@svg}xitj|�D]X\}}t|t�rS|ji||6|dd6�q|ji||6|d6�qW|S(u�
    Transforms dictionary into pipeline object properties.

    The output format conforms to boto's specification.

    Example input:
        {
            'a': '1',
            'b': {
                'ref': '2'
            },
        }

    Example output:
        [
            {
                'key': 'a',
                'stringValue': '1',
            },
            {
                'key': 'b',
                'refValue': '2',
            },
        ]
    urefurefValueustringValue(RRVR<RARe(tdRctfieldsR	Rh((sA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pyR^�s		c
C@s�i|d6td6dd6id6}td|d|d|d	|d
|�}d|kr�|d}tdr�d
j|�|d<d|d<|Std|d|d|d	|d
|�i|d6|dd<d|dd<ndj|�|d<|S(u�
    Ensure a pipeline with the service_name does not exist

    name
        Name of the service to ensure a data pipeline does not exist for.

    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.
    unameuresultuucommentuchangesu'boto_datapipeline.pipeline_id_from_nameRR	R
Ruerrorutestu$Data pipeline {0} set to be deleted.u!boto_datapipeline.delete_pipelineupipeline_iduoldunewuAWS data pipeline {0} absent.N(RRRRR(RRR	R
RRR1R#((sA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pytabsents."	


(t__doc__t
__future__RRRR3R5ROtsalt.utils.dataRKtsalt.utils.jsontsalt.extRtsalt.ext.six.movesRRRR RRR-R,R@RRRRRR]R^Rl(((sA/usr/lib/python2.7/site-packages/salt/states/boto_datapipeline.pyt<module>2s<	�		B									)

Zerion Mini Shell 1.0