prestoadmin.util package¶
Submodules¶
prestoadmin.util.all_write_handler module¶
prestoadmin.util.application module¶
Logic at the application level for logging and exception handling
-
class
prestoadmin.util.application.
Application
(name, version=None, log_file_path=None)[source]¶ Bases:
object
A generic application entry point. Provides logging and exception handling features. This class is expected to be used as a base class for various applications.
Parameters: - - human readable name for the application (name) –
- - the version of the application, as a string (version) –
- - optional name of the log file including whatever (log_file_path) –
- you may want to use. For example, 'foo.log' would create (extension) –
- file called 'foo.log' in the default presto-admin logging directory (a) –
- tree. –
-
prestoadmin.util.application.
entry_point
(name, version=None, log_file_path=None, application_class=<class 'prestoadmin.util.application.Application'>)[source]¶ A decorator for application entry points. The decorated function will be wrapped in an Application object and executed in that safe environment. Note that decorating a function with this decorator will not actually cause it to be invoked. You must explicitly call the function in the script.
Parameters: - - human readable name for the application (name) –
- - the version of the application, as a string (version) –
- - optional name of the log file including whatever (log_file_path) –
- you may want to use. For example, 'foo.log' would create (extension) –
- file called 'foo.log' in the default prestoadmin logging directory (a) –
- tree. –
- - Type of application to run. The default is (application_class) –
- but there can be subclasses of that class. (Application) –
prestoadmin.util.base_config module¶
Module for common configuration stuff.
-
class
prestoadmin.util.base_config.
BaseConfig
(config_path, config_items)[source]¶ Bases:
object
BaseConfig provides the common config functionality for loading configuration files for presto-admin and going through the interactive config process if a config file isn’t present.
Instances of classes that subclass BaseConfig are intended to be used with the @requires_config decorator, which is responsible for adding an attribute to the task that tells main() how to load the configuration and subsequently for enforcing that the configuration has been loaded at the time the task is actually run.
In order to be compatible with @requires_config, subclasses must define a no-arguments constructor.
-
class
prestoadmin.util.base_config.
MultiConfigItem
(items, validate, validate_keys, validate_failed_text)[source]¶ Bases:
object
prestoadmin.util.constants module¶
This modules contains read-only constants used throughout the presto admin project.
prestoadmin.util.exception module¶
This module defines error types relevant to the Presto administrative suite.
-
exception
prestoadmin.util.exception.
ExceptionWithCause
(message='')[source]¶ Bases:
exceptions.Exception
prestoadmin.util.fabric_application module¶
Logic for starting and stopping Fabric applications.
-
class
prestoadmin.util.fabric_application.
FabricApplication
(name, version=None, log_file_path=None)[source]¶ Bases:
prestoadmin.util.application.Application
A Presto Fabric application entry point. Provides logging and exception handling features. Additionally cleans up Fabric network connections before exiting.
prestoadmin.util.fabricapi module¶
Module to add extensions and helpers for fabric api methods
prestoadmin.util.filesystem module¶
Filesystem tools.
prestoadmin.util.httpscacertconnection module¶
-
class
prestoadmin.util.httpscacertconnection.
HTTPSCaCertConnection
(host, port, key_file, cert_file, ca_file, strict, timeout=None)[source]¶ Bases:
httplib.HTTPSConnection
Class to make a HTTPS connection, with support for full client-based SSL Authentication
-
connect
()[source]¶ Connect to a host on a given (SSL) port. If ca_file is pointing somewhere, use it to check Server Certificate.
Redefined/copied and extended from httplib.py:1105 (Python 2.6.x). This is needed to pass cert_reqs=ssl.CERT_REQUIRED as parameter to ssl.wrap_socket(), which forces SSL to check server certificate against our client certificate.
-
prestoadmin.util.local_config_util module¶
prestoadmin.util.parser module¶
An extension to optparse for presto-admin which logs user parsing errors.
-
class
prestoadmin.util.parser.
LoggingOptionParser
(usage=None, option_list=None, option_class=<class optparse.Option>, version=None, conflict_handler='error', description=None, formatter=None, add_help_option=True, prog=None, epilog=None)[source]¶ Bases:
optparse.OptionParser
An extension to optparse which logs exceptions via the logging module in addition to writing the out to stderr.
If used with HiddenOptionGroup, print_extended_help disables the suppress_help attribute of HiddenOptionGroup so as to print out extended helptext.
prestoadmin.util.presto_config module¶
-
class
prestoadmin.util.presto_config.
PrestoConfig
(config_properties, config_path, config_host)[source]¶ -
-
default_config
= {'internal-communication.authentication.ldap.user': None, 'http-server.http.enabled': 'true', 'http-server.https.enabled': 'false', 'http-server.https.port': '8443', 'internal-communication.authentication.ldap.password': None, 'http-server.http.port': '8080', 'internal-communication.https.keystore.path': None, 'internal-communication.https.keystore.key': None}¶
-
prestoadmin.util.remote_config_util module¶
-
prestoadmin.util.remote_config_util.
lookup_port
(host)[source]¶ Get the http port from config.properties http-server.http.port property if available. If the property is missing return default port 8080. If the file is missing or cannot parse the port number, throw ConfigurationError :param host: :return:
prestoadmin.util.validators module¶
Module for validating configuration information supplied by the user.
prestoadmin.util.version_util module¶
Stuff to handle version ranges.
-
class
prestoadmin.util.version_util.
VersionRange
(min_version, max_version, versioned_thing=None)[source]¶ Bases:
object
Represents a range of version numbers [min_version, max_version). The interval is right-open so that you can construct a numerically continuous list of versions like so: l = [VersionRange((0, 0), (0, 5)), VersionRange((0, 5), (1, 0))] and for all versions v where 0.0 <= v < 1.0 is contained in exactly one VersionRange in l.
Continuity between version ranges can be checked using is_continuous.
VersionRanges understand how to check if a Teradata version is contained in a VersionRange, but do no special handling to accomodate Teradata versions in their internal min_version and max_version members. I.e., creating a VersionRange with a Teradata version will work, but __contains__ will not work correctly. We don’t currently need this, and hope not to.
Note that the right-open interval representation of a version range does NOT allow the creation of a VersionRange that contains exactly one version.
Note that empty intervals cannot be constructed as the serve no useful purpose. Specifically, we assert that min_version < max_version in the constructor.
-
class
prestoadmin.util.version_util.
VersionRangeList
(*range_list)[source]¶ Bases:
object
A VersionRangeList is a list of continuous, non-overlapping VersionRanges. This is guaranteed by calling VersionRange.is_continuous on all pairs of VersionRanges vr[i], vr[i + 1] in the list, which ensures that the list is both sorted in order of ascending version and that the interval [vr[0].min_version, vr[n].max_version) has no discontinuities.
-
prestoadmin.util.version_util.
strip_tag
(version)[source]¶ Strip any parts of the version that are not numeric components or t’s We leave the ‘t’ on numeric components if it’s present. [‘1’, ‘2’, ‘THREE’] -> (1, 2) [‘1’, ‘TWO’, ‘3’] -> (1, 3) [‘0’, ‘115t’, ‘SNAPSHOT’] -> (0, ‘115t’) [‘ZERO’, ‘123t’] -> (123t) [‘0’, ‘148’, ‘t’] => (0, 148, ‘t’) [‘0’, ‘148’, ‘t’, 0, 1] => (0, 148, ‘t’, 0, 1) [‘0’, ‘148’, ‘t’, 0, 1, ‘SNAPSHOT’] => (0, 148, ‘t’, 0, 1) [‘0’, ‘162’, ‘SNAPSHOT’, ‘t’, ‘SNAPSHOT’] => (0, 162, ‘t’)
This checks the components of the version from least to most significant.
Parameters: version – something that can be sliced Returns: a tuple containing only integer components or the letter t