예제 #1
0
 def __init__(self, session=None, service_type='alarming', **kwargs):
     """Initialize a new client for the Aodh v2 API."""
     self.api = client.SessionClient(session,
                                     service_type=service_type,
                                     **kwargs)
     self.alarm = alarm.AlarmManager(self)
     self.alarm_history = alarm_history.AlarmHistoryManager(self)
     self.capabilities = capabilities.CapabilitiesManager(self)
예제 #2
0
 def test_search(self, mock_ahm):
     ahm = alarm_history.AlarmHistoryManager(self.client)
     q = '{"and": [{"=": {"type": "threshold"}}, ' + \
         '{"=": {"alarm_id": "87bacbcb-a09c-4cb9-86d0-ad410dd8ad98"}}]}'
     ahm.search(q)
     expected_called_data = '{"filter": "{\\"and\\": [{\\"=\\": ' + \
                            '{\\"type\\": \\"threshold\\"}}, ' + \
                            '{\\"=\\": {\\"alarm_id\\": \\"87bacbcb-' + \
                            'a09c-4cb9-86d0-ad410dd8ad98\\"}}]}"}'
     mock_ahm.assert_called_with(
         'v2/query/alarms/history',
         data=expected_called_data,
         headers={'Content-Type': 'application/json'})
 def test_get(self, mock_ahm):
     ahm = alarm_history.AlarmHistoryManager(self.client)
     ahm.get('01919bbd-8b0e-451c-be28-abe250ae9b1b')
     mock_ahm.assert_called_with(
         'v2/alarms/01919bbd-8b0e-451c-be28-abe250ae9b1b/history')