def setUpClass(cls): super(TestActionsBase, cls).setUpClass() host = vitrage_utils.get_first_host() if not host: raise Exception("No host found") if not host.get(VProps.VITRAGE_AGGREGATED_STATE) == 'AVAILABLE': raise Exception("Host is not running %s" % host) cls.orig_host = host
def _do_test_action_set_state_host(self, trigger_name): try: # Do self._trigger_do_action(trigger_name) curr_host = v_utils.get_first_host() self.assertEqual('ERROR', curr_host.get(VProps.VITRAGE_AGGREGATED_STATE), 'state should change after set_state action') # Undo self._trigger_undo_action(trigger_name) curr_host = v_utils.get_first_host() self.assertEqual( self.orig_host.get(VProps.VITRAGE_AGGREGATED_STATE), curr_host.get(VProps.VITRAGE_AGGREGATED_STATE), 'state should change after undo set_state action') finally: self._trigger_undo_action(trigger_name)
def test_action_set_state_host(self): try: # Do self._trigger_do_action(TRIGGER_ALARM_1) curr_host = v_utils.get_first_host() self.assertEqual('ERROR', curr_host.get(VProps.VITRAGE_AGGREGATED_STATE), 'state should change after set_state action') # Undo self._trigger_undo_action(TRIGGER_ALARM_1) curr_host = v_utils.get_first_host() self.assertEqual( self.orig_host.get(VProps.VITRAGE_AGGREGATED_STATE), curr_host.get(VProps.VITRAGE_AGGREGATED_STATE), 'state should change after undo set_state action') except Exception as e: self._handle_exception(e) raise finally: self._trigger_undo_action(TRIGGER_ALARM_1)
def test_overlapping_action_set_state(self): try: # Do - first self._trigger_do_action(TRIGGER_ALARM_1) curr_host = v_utils.get_first_host() self.assertEqual( 'ERROR', curr_host.get(VProps.VITRAGE_AGGREGATED_STATE), 'state should change after set_state action') # Do - second self._trigger_do_action(TRIGGER_ALARM_2) curr_host = v_utils.get_first_host() self.assertEqual( 'ERROR', curr_host.get(VProps.VITRAGE_AGGREGATED_STATE), 'state should remain unchanged') # Undo - first self._trigger_undo_action(TRIGGER_ALARM_1) curr_host = v_utils.get_first_host() self.assertEqual( 'ERROR', curr_host.get(VProps.VITRAGE_AGGREGATED_STATE), 'state should remain unchanged') # Undo - second self._trigger_undo_action(TRIGGER_ALARM_2) curr_host = v_utils.get_first_host() self.assertEqual( self.orig_host.get(VProps.VITRAGE_AGGREGATED_STATE), curr_host.get(VProps.VITRAGE_AGGREGATED_STATE), 'state should change after undo set_state action') finally: self._trigger_undo_action(TRIGGER_ALARM_1) self._trigger_undo_action(TRIGGER_ALARM_2)
def _get_hostname(): host = vitrage_utils.get_first_host() return host.get(VProps.ID)