How to use the eliot.Field.for_types function in eliot

To help you get started, we’ve selected a few eliot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ClusterHQ / flocker / flocker / node / agents / _logging.py View on Github external
u"flocker:node:agents:blockdevice:aws:in_use_devices",
    [DEVICES],
    u"Log current devices.",
)

NEW_DEVICES = Field.for_types(
    u"new_devices", [list],
    u"List of new devices in the compute instance.")
NEW_DEVICES_SIZE = Field.for_types(
    u"new_devices_size", [list],
    u"List of sizes of new devices in the compute instance.")
EXPECTED_SIZE = Field.for_types(
    u"expected_size", [int],
    u"Size, in bytes, of new device we are expecting to manifest."
    u"in the OS.")
TIME_LIMIT = Field.for_types(
    u"time_limit", [int],
    u"Time, in seconds, waited for new device to manifest in the OS.")
NO_NEW_DEVICE_IN_OS = MessageType(
    u"flocker:node:agents:blockdevice:aws:no_new_device",
    [NEW_DEVICES, NEW_DEVICES_SIZE, EXPECTED_SIZE, TIME_LIMIT],
    u"No new block device manifested in the OS in given time.",)

VOLUME_ID = Field.for_types(
    u"volume_id", [bytes, unicode],
    u"The identifier of volume of interest.")
STATUS = Field.for_types(
    u"status", [bytes, unicode],
    u"Current status of the volume.")
TARGET_STATUS = Field.for_types(
    u"target_status", [bytes, unicode],
    u"Expected target status of the volume, as a result of an AWS API call.")
github ClusterHQ / flocker / flocker / common / runner.py View on Github external
u"Local path."
        ),
        Field.for_types(u"port", [int], u"SSH port."),
        Field(
            u"identity_file",
            lambda f: f and f.path,
            u"SSH identity file."
        ),
    ],
    successFields=[],
    description="An SCP operation.",
)
SCP_OUTPUT_MESSAGE = MessageType(
    message_type="flocker.common.runner:scp:stdout",
    fields=[
        Field.for_types(u"line", [bytes], u"The output."),
    ],
    description=u"A line of command output.",
)
SCP_ERROR_MESSAGE = MessageType(
    message_type="flocker.common.runner:scp:stderr",
    fields=[
        Field.for_types(u"line", [bytes], u"The error."),
    ],
    description=u"A line of command stderr.",
)


class RemoteFileNotFound(Exception):
    """
    A file on a remote server was not found.
    """
github ClusterHQ / flocker / flocker / common / _openstack.py View on Github external
)

from ._thread import _interface_decorator


CODE = Field.for_types("code", [int], u"The HTTP response code.")
MESSAGE = Field.for_types(
    "message", [bytes, unicode],
    u"A human-readable error message given by the response.",
)
DETAILS = Field.for_types("details", [dict], u"Extra details about the error.")
REQUEST_ID = Field.for_types(
    "request_id", [bytes, unicode],
    u"The unique identifier assigned by the server for this request.",
)
URL = Field.for_types("url", [bytes, unicode], u"The request URL.")
METHOD = Field.for_types("method", [bytes, unicode], u"The request method.")

NOVA_CLIENT_EXCEPTION = MessageType(
    u"openstack:nova_client_exception", [
        CODE,
        MESSAGE,
        DETAILS,
        REQUEST_ID,
        URL,
        METHOD,
    ],
)

RESPONSE = Field.for_types("response", [bytes, unicode], u"The response body.")

KEYSTONE_HTTP_ERROR = MessageType(
github ClusterHQ / flocker / flocker / node / agents / _logging.py View on Github external
[VOLUME_ID, STATUS, TARGET_STATUS, NEEDS_ATTACH_DATA, WAIT_TIME],
    u"Waiting for a volume to reach target status.",)

CREATE_VOLUME_FAILURE = MessageType(
    u"flocker:node:agents:blockdevice:aws:boto_create_volume_failure",
    [DATASET_ID, AWS_CODE, AWS_MESSAGE],
    u"Create volume operation failed. Retrying with default profile.",)

BOTO_LOG_HEADER = u'flocker:node:agents:blockdevice:aws:boto_logs'

BOTO_LOG_RESULT = u'flocker:node:agents:blockdevice:aws:boto_result'

VOLUME_BUSY_MESSAGE = MessageType(
    u"flocker:node:agents:blockdevice:aws:volume_busy",
    [
        Field.for_types("attachments", [list], u"Known volume attachments."),
        Field.for_types("volume_id", [bytes, unicode], u"The blockdevice ID."),
    ],
)

INVALID_FLOCKER_CLUSTER_ID = MessageType(
    u"flocker:node:agents:blockdevice:aws:invalid_flocker_cluster_id",
    [
        Field.for_types(
            "flocker_cluster_id",
            [unicode],
            u"The discovered flocker-cluster-id value."
        ),
        Field.for_types("volume_id", [bytes, unicode], u"The blockdevice ID."),
    ],
    u"A volume had a flocker-cluster-id tag but the value was not a uuid4.",)
github ClusterHQ / flocker / flocker / common / runner.py View on Github external
from characteristic import attributes
from eliot import MessageType, ActionType, Field
from eliot.twisted import DeferredContext

from twisted.python.failure import Failure
from twisted.internet.error import ProcessTerminated, ProcessDone
from twisted.internet.defer import Deferred
from twisted.internet.protocol import ProcessProtocol

from twisted.protocols.basic import LineOnlyReceiver


RUN_ACTION = ActionType(
    action_type="flocker.common.runner:run",
    startFields=[
        Field.for_types(u"command", [list], u"The command.")
    ],
    successFields=[],
    description="Run a command.",
)
RUN_OUTPUT_MESSAGE = MessageType(
    message_type="flocker.common.runner:run:stdout",
    fields=[
        Field.for_types(u"line", [bytes], u"The output."),
    ],
    description=u"A line of command output.",
)
RUN_ERROR_MESSAGE = MessageType(
    message_type="flocker.common.runner:run:stderr",
    fields=[
        Field.for_types(u"line", [bytes], u"The error."),
    ],
github ClusterHQ / flocker / flocker / node / agents / functional / logging.py View on Github external
# Copyright ClusterHQ Inc.  See LICENSE file for details.

from eliot import Field, MessageType

CINDER_VOLUME = MessageType(
    u"flocker:functional:cinder:cinder_volume:created",
    [Field.for_types(
        u"id", [bytes, unicode],
        u"The Cinder-assigned unique identifier for the volume that was "
        u"created.",
github ClusterHQ / flocker / flocker / control / _persistence.py View on Github external
are JSON serializable.

    :param obj: An object that can be passed to ``wire_encode``.
    :return: Python object that can be JSON serialized.
    """
    return _cached_dfs_serialize(obj)

_DEPLOYMENT_FIELD = Field(u"configuration", to_unserialized_json)
_LOG_STARTUP = MessageType(u"flocker-control:persistence:startup",
                           [_DEPLOYMENT_FIELD])
_LOG_SAVE = ActionType(u"flocker-control:persistence:save",
                       [_DEPLOYMENT_FIELD], [])

_UPGRADE_SOURCE_FIELD = Field.for_types(
    u"source_version", [int], u"Configuration version to upgrade from.")
_UPGRADE_TARGET_FIELD = Field.for_types(
    u"target_version", [int], u"Configuration version to upgrade to.")
_LOG_UPGRADE = ActionType(u"flocker-control:persistence:migrate_configuration",
                          [_DEPLOYMENT_FIELD, _UPGRADE_SOURCE_FIELD,
                           _UPGRADE_TARGET_FIELD, ], [])
_LOG_EXPIRE = MessageType(
    u"flocker-control:persistence:lease-expired",
    [Field(u"dataset_id", unicode), Field(u"node_id", unicode)],
    u"A lease for a dataset has expired.")

_LOG_UNCHANGED_DEPLOYMENT_NOT_SAVED = MessageType(
    u"flocker-control:persistence:unchanged-deployment-not-saved",
    [],
    u"The persistence service was told to save a deployment which is the same "
    u"as the already-saved deployment.  It has optimized this away."
)
github ClusterHQ / flocker / flocker / provision / _ssh / _conch.py View on Github external
from twisted.internet.error import ConnectionDone
from twisted.protocols.basic import LineOnlyReceiver
from twisted.python.filepath import FilePath
import os

from ...common import loop_until, timeout
from ._model import (
    Run, Sudo, Put, Comment, RunRemotely, perform_comment, perform_put,
    perform_sudo)

from .._effect import dispatcher as base_dispatcher

RUN_OUTPUT_MESSAGE = MessageType(
    message_type="flocker.provision.ssh:run:output",
    fields=[
        Field.for_types(u"line", [bytes], u"The output."),
    ],
    description=u"A line of command output.",
)


def extReceived(self, ext_type, data):
    from twisted.conch.ssh.connection import EXTENDED_DATA_STDERR
    if ext_type == EXTENDED_DATA_STDERR:
        self.dataReceived(data)


@attributes([
    "deferred",
    "context",
])
class CommandProtocol(LineOnlyReceiver, object):
github ClusterHQ / flocker / flocker / node / agents / _logging.py View on Github external
)

DEVICES = Field.for_types(
    u"devices", [list],
    u"List of devices currently in use by the compute instance.")
NO_AVAILABLE_DEVICE = MessageType(
    u"flocker:node:agents:blockdevice:aws:no_available_device",
    [DEVICES],
)
IN_USE_DEVICES = MessageType(
    u"flocker:node:agents:blockdevice:aws:in_use_devices",
    [DEVICES],
    u"Log current devices.",
)

NEW_DEVICES = Field.for_types(
    u"new_devices", [list],
    u"List of new devices in the compute instance.")
NEW_DEVICES_SIZE = Field.for_types(
    u"new_devices_size", [list],
    u"List of sizes of new devices in the compute instance.")
EXPECTED_SIZE = Field.for_types(
    u"expected_size", [int],
    u"Size, in bytes, of new device we are expecting to manifest."
    u"in the OS.")
TIME_LIMIT = Field.for_types(
    u"time_limit", [int],
    u"Time, in seconds, waited for new device to manifest in the OS.")
NO_NEW_DEVICE_IN_OS = MessageType(
    u"flocker:node:agents:blockdevice:aws:no_new_device",
    [NEW_DEVICES, NEW_DEVICES_SIZE, EXPECTED_SIZE, TIME_LIMIT],
    u"No new block device manifested in the OS in given time.",)