예제 #1
0
def _setup_network_listeners(command_parser, session_coordinator):
    """ Initializes the various network listeners used by the hardware manager.
  
  This method initializes the network listeners required to accept ground station commands and relay pipeline data 
  streams.
  
  @param command_parser       An instance of CommandParser which will be used to handle commands received over the 
                              network.
  @param session_coordinator  A SessionCoordinator instance that will be passed to the pipeline protocol factories which
                              will allow them to associate connections with existing sessions. 
  """

    # Create a TLS context factory for the various listeners
    tls_context_factory = verification.create_tls_context_factory()

    # Setup the command listener
    command_factory = Site(command_connection.CommandResource(command_parser))
    reactor.listenSSL(Configuration.get("command-port"), command_factory, tls_context_factory)

    # Setup the pipeline data & telemetry stream listeners
    pipeline_data_factory = data.PipelineDataFactory(session_coordinator)
    reactor.listenSSL(Configuration.get("pipeline-data-port"), pipeline_data_factory, tls_context_factory)
    pipeline_telemetry_factory = telemetry.PipelineTelemetryFactory(session_coordinator)
    reactor.listenSSL(
        Configuration.get("pipeline-telemetry-port"), WebSocketFactory(pipeline_telemetry_factory), tls_context_factory
    )
예제 #2
0
def _setup_schedule_manager():
    """ Initializes the schedule manager.
  
  This function initializes the schedule manager based on the location of the schedule (either local or remote).
  
  @return Returns an instance to the new ScheduleManager instance.
  """

    # Setup the schedule manager
    if Configuration.get("offline-mode"):
        schedule_manager = schedule.ScheduleManager(Configuration.get("schedule-location-local"))
    else:
        schedule_manager = schedule.ScheduleManager(Configuration.get("schedule-location-network"))

    return schedule_manager
예제 #3
0
def _setup_configuration():
    """ Sets up the HWM configuration class.
  
  This function initializes the HWM configuration class (a singleton) by loading the required configuration files into
  it and validating the loaded configuration against the configuration schema (which defines which options are required
  and any formatting constraints).

  @throws May pass on ConfigInvalid exceptions if the loaded configuration set is invalid or incomplete.
  """

    # Read the configuration files
    Configuration.read_configuration(Configuration.config_directory + "configuration.yml")
    Configuration.read_configuration(Configuration.config_directory + "devices.yml")
    Configuration.read_configuration(Configuration.config_directory + "pipelines.yml")

    # Verify that all required configuration options are set
    Configuration.validate_configuration()
예제 #4
0
def _setup_command_system():
    """ Sets up the command system.
  
  This function sets up the CommandParser class which is responsible for parsing, validating, and executing commands
  (either from the network or internal scripts). It also, consequently, initializes the permission system which updates
  and exposes user command execution permissions.
  
  @return Returns a reference to the new CommandParser instance.
  """

    # Initialize the command resources
    system_command_handlers = []
    system_command_handlers.append(system_command_handler.SystemCommandHandler("system"))
    if Configuration.get("offline-mode"):
        permission_manager = permissions.PermissionManager(
            Configuration.get("permissions-location-local"), Configuration.get("permissions-update-period")
        )
    else:
        permission_manager = permissions.PermissionManager(
            Configuration.get("permissions-location-network"), Configuration.get("permissions-update-period")
        )
    command_parser = command_parser_mod.CommandParser(system_command_handlers, permission_manager)

    return command_parser