Пример #1
0
def get_huawei():
        print('running show huawei facts')
        #commands = ['NO','display version | incl VRP|HUAWEI']
        show_huawei_facts = all_huawei.run(task=netmiko_send_command,command_string="display version | incl VRP|HUAWEI")
        #show_huawei_facts = all_huawei.run(task=netmiko_send_command,command_string=commands)
        print('process show facts huawei')
        for i in show_huawei_facts.keys():
                if i not in show_huawei_facts.failed_hosts.keys():
                        try:
                                version,model = huawei_parse_show_version(show_huawei_facts[i].result)
                                update_routers_sqlite3('Routers',i,version,model,'huawei')
                        except Exception as e:
                                pass

        print('failed huawei hosts:\n{}\n'.format(show_huawei_facts.failed_hosts.keys()))
Пример #2
0
def get_cisco_ios():
        print('running show cisco IOS facts')
        show_ios_facts = all_cisco_ios.run(task=networking.napalm_get,getters=["facts"])

        print('process show facts cisco XR')

        for i in show_ios_facts.keys():
                if i not in show_ios_facts.failed_hosts.keys():
                        try:
                                version = show_ios_facts[i][0].result['facts']['os_version']
                                version = version.split('Version')[1].split(',')[0].strip()
                                model = show_ios_facts[i][0].result['facts']['model']
                                update_routers_sqlite3('Routers',i,version,model,'cisco-ios')
                        except Exception as e:
                                pass

        print('failed IOS hosts:\n{}\n'.format(show_ios_facts.failed_hosts.keys()))
Пример #3
0
def get_cisco_xr():
        print('running show cisco XR facts')
        show_facts = all_cisco_xr.run(task=networking.napalm_get,getters=["facts"])

        print('process show facts cisco XR')

        for i in show_facts.keys():
                if i not in show_facts.failed_hosts.keys():
                        try:
                                version = show_facts[i][0].result['facts']['os_version']
                                model = show_facts[i][0].result['facts']['model'].upper()
                                update_routers_sqlite3('Routers',i,version,model,'cisco-xr')
                                #print(i,version,model,'cisco-xr')
                        except Exception as e:
                                pass

        print('failed XR hosts:\n{}\n'.format(show_facts.failed_hosts.keys()))
Пример #4
0
def get_juniper():
        print('running show juniper facts')
        all_juniper = nr.filter(type='juniper')
        show_juniper_facts = all_juniper.run(task=networking.napalm_get,getters=["facts"])

        print('process show facts Juniper for: {}'.format(show_juniper_facts.keys()))

        for i in show_juniper_facts.keys():
                if i not in show_juniper_facts.failed_hosts.keys():
                        try:
                                version = show_juniper_facts[i][0].result['facts']['os_version']
                                model = show_juniper_facts[i][0].result['facts']['model'].upper()
                                update_routers_sqlite3('Routers',i,version,model,'juniper')
                                #print(i,version,model,'juniper')
                        except Exception as e:
                                pass
        print('failed juniper hosts:\n{}\n'.format(show_juniper_facts.failed_hosts.keys()))
Пример #5
0
def get_cisco_xr():
    print("running show cisco XR facts")
    show_facts = all_cisco_xr.run(task=networking.napalm_get,
                                  getters=["facts"])
    print("process show facts cisco XR")

    for i in show_facts.keys():
        if i not in show_facts.failed_hosts.keys():
            try:
                version = show_facts[i][0].result["facts"]["os_version"]
                model = show_facts[i][0].result["facts"]["model"].upper()
                update_routers_sqlite3("Routers", i, version, model,
                                       "cisco-xr")
            except Exception as e:
                pass
        else:
            print("failed XR hosts:\n{}\n".format(
                show_facts.failed_hosts.keys()))
Пример #6
0
def get_cisco_ios():
    print("running show cisco IOS facts")
    show_ios_facts = all_cisco_ios.run(task=networking.napalm_get,
                                       getters=["facts"])

    print("process show facts cisco IOS")

    for i in show_ios_facts.keys():
        if i not in show_ios_facts.failed_hosts.keys():
            try:
                version = show_ios_facts[i][0].result["facts"]["os_version"]
                version = version.split("Version")[1].split(",")[0].strip()
                model = show_ios_facts[i][0].result["facts"]["model"]
                update_routers_sqlite3("Routers", i, version, model,
                                       "cisco-ios")
            except Exception as e:
                pass
        else:
            print("failed IOS hosts:\n{}\n".format(
                show_ios_facts.failed_hosts.keys()))
Пример #7
0
def get_cisco_xr_genie():
    print("Find XR model and version using Genie")
    with tqdm(
            total=len(all_cisco_xr.inventory.hosts),
            desc="Get Model Number for XR using Genie parser",
    ) as progress_bar:
        show_facts = all_cisco_xr.run(task=collect_xr_multiple,
                                      progress_bar=progress_bar,
                                      on_failed=True)
    for i in show_facts.keys():
        if i not in show_facts.failed_hosts.keys():
            try:
                version = show_facts[i][2].result["software_version"]
                model = show_facts[i][1].result["module_name"]["Rack 0"]["pid"]
                update_routers_sqlite3("Routers", i, version, model,
                                       "cisco-xr")
            except Exception as e:
                pass
        else:
            print("failed XR with Genie hosts:\n{}\n".format(
                show_facts.failed_hosts.keys()))
Пример #8
0
def get_juniper():
    print("running show juniper facts")
    with tqdm(
            total=len(all_juniper.inventory.hosts),
            desc="Get Model Number for Juniper using Napalm",
    ) as progress_bar:
        show_juniper_facts = all_juniper.run(task=_napalm_get,
                                             progress_bar=progress_bar)

    for i in show_juniper_facts.keys():
        if i not in show_juniper_facts.failed_hosts.keys():
            try:
                version = show_juniper_facts[i][0].result["facts"][
                    "os_version"]
                model = show_juniper_facts[i][0].result["facts"][
                    "model"].upper()
                update_routers_sqlite3("Routers", i, version, model, "juniper")
            except Exception as e:
                pass
        else:
            print("failed juniper hosts:\n{}\n".format(
                show_juniper_facts.failed_hosts.keys()))