コード例 #1
0
ファイル: catalog.py プロジェクト: prestodb/presto-admin
def add(name=None):
    """
    Deploy configuration for a catalog onto a cluster.

    E.g.: 'presto-admin catalog add tpch'
    deploys a configuration file for the tpch connector.  The configuration is
    defined by tpch.properties in the local catalog directory, which defaults to
    ~/.prestoadmin/catalog.

    If no catalog name is specified, then  configurations for all catalogs
    in the catalog directory will be deployed

    Parameters:
        name - Name of the catalog to be added
    """
    catalog_dir = get_catalog_directory()
    if name:
        filename = name + '.properties'
        config_path = os.path.join(catalog_dir, filename)
        if not os.path.isfile(config_path):
            raise ConfigFileNotFoundError(
                config_path=config_path,
                message='Configuration for catalog ' + name + ' not found')
        filenames = [filename]
    elif not os.path.isdir(catalog_dir):
        message = ('Cannot add catalogs because directory %s does not exist'
                   % catalog_dir)
        raise ConfigFileNotFoundError(config_path=catalog_dir,
                                      message=message)
    else:
        try:
            filenames = os.listdir(catalog_dir)
        except OSError as e:
            fabric.utils.error(e.strerror)
            return
        if not filenames:
            fabric.utils.warn(
                'Directory %s is empty. No catalogs will be deployed' %
                catalog_dir)
            return

    if not validate(filenames):
        return
    filenames.sort()
    _LOGGER.info('Adding catalog configurations: ' + str(filenames))
    print('Deploying %s catalog configurations on: %s ' %
          (', '.join(filenames), env.host))

    deploy_files(filenames, catalog_dir,
                 constants.REMOTE_CATALOG_DIR, PRESTO_STANDALONE_USER_GROUP)
コード例 #2
0
ファイル: connector.py プロジェクト: ludun624/presto-admin
def add(name=None):
    """
    Deploy configuration for a connector onto a cluster.

    E.g.: 'presto-admin connector add tpch'
    deploys a configuration file for the tpch connector.  The configuration is
    defined by tpch.properties in /etc/opt/prestoadmin/connectors directory.

    If no connector name is specified, then  configurations for all connectors
    in the connectors directory will be deployed

    Parameters:
        name - Name of the connector to be added
    """
    if name:
        filename = name + '.properties'
        config_path = os.path.join(constants.CONNECTORS_DIR, filename)
        if not os.path.isfile(config_path):
            raise ConfigFileNotFoundError(
                config_path=config_path,
                message='Configuration for connector ' + name + ' not found')
        filenames = [filename]
    elif not os.path.isdir(constants.CONNECTORS_DIR):
        message = (
            'Cannot add connectors because directory %s does not exist' %
            constants.CONNECTORS_DIR)
        raise ConfigFileNotFoundError(config_path=constants.CONNECTORS_DIR,
                                      message=message)
    else:
        try:
            filenames = os.listdir(constants.CONNECTORS_DIR)
        except OSError as e:
            fabric.utils.error(e.strerror)
            return
        if not filenames:
            fabric.utils.warn(
                'Directory %s is empty. No connectors will be deployed' %
                constants.CONNECTORS_DIR)
            return

    if not validate(filenames):
        return
    filenames.sort()
    _LOGGER.info('Adding connector configurations: ' + str(filenames))
    print('Deploying %s connector configurations on: %s ' %
          (', '.join(filenames), env.host))

    deploy_files(filenames, constants.CONNECTORS_DIR,
                 constants.REMOTE_CATALOG_DIR, PRESTO_STANDALONE_USER_GROUP)
コード例 #3
0
def add(name=None):
    """
    Deploy configuration for a connector onto a cluster.

    E.g.: 'presto-admin connector add tpch'
    deploys a configuration file for the tpch connector.  The configuration is
    defined by tpch.properties in /etc/opt/prestoadmin/connectors directory.

    If no connector name is specified, then  configurations for all connectors
    in the connectors directory will be deployed

    Parameters:
        name - Name of the connector to be added
    """
    if name:
        filename = name + '.properties'
        config_path = os.path.join(constants.CONNECTORS_DIR, filename)
        if not os.path.isfile(config_path):
            raise ConfigFileNotFoundError(
                config_path=config_path,
                message='Configuration for connector ' + name + ' not found')
        filenames = [filename]
    elif not os.path.isdir(constants.CONNECTORS_DIR):
        message = ('Cannot add connectors because directory %s does not exist'
                   % constants.CONNECTORS_DIR)
        raise ConfigFileNotFoundError(config_path=constants.CONNECTORS_DIR,
                                      message=message)
    else:
        try:
            filenames = os.listdir(constants.CONNECTORS_DIR)
        except OSError as e:
            fabric.utils.error(e.strerror)
            return
        if not filenames:
            fabric.utils.warn(
                'Directory %s is empty. No connectors will be deployed' %
                constants.CONNECTORS_DIR)
            return

    if not validate(filenames):
        return
    filenames.sort()
    _LOGGER.info('Adding connector configurations: ' + str(filenames))
    print('Deploying %s connector configurations on: %s ' %
          (', '.join(filenames), env.host))

    deploy_files(filenames, constants.CONNECTORS_DIR,
                 constants.REMOTE_CATALOG_DIR)