示例#1
0
def create_aodh_alarm(resource_id=None, name=None, unic=True):
    if not name:
        name = '%s-%s' % ('test_', random.randrange(0, 100000, 1))
    elif unic:
        name = '%s-%s' % (name, random.randrange(0, 100000, 1))

    aodh_request = _aodh_request(resource_id=resource_id, name=name)
    TempestClients.aodh().alarm.create(aodh_request)
    time.sleep(45)
示例#2
0
    def test_validate_notifier(self):
        """validate_notifier test

        There tests validates work of aodh alarm notifier -
        all created vitrage alarms appears in ceilometer
        alarms-list.
        IMPORTANT: enable notifiers=aodh in vitrage.conf file
        """
        try:
            nova_utils.create_instances(num_instances=2,
                                        set_public_network=True)
            self._create_alarm(
                resource_id=self._get_hostname(),
                alarm_name=RCA_ALARM_NAME)
            vitrage_alarms = TempestClients.vitrage().alarm.list(
                vitrage_id='all', all_tenants=True)
            aodh_alarms = TempestClients.aodh().alarm.list()

            self._validate_notifier(alarms=aodh_alarms,
                                    vitrage_alarms=vitrage_alarms)
        except Exception as e:
            self._handle_exception(e)
            raise
        finally:
            self._clean_all()
示例#3
0
def delete_all_aodh_alarms():
    alarms = TempestClients.aodh().alarm.list()
    for alarm in alarms:
        TempestClients.aodh().alarm.delete(alarm[AodhProps.ALARM_ID])
    time.sleep(120)
示例#4
0
    def _check_num_alarms(self, num_alarms=0, state=''):
        if len(TempestClients.aodh().alarm.list()) != num_alarms:
            return False

        return all(alarm[AodhProps.STATE].upper() == state.upper()
                   for alarm in TempestClients.aodh().alarm.list())