Beispiel #1
0
def initialize_logging(instance_id: str = None,
                       instance: Instance = None,
                       system: System = None) -> Instance:
    """Initialize logging of Instance.

    Args:
        instance_id: The Instance ID
        instance: The Instance
        system: The System

    Returns:
        The Instance
    """
    system, instance = _from_kwargs(system=system,
                                    instance=instance,
                                    instance_id=instance_id)

    logger.debug(f"Initializing logging for instance {system}[{instance}]")

    requests.process_request(
        Request.from_template(
            initialize_logging_request,
            namespace=system.namespace,
            system=system.name,
            system_version=system.version,
            instance_name=instance.name,
        ),
        is_admin=True,
        priority=1,
    )

    return instance
Beispiel #2
0
def publish_start(system, instance):
    requests.process_request(
        Request.from_template(
            start_request,
            namespace=system.namespace,
            system=system.name,
            system_version=system.version,
            instance_name=instance.name,
        ),
        is_admin=True,
        priority=1,
    )
Beispiel #3
0
def publish_stop(system, instance=None):
    request_args = {
        "namespace": system.namespace,
        "system": system.name,
        "system_version": system.version,
    }

    if instance:
        request_args["instance_name"] = instance.name

    requests.process_request(Request.from_template(stop_request,
                                                   **request_args),
                             is_admin=True,
                             priority=1)
Beispiel #4
0
def read_logs(
    instance_id: str = None,
    instance: Instance = None,
    system: System = None,
    start_line: int = None,
    end_line: int = None,
    wait_event: threading.Event = None,
) -> Request:
    """Read lines from an Instance's log file.

    Args:
        instance_id: The Instance ID
        instance: The Instance
        system: The System
        start_line: Start reading log file at
        end_line: Stop reading log file at
        wait_event: Wait event for response

    Returns:
        Request object with logs as output
    """
    system, instance = _from_kwargs(system=system,
                                    instance=instance,
                                    instance_id=instance_id)

    logger.debug(f"Reading Logs from instance {system}[{instance}]")

    request = requests.process_request(
        Request.from_template(
            read_logs_request,
            namespace=system.namespace,
            system=system.name,
            system_version=system.version,
            instance_name=instance.name,
            parameters={
                "start_line": start_line,
                "end_line": end_line
            },
        ),
        is_admin=True,
        wait_event=wait_event,
    )

    return request