Пример #1
0
    return method, access_params


def log_debug(message):
    if verbose is True:
        logging.basicConfig(level=logging.DEBUG)
        logging.debug(message)


def log_error(message):
    logging.basicConfig(level=logging.ERROR)
    logging.error(message)


if __name__ == '__main__':
    args = default_args(hosts_file, command_file, protocol, command_output,
                        verbose)
    hosts_file = args[0]
    command_file = args[1]
    protocol = args[2].lower()
    command_output = args[3]
    verbose = args[4]

    if not os.path.isfile(hosts_file):
        log_error(message=' Invalid Hosts File')
        exit(1)
    if not os.path.isfile(command_file):
        log_error(message=' Invalid Commands File')
        exit(1)
    access_method = RouterLib()
    hosts = open(hosts_file, 'r')
    log_debug(message=' Reading the hosts file.')
Пример #2
0
from netlib.netlib.conn_type import Telnet
from netlib.netlib.user_creds import simple

import logging
import os
import sys


def log_debug(message):
    if verbose is True:
        logging.basicConfig(level=logging.DEBUG)
        logging.debug(message)


if __name__ == "__main__":
    args = default_args()
    verbose = args['verbose']
    creds = simple()

    if not os.path.isfile(args['hosts_file']):
        log_error(message=' Invalid Hosts File.')
        exit(1)
    if not os.path.isfile(args['command_file']):
        log_error(message=' Invalid Commands File.')
        exit(1)

    with open(args['hosts_file'], 'r') as hf:
        for host in hf:
            host = host.strip()
            ssh_message = " Attempting to log into %s via SSH." % host
            telnet_message = " Attempting to log into %s via Telnet." % host
Пример #3
0
    return method, access_params


def log_debug(message):
    if verbose is True:
        logging.basicConfig(level=logging.DEBUG)
        logging.debug(message)


def log_error(message):
    logging.basicConfig(level=logging.ERROR)
    logging.error(message)


if __name__ == '__main__':
    args = default_args(hosts_file, command_file, protocol, command_output,
                        verbose)
    hosts_file = args[0]
    command_file = args[1]
    protocol = args[2].lower()
    command_output = args[3]
    verbose = args[4]

    if not os.path.isfile(hosts_file):
        log_error(message=' Invalid Hosts File')
        exit(1)
    if not os.path.isfile(command_file):
        log_error(message=' Invalid Commands File')
        exit(1)
    access_method = RouterLib()
    hosts = open(hosts_file, 'r')
    log_debug(message=' Reading the hosts file.')