def do_alarm_combination_create(cc, args={}): '''Create a new alarm based on state of other alarms.''' fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = utils.key_with_slash_to_nested_dict(fields) fields['type'] = 'combination' alarm = cc.alarms.create(**fields) _display_alarm(alarm)
def do_alarm_combination_create(cc, args={}): """Create a new alarm based on state of other alarms.""" fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = utils.args_array_to_list_of_dicts(fields, 'time_constraints') fields = utils.key_with_slash_to_nested_dict(fields) fields['type'] = 'combination' alarm = cc.alarms.create(**fields) _display_alarm(alarm)
def do_alarm_combination_create(cc, args={}): """Create a new alarm based on state of other alarms.""" fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = utils.args_array_to_list_of_dicts(fields, "time_constraints") fields = utils.key_with_slash_to_nested_dict(fields) fields["type"] = "combination" alarm = cc.alarms.create(**fields) _display_alarm(alarm)
def do_alarm_gnocchi_aggregation_by_resources_threshold_create(cc, args={}): """Create a new alarm based on computed statistics.""" fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = utils.args_array_to_list_of_dicts(fields, "time_constraints") fields = utils.key_with_slash_to_nested_dict(fields) fields["type"] = "gnocchi_aggregation_by_resources_threshold" alarm = cc.alarms.create(**fields) _display_alarm(alarm)
def do_alarm_threshold_create(cc, args={}): '''Create a new alarm based on computed statistics.''' fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = utils.key_with_slash_to_nested_dict(fields) fields['type'] = 'threshold' if 'query' in fields['threshold_rule']: fields['threshold_rule']['query'] = options.cli_to_array( fields['threshold_rule']['query']) alarm = cc.alarms.create(**fields) _display_alarm(alarm)
def do_alarm_threshold_create(cc, args={}): """Create a new alarm based on computed statistics.""" fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = utils.args_array_to_list_of_dicts(fields, "time_constraints") fields = utils.key_with_slash_to_nested_dict(fields) fields["type"] = "threshold" if "query" in fields["threshold_rule"]: fields["threshold_rule"]["query"] = options.cli_to_array(fields["threshold_rule"]["query"]) alarm = cc.alarms.create(**fields) _display_alarm(alarm)
def do_alarm_combination_update(cc, args={}): '''Update an existing alarm based on state of other alarms.''' fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = utils.key_with_slash_to_nested_dict(fields) fields.pop('alarm_id') fields['type'] = 'combination' try: alarm = cc.alarms.update(args.alarm_id, **fields) except exc.HTTPNotFound: raise exc.CommandError('Alarm not found: %s' % args.alarm_id) _display_alarm(alarm)
def do_alarm_combination_update(cc, args={}): """Update an existing alarm based on state of other alarms.""" fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = utils.args_array_to_list_of_dicts(fields, "time_constraints") fields = utils.key_with_slash_to_nested_dict(fields) fields.pop("alarm_id") fields["type"] = "combination" try: alarm = cc.alarms.update(args.alarm_id, **fields) except exc.HTTPNotFound: raise exc.CommandError("Alarm not found: %s" % args.alarm_id) _display_alarm(alarm)
def do_alarm_threshold_update(cc, args={}): '''Update an existing alarm based on computed statistics.''' fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = utils.key_with_slash_to_nested_dict(fields) fields.pop('alarm_id') fields['type'] = 'threshold' if 'threshold_rule' in fields and 'query' in fields['threshold_rule']: fields['threshold_rule']['query'] = options.cli_to_array( fields['threshold_rule']['query']) try: alarm = cc.alarms.update(args.alarm_id, **fields) except exc.HTTPNotFound: raise exc.CommandError('Alarm not found: %s' % args.alarm_id) _display_alarm(alarm)
def do_alarm_threshold_update(cc, args={}): '''Update an existing alarm based on computed statistics.''' fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = utils.key_with_slash_to_nested_dict(fields) fields.pop('alarm_id') fields['type'] = 'threshold' if 'query' in fields['threshold_rule']: fields['threshold_rule']['query'] = options.cli_to_array( fields['threshold_rule']['query']) try: alarm = cc.alarms.update(args.alarm_id, **fields) except exc.HTTPNotFound: raise exc.CommandError('Alarm not found: %s' % args.alarm_id) _display_alarm(alarm)
def do_alarm_threshold_update(cc, args={}): """Update an existing alarm based on computed statistics.""" fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = utils.args_array_to_list_of_dicts(fields, "time_constraints") fields = utils.key_with_slash_to_nested_dict(fields) fields.pop("alarm_id") fields["type"] = "threshold" if "threshold_rule" in fields and "query" in fields["threshold_rule"]: fields["threshold_rule"]["query"] = options.cli_to_array(fields["threshold_rule"]["query"]) try: alarm = cc.alarms.update(args.alarm_id, **fields) except exc.HTTPNotFound: raise exc.CommandError("Alarm not found: %s" % args.alarm_id) _display_alarm(alarm)
def take_action(self, parsed_args): """Update output values for an existing csv pipeline.""" ceilometer_client = self.app.client_manager.telemetry fields = dict( filter(lambda x: not (x[1] is None), vars(parsed_args).items())) fields = ceilometer_utils.key_with_slash_to_nested_dict(fields) fields.pop('name') try: pipeline = ceilometer_client.pipelines.update( parsed_args.name, **fields) except exc.HTTPNotFound: raise exc.CommandError('Pipeline not found: %s' % parsed_args.name) _show_pipeline(pipeline)
def test_key_with_slash_to_nested_dict(self): my_args = { 'combination_rule/alarm_ids': ['id1', 'id2'], 'combination_rule/operator': 'and', 'threshold_rule/threshold': 400, 'threshold_rule/statictic': 'avg', 'threshold_rule/comparison_operator': 'or', } nested_dict = utils.key_with_slash_to_nested_dict(my_args) self.assertEqual(nested_dict, { 'combination_rule': {'alarm_ids': ['id1', 'id2'], 'operator': 'and'}, 'threshold_rule': {'threshold': 400, 'statictic': 'avg', 'comparison_operator': 'or'}, })
def test_key_with_slash_to_nested_dict(self): my_args = { 'combination_rule/alarm_ids': ['id1', 'id2'], 'combination_rule/operator': 'and', 'threshold_rule/threshold': 400, 'threshold_rule/statictic': 'avg', 'threshold_rule/comparison_operator': 'or', } nested_dict = utils.key_with_slash_to_nested_dict(my_args) self.assertEqual({ 'combination_rule': {'alarm_ids': ['id1', 'id2'], 'operator': 'and'}, 'threshold_rule': {'threshold': 400, 'statictic': 'avg', 'comparison_operator': 'or'}, }, nested_dict)
def test_key_with_slash_to_nested_dict(self): my_args = { "combination_rule/alarm_ids": ["id1", "id2"], "combination_rule/operator": "and", "threshold_rule/threshold": 400, "threshold_rule/statictic": "avg", "threshold_rule/comparison_operator": "or", } nested_dict = utils.key_with_slash_to_nested_dict(my_args) self.assertEqual( nested_dict, { "combination_rule": {"alarm_ids": ["id1", "id2"], "operator": "and"}, "threshold_rule": {"threshold": 400, "statictic": "avg", "comparison_operator": "or"}, }, )