def __get_monitor_config(
            self, config_dir: str) -> Sequence[ComponentMonitorConfig]:
        '''Reads all component configuration parameters from the given config directory.

        Keyword arguments:
        config_dir -- absolute path to a component configuration directory

        '''
        monitor_config_params = ConfigUtils.get_config_params(config_dir)
        return monitor_config_params
Beispiel #2
0
 def setUpClass(cls):
     test_dir = os.path.abspath(os.path.dirname(__file__))
     main_dir = os.path.dirname(test_dir)
     config_file = os.path.join(main_dir,
                                "config/component_monitoring_config.yaml")
     cls.config_data = ConfigUtils.read_config(config_file)
     cls.robot_id = cls.config_data['robot_id']
     cls.query_interface = ComponentMonitoringQueryInterface(
         config_file, main_dir)
     cls.test_pyre_node = QueryTest()
     cls.timeout_duration = 3
     time.sleep(3)
 def __init__(self, config_file, main_dir):
     config_data = ConfigUtils.read_config(config_file)
     self.robot_id = config_data['robot_id']
     self.config_file = config_file
     self.main_dir = main_dir
     super(ComponentMonitoringQueryInterface, self).__init__(
         {
             'node_name':
             'component_monitoring_query_interface_' + self.robot_id,
             'groups': ['ROPOD'],
             'message_types': list()
         },
         verbose=True)
     self.start()
    def get_config(self):
        """Get all configuration for component monitoring and return it in a 
        single dict.

        :returns: dict

        """
        config = dict()
        config_data = ConfigUtils.read_config(self.config_file)
        config['main_config'] = config_data

        hw_monitor_config_dir = os.path.join(
            self.main_dir, config_data['config_dirs']['hardware'])
        hw_monitor_config_params = ConfigUtils.get_config_params(
            hw_monitor_config_dir)
        config['hw_config'] = [i.get_dict() for i in hw_monitor_config_params]
        sw_monitor_config_dir = os.path.join(
            self.main_dir, config_data['config_dirs']['software'])
        sw_monitor_config_params = ConfigUtils.get_config_params(
            sw_monitor_config_dir)
        config['sw_config'] = [i.get_dict() for i in sw_monitor_config_params]

        return config
    def __init__(self, config_file_path: str):
        '''Keyword arguments:

        config_file_path -- path to a configuration file for the component monitoring application

        '''
        if not 'COMPONENT_MONITORING_ROOT' in os.environ:
            raise AssertionError(
                'The COMPONENT_MONITORING_ROOT environment variable has to be set to the path of the component monitoring application'
            )

        self.root_dir = os.environ['COMPONENT_MONITORING_ROOT']
        self.config_data = ConfigUtils.read_config(
            join(self.root_dir, config_file_path))
        self.network = self.__create_network()
Beispiel #6
0
from component_monitoring.config.config_utils import ConfigUtils
from component_monitoring.utils.robot_store_interface import RobotStoreInterface

if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='Initialise robot store interface',
        epilog='EXAMPLE: python3 init_robot_store_interface.py config.yaml')
    parser.add_argument(
        '--config_file',
        type=str,
        default='config/component_monitoring_config.yaml',
        help='Path to a configuration file for the component monitoring')

    args = parser.parse_args()
    config_file_path = args.config_file
    config_data = ConfigUtils.read_config(config_file_path)

    robot_id = config_data['robot_id']
    hw_monitor_config_dir = config_data['config_dirs']['hardware']
    sw_monitor_config_dir = config_data['config_dirs']['software']

    # we read the parameters of the hardware and software monitors
    print('Reading the configuration of the hardware monitors')
    hw_monitor_config_params = ConfigUtils.get_config_params(
        hw_monitor_config_dir)

    print('Reading the configuration of the software monitors')
    sw_monitor_config_params = ConfigUtils.get_config_params(
        sw_monitor_config_dir)

    # we create an interface to the robot store interface
Beispiel #7
0
        '''
        response_msg = dict()
        response_msg['header'] = dict()
        response_msg['header']['metamodel'] = 'ropod-msg-schema.json'
        response_msg['header']['type'] = 'COMPONENT-MANAGEMENT-RESPONSE'
        response_msg['header']['msgId'] = str(uuid.uuid4())
        response_msg['header']['timestamp'] = time.time()
        response_msg['payload'] = dict()
        response_msg['payload']['receiverId'] = ''
        return response_msg


if __name__ == '__main__':
    from component_monitoring.config.config_utils import ConfigUtils
    from component_monitoring.utils.component_network import ComponentNetwork

    config_file_path = 'config/component_monitoring_config.yaml'
    config_data = ConfigUtils.read_config(config_file_path)

    component_network = ComponentNetwork(config_file_path)
    recovery_manager = RecoveryManager(config_data['recovery_config'],
                                       component_network.network)

    try:
        recovery_manager.start_manager()
        while True:
            time.sleep(0.5)
    except (KeyboardInterrupt, SystemExit):
        print('Recovery manager exiting')
        recovery_manager.stop()