swift_central_api | index /Users/karl/code/swift_management/swift_central_api.py

`Central api for central ring management and health status aggregation
Manages gradual draining and filling of devices as they are removed
and added, via a redis store storing target weights of devices.`

Modules
`` |  |
argparse copy json os | pdb requests shutil socket | subprocess swift sys time | tornado tornadoredis traceback xmltodict

Classes
`` |  | exceptions.Exception(exceptions.BaseException) SwiftBuilderException swift.common.ring.ring.Ring(__builtin__.object) SwiftRingBuilder tornado_lib.CallbackHandler(tornado.web.RequestHandler) HealthHandler PushRingHandler RedisHandler SwiftHostHandler SwiftInitHandler SwiftRingHandler
class HealthHandler(tornado_lib.CallbackHandler)
`` | `Request handler for /health that summarizes health information over the entire swift cluster.`
| Method resolution order: HealthHandler tornado_lib.CallbackHandler tornado.web.RequestHandler __builtin__.object Methods defined here: get(*args, **kwargs) `GET /health Returns json with the following structure: { "[ring_type]": { "summary": { "total_space_TB": [total space], "used_space_TB": [used space], "percent_used": [percent used] }, "servers": { "[host ip:port]": { "used_space_TB": [used space], "total_space_TB": [total space], "percent_used": [percent used], "unhealthy_devices": [ { "uuid": [uuid], "drive": [device path] }, ... ] }, ... } }, ... } Any unmounted devices will show up in the unhealthy devices list. These devices require attention and/or replacement.` Methods inherited from tornado_lib.CallbackHandler: options(*args, **kwargs) `Expose all methods in options.` write_with_callback(self, obj) `Write a response as a jsonp callback.` Methods inherited from tornado.web.RequestHandler: __init__(self, application, request, **kwargs) add_header(self, name, value) `Adds the given response header and value. Unlike `set_header`, `add_header` may be called multiple times to return multiple values for the same header.` check_etag_header(self) `Checks the ``Etag`` header against requests's ``If-None-Match``. Returns ``True`` if the request's Etag matches and a 304 should be returned. For example:: set_etag_header() if check_etag_header(): set_status(304) return This method is called automatically when the request is finished, but may be called earlier for applications that override `compute_etag` and want to do an early check for ``If-None-Match`` before completing the request. The ``Etag`` header should be set (perhaps with `set_etag_header`) before calling this method.` check_xsrf_cookie(self) `Verifies that the ``_xsrf`` cookie matches the ``_xsrf`` argument. To prevent cross-site request forgery, we set an ``_xsrf`` cookie and include the same value as a non-cookie field with all ``POST`` requests. If the two do not match, we reject the form submission as a potential forgery. The ``_xsrf`` value may be set as either a form field named ``_xsrf`` or in a custom HTTP header named ``X-XSRFToken`` or ``X-CSRFToken`` (the latter is accepted for compatibility with Django). See http://en.wikipedia.org/wiki/Cross-site_request_forgery Prior to release 1.1.1, this check was ignored if the HTTP header ``X-Requested-With: XMLHTTPRequest`` was present. This exception has been shown to be insecure and has been removed. For more information please see http://www.djangoproject.com/weblog/2011/feb/08/security/ http://weblog.rubyonrails.org/2011/2/8/csrf-protection-bypass-in-ruby-on-rails .. versionchanged:: 3.2.2 Added support for cookie version 2. Both versions 1 and 2 are supported.` clear(self) `Resets all headers and content for this response.` clear_all_cookies(self, path='/', domain=None) `Deletes all the cookies the user sent with this request. See `clear_cookie` for more information on the path and domain parameters. .. versionchanged:: 3.2 Added the ``path`` and ``domain`` parameters.` clear_cookie(self, name, path='/', domain=None) `Deletes the cookie with the given name. Due to limitations of the cookie protocol, you must pass the same path and domain to clear a cookie as were used when that cookie was set (but there is no way to find out on the server side which values were used for a given cookie).` clear_header(self, name) `Clears an outgoing header, undoing a previous `set_header` call. Note that this method does not apply to multi-valued headers set by `add_header`.` compute_etag(self) `Computes the etag header to be used for this request. By default uses a hash of the content written so far. May be overridden to provide custom etag implementations, or may return None to disable tornado's default etag support.` create_signed_value(self, name, value, version=None) `Signs and timestamps a string so it cannot be forged. Normally used via set_secure_cookie, but provided as a separate method for non-cookie uses. To decode a value not stored as a cookie use the optional value argument to get_secure_cookie. .. versionchanged:: 3.2.1 Added the ``version`` argument. Introduced cookie version 2 and made it the default.` create_template_loader(self, template_path) `Returns a new template loader for the given path. May be overridden by subclasses. By default returns a directory-based loader on the given path, using the ``autoescape`` application setting. If a ``template_loader`` application setting is supplied, uses that instead.` data_received(self, chunk) `Implement this method to handle streamed request data. Requires the `.stream_request_body` decorator.` decode_argument(self, value, name=None) `Decodes an argument from the request. The argument has been percent-decoded and is now a byte string. By default, this method decodes the argument as utf-8 and returns a unicode string, but this may be overridden in subclasses. This method is used as a filter for both `get_argument()` and for values extracted from the url and passed to `get()`/`post()`/etc. The name of the argument is provided if known, but may be None (e.g. for unnamed groups in the url regex).` delete(self, *args, **kwargs) finish(self, chunk=None) `Finishes this response, ending the HTTP request.` flush(self, include_footers=False, callback=None) `Flushes the current output buffer to the network. The ``callback`` argument, if given, can be used for flow control: it will be run when all flushed data has been written to the socket. Note that only one flush callback can be outstanding at a time; if another flush occurs before the previous flush's callback has been run, the previous callback will be discarded. .. versionchanged:: 4.0 Now returns a `.Future` if no callback is given.` get_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode.` get_arguments(self, name, strip=True) `Returns a list of the arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode.` get_body_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name from the request body. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode. .. versionadded:: 3.2` get_body_arguments(self, name, strip=True) `Returns a list of the body arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode. .. versionadded:: 3.2` get_browser_locale(self, default='en_US') `Determines the user's locale from ``Accept-Language`` header. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4` get_cookie(self, name, default=None) `Gets the value of the cookie with the given name, else default.` get_current_user(self) `Override to determine the current user from, e.g., a cookie.` get_login_url(self) `Override to customize the login URL based on the request. By default, we use the ``login_url`` application setting.` get_query_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name from the request query string. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode. .. versionadded:: 3.2` get_query_arguments(self, name, strip=True) `Returns a list of the query arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode. .. versionadded:: 3.2` get_secure_cookie(self, name, value=None, max_age_days=31, min_version=None) `Returns the given signed cookie if it validates, or None. The decoded cookie value is returned as a byte string (unlike `get_cookie`). .. versionchanged:: 3.2.1 Added the ``min_version`` argument. Introduced cookie version 2; both versions 1 and 2 are accepted by default.` get_status(self) `Returns the status code for our response.` get_template_namespace(self) `Returns a dictionary to be used as the default template namespace. May be overridden by subclasses to add or modify values. The results of this method will be combined with additional defaults in the `tornado.template` module and keyword arguments to `render` or `render_string`.` get_template_path(self) `Override to customize template path for each handler. By default, we use the ``template_path`` application setting. Return None to load templates relative to the calling file.` get_user_locale(self) `Override to determine the locale from the authenticated user. If None is returned, we fall back to `get_browser_locale()`. This method should return a `tornado.locale.Locale` object, most likely obtained via a call like ``tornado.locale.get("en")``` head(self, *args, **kwargs) initialize(self) `Hook for subclass initialization. A dictionary passed as the third argument of a url spec will be supplied as keyword arguments to initialize(). Example:: class ProfileHandler(RequestHandler): def initialize(self, database): self.database = database def get(self, username): ... app = Application([ (r'/user/(.*)', ProfileHandler, dict(database=database)), ])` log_exception(self, typ, value, tb) `Override to customize logging of uncaught exceptions. By default logs instances of `HTTPError` as warnings without stack traces (on the ``tornado.general`` logger), and all other exceptions as errors with stack traces (on the ``tornado.application`` logger). .. versionadded:: 3.1` on_connection_close(self) `Called in async handlers if the client closed the connection. Override this to clean up resources associated with long-lived connections. Note that this method is called only if the connection was closed during asynchronous processing; if you need to do cleanup after every request override `on_finish` instead. Proxies may keep a connection open for a time (perhaps indefinitely) after the client has gone away, so this method may not be called promptly after the end user closes their connection.` on_finish(self) `Called after the end of a request. Override this method to perform cleanup, logging, etc. This method is a counterpart to `prepare`. ``on_finish`` may not produce any output, as it is called after the response has been sent to the client.` patch(self, *args, **kwargs) post(self, *args, **kwargs) prepare(self) `Called at the beginning of a request before `get`/`post`/etc. Override this method to perform common initialization regardless of the request method. Asynchronous support: Decorate this method with `.gen.coroutine` or `.return_future` to make it asynchronous (the `asynchronous` decorator cannot be used on `prepare`). If this method returns a `.Future` execution will not proceed until the `.Future` is done. .. versionadded:: 3.1 Asynchronous support.` put(self, *args, **kwargs) redirect(self, url, permanent=False, status=None) `Sends a redirect to the given (optionally relative) URL. If the ``status`` argument is specified, that value is used as the HTTP status code; otherwise either 301 (permanent) or 302 (temporary) is chosen based on the ``permanent`` argument. The default is 302 (temporary).` render(self, template_name, **kwargs) `Renders the template with the given arguments as the response.` render_string(self, template_name, **kwargs) `Generate the given template with the given arguments. We return the generated byte string (in utf8). To generate and write a template as a response, use render() above.` require_setting(self, name, feature='this feature') `Raises an exception if the given app setting is not defined.` reverse_url(self, name, *args) `Alias for `Application.reverse_url`.` send_error(self, status_code=500, **kwargs) `Sends the given HTTP error code to the browser. If `flush()` has already been called, it is not possible to send an error, so this method will simply terminate the response. If output has been written but not yet flushed, it will be discarded and replaced with the error page. Override `write_error()` to customize the error page that is returned. Additional keyword arguments are passed through to `write_error`.` set_cookie(self, name, value, domain=None, expires=None, path='/', expires_days=None, **kwargs) `Sets the given cookie name/value with the given options. Additional keyword arguments are set on the Cookie.Morsel directly. See http://docs.python.org/library/cookie.html#morsel-objects for available attributes.` set_default_headers(self) `Override this to set HTTP headers at the beginning of the request. For example, this is the place to set a custom ``Server`` header. Note that setting such headers in the normal flow of request processing may not do what you want, since headers may be reset during error handling.` set_etag_header(self) `Sets the response's Etag header using ``compute_etag()``. Note: no header will be set if ``compute_etag()`` returns ``None``. This method is called automatically when the request is finished.` set_header(self, name, value) `Sets the given response header name and value. If a datetime is given, we automatically format it according to the HTTP specification. If the value is not a string, we convert it to a string. All header values are then encoded as UTF-8.` set_secure_cookie(self, name, value, expires_days=30, version=None, **kwargs) `Signs and timestamps a cookie so it cannot be forged. You must specify the ``cookie_secret`` setting in your Application to use this method. It should be a long, random sequence of bytes to be used as the HMAC secret for the signature. To read a cookie set with this method, use `get_secure_cookie()`. Note that the ``expires_days`` parameter sets the lifetime of the cookie in the browser, but is independent of the ``max_age_days`` parameter to `get_secure_cookie`. Secure cookies may contain arbitrary byte values, not just unicode strings (unlike regular cookies) .. versionchanged:: 3.2.1 Added the ``version`` argument. Introduced cookie version 2 and made it the default.` set_status(self, status_code, reason=None) `Sets the status code for our response. :arg int status_code: Response status code. If ``reason`` is ``None``, it must be present in `httplib.responses <http.client.responses>`. :arg string reason: Human-readable reason phrase describing the status code. If ``None``, it will be filled in from `httplib.responses <http.client.responses>`.` static_url(self, path, include_host=None, **kwargs) `Returns a static URL for the given relative static file path. This method requires you set the ``static_path`` setting in your application (which specifies the root directory of your static files). This method returns a versioned url (by default appending ``?v=<signature>``), which allows the static files to be cached indefinitely. This can be disabled by passing ``include_version=False`` (in the default implementation; other static file implementations are not required to support this, but they may support other options). By default this method returns URLs relative to the current host, but if ``include_host`` is true the URL returned will be absolute. If this handler has an ``include_host`` attribute, that value will be used as the default for all `static_url` calls that do not pass ``include_host`` as a keyword argument.` write(self, chunk) `Writes the given chunk to the output buffer. To write the output to the network, use the flush() method below. If the given chunk is a dictionary, we write it as JSON and set the Content-Type of the response to be ``application/json``. (if you want to send JSON as a different ``Content-Type``, call set_header *after* calling write()). Note that lists are not converted to JSON because of a potential cross-site security vulnerability. All JSON output should be wrapped in a dictionary. More details at http://haacked.com/archive/2009/06/25/json-hijacking.aspx/ and https://github.com/facebook/tornado/issues/1009` write_error(self, status_code, **kwargs) `Override to implement custom error pages. ``write_error`` may call `write`, `render`, `set_header`, etc to produce output as usual. If this error was caused by an uncaught exception (including HTTPError), an ``exc_info`` triple will be available as ``kwargs["exc_info"]``. Note that this exception may not be the "current" exception for purposes of methods like ``sys.exc_info()`` or ``traceback.format_exc``.` xsrf_form_html(self) `An HTML ``<input/>`` element to be included with all POST forms. It defines the ``_xsrf`` input value, which we check on all POST requests to prevent cross-site request forgery. If you have set the ``xsrf_cookies`` application setting, you must include this HTML within all of your HTML forms. In a template, this method should be called with ``{% module xsrf_form_html() %}`` See `check_xsrf_cookie()` above for more information.` Data descriptors inherited from tornado.web.RequestHandler: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)` cookies `An alias for `self.request.cookies <.httputil.HTTPServerRequest.cookies>`.` current_user `The authenticated user for this request. This is a cached version of `get_current_user`, which you can override to set the user based on, e.g., a cookie. If that method is not overridden, this method always returns None. We lazy-load the current user the first time this method is called and cache the result after that.` locale `The local for the current session. Determined by either `get_user_locale`, which you can override to set the locale based on, e.g., a user preference stored in a database, or `get_browser_locale`, which uses the ``Accept-Language`` header.` settings `An alias for `self.application.settings <Application.settings>`.` xsrf_token `The XSRF-prevention token for the current user/session. To prevent cross-site request forgery, we set an '_xsrf' cookie and include the same '_xsrf' value as an argument with all POST requests. If the two do not match, we reject the form submission as a potential forgery. See http://en.wikipedia.org/wiki/Cross-site_request_forgery .. versionchanged:: 3.2.2 The xsrf token will now be have a random mask applied in every request, which makes it safe to include the token in pages that are compressed. See http://breachattack.com for more information on the issue fixed by this change. Old (version 1) cookies will be converted to version 2 when this method is called unless the ``xsrf_cookie_version`` `Application` setting is set to 1.` Data and other attributes inherited from tornado.web.RequestHandler: SUPPORTED_METHODS = ('GET', 'HEAD', 'POST', 'DELETE', 'PATCH', 'PUT', 'OPTIONS')
class PushRingHandler(tornado_lib.CallbackHandler)
`` | `Request handler for /push_ring, which triggers a ring file push to all swift nodes.`
| Method resolution order: PushRingHandler tornado_lib.CallbackHandler tornado.web.RequestHandler __builtin__.object Methods defined here: post(*args, **kwargs) `POST /push_ring. Causes the local ring file to be blasted everywhere.` Methods inherited from tornado_lib.CallbackHandler: options(*args, **kwargs) `Expose all methods in options.` write_with_callback(self, obj) `Write a response as a jsonp callback.` Methods inherited from tornado.web.RequestHandler: __init__(self, application, request, **kwargs) add_header(self, name, value) `Adds the given response header and value. Unlike `set_header`, `add_header` may be called multiple times to return multiple values for the same header.` check_etag_header(self) `Checks the ``Etag`` header against requests's ``If-None-Match``. Returns ``True`` if the request's Etag matches and a 304 should be returned. For example:: set_etag_header() if check_etag_header(): set_status(304) return This method is called automatically when the request is finished, but may be called earlier for applications that override `compute_etag` and want to do an early check for ``If-None-Match`` before completing the request. The ``Etag`` header should be set (perhaps with `set_etag_header`) before calling this method.` check_xsrf_cookie(self) `Verifies that the ``_xsrf`` cookie matches the ``_xsrf`` argument. To prevent cross-site request forgery, we set an ``_xsrf`` cookie and include the same value as a non-cookie field with all ``POST`` requests. If the two do not match, we reject the form submission as a potential forgery. The ``_xsrf`` value may be set as either a form field named ``_xsrf`` or in a custom HTTP header named ``X-XSRFToken`` or ``X-CSRFToken`` (the latter is accepted for compatibility with Django). See http://en.wikipedia.org/wiki/Cross-site_request_forgery Prior to release 1.1.1, this check was ignored if the HTTP header ``X-Requested-With: XMLHTTPRequest`` was present. This exception has been shown to be insecure and has been removed. For more information please see http://www.djangoproject.com/weblog/2011/feb/08/security/ http://weblog.rubyonrails.org/2011/2/8/csrf-protection-bypass-in-ruby-on-rails .. versionchanged:: 3.2.2 Added support for cookie version 2. Both versions 1 and 2 are supported.` clear(self) `Resets all headers and content for this response.` clear_all_cookies(self, path='/', domain=None) `Deletes all the cookies the user sent with this request. See `clear_cookie` for more information on the path and domain parameters. .. versionchanged:: 3.2 Added the ``path`` and ``domain`` parameters.` clear_cookie(self, name, path='/', domain=None) `Deletes the cookie with the given name. Due to limitations of the cookie protocol, you must pass the same path and domain to clear a cookie as were used when that cookie was set (but there is no way to find out on the server side which values were used for a given cookie).` clear_header(self, name) `Clears an outgoing header, undoing a previous `set_header` call. Note that this method does not apply to multi-valued headers set by `add_header`.` compute_etag(self) `Computes the etag header to be used for this request. By default uses a hash of the content written so far. May be overridden to provide custom etag implementations, or may return None to disable tornado's default etag support.` create_signed_value(self, name, value, version=None) `Signs and timestamps a string so it cannot be forged. Normally used via set_secure_cookie, but provided as a separate method for non-cookie uses. To decode a value not stored as a cookie use the optional value argument to get_secure_cookie. .. versionchanged:: 3.2.1 Added the ``version`` argument. Introduced cookie version 2 and made it the default.` create_template_loader(self, template_path) `Returns a new template loader for the given path. May be overridden by subclasses. By default returns a directory-based loader on the given path, using the ``autoescape`` application setting. If a ``template_loader`` application setting is supplied, uses that instead.` data_received(self, chunk) `Implement this method to handle streamed request data. Requires the `.stream_request_body` decorator.` decode_argument(self, value, name=None) `Decodes an argument from the request. The argument has been percent-decoded and is now a byte string. By default, this method decodes the argument as utf-8 and returns a unicode string, but this may be overridden in subclasses. This method is used as a filter for both `get_argument()` and for values extracted from the url and passed to `get()`/`post()`/etc. The name of the argument is provided if known, but may be None (e.g. for unnamed groups in the url regex).` delete(self, *args, **kwargs) finish(self, chunk=None) `Finishes this response, ending the HTTP request.` flush(self, include_footers=False, callback=None) `Flushes the current output buffer to the network. The ``callback`` argument, if given, can be used for flow control: it will be run when all flushed data has been written to the socket. Note that only one flush callback can be outstanding at a time; if another flush occurs before the previous flush's callback has been run, the previous callback will be discarded. .. versionchanged:: 4.0 Now returns a `.Future` if no callback is given.` get(self, *args, **kwargs) get_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode.` get_arguments(self, name, strip=True) `Returns a list of the arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode.` get_body_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name from the request body. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode. .. versionadded:: 3.2` get_body_arguments(self, name, strip=True) `Returns a list of the body arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode. .. versionadded:: 3.2` get_browser_locale(self, default='en_US') `Determines the user's locale from ``Accept-Language`` header. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4` get_cookie(self, name, default=None) `Gets the value of the cookie with the given name, else default.` get_current_user(self) `Override to determine the current user from, e.g., a cookie.` get_login_url(self) `Override to customize the login URL based on the request. By default, we use the ``login_url`` application setting.` get_query_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name from the request query string. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode. .. versionadded:: 3.2` get_query_arguments(self, name, strip=True) `Returns a list of the query arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode. .. versionadded:: 3.2` get_secure_cookie(self, name, value=None, max_age_days=31, min_version=None) `Returns the given signed cookie if it validates, or None. The decoded cookie value is returned as a byte string (unlike `get_cookie`). .. versionchanged:: 3.2.1 Added the ``min_version`` argument. Introduced cookie version 2; both versions 1 and 2 are accepted by default.` get_status(self) `Returns the status code for our response.` get_template_namespace(self) `Returns a dictionary to be used as the default template namespace. May be overridden by subclasses to add or modify values. The results of this method will be combined with additional defaults in the `tornado.template` module and keyword arguments to `render` or `render_string`.` get_template_path(self) `Override to customize template path for each handler. By default, we use the ``template_path`` application setting. Return None to load templates relative to the calling file.` get_user_locale(self) `Override to determine the locale from the authenticated user. If None is returned, we fall back to `get_browser_locale()`. This method should return a `tornado.locale.Locale` object, most likely obtained via a call like ``tornado.locale.get("en")``` head(self, *args, **kwargs) initialize(self) `Hook for subclass initialization. A dictionary passed as the third argument of a url spec will be supplied as keyword arguments to initialize(). Example:: class ProfileHandler(RequestHandler): def initialize(self, database): self.database = database def get(self, username): ... app = Application([ (r'/user/(.*)', ProfileHandler, dict(database=database)), ])` log_exception(self, typ, value, tb) `Override to customize logging of uncaught exceptions. By default logs instances of `HTTPError` as warnings without stack traces (on the ``tornado.general`` logger), and all other exceptions as errors with stack traces (on the ``tornado.application`` logger). .. versionadded:: 3.1` on_connection_close(self) `Called in async handlers if the client closed the connection. Override this to clean up resources associated with long-lived connections. Note that this method is called only if the connection was closed during asynchronous processing; if you need to do cleanup after every request override `on_finish` instead. Proxies may keep a connection open for a time (perhaps indefinitely) after the client has gone away, so this method may not be called promptly after the end user closes their connection.` on_finish(self) `Called after the end of a request. Override this method to perform cleanup, logging, etc. This method is a counterpart to `prepare`. ``on_finish`` may not produce any output, as it is called after the response has been sent to the client.` patch(self, *args, **kwargs) prepare(self) `Called at the beginning of a request before `get`/`post`/etc. Override this method to perform common initialization regardless of the request method. Asynchronous support: Decorate this method with `.gen.coroutine` or `.return_future` to make it asynchronous (the `asynchronous` decorator cannot be used on `prepare`). If this method returns a `.Future` execution will not proceed until the `.Future` is done. .. versionadded:: 3.1 Asynchronous support.` put(self, *args, **kwargs) redirect(self, url, permanent=False, status=None) `Sends a redirect to the given (optionally relative) URL. If the ``status`` argument is specified, that value is used as the HTTP status code; otherwise either 301 (permanent) or 302 (temporary) is chosen based on the ``permanent`` argument. The default is 302 (temporary).` render(self, template_name, **kwargs) `Renders the template with the given arguments as the response.` render_string(self, template_name, **kwargs) `Generate the given template with the given arguments. We return the generated byte string (in utf8). To generate and write a template as a response, use render() above.` require_setting(self, name, feature='this feature') `Raises an exception if the given app setting is not defined.` reverse_url(self, name, *args) `Alias for `Application.reverse_url`.` send_error(self, status_code=500, **kwargs) `Sends the given HTTP error code to the browser. If `flush()` has already been called, it is not possible to send an error, so this method will simply terminate the response. If output has been written but not yet flushed, it will be discarded and replaced with the error page. Override `write_error()` to customize the error page that is returned. Additional keyword arguments are passed through to `write_error`.` set_cookie(self, name, value, domain=None, expires=None, path='/', expires_days=None, **kwargs) `Sets the given cookie name/value with the given options. Additional keyword arguments are set on the Cookie.Morsel directly. See http://docs.python.org/library/cookie.html#morsel-objects for available attributes.` set_default_headers(self) `Override this to set HTTP headers at the beginning of the request. For example, this is the place to set a custom ``Server`` header. Note that setting such headers in the normal flow of request processing may not do what you want, since headers may be reset during error handling.` set_etag_header(self) `Sets the response's Etag header using ``compute_etag()``. Note: no header will be set if ``compute_etag()`` returns ``None``. This method is called automatically when the request is finished.` set_header(self, name, value) `Sets the given response header name and value. If a datetime is given, we automatically format it according to the HTTP specification. If the value is not a string, we convert it to a string. All header values are then encoded as UTF-8.` set_secure_cookie(self, name, value, expires_days=30, version=None, **kwargs) `Signs and timestamps a cookie so it cannot be forged. You must specify the ``cookie_secret`` setting in your Application to use this method. It should be a long, random sequence of bytes to be used as the HMAC secret for the signature. To read a cookie set with this method, use `get_secure_cookie()`. Note that the ``expires_days`` parameter sets the lifetime of the cookie in the browser, but is independent of the ``max_age_days`` parameter to `get_secure_cookie`. Secure cookies may contain arbitrary byte values, not just unicode strings (unlike regular cookies) .. versionchanged:: 3.2.1 Added the ``version`` argument. Introduced cookie version 2 and made it the default.` set_status(self, status_code, reason=None) `Sets the status code for our response. :arg int status_code: Response status code. If ``reason`` is ``None``, it must be present in `httplib.responses <http.client.responses>`. :arg string reason: Human-readable reason phrase describing the status code. If ``None``, it will be filled in from `httplib.responses <http.client.responses>`.` static_url(self, path, include_host=None, **kwargs) `Returns a static URL for the given relative static file path. This method requires you set the ``static_path`` setting in your application (which specifies the root directory of your static files). This method returns a versioned url (by default appending ``?v=<signature>``), which allows the static files to be cached indefinitely. This can be disabled by passing ``include_version=False`` (in the default implementation; other static file implementations are not required to support this, but they may support other options). By default this method returns URLs relative to the current host, but if ``include_host`` is true the URL returned will be absolute. If this handler has an ``include_host`` attribute, that value will be used as the default for all `static_url` calls that do not pass ``include_host`` as a keyword argument.` write(self, chunk) `Writes the given chunk to the output buffer. To write the output to the network, use the flush() method below. If the given chunk is a dictionary, we write it as JSON and set the Content-Type of the response to be ``application/json``. (if you want to send JSON as a different ``Content-Type``, call set_header *after* calling write()). Note that lists are not converted to JSON because of a potential cross-site security vulnerability. All JSON output should be wrapped in a dictionary. More details at http://haacked.com/archive/2009/06/25/json-hijacking.aspx/ and https://github.com/facebook/tornado/issues/1009` write_error(self, status_code, **kwargs) `Override to implement custom error pages. ``write_error`` may call `write`, `render`, `set_header`, etc to produce output as usual. If this error was caused by an uncaught exception (including HTTPError), an ``exc_info`` triple will be available as ``kwargs["exc_info"]``. Note that this exception may not be the "current" exception for purposes of methods like ``sys.exc_info()`` or ``traceback.format_exc``.` xsrf_form_html(self) `An HTML ``<input/>`` element to be included with all POST forms. It defines the ``_xsrf`` input value, which we check on all POST requests to prevent cross-site request forgery. If you have set the ``xsrf_cookies`` application setting, you must include this HTML within all of your HTML forms. In a template, this method should be called with ``{% module xsrf_form_html() %}`` See `check_xsrf_cookie()` above for more information.` Data descriptors inherited from tornado.web.RequestHandler: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)` cookies `An alias for `self.request.cookies <.httputil.HTTPServerRequest.cookies>`.` current_user `The authenticated user for this request. This is a cached version of `get_current_user`, which you can override to set the user based on, e.g., a cookie. If that method is not overridden, this method always returns None. We lazy-load the current user the first time this method is called and cache the result after that.` locale `The local for the current session. Determined by either `get_user_locale`, which you can override to set the locale based on, e.g., a user preference stored in a database, or `get_browser_locale`, which uses the ``Accept-Language`` header.` settings `An alias for `self.application.settings <Application.settings>`.` xsrf_token `The XSRF-prevention token for the current user/session. To prevent cross-site request forgery, we set an '_xsrf' cookie and include the same '_xsrf' value as an argument with all POST requests. If the two do not match, we reject the form submission as a potential forgery. See http://en.wikipedia.org/wiki/Cross-site_request_forgery .. versionchanged:: 3.2.2 The xsrf token will now be have a random mask applied in every request, which makes it safe to include the token in pages that are compressed. See http://breachattack.com for more information on the issue fixed by this change. Old (version 1) cookies will be converted to version 2 when this method is called unless the ``xsrf_cookie_version`` `Application` setting is set to 1.` Data and other attributes inherited from tornado.web.RequestHandler: SUPPORTED_METHODS = ('GET', 'HEAD', 'POST', 'DELETE', 'PATCH', 'PUT', 'OPTIONS')
class RedisHandler(tornado_lib.CallbackHandler)
`` | `Request handler for /redis, which gives status of objects existing in redis, such as target weights devices are moving toward and devices slated for removal.`
| Method resolution order: RedisHandler tornado_lib.CallbackHandler tornado.web.RequestHandler __builtin__.object Methods defined here: get(*args, **kwargs) `GET /redis Returns a json object with two components: { "weight_targets": { "[ring name]": { "[device uuid]": [target weight], ... }, ... }, "remove_devices": { "[ring name]": { "[device uuid]": true, ... }, ... } }` Methods inherited from tornado_lib.CallbackHandler: options(*args, **kwargs) `Expose all methods in options.` write_with_callback(self, obj) `Write a response as a jsonp callback.` Methods inherited from tornado.web.RequestHandler: __init__(self, application, request, **kwargs) add_header(self, name, value) `Adds the given response header and value. Unlike `set_header`, `add_header` may be called multiple times to return multiple values for the same header.` check_etag_header(self) `Checks the ``Etag`` header against requests's ``If-None-Match``. Returns ``True`` if the request's Etag matches and a 304 should be returned. For example:: set_etag_header() if check_etag_header(): set_status(304) return This method is called automatically when the request is finished, but may be called earlier for applications that override `compute_etag` and want to do an early check for ``If-None-Match`` before completing the request. The ``Etag`` header should be set (perhaps with `set_etag_header`) before calling this method.` check_xsrf_cookie(self) `Verifies that the ``_xsrf`` cookie matches the ``_xsrf`` argument. To prevent cross-site request forgery, we set an ``_xsrf`` cookie and include the same value as a non-cookie field with all ``POST`` requests. If the two do not match, we reject the form submission as a potential forgery. The ``_xsrf`` value may be set as either a form field named ``_xsrf`` or in a custom HTTP header named ``X-XSRFToken`` or ``X-CSRFToken`` (the latter is accepted for compatibility with Django). See http://en.wikipedia.org/wiki/Cross-site_request_forgery Prior to release 1.1.1, this check was ignored if the HTTP header ``X-Requested-With: XMLHTTPRequest`` was present. This exception has been shown to be insecure and has been removed. For more information please see http://www.djangoproject.com/weblog/2011/feb/08/security/ http://weblog.rubyonrails.org/2011/2/8/csrf-protection-bypass-in-ruby-on-rails .. versionchanged:: 3.2.2 Added support for cookie version 2. Both versions 1 and 2 are supported.` clear(self) `Resets all headers and content for this response.` clear_all_cookies(self, path='/', domain=None) `Deletes all the cookies the user sent with this request. See `clear_cookie` for more information on the path and domain parameters. .. versionchanged:: 3.2 Added the ``path`` and ``domain`` parameters.` clear_cookie(self, name, path='/', domain=None) `Deletes the cookie with the given name. Due to limitations of the cookie protocol, you must pass the same path and domain to clear a cookie as were used when that cookie was set (but there is no way to find out on the server side which values were used for a given cookie).` clear_header(self, name) `Clears an outgoing header, undoing a previous `set_header` call. Note that this method does not apply to multi-valued headers set by `add_header`.` compute_etag(self) `Computes the etag header to be used for this request. By default uses a hash of the content written so far. May be overridden to provide custom etag implementations, or may return None to disable tornado's default etag support.` create_signed_value(self, name, value, version=None) `Signs and timestamps a string so it cannot be forged. Normally used via set_secure_cookie, but provided as a separate method for non-cookie uses. To decode a value not stored as a cookie use the optional value argument to get_secure_cookie. .. versionchanged:: 3.2.1 Added the ``version`` argument. Introduced cookie version 2 and made it the default.` create_template_loader(self, template_path) `Returns a new template loader for the given path. May be overridden by subclasses. By default returns a directory-based loader on the given path, using the ``autoescape`` application setting. If a ``template_loader`` application setting is supplied, uses that instead.` data_received(self, chunk) `Implement this method to handle streamed request data. Requires the `.stream_request_body` decorator.` decode_argument(self, value, name=None) `Decodes an argument from the request. The argument has been percent-decoded and is now a byte string. By default, this method decodes the argument as utf-8 and returns a unicode string, but this may be overridden in subclasses. This method is used as a filter for both `get_argument()` and for values extracted from the url and passed to `get()`/`post()`/etc. The name of the argument is provided if known, but may be None (e.g. for unnamed groups in the url regex).` delete(self, *args, **kwargs) finish(self, chunk=None) `Finishes this response, ending the HTTP request.` flush(self, include_footers=False, callback=None) `Flushes the current output buffer to the network. The ``callback`` argument, if given, can be used for flow control: it will be run when all flushed data has been written to the socket. Note that only one flush callback can be outstanding at a time; if another flush occurs before the previous flush's callback has been run, the previous callback will be discarded. .. versionchanged:: 4.0 Now returns a `.Future` if no callback is given.` get_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode.` get_arguments(self, name, strip=True) `Returns a list of the arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode.` get_body_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name from the request body. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode. .. versionadded:: 3.2` get_body_arguments(self, name, strip=True) `Returns a list of the body arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode. .. versionadded:: 3.2` get_browser_locale(self, default='en_US') `Determines the user's locale from ``Accept-Language`` header. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4` get_cookie(self, name, default=None) `Gets the value of the cookie with the given name, else default.` get_current_user(self) `Override to determine the current user from, e.g., a cookie.` get_login_url(self) `Override to customize the login URL based on the request. By default, we use the ``login_url`` application setting.` get_query_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name from the request query string. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode. .. versionadded:: 3.2` get_query_arguments(self, name, strip=True) `Returns a list of the query arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode. .. versionadded:: 3.2` get_secure_cookie(self, name, value=None, max_age_days=31, min_version=None) `Returns the given signed cookie if it validates, or None. The decoded cookie value is returned as a byte string (unlike `get_cookie`). .. versionchanged:: 3.2.1 Added the ``min_version`` argument. Introduced cookie version 2; both versions 1 and 2 are accepted by default.` get_status(self) `Returns the status code for our response.` get_template_namespace(self) `Returns a dictionary to be used as the default template namespace. May be overridden by subclasses to add or modify values. The results of this method will be combined with additional defaults in the `tornado.template` module and keyword arguments to `render` or `render_string`.` get_template_path(self) `Override to customize template path for each handler. By default, we use the ``template_path`` application setting. Return None to load templates relative to the calling file.` get_user_locale(self) `Override to determine the locale from the authenticated user. If None is returned, we fall back to `get_browser_locale()`. This method should return a `tornado.locale.Locale` object, most likely obtained via a call like ``tornado.locale.get("en")``` head(self, *args, **kwargs) initialize(self) `Hook for subclass initialization. A dictionary passed as the third argument of a url spec will be supplied as keyword arguments to initialize(). Example:: class ProfileHandler(RequestHandler): def initialize(self, database): self.database = database def get(self, username): ... app = Application([ (r'/user/(.*)', ProfileHandler, dict(database=database)), ])` log_exception(self, typ, value, tb) `Override to customize logging of uncaught exceptions. By default logs instances of `HTTPError` as warnings without stack traces (on the ``tornado.general`` logger), and all other exceptions as errors with stack traces (on the ``tornado.application`` logger). .. versionadded:: 3.1` on_connection_close(self) `Called in async handlers if the client closed the connection. Override this to clean up resources associated with long-lived connections. Note that this method is called only if the connection was closed during asynchronous processing; if you need to do cleanup after every request override `on_finish` instead. Proxies may keep a connection open for a time (perhaps indefinitely) after the client has gone away, so this method may not be called promptly after the end user closes their connection.` on_finish(self) `Called after the end of a request. Override this method to perform cleanup, logging, etc. This method is a counterpart to `prepare`. ``on_finish`` may not produce any output, as it is called after the response has been sent to the client.` patch(self, *args, **kwargs) post(self, *args, **kwargs) prepare(self) `Called at the beginning of a request before `get`/`post`/etc. Override this method to perform common initialization regardless of the request method. Asynchronous support: Decorate this method with `.gen.coroutine` or `.return_future` to make it asynchronous (the `asynchronous` decorator cannot be used on `prepare`). If this method returns a `.Future` execution will not proceed until the `.Future` is done. .. versionadded:: 3.1 Asynchronous support.` put(self, *args, **kwargs) redirect(self, url, permanent=False, status=None) `Sends a redirect to the given (optionally relative) URL. If the ``status`` argument is specified, that value is used as the HTTP status code; otherwise either 301 (permanent) or 302 (temporary) is chosen based on the ``permanent`` argument. The default is 302 (temporary).` render(self, template_name, **kwargs) `Renders the template with the given arguments as the response.` render_string(self, template_name, **kwargs) `Generate the given template with the given arguments. We return the generated byte string (in utf8). To generate and write a template as a response, use render() above.` require_setting(self, name, feature='this feature') `Raises an exception if the given app setting is not defined.` reverse_url(self, name, *args) `Alias for `Application.reverse_url`.` send_error(self, status_code=500, **kwargs) `Sends the given HTTP error code to the browser. If `flush()` has already been called, it is not possible to send an error, so this method will simply terminate the response. If output has been written but not yet flushed, it will be discarded and replaced with the error page. Override `write_error()` to customize the error page that is returned. Additional keyword arguments are passed through to `write_error`.` set_cookie(self, name, value, domain=None, expires=None, path='/', expires_days=None, **kwargs) `Sets the given cookie name/value with the given options. Additional keyword arguments are set on the Cookie.Morsel directly. See http://docs.python.org/library/cookie.html#morsel-objects for available attributes.` set_default_headers(self) `Override this to set HTTP headers at the beginning of the request. For example, this is the place to set a custom ``Server`` header. Note that setting such headers in the normal flow of request processing may not do what you want, since headers may be reset during error handling.` set_etag_header(self) `Sets the response's Etag header using ``compute_etag()``. Note: no header will be set if ``compute_etag()`` returns ``None``. This method is called automatically when the request is finished.` set_header(self, name, value) `Sets the given response header name and value. If a datetime is given, we automatically format it according to the HTTP specification. If the value is not a string, we convert it to a string. All header values are then encoded as UTF-8.` set_secure_cookie(self, name, value, expires_days=30, version=None, **kwargs) `Signs and timestamps a cookie so it cannot be forged. You must specify the ``cookie_secret`` setting in your Application to use this method. It should be a long, random sequence of bytes to be used as the HMAC secret for the signature. To read a cookie set with this method, use `get_secure_cookie()`. Note that the ``expires_days`` parameter sets the lifetime of the cookie in the browser, but is independent of the ``max_age_days`` parameter to `get_secure_cookie`. Secure cookies may contain arbitrary byte values, not just unicode strings (unlike regular cookies) .. versionchanged:: 3.2.1 Added the ``version`` argument. Introduced cookie version 2 and made it the default.` set_status(self, status_code, reason=None) `Sets the status code for our response. :arg int status_code: Response status code. If ``reason`` is ``None``, it must be present in `httplib.responses <http.client.responses>`. :arg string reason: Human-readable reason phrase describing the status code. If ``None``, it will be filled in from `httplib.responses <http.client.responses>`.` static_url(self, path, include_host=None, **kwargs) `Returns a static URL for the given relative static file path. This method requires you set the ``static_path`` setting in your application (which specifies the root directory of your static files). This method returns a versioned url (by default appending ``?v=<signature>``), which allows the static files to be cached indefinitely. This can be disabled by passing ``include_version=False`` (in the default implementation; other static file implementations are not required to support this, but they may support other options). By default this method returns URLs relative to the current host, but if ``include_host`` is true the URL returned will be absolute. If this handler has an ``include_host`` attribute, that value will be used as the default for all `static_url` calls that do not pass ``include_host`` as a keyword argument.` write(self, chunk) `Writes the given chunk to the output buffer. To write the output to the network, use the flush() method below. If the given chunk is a dictionary, we write it as JSON and set the Content-Type of the response to be ``application/json``. (if you want to send JSON as a different ``Content-Type``, call set_header *after* calling write()). Note that lists are not converted to JSON because of a potential cross-site security vulnerability. All JSON output should be wrapped in a dictionary. More details at http://haacked.com/archive/2009/06/25/json-hijacking.aspx/ and https://github.com/facebook/tornado/issues/1009` write_error(self, status_code, **kwargs) `Override to implement custom error pages. ``write_error`` may call `write`, `render`, `set_header`, etc to produce output as usual. If this error was caused by an uncaught exception (including HTTPError), an ``exc_info`` triple will be available as ``kwargs["exc_info"]``. Note that this exception may not be the "current" exception for purposes of methods like ``sys.exc_info()`` or ``traceback.format_exc``.` xsrf_form_html(self) `An HTML ``<input/>`` element to be included with all POST forms. It defines the ``_xsrf`` input value, which we check on all POST requests to prevent cross-site request forgery. If you have set the ``xsrf_cookies`` application setting, you must include this HTML within all of your HTML forms. In a template, this method should be called with ``{% module xsrf_form_html() %}`` See `check_xsrf_cookie()` above for more information.` Data descriptors inherited from tornado.web.RequestHandler: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)` cookies `An alias for `self.request.cookies <.httputil.HTTPServerRequest.cookies>`.` current_user `The authenticated user for this request. This is a cached version of `get_current_user`, which you can override to set the user based on, e.g., a cookie. If that method is not overridden, this method always returns None. We lazy-load the current user the first time this method is called and cache the result after that.` locale `The local for the current session. Determined by either `get_user_locale`, which you can override to set the locale based on, e.g., a user preference stored in a database, or `get_browser_locale`, which uses the ``Accept-Language`` header.` settings `An alias for `self.application.settings <Application.settings>`.` xsrf_token `The XSRF-prevention token for the current user/session. To prevent cross-site request forgery, we set an '_xsrf' cookie and include the same '_xsrf' value as an argument with all POST requests. If the two do not match, we reject the form submission as a potential forgery. See http://en.wikipedia.org/wiki/Cross-site_request_forgery .. versionchanged:: 3.2.2 The xsrf token will now be have a random mask applied in every request, which makes it safe to include the token in pages that are compressed. See http://breachattack.com for more information on the issue fixed by this change. Old (version 1) cookies will be converted to version 2 when this method is called unless the ``xsrf_cookie_version`` `Application` setting is set to 1.` Data and other attributes inherited from tornado.web.RequestHandler: SUPPORTED_METHODS = ('GET', 'HEAD', 'POST', 'DELETE', 'PATCH', 'PUT', 'OPTIONS')
class SwiftBuilderException(exceptions.Exception)
`` | `Exception when we fail to find or open the local ring file.`
| Method resolution order: SwiftBuilderException exceptions.Exception exceptions.BaseException __builtin__.object Data descriptors defined here: __weakref__ `list of weak references to the object (if defined)` Methods inherited from exceptions.Exception: __init__(...) `x.__init__(...) initializes x; see help(type(x)) for signature` Data and other attributes inherited from exceptions.Exception: __new__ = <built-in method __new__ of type object> `T.__new__(S, ...) -> a new object with type S, a subtype of T` Methods inherited from exceptions.BaseException: __delattr__(...) `x.__delattr__('name') <==> del x.name` __getattribute__(...) `x.__getattribute__('name') <==> x.name` __getitem__(...) `x.__getitem__(y) <==> x[y]` __getslice__(...) `x.__getslice__(i, j) <==> x[i:j] Use of negative indices is not supported.` __reduce__(...) __repr__(...) `x.__repr__() <==> repr(x)` __setattr__(...) `x.__setattr__('name', value) <==> x.name = value` __setstate__(...) __str__(...) `x.__str__() <==> str(x)` __unicode__(...) Data descriptors inherited from exceptions.BaseException: __dict__ args message
class SwiftHostHandler(tornado_lib.CallbackHandler)
`` | `Request handler for /hosts, an endpoint that lists the swift hosts`
| Method resolution order: SwiftHostHandler tornado_lib.CallbackHandler tornado.web.RequestHandler __builtin__.object Methods defined here: get(*args, **kwargs) `GET /hosts Returns the result of swift_host_dicts in json form.` Methods inherited from tornado_lib.CallbackHandler: options(*args, **kwargs) `Expose all methods in options.` write_with_callback(self, obj) `Write a response as a jsonp callback.` Methods inherited from tornado.web.RequestHandler: __init__(self, application, request, **kwargs) add_header(self, name, value) `Adds the given response header and value. Unlike `set_header`, `add_header` may be called multiple times to return multiple values for the same header.` check_etag_header(self) `Checks the ``Etag`` header against requests's ``If-None-Match``. Returns ``True`` if the request's Etag matches and a 304 should be returned. For example:: set_etag_header() if check_etag_header(): set_status(304) return This method is called automatically when the request is finished, but may be called earlier for applications that override `compute_etag` and want to do an early check for ``If-None-Match`` before completing the request. The ``Etag`` header should be set (perhaps with `set_etag_header`) before calling this method.` check_xsrf_cookie(self) `Verifies that the ``_xsrf`` cookie matches the ``_xsrf`` argument. To prevent cross-site request forgery, we set an ``_xsrf`` cookie and include the same value as a non-cookie field with all ``POST`` requests. If the two do not match, we reject the form submission as a potential forgery. The ``_xsrf`` value may be set as either a form field named ``_xsrf`` or in a custom HTTP header named ``X-XSRFToken`` or ``X-CSRFToken`` (the latter is accepted for compatibility with Django). See http://en.wikipedia.org/wiki/Cross-site_request_forgery Prior to release 1.1.1, this check was ignored if the HTTP header ``X-Requested-With: XMLHTTPRequest`` was present. This exception has been shown to be insecure and has been removed. For more information please see http://www.djangoproject.com/weblog/2011/feb/08/security/ http://weblog.rubyonrails.org/2011/2/8/csrf-protection-bypass-in-ruby-on-rails .. versionchanged:: 3.2.2 Added support for cookie version 2. Both versions 1 and 2 are supported.` clear(self) `Resets all headers and content for this response.` clear_all_cookies(self, path='/', domain=None) `Deletes all the cookies the user sent with this request. See `clear_cookie` for more information on the path and domain parameters. .. versionchanged:: 3.2 Added the ``path`` and ``domain`` parameters.` clear_cookie(self, name, path='/', domain=None) `Deletes the cookie with the given name. Due to limitations of the cookie protocol, you must pass the same path and domain to clear a cookie as were used when that cookie was set (but there is no way to find out on the server side which values were used for a given cookie).` clear_header(self, name) `Clears an outgoing header, undoing a previous `set_header` call. Note that this method does not apply to multi-valued headers set by `add_header`.` compute_etag(self) `Computes the etag header to be used for this request. By default uses a hash of the content written so far. May be overridden to provide custom etag implementations, or may return None to disable tornado's default etag support.` create_signed_value(self, name, value, version=None) `Signs and timestamps a string so it cannot be forged. Normally used via set_secure_cookie, but provided as a separate method for non-cookie uses. To decode a value not stored as a cookie use the optional value argument to get_secure_cookie. .. versionchanged:: 3.2.1 Added the ``version`` argument. Introduced cookie version 2 and made it the default.` create_template_loader(self, template_path) `Returns a new template loader for the given path. May be overridden by subclasses. By default returns a directory-based loader on the given path, using the ``autoescape`` application setting. If a ``template_loader`` application setting is supplied, uses that instead.` data_received(self, chunk) `Implement this method to handle streamed request data. Requires the `.stream_request_body` decorator.` decode_argument(self, value, name=None) `Decodes an argument from the request. The argument has been percent-decoded and is now a byte string. By default, this method decodes the argument as utf-8 and returns a unicode string, but this may be overridden in subclasses. This method is used as a filter for both `get_argument()` and for values extracted from the url and passed to `get()`/`post()`/etc. The name of the argument is provided if known, but may be None (e.g. for unnamed groups in the url regex).` delete(self, *args, **kwargs) finish(self, chunk=None) `Finishes this response, ending the HTTP request.` flush(self, include_footers=False, callback=None) `Flushes the current output buffer to the network. The ``callback`` argument, if given, can be used for flow control: it will be run when all flushed data has been written to the socket. Note that only one flush callback can be outstanding at a time; if another flush occurs before the previous flush's callback has been run, the previous callback will be discarded. .. versionchanged:: 4.0 Now returns a `.Future` if no callback is given.` get_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode.` get_arguments(self, name, strip=True) `Returns a list of the arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode.` get_body_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name from the request body. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode. .. versionadded:: 3.2` get_body_arguments(self, name, strip=True) `Returns a list of the body arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode. .. versionadded:: 3.2` get_browser_locale(self, default='en_US') `Determines the user's locale from ``Accept-Language`` header. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4` get_cookie(self, name, default=None) `Gets the value of the cookie with the given name, else default.` get_current_user(self) `Override to determine the current user from, e.g., a cookie.` get_login_url(self) `Override to customize the login URL based on the request. By default, we use the ``login_url`` application setting.` get_query_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name from the request query string. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode. .. versionadded:: 3.2` get_query_arguments(self, name, strip=True) `Returns a list of the query arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode. .. versionadded:: 3.2` get_secure_cookie(self, name, value=None, max_age_days=31, min_version=None) `Returns the given signed cookie if it validates, or None. The decoded cookie value is returned as a byte string (unlike `get_cookie`). .. versionchanged:: 3.2.1 Added the ``min_version`` argument. Introduced cookie version 2; both versions 1 and 2 are accepted by default.` get_status(self) `Returns the status code for our response.` get_template_namespace(self) `Returns a dictionary to be used as the default template namespace. May be overridden by subclasses to add or modify values. The results of this method will be combined with additional defaults in the `tornado.template` module and keyword arguments to `render` or `render_string`.` get_template_path(self) `Override to customize template path for each handler. By default, we use the ``template_path`` application setting. Return None to load templates relative to the calling file.` get_user_locale(self) `Override to determine the locale from the authenticated user. If None is returned, we fall back to `get_browser_locale()`. This method should return a `tornado.locale.Locale` object, most likely obtained via a call like ``tornado.locale.get("en")``` head(self, *args, **kwargs) initialize(self) `Hook for subclass initialization. A dictionary passed as the third argument of a url spec will be supplied as keyword arguments to initialize(). Example:: class ProfileHandler(RequestHandler): def initialize(self, database): self.database = database def get(self, username): ... app = Application([ (r'/user/(.*)', ProfileHandler, dict(database=database)), ])` log_exception(self, typ, value, tb) `Override to customize logging of uncaught exceptions. By default logs instances of `HTTPError` as warnings without stack traces (on the ``tornado.general`` logger), and all other exceptions as errors with stack traces (on the ``tornado.application`` logger). .. versionadded:: 3.1` on_connection_close(self) `Called in async handlers if the client closed the connection. Override this to clean up resources associated with long-lived connections. Note that this method is called only if the connection was closed during asynchronous processing; if you need to do cleanup after every request override `on_finish` instead. Proxies may keep a connection open for a time (perhaps indefinitely) after the client has gone away, so this method may not be called promptly after the end user closes their connection.` on_finish(self) `Called after the end of a request. Override this method to perform cleanup, logging, etc. This method is a counterpart to `prepare`. ``on_finish`` may not produce any output, as it is called after the response has been sent to the client.` patch(self, *args, **kwargs) post(self, *args, **kwargs) prepare(self) `Called at the beginning of a request before `get`/`post`/etc. Override this method to perform common initialization regardless of the request method. Asynchronous support: Decorate this method with `.gen.coroutine` or `.return_future` to make it asynchronous (the `asynchronous` decorator cannot be used on `prepare`). If this method returns a `.Future` execution will not proceed until the `.Future` is done. .. versionadded:: 3.1 Asynchronous support.` put(self, *args, **kwargs) redirect(self, url, permanent=False, status=None) `Sends a redirect to the given (optionally relative) URL. If the ``status`` argument is specified, that value is used as the HTTP status code; otherwise either 301 (permanent) or 302 (temporary) is chosen based on the ``permanent`` argument. The default is 302 (temporary).` render(self, template_name, **kwargs) `Renders the template with the given arguments as the response.` render_string(self, template_name, **kwargs) `Generate the given template with the given arguments. We return the generated byte string (in utf8). To generate and write a template as a response, use render() above.` require_setting(self, name, feature='this feature') `Raises an exception if the given app setting is not defined.` reverse_url(self, name, *args) `Alias for `Application.reverse_url`.` send_error(self, status_code=500, **kwargs) `Sends the given HTTP error code to the browser. If `flush()` has already been called, it is not possible to send an error, so this method will simply terminate the response. If output has been written but not yet flushed, it will be discarded and replaced with the error page. Override `write_error()` to customize the error page that is returned. Additional keyword arguments are passed through to `write_error`.` set_cookie(self, name, value, domain=None, expires=None, path='/', expires_days=None, **kwargs) `Sets the given cookie name/value with the given options. Additional keyword arguments are set on the Cookie.Morsel directly. See http://docs.python.org/library/cookie.html#morsel-objects for available attributes.` set_default_headers(self) `Override this to set HTTP headers at the beginning of the request. For example, this is the place to set a custom ``Server`` header. Note that setting such headers in the normal flow of request processing may not do what you want, since headers may be reset during error handling.` set_etag_header(self) `Sets the response's Etag header using ``compute_etag()``. Note: no header will be set if ``compute_etag()`` returns ``None``. This method is called automatically when the request is finished.` set_header(self, name, value) `Sets the given response header name and value. If a datetime is given, we automatically format it according to the HTTP specification. If the value is not a string, we convert it to a string. All header values are then encoded as UTF-8.` set_secure_cookie(self, name, value, expires_days=30, version=None, **kwargs) `Signs and timestamps a cookie so it cannot be forged. You must specify the ``cookie_secret`` setting in your Application to use this method. It should be a long, random sequence of bytes to be used as the HMAC secret for the signature. To read a cookie set with this method, use `get_secure_cookie()`. Note that the ``expires_days`` parameter sets the lifetime of the cookie in the browser, but is independent of the ``max_age_days`` parameter to `get_secure_cookie`. Secure cookies may contain arbitrary byte values, not just unicode strings (unlike regular cookies) .. versionchanged:: 3.2.1 Added the ``version`` argument. Introduced cookie version 2 and made it the default.` set_status(self, status_code, reason=None) `Sets the status code for our response. :arg int status_code: Response status code. If ``reason`` is ``None``, it must be present in `httplib.responses <http.client.responses>`. :arg string reason: Human-readable reason phrase describing the status code. If ``None``, it will be filled in from `httplib.responses <http.client.responses>`.` static_url(self, path, include_host=None, **kwargs) `Returns a static URL for the given relative static file path. This method requires you set the ``static_path`` setting in your application (which specifies the root directory of your static files). This method returns a versioned url (by default appending ``?v=<signature>``), which allows the static files to be cached indefinitely. This can be disabled by passing ``include_version=False`` (in the default implementation; other static file implementations are not required to support this, but they may support other options). By default this method returns URLs relative to the current host, but if ``include_host`` is true the URL returned will be absolute. If this handler has an ``include_host`` attribute, that value will be used as the default for all `static_url` calls that do not pass ``include_host`` as a keyword argument.` write(self, chunk) `Writes the given chunk to the output buffer. To write the output to the network, use the flush() method below. If the given chunk is a dictionary, we write it as JSON and set the Content-Type of the response to be ``application/json``. (if you want to send JSON as a different ``Content-Type``, call set_header *after* calling write()). Note that lists are not converted to JSON because of a potential cross-site security vulnerability. All JSON output should be wrapped in a dictionary. More details at http://haacked.com/archive/2009/06/25/json-hijacking.aspx/ and https://github.com/facebook/tornado/issues/1009` write_error(self, status_code, **kwargs) `Override to implement custom error pages. ``write_error`` may call `write`, `render`, `set_header`, etc to produce output as usual. If this error was caused by an uncaught exception (including HTTPError), an ``exc_info`` triple will be available as ``kwargs["exc_info"]``. Note that this exception may not be the "current" exception for purposes of methods like ``sys.exc_info()`` or ``traceback.format_exc``.` xsrf_form_html(self) `An HTML ``<input/>`` element to be included with all POST forms. It defines the ``_xsrf`` input value, which we check on all POST requests to prevent cross-site request forgery. If you have set the ``xsrf_cookies`` application setting, you must include this HTML within all of your HTML forms. In a template, this method should be called with ``{% module xsrf_form_html() %}`` See `check_xsrf_cookie()` above for more information.` Data descriptors inherited from tornado.web.RequestHandler: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)` cookies `An alias for `self.request.cookies <.httputil.HTTPServerRequest.cookies>`.` current_user `The authenticated user for this request. This is a cached version of `get_current_user`, which you can override to set the user based on, e.g., a cookie. If that method is not overridden, this method always returns None. We lazy-load the current user the first time this method is called and cache the result after that.` locale `The local for the current session. Determined by either `get_user_locale`, which you can override to set the locale based on, e.g., a user preference stored in a database, or `get_browser_locale`, which uses the ``Accept-Language`` header.` settings `An alias for `self.application.settings <Application.settings>`.` xsrf_token `The XSRF-prevention token for the current user/session. To prevent cross-site request forgery, we set an '_xsrf' cookie and include the same '_xsrf' value as an argument with all POST requests. If the two do not match, we reject the form submission as a potential forgery. See http://en.wikipedia.org/wiki/Cross-site_request_forgery .. versionchanged:: 3.2.2 The xsrf token will now be have a random mask applied in every request, which makes it safe to include the token in pages that are compressed. See http://breachattack.com for more information on the issue fixed by this change. Old (version 1) cookies will be converted to version 2 when this method is called unless the ``xsrf_cookie_version`` `Application` setting is set to 1.` Data and other attributes inherited from tornado.web.RequestHandler: SUPPORTED_METHODS = ('GET', 'HEAD', 'POST', 'DELETE', 'PATCH', 'PUT', 'OPTIONS')
class SwiftInitHandler(tornado_lib.CallbackHandler)
`` | `Request handler that interacts with swift-init, on /swift_init. Can get the status of any service or start / stop /restart a service.`
| Method resolution order: SwiftInitHandler tornado_lib.CallbackHandler tornado.web.RequestHandler __builtin__.object Methods defined here: get(*args, **kwargs) `GET /swift_init/{host} Show all services running on the specified host` post(*args, **kwargs) `POST /swift_init/{host}/(start|stop|restart) Stop / start / restart all services on the specified host.` Methods inherited from tornado_lib.CallbackHandler: options(*args, **kwargs) `Expose all methods in options.` write_with_callback(self, obj) `Write a response as a jsonp callback.` Methods inherited from tornado.web.RequestHandler: __init__(self, application, request, **kwargs) add_header(self, name, value) `Adds the given response header and value. Unlike `set_header`, `add_header` may be called multiple times to return multiple values for the same header.` check_etag_header(self) `Checks the ``Etag`` header against requests's ``If-None-Match``. Returns ``True`` if the request's Etag matches and a 304 should be returned. For example:: set_etag_header() if check_etag_header(): set_status(304) return This method is called automatically when the request is finished, but may be called earlier for applications that override `compute_etag` and want to do an early check for ``If-None-Match`` before completing the request. The ``Etag`` header should be set (perhaps with `set_etag_header`) before calling this method.` check_xsrf_cookie(self) `Verifies that the ``_xsrf`` cookie matches the ``_xsrf`` argument. To prevent cross-site request forgery, we set an ``_xsrf`` cookie and include the same value as a non-cookie field with all ``POST`` requests. If the two do not match, we reject the form submission as a potential forgery. The ``_xsrf`` value may be set as either a form field named ``_xsrf`` or in a custom HTTP header named ``X-XSRFToken`` or ``X-CSRFToken`` (the latter is accepted for compatibility with Django). See http://en.wikipedia.org/wiki/Cross-site_request_forgery Prior to release 1.1.1, this check was ignored if the HTTP header ``X-Requested-With: XMLHTTPRequest`` was present. This exception has been shown to be insecure and has been removed. For more information please see http://www.djangoproject.com/weblog/2011/feb/08/security/ http://weblog.rubyonrails.org/2011/2/8/csrf-protection-bypass-in-ruby-on-rails .. versionchanged:: 3.2.2 Added support for cookie version 2. Both versions 1 and 2 are supported.` clear(self) `Resets all headers and content for this response.` clear_all_cookies(self, path='/', domain=None) `Deletes all the cookies the user sent with this request. See `clear_cookie` for more information on the path and domain parameters. .. versionchanged:: 3.2 Added the ``path`` and ``domain`` parameters.` clear_cookie(self, name, path='/', domain=None) `Deletes the cookie with the given name. Due to limitations of the cookie protocol, you must pass the same path and domain to clear a cookie as were used when that cookie was set (but there is no way to find out on the server side which values were used for a given cookie).` clear_header(self, name) `Clears an outgoing header, undoing a previous `set_header` call. Note that this method does not apply to multi-valued headers set by `add_header`.` compute_etag(self) `Computes the etag header to be used for this request. By default uses a hash of the content written so far. May be overridden to provide custom etag implementations, or may return None to disable tornado's default etag support.` create_signed_value(self, name, value, version=None) `Signs and timestamps a string so it cannot be forged. Normally used via set_secure_cookie, but provided as a separate method for non-cookie uses. To decode a value not stored as a cookie use the optional value argument to get_secure_cookie. .. versionchanged:: 3.2.1 Added the ``version`` argument. Introduced cookie version 2 and made it the default.` create_template_loader(self, template_path) `Returns a new template loader for the given path. May be overridden by subclasses. By default returns a directory-based loader on the given path, using the ``autoescape`` application setting. If a ``template_loader`` application setting is supplied, uses that instead.` data_received(self, chunk) `Implement this method to handle streamed request data. Requires the `.stream_request_body` decorator.` decode_argument(self, value, name=None) `Decodes an argument from the request. The argument has been percent-decoded and is now a byte string. By default, this method decodes the argument as utf-8 and returns a unicode string, but this may be overridden in subclasses. This method is used as a filter for both `get_argument()` and for values extracted from the url and passed to `get()`/`post()`/etc. The name of the argument is provided if known, but may be None (e.g. for unnamed groups in the url regex).` delete(self, *args, **kwargs) finish(self, chunk=None) `Finishes this response, ending the HTTP request.` flush(self, include_footers=False, callback=None) `Flushes the current output buffer to the network. The ``callback`` argument, if given, can be used for flow control: it will be run when all flushed data has been written to the socket. Note that only one flush callback can be outstanding at a time; if another flush occurs before the previous flush's callback has been run, the previous callback will be discarded. .. versionchanged:: 4.0 Now returns a `.Future` if no callback is given.` get_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode.` get_arguments(self, name, strip=True) `Returns a list of the arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode.` get_body_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name from the request body. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode. .. versionadded:: 3.2` get_body_arguments(self, name, strip=True) `Returns a list of the body arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode. .. versionadded:: 3.2` get_browser_locale(self, default='en_US') `Determines the user's locale from ``Accept-Language`` header. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4` get_cookie(self, name, default=None) `Gets the value of the cookie with the given name, else default.` get_current_user(self) `Override to determine the current user from, e.g., a cookie.` get_login_url(self) `Override to customize the login URL based on the request. By default, we use the ``login_url`` application setting.` get_query_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name from the request query string. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode. .. versionadded:: 3.2` get_query_arguments(self, name, strip=True) `Returns a list of the query arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode. .. versionadded:: 3.2` get_secure_cookie(self, name, value=None, max_age_days=31, min_version=None) `Returns the given signed cookie if it validates, or None. The decoded cookie value is returned as a byte string (unlike `get_cookie`). .. versionchanged:: 3.2.1 Added the ``min_version`` argument. Introduced cookie version 2; both versions 1 and 2 are accepted by default.` get_status(self) `Returns the status code for our response.` get_template_namespace(self) `Returns a dictionary to be used as the default template namespace. May be overridden by subclasses to add or modify values. The results of this method will be combined with additional defaults in the `tornado.template` module and keyword arguments to `render` or `render_string`.` get_template_path(self) `Override to customize template path for each handler. By default, we use the ``template_path`` application setting. Return None to load templates relative to the calling file.` get_user_locale(self) `Override to determine the locale from the authenticated user. If None is returned, we fall back to `get_browser_locale()`. This method should return a `tornado.locale.Locale` object, most likely obtained via a call like ``tornado.locale.get("en")``` head(self, *args, **kwargs) initialize(self) `Hook for subclass initialization. A dictionary passed as the third argument of a url spec will be supplied as keyword arguments to initialize(). Example:: class ProfileHandler(RequestHandler): def initialize(self, database): self.database = database def get(self, username): ... app = Application([ (r'/user/(.*)', ProfileHandler, dict(database=database)), ])` log_exception(self, typ, value, tb) `Override to customize logging of uncaught exceptions. By default logs instances of `HTTPError` as warnings without stack traces (on the ``tornado.general`` logger), and all other exceptions as errors with stack traces (on the ``tornado.application`` logger). .. versionadded:: 3.1` on_connection_close(self) `Called in async handlers if the client closed the connection. Override this to clean up resources associated with long-lived connections. Note that this method is called only if the connection was closed during asynchronous processing; if you need to do cleanup after every request override `on_finish` instead. Proxies may keep a connection open for a time (perhaps indefinitely) after the client has gone away, so this method may not be called promptly after the end user closes their connection.` on_finish(self) `Called after the end of a request. Override this method to perform cleanup, logging, etc. This method is a counterpart to `prepare`. ``on_finish`` may not produce any output, as it is called after the response has been sent to the client.` patch(self, *args, **kwargs) prepare(self) `Called at the beginning of a request before `get`/`post`/etc. Override this method to perform common initialization regardless of the request method. Asynchronous support: Decorate this method with `.gen.coroutine` or `.return_future` to make it asynchronous (the `asynchronous` decorator cannot be used on `prepare`). If this method returns a `.Future` execution will not proceed until the `.Future` is done. .. versionadded:: 3.1 Asynchronous support.` put(self, *args, **kwargs) redirect(self, url, permanent=False, status=None) `Sends a redirect to the given (optionally relative) URL. If the ``status`` argument is specified, that value is used as the HTTP status code; otherwise either 301 (permanent) or 302 (temporary) is chosen based on the ``permanent`` argument. The default is 302 (temporary).` render(self, template_name, **kwargs) `Renders the template with the given arguments as the response.` render_string(self, template_name, **kwargs) `Generate the given template with the given arguments. We return the generated byte string (in utf8). To generate and write a template as a response, use render() above.` require_setting(self, name, feature='this feature') `Raises an exception if the given app setting is not defined.` reverse_url(self, name, *args) `Alias for `Application.reverse_url`.` send_error(self, status_code=500, **kwargs) `Sends the given HTTP error code to the browser. If `flush()` has already been called, it is not possible to send an error, so this method will simply terminate the response. If output has been written but not yet flushed, it will be discarded and replaced with the error page. Override `write_error()` to customize the error page that is returned. Additional keyword arguments are passed through to `write_error`.` set_cookie(self, name, value, domain=None, expires=None, path='/', expires_days=None, **kwargs) `Sets the given cookie name/value with the given options. Additional keyword arguments are set on the Cookie.Morsel directly. See http://docs.python.org/library/cookie.html#morsel-objects for available attributes.` set_default_headers(self) `Override this to set HTTP headers at the beginning of the request. For example, this is the place to set a custom ``Server`` header. Note that setting such headers in the normal flow of request processing may not do what you want, since headers may be reset during error handling.` set_etag_header(self) `Sets the response's Etag header using ``compute_etag()``. Note: no header will be set if ``compute_etag()`` returns ``None``. This method is called automatically when the request is finished.` set_header(self, name, value) `Sets the given response header name and value. If a datetime is given, we automatically format it according to the HTTP specification. If the value is not a string, we convert it to a string. All header values are then encoded as UTF-8.` set_secure_cookie(self, name, value, expires_days=30, version=None, **kwargs) `Signs and timestamps a cookie so it cannot be forged. You must specify the ``cookie_secret`` setting in your Application to use this method. It should be a long, random sequence of bytes to be used as the HMAC secret for the signature. To read a cookie set with this method, use `get_secure_cookie()`. Note that the ``expires_days`` parameter sets the lifetime of the cookie in the browser, but is independent of the ``max_age_days`` parameter to `get_secure_cookie`. Secure cookies may contain arbitrary byte values, not just unicode strings (unlike regular cookies) .. versionchanged:: 3.2.1 Added the ``version`` argument. Introduced cookie version 2 and made it the default.` set_status(self, status_code, reason=None) `Sets the status code for our response. :arg int status_code: Response status code. If ``reason`` is ``None``, it must be present in `httplib.responses <http.client.responses>`. :arg string reason: Human-readable reason phrase describing the status code. If ``None``, it will be filled in from `httplib.responses <http.client.responses>`.` static_url(self, path, include_host=None, **kwargs) `Returns a static URL for the given relative static file path. This method requires you set the ``static_path`` setting in your application (which specifies the root directory of your static files). This method returns a versioned url (by default appending ``?v=<signature>``), which allows the static files to be cached indefinitely. This can be disabled by passing ``include_version=False`` (in the default implementation; other static file implementations are not required to support this, but they may support other options). By default this method returns URLs relative to the current host, but if ``include_host`` is true the URL returned will be absolute. If this handler has an ``include_host`` attribute, that value will be used as the default for all `static_url` calls that do not pass ``include_host`` as a keyword argument.` write(self, chunk) `Writes the given chunk to the output buffer. To write the output to the network, use the flush() method below. If the given chunk is a dictionary, we write it as JSON and set the Content-Type of the response to be ``application/json``. (if you want to send JSON as a different ``Content-Type``, call set_header *after* calling write()). Note that lists are not converted to JSON because of a potential cross-site security vulnerability. All JSON output should be wrapped in a dictionary. More details at http://haacked.com/archive/2009/06/25/json-hijacking.aspx/ and https://github.com/facebook/tornado/issues/1009` write_error(self, status_code, **kwargs) `Override to implement custom error pages. ``write_error`` may call `write`, `render`, `set_header`, etc to produce output as usual. If this error was caused by an uncaught exception (including HTTPError), an ``exc_info`` triple will be available as ``kwargs["exc_info"]``. Note that this exception may not be the "current" exception for purposes of methods like ``sys.exc_info()`` or ``traceback.format_exc``.` xsrf_form_html(self) `An HTML ``<input/>`` element to be included with all POST forms. It defines the ``_xsrf`` input value, which we check on all POST requests to prevent cross-site request forgery. If you have set the ``xsrf_cookies`` application setting, you must include this HTML within all of your HTML forms. In a template, this method should be called with ``{% module xsrf_form_html() %}`` See `check_xsrf_cookie()` above for more information.` Data descriptors inherited from tornado.web.RequestHandler: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)` cookies `An alias for `self.request.cookies <.httputil.HTTPServerRequest.cookies>`.` current_user `The authenticated user for this request. This is a cached version of `get_current_user`, which you can override to set the user based on, e.g., a cookie. If that method is not overridden, this method always returns None. We lazy-load the current user the first time this method is called and cache the result after that.` locale `The local for the current session. Determined by either `get_user_locale`, which you can override to set the locale based on, e.g., a user preference stored in a database, or `get_browser_locale`, which uses the ``Accept-Language`` header.` settings `An alias for `self.application.settings <Application.settings>`.` xsrf_token `The XSRF-prevention token for the current user/session. To prevent cross-site request forgery, we set an '_xsrf' cookie and include the same '_xsrf' value as an argument with all POST requests. If the two do not match, we reject the form submission as a potential forgery. See http://en.wikipedia.org/wiki/Cross-site_request_forgery .. versionchanged:: 3.2.2 The xsrf token will now be have a random mask applied in every request, which makes it safe to include the token in pages that are compressed. See http://breachattack.com for more information on the issue fixed by this change. Old (version 1) cookies will be converted to version 2 when this method is called unless the ``xsrf_cookie_version`` `Application` setting is set to 1.` Data and other attributes inherited from tornado.web.RequestHandler: SUPPORTED_METHODS = ('GET', 'HEAD', 'POST', 'DELETE', 'PATCH', 'PUT', 'OPTIONS')
class SwiftRingBuilder(swift.common.ring.ring.Ring)
`` | `The heart of what swift central api does. A class that manages adding, removing, and updating devices in a swift ring. Actions are new, add, remove, and set_weight. These actions are finalized by calling rebalance.`
| Method resolution order: SwiftRingBuilder swift.common.ring.ring.Ring __builtin__.object Methods defined here: __init__(self, file_path, ring_type) `file_path: path to local gzipped ring file. Must end in 'ring.gz' Builder file name is the same with ring.gz replaced with builder ring_type: object, account, or container` add(*args, **kwargs) `Add a device to the ring. Takes a dictionary with the following keys: weight, region, zone, ip, port, device If rebalance is True, rebalance the ring afterward.` is_in_ring(self, uuid) `For a given UUID, return whether or not it exists in the ring.` new(self, part_power=20, min_part_hours=0.5, replicas=3) `Create a new swift ring from scratch. By default the parameters of the ring are partition power 20 (a million partitions), min part hours 0.5 (30 minutes between rebalances), and 3 replicas.` read_ring(self) rebalance(*args, **kwargs) `Rebalance local ring file based on builder file. Will apply all devices added, removed, or updated and push them to each known swift host.` remove(*args, **kwargs) `Remove a device completely from the ring, by device_id. If rebalance is True, rebalance the ring afterward.` set_weight(*args, **kwargs) `Change the weight of the device identified by device_id to the supplied weight. If rebalance is True, rebalance the ring afterward.` to_dict(*args, **kwargs) `Convert ring object into serializable dict. Augment controls whether or not UUIDs are attached to devices.` Methods inherited from swift.common.ring.ring.Ring: get_more_nodes(self, part) `Generator to get extra nodes for a partition for hinted handoff. The handoff nodes will try to be in zones other than the primary zones, will take into account the device weights, and will usually keep the same sequences of handoffs even with ring changes. :param part: partition to get handoff nodes for :returns: generator of node dicts See :func:`get_nodes` for a description of the node dicts.` get_nodes(self, account, container=None, obj=None) `Get the partition and nodes for an account/container/object. If a node is responsible for more than one replica, it will only appear in the output once. :param account: account name :param container: container name :param obj: object name :returns: a tuple of (partition, list of node dicts) Each node dict will have at least the following keys: ====== =============================================================== id unique integer identifier amongst devices weight a float of the relative weight of this device as compared to others; this indicates how many partitions the builder will try to assign to this device zone integer indicating which zone the device is in; a given partition will not be assigned to multiple devices within the same zone ip the ip address of the device port the tcp port of the device device the device's name on disk (sdb1, for example) meta general use 'extra' field; for example: the online date, the hardware description ====== ===============================================================` get_part(self, account, container=None, obj=None) `Get the partition for an account/container/object. :param account: account name :param container: container name :param obj: object name :returns: the partition number` get_part_nodes(self, part) `Get the nodes that are responsible for the partition. If one node is responsible for more than one replica of the same partition, it will only appear in the output once. :param part: partition to get nodes for :returns: list of node dicts See :func:`get_nodes` for a description of the node dicts.` has_changed(self) `Check to see if the ring on disk is different than the current one in memory. :returns: True if the ring on disk has changed, False otherwise` Data descriptors inherited from swift.common.ring.ring.Ring: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)` devs `devices in the ring` partition_count `Number of partitions in the ring.` replica_count `Number of replicas (full or partial) used in the ring.`
class SwiftRingHandler(tornado_lib.CallbackHandler)
`` | `Request handler to display swift rings, under /swift`
| Method resolution order: SwiftRingHandler tornado_lib.CallbackHandler tornado.web.RequestHandler __builtin__.object Methods defined here: delete(*args, **kwargs) `DELETE /ring/{ring_type}/{device_id} ring_type: object, account, or container device_id: id of device to delete` get(*args, **kwargs) `GET /ring/{ring_type} Returns ring builder info for the specified ring` post(*args, **kwargs) `POST /ring/{ring_type}/[rebalance] if rebalance is specified, rebalance the ring denoted by ring_type. Otherwise, insert a new device with the json body. Device parameters are weight, region, zone, ip, port, and device.` put(*args, **kwargs) `PUT /ring/{ring_type}/[{device_id}] If device_id is present, update device_id with weight url parameter. Otherwise, create a new ring of ring_type.` ring(self, ring_type) `Looks up ring based on ring_type and writes an error out if the ring does not exist.` target_weight(*args, **kwargs) `Set a device to target a weight. ring: ring in which device resides. device_id: id of device in that ring. weight: weight that device should ultimately have.` Methods inherited from tornado_lib.CallbackHandler: options(*args, **kwargs) `Expose all methods in options.` write_with_callback(self, obj) `Write a response as a jsonp callback.` Methods inherited from tornado.web.RequestHandler: __init__(self, application, request, **kwargs) add_header(self, name, value) `Adds the given response header and value. Unlike `set_header`, `add_header` may be called multiple times to return multiple values for the same header.` check_etag_header(self) `Checks the ``Etag`` header against requests's ``If-None-Match``. Returns ``True`` if the request's Etag matches and a 304 should be returned. For example:: set_etag_header() if check_etag_header(): set_status(304) return This method is called automatically when the request is finished, but may be called earlier for applications that override `compute_etag` and want to do an early check for ``If-None-Match`` before completing the request. The ``Etag`` header should be set (perhaps with `set_etag_header`) before calling this method.` check_xsrf_cookie(self) `Verifies that the ``_xsrf`` cookie matches the ``_xsrf`` argument. To prevent cross-site request forgery, we set an ``_xsrf`` cookie and include the same value as a non-cookie field with all ``POST`` requests. If the two do not match, we reject the form submission as a potential forgery. The ``_xsrf`` value may be set as either a form field named ``_xsrf`` or in a custom HTTP header named ``X-XSRFToken`` or ``X-CSRFToken`` (the latter is accepted for compatibility with Django). See http://en.wikipedia.org/wiki/Cross-site_request_forgery Prior to release 1.1.1, this check was ignored if the HTTP header ``X-Requested-With: XMLHTTPRequest`` was present. This exception has been shown to be insecure and has been removed. For more information please see http://www.djangoproject.com/weblog/2011/feb/08/security/ http://weblog.rubyonrails.org/2011/2/8/csrf-protection-bypass-in-ruby-on-rails .. versionchanged:: 3.2.2 Added support for cookie version 2. Both versions 1 and 2 are supported.` clear(self) `Resets all headers and content for this response.` clear_all_cookies(self, path='/', domain=None) `Deletes all the cookies the user sent with this request. See `clear_cookie` for more information on the path and domain parameters. .. versionchanged:: 3.2 Added the ``path`` and ``domain`` parameters.` clear_cookie(self, name, path='/', domain=None) `Deletes the cookie with the given name. Due to limitations of the cookie protocol, you must pass the same path and domain to clear a cookie as were used when that cookie was set (but there is no way to find out on the server side which values were used for a given cookie).` clear_header(self, name) `Clears an outgoing header, undoing a previous `set_header` call. Note that this method does not apply to multi-valued headers set by `add_header`.` compute_etag(self) `Computes the etag header to be used for this request. By default uses a hash of the content written so far. May be overridden to provide custom etag implementations, or may return None to disable tornado's default etag support.` create_signed_value(self, name, value, version=None) `Signs and timestamps a string so it cannot be forged. Normally used via set_secure_cookie, but provided as a separate method for non-cookie uses. To decode a value not stored as a cookie use the optional value argument to get_secure_cookie. .. versionchanged:: 3.2.1 Added the ``version`` argument. Introduced cookie version 2 and made it the default.` create_template_loader(self, template_path) `Returns a new template loader for the given path. May be overridden by subclasses. By default returns a directory-based loader on the given path, using the ``autoescape`` application setting. If a ``template_loader`` application setting is supplied, uses that instead.` data_received(self, chunk) `Implement this method to handle streamed request data. Requires the `.stream_request_body` decorator.` decode_argument(self, value, name=None) `Decodes an argument from the request. The argument has been percent-decoded and is now a byte string. By default, this method decodes the argument as utf-8 and returns a unicode string, but this may be overridden in subclasses. This method is used as a filter for both `get_argument()` and for values extracted from the url and passed to `get()`/`post()`/etc. The name of the argument is provided if known, but may be None (e.g. for unnamed groups in the url regex).` finish(self, chunk=None) `Finishes this response, ending the HTTP request.` flush(self, include_footers=False, callback=None) `Flushes the current output buffer to the network. The ``callback`` argument, if given, can be used for flow control: it will be run when all flushed data has been written to the socket. Note that only one flush callback can be outstanding at a time; if another flush occurs before the previous flush's callback has been run, the previous callback will be discarded. .. versionchanged:: 4.0 Now returns a `.Future` if no callback is given.` get_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode.` get_arguments(self, name, strip=True) `Returns a list of the arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode.` get_body_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name from the request body. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode. .. versionadded:: 3.2` get_body_arguments(self, name, strip=True) `Returns a list of the body arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode. .. versionadded:: 3.2` get_browser_locale(self, default='en_US') `Determines the user's locale from ``Accept-Language`` header. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4` get_cookie(self, name, default=None) `Gets the value of the cookie with the given name, else default.` get_current_user(self) `Override to determine the current user from, e.g., a cookie.` get_login_url(self) `Override to customize the login URL based on the request. By default, we use the ``login_url`` application setting.` get_query_argument(self, name, default=[], strip=True) `Returns the value of the argument with the given name from the request query string. If default is not provided, the argument is considered to be required, and we raise a `MissingArgumentError` if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is always unicode. .. versionadded:: 3.2` get_query_arguments(self, name, strip=True) `Returns a list of the query arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode. .. versionadded:: 3.2` get_secure_cookie(self, name, value=None, max_age_days=31, min_version=None) `Returns the given signed cookie if it validates, or None. The decoded cookie value is returned as a byte string (unlike `get_cookie`). .. versionchanged:: 3.2.1 Added the ``min_version`` argument. Introduced cookie version 2; both versions 1 and 2 are accepted by default.` get_status(self) `Returns the status code for our response.` get_template_namespace(self) `Returns a dictionary to be used as the default template namespace. May be overridden by subclasses to add or modify values. The results of this method will be combined with additional defaults in the `tornado.template` module and keyword arguments to `render` or `render_string`.` get_template_path(self) `Override to customize template path for each handler. By default, we use the ``template_path`` application setting. Return None to load templates relative to the calling file.` get_user_locale(self) `Override to determine the locale from the authenticated user. If None is returned, we fall back to `get_browser_locale()`. This method should return a `tornado.locale.Locale` object, most likely obtained via a call like ``tornado.locale.get("en")``` head(self, *args, **kwargs) initialize(self) `Hook for subclass initialization. A dictionary passed as the third argument of a url spec will be supplied as keyword arguments to initialize(). Example:: class ProfileHandler(RequestHandler): def initialize(self, database): self.database = database def get(self, username): ... app = Application([ (r'/user/(.*)', ProfileHandler, dict(database=database)), ])` log_exception(self, typ, value, tb) `Override to customize logging of uncaught exceptions. By default logs instances of `HTTPError` as warnings without stack traces (on the ``tornado.general`` logger), and all other exceptions as errors with stack traces (on the ``tornado.application`` logger). .. versionadded:: 3.1` on_connection_close(self) `Called in async handlers if the client closed the connection. Override this to clean up resources associated with long-lived connections. Note that this method is called only if the connection was closed during asynchronous processing; if you need to do cleanup after every request override `on_finish` instead. Proxies may keep a connection open for a time (perhaps indefinitely) after the client has gone away, so this method may not be called promptly after the end user closes their connection.` on_finish(self) `Called after the end of a request. Override this method to perform cleanup, logging, etc. This method is a counterpart to `prepare`. ``on_finish`` may not produce any output, as it is called after the response has been sent to the client.` patch(self, *args, **kwargs) prepare(self) `Called at the beginning of a request before `get`/`post`/etc. Override this method to perform common initialization regardless of the request method. Asynchronous support: Decorate this method with `.gen.coroutine` or `.return_future` to make it asynchronous (the `asynchronous` decorator cannot be used on `prepare`). If this method returns a `.Future` execution will not proceed until the `.Future` is done. .. versionadded:: 3.1 Asynchronous support.` redirect(self, url, permanent=False, status=None) `Sends a redirect to the given (optionally relative) URL. If the ``status`` argument is specified, that value is used as the HTTP status code; otherwise either 301 (permanent) or 302 (temporary) is chosen based on the ``permanent`` argument. The default is 302 (temporary).` render(self, template_name, **kwargs) `Renders the template with the given arguments as the response.` render_string(self, template_name, **kwargs) `Generate the given template with the given arguments. We return the generated byte string (in utf8). To generate and write a template as a response, use render() above.` require_setting(self, name, feature='this feature') `Raises an exception if the given app setting is not defined.` reverse_url(self, name, *args) `Alias for `Application.reverse_url`.` send_error(self, status_code=500, **kwargs) `Sends the given HTTP error code to the browser. If `flush()` has already been called, it is not possible to send an error, so this method will simply terminate the response. If output has been written but not yet flushed, it will be discarded and replaced with the error page. Override `write_error()` to customize the error page that is returned. Additional keyword arguments are passed through to `write_error`.` set_cookie(self, name, value, domain=None, expires=None, path='/', expires_days=None, **kwargs) `Sets the given cookie name/value with the given options. Additional keyword arguments are set on the Cookie.Morsel directly. See http://docs.python.org/library/cookie.html#morsel-objects for available attributes.` set_default_headers(self) `Override this to set HTTP headers at the beginning of the request. For example, this is the place to set a custom ``Server`` header. Note that setting such headers in the normal flow of request processing may not do what you want, since headers may be reset during error handling.` set_etag_header(self) `Sets the response's Etag header using ``compute_etag()``. Note: no header will be set if ``compute_etag()`` returns ``None``. This method is called automatically when the request is finished.` set_header(self, name, value) `Sets the given response header name and value. If a datetime is given, we automatically format it according to the HTTP specification. If the value is not a string, we convert it to a string. All header values are then encoded as UTF-8.` set_secure_cookie(self, name, value, expires_days=30, version=None, **kwargs) `Signs and timestamps a cookie so it cannot be forged. You must specify the ``cookie_secret`` setting in your Application to use this method. It should be a long, random sequence of bytes to be used as the HMAC secret for the signature. To read a cookie set with this method, use `get_secure_cookie()`. Note that the ``expires_days`` parameter sets the lifetime of the cookie in the browser, but is independent of the ``max_age_days`` parameter to `get_secure_cookie`. Secure cookies may contain arbitrary byte values, not just unicode strings (unlike regular cookies) .. versionchanged:: 3.2.1 Added the ``version`` argument. Introduced cookie version 2 and made it the default.` set_status(self, status_code, reason=None) `Sets the status code for our response. :arg int status_code: Response status code. If ``reason`` is ``None``, it must be present in `httplib.responses <http.client.responses>`. :arg string reason: Human-readable reason phrase describing the status code. If ``None``, it will be filled in from `httplib.responses <http.client.responses>`.` static_url(self, path, include_host=None, **kwargs) `Returns a static URL for the given relative static file path. This method requires you set the ``static_path`` setting in your application (which specifies the root directory of your static files). This method returns a versioned url (by default appending ``?v=<signature>``), which allows the static files to be cached indefinitely. This can be disabled by passing ``include_version=False`` (in the default implementation; other static file implementations are not required to support this, but they may support other options). By default this method returns URLs relative to the current host, but if ``include_host`` is true the URL returned will be absolute. If this handler has an ``include_host`` attribute, that value will be used as the default for all `static_url` calls that do not pass ``include_host`` as a keyword argument.` write(self, chunk) `Writes the given chunk to the output buffer. To write the output to the network, use the flush() method below. If the given chunk is a dictionary, we write it as JSON and set the Content-Type of the response to be ``application/json``. (if you want to send JSON as a different ``Content-Type``, call set_header *after* calling write()). Note that lists are not converted to JSON because of a potential cross-site security vulnerability. All JSON output should be wrapped in a dictionary. More details at http://haacked.com/archive/2009/06/25/json-hijacking.aspx/ and https://github.com/facebook/tornado/issues/1009` write_error(self, status_code, **kwargs) `Override to implement custom error pages. ``write_error`` may call `write`, `render`, `set_header`, etc to produce output as usual. If this error was caused by an uncaught exception (including HTTPError), an ``exc_info`` triple will be available as ``kwargs["exc_info"]``. Note that this exception may not be the "current" exception for purposes of methods like ``sys.exc_info()`` or ``traceback.format_exc``.` xsrf_form_html(self) `An HTML ``<input/>`` element to be included with all POST forms. It defines the ``_xsrf`` input value, which we check on all POST requests to prevent cross-site request forgery. If you have set the ``xsrf_cookies`` application setting, you must include this HTML within all of your HTML forms. In a template, this method should be called with ``{% module xsrf_form_html() %}`` See `check_xsrf_cookie()` above for more information.` Data descriptors inherited from tornado.web.RequestHandler: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)` cookies `An alias for `self.request.cookies <.httputil.HTTPServerRequest.cookies>`.` current_user `The authenticated user for this request. This is a cached version of `get_current_user`, which you can override to set the user based on, e.g., a cookie. If that method is not overridden, this method always returns None. We lazy-load the current user the first time this method is called and cache the result after that.` locale `The local for the current session. Determined by either `get_user_locale`, which you can override to set the locale based on, e.g., a user preference stored in a database, or `get_browser_locale`, which uses the ``Accept-Language`` header.` settings `An alias for `self.application.settings <Application.settings>`.` xsrf_token `The XSRF-prevention token for the current user/session. To prevent cross-site request forgery, we set an '_xsrf' cookie and include the same '_xsrf' value as an argument with all POST requests. If the two do not match, we reject the form submission as a potential forgery. See http://en.wikipedia.org/wiki/Cross-site_request_forgery .. versionchanged:: 3.2.2 The xsrf token will now be have a random mask applied in every request, which makes it safe to include the token in pages that are compressed. See http://breachattack.com for more information on the issue fixed by this change. Old (version 1) cookies will be converted to version 2 when this method is called unless the ``xsrf_cookie_version`` `Application` setting is set to 1.` Data and other attributes inherited from tornado.web.RequestHandler: SUPPORTED_METHODS = ('GET', 'HEAD', 'POST', 'DELETE', 'PATCH', 'PUT', 'OPTIONS')

Functions
`` |  | call_subprocess(*args, **kwargs) `Wrapper around subprocess call using Tornado's Subprocess class.` check_arguments(body, args) `Helper function to check that all required arguments are present. body: dictionary to check args: required arguments` check_hosts(*args, **kwargs) `Loop that checks to see if all swift hosts have ring files. If a ring file is absent, pushes it to the host.` push_ring(host, ring, ring_file) `Push a new ring file a remote swift instance.` ring_for_type(ring_type) `Given a ring name, returns the corresponding ring object` swift_host_dicts(*args, **kwargs) `Queries consul for each swift group and returns a dict of hostnames to ip:port of the local swift api running on them.` swift_hosts(*args, **kwargs) `Returns a list of all the swift hosts (ip:port) in the system, as known about by consul.` update_weights(*args, **kwargs) `Main loop that runs and updates weights on devices as necessary. When a weight is updated, a key value pair is inserted into redis specifying the target weight. At an interval, we increment or decrement the weight by a set interval toward the target.`

Data
`` |  | CONSUL_CACHE_DURATION = 60 CONSUL_SERVICES = ['swift', 'swift_object', 'swift_proxy', 'swift_container'] CONSUL_URL = 'http://localhost:8500/v1/catalog/service/{0}' REQUEST_TIMEOUT = 80 RINGS = {} RING_PATHS = {'account': '/etc/swift/account.ring.gz', 'container': '/etc/swift/container.ring.gz', 'object': '/etc/swift/object.ring.gz'} RING_TYPES = ['account', 'object', 'container'] WEIGHT_INCREMENT = 2 WEIGHT_UPDATE_INTERVAL = 1800 cached_hw = {} cached_uuids = {} consul_cache = {} consul_last_cached = 0 last_cached = 0