def main():
    """Pattoo CLI script.

    Args:
        None

    Returns:
        None

    """
    # Initialize key variables
    _help = 'This program is the CLI interface to configuring the linux agent'
    template_dir = os.path.join(ROOT_DIR, 'setup/systemd/system')
    daemon_list = [
        'pattoo_agent_linux_autonomousd', 'pattoo_agent_linux_spoked',
        'pattoo_agent_linux_hubd'
    ]

    # Ensure user is running as root or travis
    check_user()

    # Process the CLI
    _parser = Parser(additional_help=_help)
    (args, parser) = _parser.args()

    # Process CLI options
    if args.action == 'install':

        # Installs all linux agent components
        if args.qualifier == 'all':
            print('Installing everything')
            configure.install(daemon_list)
            packages.install(ROOT_DIR)
            systemd.install(daemon_list=daemon_list,
                            template_dir=template_dir,
                            installation_dir=ROOT_DIR)

        # Sets up configuration for linux agent
        elif args.qualifier == 'configuration':
            print('Installing configuration')
            configure.install(daemon_list)

        # Installs necessary pip packages
        elif args.qualifier == 'pip':
            print('Installing pip packages')
            packages.install(ROOT_DIR, args.verbose)

        # Installs and runs system daemons
        elif args.qualifier == 'systemd':
            print('Installing and running system daemons')
            systemd.install(daemon_list=daemon_list,
                            template_dir=template_dir,
                            installation_dir=ROOT_DIR)

        else:
            parser.print_help(sys.stderr)
            sys.exit(1)

        # Done
        print('Done')
Beispiel #2
0
def main():
    """Pattoo CLI script.

        None

    Returns:
        None

    """
    # Initialize key variables
    _help = 'This program is the CLI interface to configuring pattoo'
    daemon_list = ['pattoo_apid', 'pattoo_api_agentd', 'pattoo_ingesterd']
    template_dir = os.path.join(ROOT_DIR, 'setup/systemd/system')

    # Process the CLI
    _parser = Parser(additional_help=_help)
    (args, parser) = _parser.args()

    # Perform checks
    checks.parser_check(_parser.args()[1], _parser.args()[0])
    checks.pattoo_shared_check()
    checks.venv_check()

    # Import packages that depend on pattoo shared
    from _pattoo import configure
    from pattoo_shared.installation import packages, systemd, environment

    # Set up essentials for creating the virtualenv
    pattoo_home = get_pattoo_home()
    venv_dir = os.path.join(pattoo_home, 'pattoo-venv')
    if getpass.getuser() != 'travis':
        environment.environment_setup(venv_dir)
    venv_interpreter = os.path.join(venv_dir, 'bin/python3')
    installation_dir = '{} {}'.format(venv_interpreter, ROOT_DIR)

    # Installs all pattoo components
    if args.qualifier == 'all':
        print('Installing everything')
        configure.install(pattoo_home)
        packages.install(ROOT_DIR, venv_dir, args.verbose)

        # Import db after pip3 packages are installed
        from _pattoo import db
        db.install()
        if shared.root_check() is True and args.action != 'developer':
            systemd.install(daemon_list=daemon_list,
                            template_dir=template_dir,
                            installation_dir=installation_dir,
                            verbose=args.verbose)

    # Configures pattoo and sets up database tables
    elif args.qualifier == 'database':
        print('Installing database tables')
        configure.install(pattoo_home)
        packages.install(ROOT_DIR, venv_dir)
        # Import db after pip3 packages are installed
        from _pattoo import db
        db.install()

    # Installs and starts system daemons
    elif args.qualifier == 'systemd':
        print('Installing systemd daemons')
        if shared.root_check() is True:
            systemd.install(daemon_list=daemon_list,
                            template_dir=template_dir,
                            installation_dir=installation_dir,
                            verbose=True)
        else:
            shared.log('You need to be running as root to install the daemons')

    elif args.qualifier == 'pip':
        # Installs additionally required pip3 packages
        packages.install(ROOT_DIR, venv_dir, args.verbose)

    # Sets up the configuration for pattoo
    elif args.qualifier == 'configuration':
        configure.install(pattoo_home)

    # Print help if no argument options were triggered
    else:
        parser.print_help(sys.stderr)
        sys.exit(1)

        # Done
        print('Done')
def main():
    """Pattoo CLI script.

    Args:
        None

    Returns:
        None

    """
    # Initialize key variables
    _help = 'This program is the CLI interface to configuring the snmp agent'
    template_dir = os.path.join(ROOT_DIR, 'setup/systemd/system')
    daemon_list = ['pattoo_agent_snmp_ifmibd', 'pattoo_agent_snmpd']

    # Process the CLI
    _parser = Parser(additional_help=_help)
    (args, parser) = _parser.args()

    # Perform checks
    checks.parser_check(_parser.args()[1], _parser.args()[0])
    checks.pattoo_shared_check()
    checks.venv_check()

    # Import packages that depend on pattoo shared
    from _pattoo_agent_snmp import configure, packages
    from pattoo_shared.installation import systemd, environment

    # Set up essentials for creating the virtualenv
    pattoo_home = get_pattoo_home()
    venv_dir = os.path.join(pattoo_home, 'pattoo-venv')
    if getpass.getuser() != 'travis':
        environment.environment_setup(venv_dir)
    venv_interpreter = os.path.join(venv_dir, 'bin/python3')
    installation_dir = '{} {}'.format(venv_interpreter, ROOT_DIR)

    # Installs all linux agent components
    if args.qualifier == 'all':
        print('Installing everything')
        configure.install(daemon_list, pattoo_home)
        packages.install(ROOT_DIR, venv_dir, args.verbose)
        if shared.root_check() is True and args.action != 'developer':
            systemd.install(daemon_list=daemon_list,
                            template_dir=template_dir,
                            installation_dir=installation_dir)

    # Sets up configuration for linux agent
    elif args.qualifier == 'configuration':
        print('Installing configuration')
        configure.install(daemon_list, pattoo_home)

    # Installs necessary pip packages
    elif args.qualifier == 'pip':
        print('Installing pip packages')
        packages.install(ROOT_DIR, venv_dir, args.verbose)

    # Installs and runs system daemons
    elif args.qualifier == 'systemd':
        if shared.root_check() is True:
            print('Installing and running system daemons')
            systemd.install(daemon_list=daemon_list,
                            template_dir=template_dir,
                            installation_dir=installation_dir)
        else:
            shared.log('You need to be running as root to install the daemons')

    else:
        parser.print_help(sys.stderr)
        sys.exit(1)

        # Done
        print('Done')
Beispiel #4
0
def main():
    """Pattoo CLI script.

    Args:
        None

    Returns:
        None

    """
    # Initialize key variables
    _help = 'This program is the CLI interface to configuring pattoo web'
    template_dir = os.path.join(ROOT_DIR, 'setup/systemd/system')
    daemon_list = ['pattoo_webd']
    config_files = [
        'pattoo.yaml', 'pattoo_server.yaml', 'pattoo_agent.yaml',
        'pattoo_webd.yaml'
    ]

    # Ensure user is running as root or travis
    installation_checks()

    # Process the CLI
    _parser = Parser(additional_help=_help)
    (args, parser) = _parser.args()

    # Process CLI options
    if args.action == 'install':
        # Do package checks
        pattoo_shared_check()
        venv_check()

        # Import packages that depend on pattoo shared
        from _pattoo_web import configure, docker
        from pattoo_shared.installation import packages, systemd, environment

        # Setup virtual environment
        if getpass.getuser() != 'travis':
            pattoo_home = get_pattoo_home()
            venv_dir = os.path.join(pattoo_home, 'pattoo-venv')
            environment.environment_setup(venv_dir)
            venv_interpreter = os.path.join(venv_dir, 'bin/python3')
            installation_dir = '{} {}'.format(venv_interpreter, ROOT_DIR)
        else:
            # Set default directories for travis
            pattoo_home = os.path.join(os.path.expanduser('~'), 'pattoo')
            venv_dir = DEFAULT_PATH
            installation_dir = ROOT_DIR

        # Installs all pattoo webd agent components
        if args.qualifier == 'all':
            print('Installing everything')
            configure.install(pattoo_home)
            packages.install(ROOT_DIR, venv_dir, verbose=args.verbose)
            systemd.install(daemon_list=daemon_list,
                            template_dir=template_dir,
                            installation_dir=installation_dir,
                            verbose=args.verbose)

        # Sets up configuration for agent
        elif args.qualifier == 'configuration':
            print('Installing configuration')
            configure.install(pattoo_home)

        # Installs pip packages
        elif args.qualifier == 'pip':
            print('Installing pip packages')
            packages.install(ROOT_DIR, venv_dir, verbose=args.verbose)

        # Installs and runs system daemons in the daemon list
        elif args.qualifier == 'systemd':
            print('Installing and running system daemons')
            systemd.install(daemon_list=daemon_list,
                            template_dir=template_dir,
                            installation_dir=installation_dir,
                            verbose=args.verbose)
        elif args.qualifier == 'docker':
            docker.install('pattoo-web', config_files)

        else:
            parser.print_help(sys.stderr)
            sys.exit(1)

        # Done
        print('Done')