def get_config(self):
        """
        Factory to create the configuration of the recorder

        The configuration will be created from the parsed configuration data.
        @return: Configuration of the recorder.
        @rtype: ctamonitoring.property_recorder.config.RecorderConfig
        """
        recorder_config = RecorderConfig()

        if 'default_timer_trigger' in self._args:
            recorder_config.default_timer_trigger = (
                self._args['default_timer_trigger'])
        if 'max_comps' in self._args:
            recorder_config.max_comps = self._args['max_comps']
        if 'max_props' in self._args:
            recorder_config.max_props = self._args['max_props']
        if 'checking_period' in self._args:
            recorder_config.checking_period = self._args['checking_period']
        if 'backend_type' in self._args:
            recorder_config.backend_type = self._args['backend_type']
        if 'backend_config' in self._args:
            recorder_config.backend_config = self._args['backend_config']
        if 'is_include_mode' in self._args:
            recorder_config.is_include_mode = self._args['is_include_mode']
        if 'component_list' in self._args:
            recorder_config.set_components(self._args['component_list'])
        recorder_config.autostart = False  # in standalone mode recording start automatically anyway

        return recorder_config
Example #2
0
    def setUp(self):

        self._my_acs_client = create_autospec(PySimpleClient)
        self._logger = logging.Logger("test_logger")
        self._logger.setLevel(logging.CRITICAL)
        #self._my_acs_client.getLogger = MagicMock(return_value=self._logger)
        config = RecorderConfig()
        config.backend_type = BACKEND_TYPE.DUMMY
        self._front_end = FrontEnd(config, self._my_acs_client)
        self._my_component_id = "TEST_PROPERTIES_COMPONENT"
    def get_cdb_data(component_name):

        cdb = CDBAccess.cdb()

        try:
            componentCDB = XmlObjectifier.XmlObject(
                cdb.get_DAO('alma/%s' % (component_name)))
        except CDBRecordDoesNotExistEx as e:
            raise BadCdbRecorderConfig(e)
        except ExpatError as e:
            raise BadCdbRecorderConfig(e)
        except Exception as e:
            raise BadCdbRecorderConfig(e)

        recorder_config = RecorderConfig()

        try:
            recorder_config.default_timer_trigger = float(
                componentCDB.firstChild.getAttribute(
                    "default_timer_trigger")
                )

        except Exception as e:
            raise BadCdbRecorderConfig(e, "default_timer_trigger")

        try:
            recorder_config.max_comps = int(
                componentCDB.firstChild.getAttribute(
                    "max_comps")
                )
        except Exception as e:
            raise BadCdbRecorderConfig(e, "max_comps")

        try:
            recorder_config.max_props = int(
                componentCDB.firstChild.getAttribute(
                    "max_props")
                )
        except Exception as e:
                raise BadCdbRecorderConfig(e, "max_props")

        try:
            recorder_config.backend_type = enum_util.from_string(
                BACKEND_TYPE,
                componentCDB.firstChild.getAttribute(
                    "backend")
                )
        except Exception as e:
            raise BadCdbRecorderConfig(e, "backend")

        try:
            recorder_config.backend_config = ast.literal_eval(
                componentCDB.firstChild.getAttribute(
                    "backend_config"))
        except Exception as e:
            raise BadCdbRecorderConfig(e, "backend_config")

        try:
            recorder_config.checking_period = int(
                componentCDB.firstChild.getAttribute(
                    "checking_period")
                )
        except Exception as e:
            raise BadCdbRecorderConfig(e, "checking_period")

        try:

            if componentCDB.firstChild.getAttribute("is_include") == 'true':
                recorder_config.is_include_mode = True
            elif componentCDB.firstChild.getAttribute("is_include") == 'false':
                recorder_config.is_include_mode = False
            else:
                raise BadCdbRecorderConfig()
        except Exception as e:
            raise BadCdbRecorderConfig(e, "is_include")

        try:
            if componentCDB.firstChild.getAttribute("autostart") == 'true':
                recorder_config.autostart = True
            else:
                recorder_config.autostart = False
        except Exception as e:
            pass

        try:
            componentCDB.firstChild.getAttribute(
                "component_list")
            recorder_config.set_components(set(
                ast.literal_eval(componentCDB.firstChild.getAttribute(
                    "component_list")
                )))
        except Exception as e:
            raise BadCdbRecorderConfig(e, "component_list")

        return recorder_config
Example #4
0
 def setUp(self):
     self._my_acs_client = PySimpleClient()
     self._my_acs_client.getLogger().setLevel(logging.CRITICAL)
     self._front_end = FrontEnd(RecorderConfig(), self._my_acs_client)
     self.__my_component_id = "TEST_PROPERTIES_COMPONENT"
Example #5
0
 def setUp(self):
     self.recoder_config = RecorderConfig()
 def setUp(self):
     recorder_config = RecorderConfig()
     self.recorder = MockedStandaloneRecorder(
         recorder_config, logging.CRITICAL)