Esempio n. 1
0
def generate_listof_lists(custdictionary, command, creds):
    '''Returns a list of lists from the input dictionary'''
    swlist = []
    if creds is not None:
        username, password, secret = credentials.cred_csv(creds)
    else:
        username, password, secret = credentials.cred_csv()
    for row in custdictionary:
        swlist.append(generate_switch_dict(username, password, secret, row, command))
    logging.debug("List of Lists:")
    logging.debug(str(swlist))
    return swlist
Esempio n. 2
0
            print("\n\n>>>>>>>>> Device {0} <<<<<<<<<".format(row['SysName']))
            print("\nMAC Address Hits on this switch: ")
            print(macreturn)
            print("\nCisco Discovery Protocol Hits on this switch: ")
            if cdpreturn == "":
                print("No CDP results for this MAC")
            else:
                print(cdpreturn)
                cdplist = ' '.join(macreturn.split())
                port = cdplist.split(' ')[3]
                command_string_port = 'show run int ' + str(port)
                portreturn = net_connect.send_command(command_string_port)
                print("\nPort Configuration for matched CDP: ")
                print(portreturn)
            print("\n>>>>>>>>> End <<<<<<<<<")

            net_connect.disconnect()

# Grab the Customer name to search
customer = input('Customer name: ') + ".csv"
# Flesh out these variables using the credentials.cred_csv module
username, password, secret = credentials.cred_csv()
# Run the primary function in this program
findmac(username, password, secret)

end_time = datetime.now()
# How long did it run?
total_time = end_time - start_time
print("\nTotal time for script: \n" + str(total_time))
Esempio n. 3
0
from netmiko import ConnectHandler
import credentials # Local import of credentials.py


STARTTIME = datetime.now() # Begin timing the script

config = configparser.ConfigParser()
config.read("netsparkconfig.ini")
OLDCOMM = config.get("snmpinfo", "oldcomm")
ACLNUM = config.get("snmpinfo", "aclnum")
SNMPSERV = config.get("snmpinfo", "snmpserv")
V2CCOMM = config.get("snmpinfo", "v2ccomm")
CONTACT = config.get("snmpinfo", "contact")
LOCATION = config.get("snmpinfo", "location")

USERNAME, PASSWORD, SECRET = credentials.cred_csv()
COMMAND = [ 'no ip access-list standard snmplist',
            'no snmp-server community ' + OLDCOMM,
            'ip access-list standard ' + ACLNUM,
	        'no 10',
	        'no 20',
	        '10 permit host ' + SNMPSERV + ' log',
	        '20 deny any log',
	        'exit',
            'snmp-server community ' + V2CCOMM + ' ro 10',
            'snmp-server contact ' + CONTACT,
            'snmp-server location ' + LOCATION ]

CUSTOMER = input("Which customer? ") + ".csv"
POOL = ThreadPool()