Exemplo n.º 1
0
def get_status_from_coordinator():
    with closing(PrestoClient(get_coordinator_role()[0], env.user)) as client:
        try:
            coordinator_status = run_sql(client, SYSTEM_RUNTIME_NODES)
            catalog_status = get_catalog_info_from(client)
        except BaseException as e:
            # Just log errors that come from a missing port or anything else; if
            # we can't connect to the coordinator, we just want to print out a
            # minimal status anyway.
            _LOGGER.warn(e.message)
            coordinator_status = []
            catalog_status = []

        with settings(hide('running')):
            node_information = execute(collect_node_information,
                                       hosts=get_host_list())

        for host in get_host_list():
            if isinstance(node_information[host], Exception):
                external_ip = 'Unknown'
                is_running = False
                error_message = node_information[host].message
            else:
                (external_ip, is_running,
                 error_message) = node_information[host]

            print_status_header(external_ip, is_running, host)
            if error_message:
                print('\t' + error_message)
            elif not coordinator_status:
                print(
                    '\tNo information available: unable to query coordinator')
            elif not is_running:
                print('\tNo information available')
            else:
                version_string = get_presto_version()
                version = strip_tag(split_version(version_string))
                query, processor = NODE_INFO_PER_URI_SQL.for_version(version)
                # just get the node_info row for the host if server is up
                node_info_row = run_sql(client, query % external_ip)
                node_status = processor(node_info_row)
                if node_status:
                    print_node_info(node_status, catalog_status)
                else:
                    print(
                        '\tNo information available: the coordinator has not yet'
                        ' discovered this node')
Exemplo n.º 2
0
def slider_install(slider_tarball):
    """
    Install slider on the slider master. You must provide a tar file on the
    local machine that contains the slider distribution.

    :param slider_tarball:
    """
    execute(deploy_install, slider_tarball, hosts=get_host_list())
Exemplo n.º 3
0
def slider_install(slider_tarball):
    """
    Install slider on the slider master. You must provide a tar file on the
    local machine that contains the slider distribution.

    :param slider_tarball:
    """
    execute(deploy_install, slider_tarball, hosts=get_host_list())
Exemplo n.º 4
0
def get_status_from_coordinator():
    client = PrestoClient(get_coordinator_role()[0], env.user)
    try:
        coordinator_status = run_sql(client, SYSTEM_RUNTIME_NODES)
        connector_status = get_connector_info_from(client)
    except BaseException as e:
        # Just log errors that come from a missing port or anything else; if
        # we can't connect to the coordinator, we just want to print out a
        # minimal status anyway.
        _LOGGER.warn(e.message)
        coordinator_status = []
        connector_status = []

    with settings(hide('running')):
        node_information = execute(collect_node_information,
                                   hosts=get_host_list())

    for host in get_host_list():
        if isinstance(node_information[host], Exception):
            external_ip = 'Unknown'
            is_running = False
            error_message = node_information[host].message
        else:
            (external_ip, is_running, error_message) = node_information[host]

        print_status_header(external_ip, is_running, host)
        if error_message:
            print('\t' + error_message)
        elif not coordinator_status:
            print('\tNo information available: unable to query coordinator')
        elif not is_running:
            print('\tNo information available')
        else:
            version_string = get_presto_version()
            version = strip_tag(split_version(version_string))
            query, processor = NODE_INFO_PER_URI_SQL.for_version(version)
            # just get the node_info row for the host if server is up
            node_info_row = run_sql(client, query % external_ip)
            node_status = processor(node_info_row)
            if node_status:
                print_node_info(node_status, connector_status)
            else:
                print('\tNo information available: the coordinator has not yet'
                      ' discovered this node')
Exemplo n.º 5
0
def uninstall(rpm_name):
    """
    Uninstall the rpm package from the cluster

    Args:
        rpm_name: Name of the rpm to be uninstalled
        --nodeps (optional): Flag to indicate if rpm uninstall) should ignore checking package dependencies. Equivalent
            to adding --nodeps flag to rpm -e.
        --force (optional): Flag to indicate that rpm uninstall should not fail if package is not installed.
    """
    return execute(rpm_uninstall, rpm_name, hosts=get_host_list())
Exemplo n.º 6
0
def uninstall(rpm_name):
    """
    Uninstall the rpm package from the cluster

    Args:
        rpm_name: Name of the rpm to be uninstalled
        --nodeps (optional): Flag to indicate if rpm uninstall) should ignore checking package dependencies. Equivalent
            to adding --nodeps flag to rpm -e.
        --force (optional): Flag to indicate that rpm uninstall should not fail if package is not installed.
    """
    return execute(rpm_uninstall, rpm_name, hosts=get_host_list())
Exemplo n.º 7
0
def install(local_path):
    """
    Install the rpm package on the cluster

    Args:
        local_path: Absolute path to the rpm to be installed
        --nodeps (optional): Flag to indicate if rpm install
            should ignore checking package dependencies. Equivalent
            to adding --nodeps flag to rpm -i.
    """
    check_if_valid_rpm(local_path)
    return execute(deploy_install, local_path, hosts=get_host_list())
Exemplo n.º 8
0
def install(local_path):
    """
    Install the rpm package on the cluster

    Args:
        local_path: Absolute path to the rpm to be installed
        --nodeps (optional): Flag to indicate if rpm install
            should ignore checking package dependencies. Equivalent
            to adding --nodeps flag to rpm -i.
    """
    check_if_valid_rpm(local_path)
    return execute(deploy_install, local_path, hosts=get_host_list())
Exemplo n.º 9
0
def install(rpm_specifier):
    """
    Copy and install the presto-server rpm to all the nodes in the cluster and
    configure the nodes.

    The topology information will be read from the config.json file. If this
    file is missing, then the coordinator and workers will be obtained
    interactively. Install will fail for invalid json configuration.

    The catalog configurations will be read from the local catalog directory
    which defaults to ~/.prestoadmin/catalog. If this directory is missing or empty
    then no catalog configuration is deployed.

    Install will fail for incorrectly formatted configuration files. Expected
    format is key=value for .properties files and one option per line for
    jvm.config

    Parameters:
        rpm_specifier - String specifying location of presto rpm to copy and install
                        to nodes in the cluster. The string can specify a presto rpm
                        in the following ways:

                        1.  'latest' to download the latest release
                        2.  Url to download
                        3.  Version number to download
                        4.  Path to a local copy

                        If rpm_specifier matches multiple forms, it is interpreted as the form with
                        highest precedence. The forms are listed from highest to lowest precedence
                        (going top to bottom) For example, if the rpm_specifier matches the criteria
                        to be a url to download, it will be interpreted as such and will never be
                        interpreted as a version number or a local path.

                        Before downloading an rpm, install will attempt to find a local
                        copy with a matching version number to the requested rpm. If such
                        a match is found, it will use the local copy instead of downloading
                        the rpm again.

        --nodeps -      (optional) Flag to indicate if server install
                        should ignore checking Presto rpm package
                        dependencies. Equivalent to adding --nodeps
                        flag to rpm -i.

        --no-config-update - pass this in order to avoid server update after installation
    """
    rpm_fetcher = PrestoRpmFetcher(rpm_specifier)
    path_to_rpm = rpm_fetcher.get_path_to_presto_rpm()
    package.check_if_valid_rpm(path_to_rpm)
    return execute(deploy_install_configure,
                   path_to_rpm,
                   hosts=get_host_list())
Exemplo n.º 10
0
def install(rpm_specifier):
    """
    Copy and install the presto-server rpm to all the nodes in the cluster and
    configure the nodes.

    The topology information will be read from the config.json file. If this
    file is missing, then the coordinator and workers will be obtained
    interactively. Install will fail for invalid json configuration.

    The connector configurations will be read from the directory
    /etc/opt/prestoadmin/connectors. If this directory is missing or empty
    then no connector configuration is deployed.

    Install will fail for incorrectly formatted configuration files. Expected
    format is key=value for .properties files and one option per line for
    jvm.config

    Parameters:
        rpm_specifier - String specifying location of presto rpm to copy and install
                        to nodes in the cluster. The string can specify a presto rpm
                        in the following ways:

                        1.  'latest' to download the latest release
                        2.  Url to download
                        3.  Version number to download
                        4.  Path to a local copy

                        If rpm_specifier matches multiple forms, it is interpreted as the form with
                        highest precedence. The forms are listed from highest to lowest precedence
                        (going top to bottom) For example, if the rpm_specifier matches the criteria
                        to be a url to download, it will be interpreted as such and will never be
                        interpreted as a version number or a local path.

                        Before downloading an rpm, install will attempt to find a local
                        copy with a matching version number to the requested rpm. If such
                        a match is found, it will use the local copy instead of downloading
                        the rpm again.

        --nodeps -      (optional) Flag to indicate if server install
                        should ignore checking Presto rpm package
                        dependencies. Equivalent to adding --nodeps
                        flag to rpm -i.
    """
    rpm_fetcher = PrestoRpmFetcher(rpm_specifier)
    path_to_rpm = rpm_fetcher.get_path_to_presto_rpm()
    package.check_if_valid_rpm(path_to_rpm)
    return execute(deploy_install_configure, path_to_rpm, hosts=get_host_list())
Exemplo n.º 11
0
 def call_and_assert_install_with_rpm_specifier(self, mock_download_rpm, mock_check_rpm, mock_execute, location,
                                                rpm_specifier, rpm_path):
     if location == 'local' or location == 'download':
         server.install(rpm_specifier)
         if location == 'local':
             mock_download_rpm.assert_not_called()
         else:
             self.assertTrue(mock_download_rpm.called)
         mock_check_rpm.assert_called_with(rpm_path)
         mock_execute.assert_called_with(server.deploy_install_configure,
                                         rpm_path, hosts=get_host_list())
     elif location == 'none':
         self.assertRaises(SystemExit, server.install, rpm_specifier)
         mock_check_rpm.assert_not_called()
         mock_execute.assert_not_called()
     else:
         exit('Cannot assert because of invalid location: %s' % location)
Exemplo n.º 12
0
 def call_and_assert_install_with_rpm_specifier(self, mock_download_rpm, mock_check_rpm, mock_execute, location,
                                                rpm_specifier, rpm_path):
     if location == 'local' or location == 'download':
         server.install(rpm_specifier)
         if location == 'local':
             mock_download_rpm.assert_not_called()
         else:
             self.assertTrue(mock_download_rpm.called)
         mock_check_rpm.assert_called_with(rpm_path)
         mock_execute.assert_called_with(server.deploy_install_configure,
                                         rpm_path, hosts=get_host_list())
     elif location == 'none':
         self.assertRaises(SystemExit, server.install, rpm_specifier)
         mock_check_rpm.assert_not_called()
         mock_execute.assert_not_called()
     else:
         exit('Cannot assert because of invalid location: %s' % location)
Exemplo n.º 13
0
def install(local_path):
    """
    Copy and install the presto-server rpm to all the nodes in the cluster and
    configure the nodes.

    The topology information will be read from the config.json file. If this
    file is missing, then the coordinator and workers will be obtained
    interactively. Install will fail for invalid json configuration.

    The connector configurations will be read from the directory
    /etc/opt/prestoadmin/connectors. If this directory is missing or empty
    then no connector configuration is deployed.

    Install will fail for incorrectly formatted configuration files. Expected
    format is key=value for .properties files and one option per line for
    jvm.config

    Parameters:
        local_path - Absolute path to the presto rpm to be installed
    """
    package.check_if_valid_rpm(local_path)
    return execute(deploy_install_configure, local_path, hosts=get_host_list())
Exemplo n.º 14
0
def install(local_path):
    """
    Copy and install the presto-server rpm to all the nodes in the cluster and
    configure the nodes.

    The topology information will be read from the config.json file. If this
    file is missing, then the coordinator and workers will be obtained
    interactively. Install will fail for invalid json configuration.

    The connector configurations will be read from the directory
    /etc/opt/prestoadmin/connectors. If this directory is missing or empty
    then no connector configuration is deployed.

    Install will fail for incorrectly formatted configuration files. Expected
    format is key=value for .properties files and one option per line for
    jvm.config

    Parameters:
        local_path - Absolute path to the presto rpm to be installed
    """
    package.check_if_valid_rpm(local_path)
    return execute(deploy_install_configure, local_path, hosts=get_host_list())
Exemplo n.º 15
0
 def test_get_host_with_exclude(self):
     env.hosts = ['a', 'b', 'bad']
     env.exclude_hosts = ['bad']
     self.assertEqual(fabricapi.get_host_list(), ['a', 'b'])
Exemplo n.º 16
0
 def test_install_server(self, mock_execute, mock_check_rpm):
     local_path = "/any/path/rpm"
     server.install(local_path)
     mock_check_rpm.assert_called_with(local_path)
     mock_execute.assert_called_with(server.deploy_install_configure,
                                     local_path, hosts=get_host_list())
Exemplo n.º 17
0
 def test_install_server(self, mock_execute, mock_check_rpm):
     local_path = "/any/path/rpm"
     server.install(local_path)
     mock_check_rpm.assert_called_with(local_path)
     mock_execute.assert_called_with(server.deploy_install_configure,
                                     local_path, hosts=get_host_list())