Beispiel #1
0
class ApiSiteConfig(Config):

    BACKENDS = {
        "memory": MemoryOptOutBackend,
        "riak": RiakOptOutBackend,
    }

    backend = ConfigText("Optout backend to use. One of 'memory' or 'riak'",
                         required=True)

    backend_config = ConfigDict("Configuration for backend.", default={})

    auth_bouncer_url = ConfigText(
        "URL to bounce requests to for authentication", default=None)

    url_path_prefix = ConfigText("URL path prefix for the optout API.",
                                 default="optouts")

    def post_validate(self):
        if self.backend not in self.BACKENDS:
            self.raise_config_error("Backend must be one of: %s" %
                                    ", ".join(self.BACKENDS.keys()))

    def create_backend(self):
        return self.BACKENDS[self.backend].from_config(self.backend_config)

    def create_auth(self):
        if self.auth_bouncer_url:
            return BouncerAuth(self.auth_bouncer_url)
        return RequestHeaderAuth()
Beispiel #2
0
class NginxPluginConfig(Config):
    '''Config for :class:`NginxJunebugPlugin`'''

    vhost_file = ConfigText(
        "The file to write the junebug nginx vhost file to",
        default='/etc/nginx/sites-enabled/junebug.conf',
        static=True)

    locations_dir = ConfigText(
        "The directory to write location block config files to",
        default='/etc/nginx/includes/junebug/',
        static=True)

    server_name = ConfigText("Server name to use for nginx vhost",
                             required=True,
                             static=True)

    vhost_template = ConfigText(
        "Path to the template file to use for the vhost config",
        default=resource_path('vhost.template'),
        static=True)

    location_template = ConfigText(
        "Path to the template file to use for each channel's location config",
        default=resource_path('location.template'),
        static=True)
Beispiel #3
0
class GraphiteBackendConfig(MetricsBackend.config_class):
    graphite_url = ConfigText(
        "Url for the graphite web server to query",
        default='http://127.0.0.1:8080')

    prefix = ConfigText(
        "Prefix for all metric names. Defaults to 'go.campaigns'",
        default='go.campaigns')

    persistent = ConfigBool(
        ("Flag given to treq telling it whether to maintain a single "
         "connection for the requests made to graphite's web app."),
        default=True)

    username = ConfigText(
        "Basic auth username for authenticating requests to graphite.",
        required=False)

    password = ConfigText(
        "Basic auth password for authenticating requests to graphite.",
        required=False)

    max_response_size = ConfigInt(
        ("Maximum number of data points to return. If a request specifies a "
         "time range and interval that contains more data than this, it is "
         "rejected."),
        default=10000)

    amqp_hostname = ConfigText(
        "Hostname for where AMQP broker is located",
        default='127.0.0.1')

    amqp_port = ConfigInt(
        "Port to connect to the AMQP broker",
        default=5672)

    amqp_username = ConfigText(
        "Username to connect to the AMQP broker",
        default="guest")

    amqp_password = ConfigText(
        "Password to connect to the AMQP broker",
        default="guest")

    amqp_vhost = ConfigText(
        "Virtualhost for AMQP broker",
        default="/")

    amqp_spec = ConfigText(
        "Spec file for AMQP",
        default="amqp-spec-0-8.xml")

    def post_validate(self):
        auth = (self.username, self.password)
        exists = [x is not None for x in auth]

        if any(exists) and not all(exists):
            raise ConfigError(
                "Either both a username and password need to be given or "
                "neither for graphite backend config")
Beispiel #4
0
class LoggingMiddlewareConfig(BaseMiddlewareConfig):
    """
    Configuration class for the logging middleware.
    """
    log_level = ConfigText(
        "Log level from :mod:`vumi.log` to log inbound and outbound messages "
        "and events at",
        default='info',
        static=True)
    failure_log_level = ConfigText(
        "Log level from :mod:`vumi.log` to log failure messages at",
        default='error',
        static=True)
Beispiel #5
0
class StaticProviderSetterMiddlewareConfig(BaseMiddlewareConfig):
    """
    Config class for the static provider setting middleware.
    """
    provider = ConfigText("Value to set the ``provider`` field to",
                          required=True,
                          static=True)
Beispiel #6
0
class SessionLengthMiddlewareConfig(BaseMiddlewareConfig):
    """
    Configuration class for the session length middleware.
    """

    redis = ConfigDict("Redis config", default={}, static=True)
    timeout = ConfigInt("Redis key timeout (secs)", default=600, static=True)
    field_name = ConfigText(
        "Field name in message helper_metadata", default="session",
        static=True)
Beispiel #7
0
class SessionLengthMiddlewareConfig(BaseMiddlewareConfig):
    """
    Configuration class for the session length middleware.
    """

    redis_manager = ConfigDict("Redis config", default={}, static=True)
    timeout = ConfigInt("Redis key timeout (secs)", default=600, static=True)
    namespace_type = ConfigText(
        "Namespace to use to lookup and set the (address, timestamp) "
        "key-value pairs in redis. Possible types: "
        "    - transport_name: the message's `transport_name` field is used."
        "    - tag: the tag associated to the message is used. *Note*: this "
        "      requires the `TaggingMiddleware` to be earlier in the "
        "      middleware chain.",
        default='transport_name',
        static=True)
    field_name = ConfigText("Field name in message helper_metadata",
                            default="session",
                            static=True)
Beispiel #8
0
class StoringMiddlewareConfig(BaseMiddlewareConfig):
    """
    Config class for the storing middleware.
    """
    store_prefix = ConfigText(
        "Prefix for message store keys in key-value store.",
        default='message_store',
        static=True)
    redis_manager = ConfigDict("Redis configuration parameters",
                               default={},
                               static=True)
    riak_manager = ConfigRiak(
        "Riak configuration parameters. Must contain at least a bucket_prefix"
        " key",
        required=True,
        static=True)
    store_on_consume = ConfigBool(
        "``True`` to store consumed messages as well as published ones, "
        "``False`` to store only published messages.",
        default=True,
        static=True)
Beispiel #9
0
class JunebugConfig(Config):
    interface = ConfigText(
        "Interface to expose the API on",
        default='localhost')

    port = ConfigInt(
        "Port to expose the API on",
        default=8080)

    logfile = ConfigText(
        "File to log to or `None` for no logging",
        default=None)

    redis = ConfigDict(
        "Config to use for redis connection",
        default={
            'host': 'localhost',
            'port': 6379,
            'db': 0,
            'password': None
        })

    amqp = ConfigDict(
        "Config to use for amqp connection",
        default={
            'hostname': '127.0.0.1',
            'vhost': '/',
            'port': 5672,
            'db': 0,
            'username': '******',
            'password': '******'
        })

    inbound_message_ttl = ConfigInt(
        "Maximum time (in seconds) allowed to reply to messages",
        default=60 * 10)

    outbound_message_ttl = ConfigInt(
        "Maximum time (in seconds) allowed for events to arrive for messages",
        default=60 * 60 * 24 * 2)

    channels = ConfigDict(
        "Mapping between channel types and python classes.",
        default={})

    replace_channels = ConfigBool(
        "If `True`, replaces the default channels with `channels`. If `False`,"
        " `channels` is added to the default channels.",
        default=False)

    plugins = ConfigList(
        "A list of dictionaries describing all of the enabled plugins. Each "
        "item should have a `type` key, with the full python class name of "
        "the plugin.", default=[])

    metric_window = ConfigFloat(
        "The size of the buckets (in seconds) used for metrics.", default=10.0)

    logging_path = ConfigText(
        "The path to place log files in.", default="logs/")

    log_rotate_size = ConfigInt(
        "The maximum size (in bytes) of a log file before it gets rotated.",
        default=1000000)

    max_log_files = ConfigInt(
        "The maximum amount of log files allowed before old files start to "
        "get deleted. 0 is unlimited.", default=5)

    max_logs = ConfigInt(
        "The maximum amount of logs that is allowed to be retrieved via the "
        "API.", default=100)
Beispiel #10
0
 class ToyBackendConfig(DummyBackend.config_class):
     foo = ConfigText("A foo")
Beispiel #11
0
 class ConfigWithFallback(Config):
     oldfield = ConfigText("oldfield", required=False)
     newfield = ConfigText(
         "newfield", required=False,
         fallbacks=[SingleFieldFallback("oldfield")])
Beispiel #12
0
 class ConfigWithFallback(Config):
     text_field = ConfigText("text_field", default="foo")
     int_field = ConfigInt("int_field")
Beispiel #13
0
 class ConfigWithFallback(Config):
     field = ConfigText("field")
     field_empty = ConfigText("field_empty")
     field_default = ConfigText("field_default", default="bar")
     field_default_required = ConfigText("field_default", default="baz")
Beispiel #14
0
 class FooConfig(Config):
     "Test config."
     foo = ConfigField("A foo field.")
     bar = ConfigText("A bar field.")
Beispiel #15
0
class VoiceServerTransportConfig(Transport.CONFIG_CLASS):
    """
    Configuration parameters for the voice transport
    """

    to_addr = ConfigText("The ``to_addr`` to use for inbound messages.",
                         default="freeswitchvoice",
                         static=True)

    tts_type = ConfigText(
        "Either 'freeswitch' or 'local' to specify where TTS is executed.",
        default="freeswitch",
        static=True)

    tts_fs_engine = ConfigText(
        "Specify Freeswitch TTS engine to use (only affects tts_type"
        " 'freeswitch').",
        default="flite",
        static=True)

    tts_fs_voice = ConfigText(
        "Specify Freeswitch TTS voice to use (only affects tts_type"
        " 'freeswitch').",
        default="kal",
        static=True)

    tts_local_command = ConfigText(
        "Specify command template to use for generating voice files (only"
        " affects tts_type 'local'). E.g. 'flite -o {filename} -t {text}'."
        " Command parameters are split on whitespace (no shell-like escape"
        " processing is performed on the command).",
        default=None,
        static=True)

    tts_local_cache = ConfigText(
        "Specify folder to cache voice files (only affects tts_type"
        " 'local').",
        default=".",
        static=True)

    tts_local_ext = ConfigText(
        "Specify the file extension used for cached voice files (only affects"
        " tts_type 'local').",
        default="wav",
        static=True)

    twisted_endpoint = ConfigServerEndpoint(
        "The endpoint the voice transport will listen on (and that Freeswitch"
        " will connect to).",
        required=True,
        default="tcp:port=8084",
        static=True)

    freeswitch_endpoint = ConfigClientEndpoint(
        "The endpoint the voice transport will send originate commands"
        "to (and that Freeswitch listens on).",
        default=None,
        static=True)

    freeswitch_auth = ConfigText(
        "Password for connecting to the Freeswitch endpoint."
        " None means no authentication credentials are offered.",
        default=None,
        static=True)

    originate_parameters = ConfigDict(
        "The parameters to pass to the originate command when initiating"
        " outbound calls. This dictionary of parameters is passed to the"
        " originate call template:\n\n"
        "  %(template)r\n\n"
        "All call parameters are required but the following defaults are"
        " supplied:\n\n"
        "  %(defaults)r" % {
            'template': OriginateFormatter.PROTO_TEMPLATE,
            'defaults': OriginateFormatter.DEFAULT_PARAMS,
        },
        default=None,
        static=True)

    wait_for_answer = ConfigBool(
        "If True, the transport waits for a ChannelAnswer event for outbound "
        "(originated) calls before playing any media.",
        default=True,
        static=True)

    @property
    def supports_outbound(self):
        return self.freeswitch_endpoint is not None

    def post_validate(self):
        super(VoiceServerTransportConfig, self).post_validate()
        required_outbound = (self.freeswitch_endpoint
                             is not None, self.originate_parameters
                             is not None)
        if self.supports_outbound and not all(required_outbound):
            raise ConfigError(
                "If any outbound message parameters are supplied"
                " (freeswitch_endpoint or originate_params), all must be"
                " given.")
        if self.originate_parameters is not None:
            try:
                OriginateFormatter(**self.originate_parameters)
            except OriginateMissingParameter as err:
                raise ConfigError(str(err))
Beispiel #16
0
class JunebugConfig(Config):
    interface = ConfigText(
        "Interface to expose the API on",
        default='localhost')

    port = ConfigInt(
        "Port to expose the API on",
        default=8080)

    logfile = ConfigText(
        "File to log to or `None` for no logging",
        default=None)

    sentry_dsn = ConfigText(
        "DSN to send exceptions",
        default=None)

    redis = ConfigDict(
        "Config to use for redis connection",
        default={
            'host': 'localhost',
            'port': 6379,
            'db': 0,
            'password': None
        })

    amqp = ConfigDict(
        "Config to use for amqp connection",
        default={
            'hostname': '127.0.0.1',
            'vhost': '/',
            'port': 5672,
            'db': 0,
            'username': '******',
            'password': '******'
        })

    inbound_message_ttl = ConfigInt(
        "Maximum time (in seconds) allowed to reply to messages",
        default=60 * 10)

    outbound_message_ttl = ConfigInt(
        "Maximum time (in seconds) allowed for events to arrive for messages",
        default=60 * 60 * 24 * 2)

    allow_expired_replies = ConfigBool(
        "If `True` messages with a reply_to that arrive for which the "
        "original inbound cannot be found (possible of the TTL expiring) are "
        "sent as normal outbound messages. ",
        default=False)

    channels = ConfigDict(
        "Mapping between channel types and python classes.",
        default={})

    replace_channels = ConfigBool(
        "If `True`, replaces the default channels with `channels`. If `False`,"
        " `channels` is added to the default channels.",
        default=False)

    routers = ConfigDict(
        "Mapping between router types and python classes.",
        default={})

    replace_routers = ConfigBool(
        "If `True`, replaces the default routers with `routers`. If `False`,"
        "`routers` is added to the default routers.",
        default=False)

    plugins = ConfigList(
        "A list of dictionaries describing all of the enabled plugins. Each "
        "item should have a `type` key, with the full python class name of "
        "the plugin.", default=[])

    metric_window = ConfigFloat(
        "The size of the buckets (in seconds) used for metrics.", default=10.0)

    logging_path = ConfigText(
        "The path to place log files in.", default="logs/")

    log_rotate_size = ConfigInt(
        "The maximum size (in bytes) of a log file before it gets rotated.",
        default=1000000)

    max_log_files = ConfigInt(
        "The maximum amount of log files allowed before old files start to "
        "get deleted. 0 is unlimited.", default=5)

    max_logs = ConfigInt(
        "The maximum amount of logs that is allowed to be retrieved via the "
        "API.", default=100)

    rabbitmq_management_interface = ConfigText(
        "This should be the url string of the rabbitmq management interface."
        "If set, the health of each individual queue will be checked. "
        "This is only available for RabbitMQ",
        default=None)
Beispiel #17
0
 class ConfigWithFallback(Config):
     field = ConfigText("field", default="foo")
Beispiel #18
0
 class ConfigWithFallback(Config):
     text_field = ConfigText("text_field")
     int_field = ConfigInt("int_field")
Beispiel #19
0
 class ConfigWithFallback(Config):
     field = ConfigText("field")