File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/boto_cloudwatch.cpython-310.pyc
Back
o ;j�+ � @ s d Z ddlZddlmZ ddlZddlZddlZzddlZddl Zddl ZddlZe�d�� ej� dZW n ey@ dZY nw e�e�Zdd� Zdd d �Zdd� Zdd d�Z ddd�Zddd�Zddd�Zdd� ZdS )a� Connection module for Amazon CloudWatch .. versionadded:: 2014.7.0 :configuration: This module accepts explicit 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 cloudwatch.keyid: GKTADJGHEIQSXMKKRBJ08H cloudwatch.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs A region may also be specified in the configuration: .. code-block:: yaml cloudwatch.region: us-east-1 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: boto � N)�OrderedDict�botoTFc C s0 t jjjdd�} | du rtd tddtd� | S )z, Only load if boto libraries exist. F)Zcheck_boto3Tzboto.assign_funcs� cloudwatchzec2.cloudwatch)�module�pack)�salt�utilsZversionsZcheck_boto_reqs� __utils__�__name__�__salt__)Z has_boto_reqs� r �P/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/boto_cloudwatch.py�__virtual__E s �r c C sJ t ||||d�}|j| gd�}|sdS t|�dkrt�d| � t|d �S )z� Get alarm details. Also can be used to check to see if an alarm exists. CLI Example: .. code-block:: bash salt myminion boto_cloudwatch.get_alarm myalarm region=us-east-1 ��region�key�keyid�profile)Zalarm_namesN� z!multiple alarms matched name '%s'r )� _get_conn�describe_alarms�len�log�error�_metric_alarm_to_dict)�namer r r r �conn�alarmsr r r � get_alarmQ s r c C s\ t d d�}dd� }tjtjjjj||d� dd� }tjtjjjj ||d� t d | |d�S ) zv this presenter magic makes yaml.safe_dump work with the objects returned from boto.describe_alarms() zyaml.get_dumperZSafeOrderedDumperc S � | � t|��S �N)Zrepresent_list�list�Zdumper�datar r r �boto_listelement_presenterm � z._safe_dump.<locals>.boto_listelement_presenter)ZDumperc S r r )Zrepresent_dict�dictr"