Пример #1
0
 def test_invalid_alarm_list(self):
     snippet = template_format.parse(combination_alarm_template)
     snippet['Resources']['CombinAlarm']['Properties']['alarm_ids'] = []
     stack = utils.parse_stack(snippet)
     resource_defns = stack.t.resource_definitions(stack)
     rsrc = alarm.CombinationAlarm('CombinAlarm',
                                   resource_defns['CombinAlarm'], stack)
     error = self.assertRaises(exception.StackValidationFailed,
                               rsrc.validate)
     self.assertEqual(
         "Property error: Resources.CombinAlarm.Properties.alarm_ids: "
         "length (0) is out of range (min: 1, max: None)",
         six.text_type(error))
Пример #2
0
 def create_alarm(self):
     ceilometer.CeilometerClientPlugin._create().AndReturn(
         self.fc)
     self.m.StubOutWithMock(self.fc.alarms, 'create')
     self.fc.alarms.create(
         alarm_actions=[],
         description=u'Do stuff in combination',
         enabled=True,
         insufficient_data_actions=[],
         ok_actions=[],
         name=mox.IgnoreArg(), type='combination',
         repeat_actions=True,
         combination_rule={'alarm_ids': [u'alarm1', u'alarm2'],
                           'operator': u'and'},
         time_constraints=[],
         severity='low'
     ).AndReturn(FakeCombinationAlarm())
     self.tmpl = template_format.parse(combination_alarm_template)
     self.stack = utils.parse_stack(self.tmpl)
     resource_defns = self.stack.t.resource_definitions(self.stack)
     return alarm.CombinationAlarm(
         'CombinAlarm', resource_defns['CombinAlarm'], self.stack)