示例#1
0
 def __call__(self, parser, namespace, values, option_string=None):
     from azure.mgmt.monitor.models import MetricTrigger
     if len(values) == 1:
         # workaround because CMD.exe eats > character... Allows condition to be
         # specified as a quoted expression
         values = values[0].split(' ')
     name_offset = 0
     try:
         metric_name = ' '.join(values[name_offset:-4])
         operator = get_autoscale_operator_map()[values[-4]]
         threshold = int(values[-3])
         aggregation = get_autoscale_aggregation_map()[values[-2].lower()]
         window = period_type(values[-1])
     except (IndexError, KeyError):
         from knack.util import CLIError
         raise CLIError('usage error: --condition METRIC {==,!=,>,>=,<,<=} '
                        'THRESHOLD {avg,min,max,total,count} PERIOD')
     condition = MetricTrigger(
         metric_name=metric_name,
         metric_resource_uri=None,  # will be filled in later
         time_grain=None,  # will be filled in later
         statistic=None,  # will be filled in later
         time_window=window,
         time_aggregation=aggregation,
         operator=operator,
         threshold=threshold
     )
     namespace.condition = condition
示例#2
0
 def __call__(self, parser, namespace, values, option_string=None):
     from azure.mgmt.monitor.models import MetricTrigger
     if len(values) == 1:
         # workaround because CMD.exe eats > character... Allows condition to be
         # specified as a quoted expression
         values = values[0].split(' ')
     name_offset = 0
     try:
         metric_name = ' '.join(values[name_offset:-4])
         operator = get_autoscale_operator_map()[values[-4]]
         threshold = int(values[-3])
         aggregation = get_autoscale_aggregation_map()[values[-2].lower()]
         window = period_type(values[-1])
     except (IndexError, KeyError):
         from knack.util import CLIError
         raise CLIError('usage error: --condition METRIC {==,!=,>,>=,<,<=} '
                        'THRESHOLD {avg,min,max,total,count} PERIOD')
     condition = MetricTrigger(
         metric_name=metric_name,
         metric_resource_uri=None,  # will be filled in later
         time_grain=None,  # will be filled in later
         statistic=None,  # will be filled in later
         time_window=window,
         time_aggregation=aggregation,
         operator=operator,
         threshold=threshold)
     namespace.condition = condition
示例#3
0
 def exitAggregation(self, ctx):
     aggregation = get_autoscale_aggregation_map()[ctx.getText().strip()]
     self.parameters['time_aggregation'] = aggregation