Ejemplo n.º 1
0
    def _prepare_environment(
        self, data: Data, listener_connection: Tuple[str, str, str]
    ) -> list:
        """Prepare environmental variables."""
        host, port, protocol = listener_connection
        environment = {
            "LISTENER_IP": host,
            "LISTENER_PORT": port,
            "LISTENER_PROTOCOL": protocol,
            "DATA_ID": data.id,
            "FLOW_MANAGER_KEEP_DATA": getattr(
                settings, "FLOW_MANAGER_KEEP_DATA", False
            ),
            "RUNNING_IN_CONTAINER": 1,
            "RUNNING_IN_KUBERNETES": 1,
            "GENIALIS_UID": os.getuid(),
            "GENIALIS_GID": os.getgid(),
            "DESCRIPTOR_CHUNK_SIZE": 100,
            "MOUNTED_CONNECTORS": ",".join(
                connector.name
                for connector in connectors.values()
                if connector.mountable
            ),
        }
        with suppress(RuntimeError):
            environment["UPLOAD_DIR"] = self._get_upload_dir()

        return [
            {"name": name, "value": str(value)} for name, value in environment.items()
        ]
Ejemplo n.º 2
0
    def _get_upload_connector_name(self) -> str:
        """Return storage connector that will be used for new data object.

        The current implementation returns the connector with the lowest
        priority.
        """
        return min((connector.priority, connector.name)
                   for connector in connectors.values())[1]