예제 #1
0
    def setup_subparser(cls, subparser):
        """Add kinesis subparser: manage.py kinesis [options]"""
        set_parser_epilog(subparser,
                          epilog=('''\
                Example:

                    manage.py kinesis disable-events --clusters corp prod
                '''))

        actions = ['disable-events', 'enable-events']
        subparser.add_argument(
            'action',
            metavar='ACTION',
            choices=actions,
            help='One of the following actions to be performed: {}'.format(
                ', '.join(actions)))

        # Add the option to specify cluster(s)
        add_clusters_arg(subparser)

        subparser.add_argument(
            '-s',
            '--skip-terraform',
            action='store_true',
            help='Only update the config options and do not run Terraform')
예제 #2
0
    def setup_subparser(cls, subparser):
        """Add the create-cluster-alarm subparser: manage.py create-cluster-alarm [options]"""
        set_parser_epilog(subparser,
                          epilog=('''\
                Other Constraints:

                    The product of the value for period multiplied by the value for evaluation
                    periods cannot exceed 86,400. 86,400 is the number of seconds in one day and
                    an alarm's total current evaluation period can be no longer than one day.

                Example:

                    manage.py create-cluster-alarm FailedParsesAlarm \\
                      --metric FailedParses \\
                      --comparison-operator GreaterThanOrEqualToThreshold \\
                      --evaluation-periods 1 \\
                      --period 300 \\
                      --threshold 1.0 \\
                      --clusters prod \\
                      --statistic Sum \\
                      --alarm-description 'Alarm for any failed parses that occur \
    within a 5 minute period in the prod cluster'

                Resources:

                    AWS:        https://docs.aws.amazon.com/AmazonCloudWatch/\
    latest/APIReference/API_PutMetricAlarm.html
                    Terraform:  https://www.terraform.io/docs/providers/aws/r/\
    cloudwatch_metric_alarm.html
                '''))

        _add_default_metric_alarms_args(subparser, clustered=True)

        # Add the option to specify cluster(s)
        add_clusters_arg(subparser, required=True)
예제 #3
0
def _add_default_tf_args(tf_parser, add_cluster_args=True):
    """Add the default terraform parser options"""
    tf_parser.add_argument(
        '-t',
        '--target',
        metavar='TARGET',
        help=
        ('One or more Terraform module name to target. Use `list-targets` for a list '
         'of available targets'),
        action=UniqueSortedListAction,
        default=[],
        nargs='+')

    if add_cluster_args:
        # Add the option to specify cluster(s)
        add_clusters_arg(tf_parser)
예제 #4
0
    def setup_subparser(cls, subparser):
        """Add the metrics subparser: manage.py custom-metrics [options]"""
        set_parser_epilog(subparser,
                          epilog=('''\
                Example:

                    manage.py custom-metrics --enable --functions rule
                '''))

        available_metrics = metrics.MetricLogger.get_available_metrics()
        available_functions = [
            func for func, value in available_metrics.items() if value
        ]

        # allow the user to select 1 or more functions to enable metrics for
        subparser.add_argument(
            '-f',
            '--functions',
            choices=available_functions,
            metavar='FUNCTION',
            help=
            'One or more of the following functions for which to enable metrics: {}'
            .format(', '.join(available_functions)),
            nargs='+',
            required=True)

        # get the metric toggle value
        toggle_group = subparser.add_mutually_exclusive_group(required=True)

        toggle_group.add_argument('-e',
                                  '--enable',
                                  dest='enable_custom_metrics',
                                  help='Enable custom CloudWatch metrics',
                                  action='store_true')

        toggle_group.add_argument('-d',
                                  '--disable',
                                  dest='enable_custom_metrics',
                                  help='Disable custom CloudWatch metrics',
                                  action='store_false')

        # Add the option to specify cluster(s)
        add_clusters_arg(subparser)