def test_check_rpm_checksum_err(self, mock_abort, mock_local): mock_local.return_value = lambda: None setattr(mock_local.return_value, 'stderr', 'Not an rpm package') setattr(mock_local.return_value, 'stdout', '') package.check_if_valid_rpm('/any/path/rpm') mock_local.assert_called_with('rpm -K --nosignature /any/path/rpm', capture=True) mock_abort.assert_called_with('Not an rpm package')
def test_check_rpm_checksum(self, mock_abort, mock_local): mock_local.return_value = lambda: None setattr(mock_local.return_value, 'stderr', '') setattr(mock_local.return_value, 'stdout', 'sha1 MD5 NOT OK') package.check_if_valid_rpm('/any/path/rpm') mock_local.assert_called_with('rpm -K --nosignature /any/path/rpm', capture=True) mock_abort.assert_called_with('Corrupted RPM. ' 'Try downloading the RPM again.')
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())
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())
def _check_rpm_uncorrupted(rpm_path): # package.check_if_valid_rpm() outputs information that is not applicable # to this function # stderr is redirected to not be displayed and should be restored at the # end of the function to behave as expected later old_stderr = sys.stderr sys.stderr = open(os.devnull, 'w') try: package.check_if_valid_rpm(rpm_path) except SystemExit: try: os.remove(rpm_path) warn('Removed corrupted rpm at: %s' % rpm_path) except OSError: pass return False finally: sys.stderr = old_stderr return True
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())