コード例 #1
0
def reporte_inventario_xr():
    master = Master()
    devices = CiscoXR.devices(master=master)
    devices_dict = [{
        "ip": device.ip,
        "hostname": device.hostname,
        "platform": device.platform
    } for device in devices]
    weblog.info("reporte_inventario: {0} dispositivos".format(
        len(devices_dict)))
    titulo = "Inventario de Equipos XR"

    return render_template('inventario.html',
                           titulo=titulo,
                           devices=devices_dict)
コード例 #2
0
def json_cisco_commands_tabulated():
    request.get_json()
    ip = request.json['ip']
    method = request.json['method']
    ufinet = Claro()
    ufinet.master = Master()

    try:
        device = ufinet.correct_device_platform(
            ufinet.devices_from_ip_list([ip]))[0]
        device.isp = ufinet
        method_instantiated = getattr(device, method)
        dict_table_data = method_instantiated()
        data_json = jsonify(dict_table_data)
        return data_json

    except Exception as e:
        print(repr(e))
コード例 #3
0
import getpass

from config.Master import Master
from model.BaseDevice import BaseDevice

master = Master()
ip = getpass._raw_input("ip del cisco")
EquipoPrueba = BaseDevice(ip, "pba", master)

device = EquipoPrueba.connect()
# print(EquipoPrueba.sendCommand(device,"show conf"))

print(EquipoPrueba.get_recursive_routes())
コード例 #4
0
                l1_protocol_attr,   
                data_flow,
                net_device_uid'''
'''

list_dev = ['172.16.30.4', '172.16.30.3', '172.16.30.1']
date = time.strftime("%Y%m%d")
parameters= {
        "ip_seed_router": "172.16.30.15",
        "shelve_name": "shelves/" + date + "_ospf_ufinet_regional"
    }
data =isp.ospf_topology_vs(**parameters)
'''

isp = ISP()
isp.master = Master()
isp.master.username = '******'
isp.master.password = '******'
# device = CiscoIOS(ip='172.16.30.5', display_name='a', master=isp.master, )
#
# honduras =  {
#     "ip_seed_router": '172.17.24.210', "process_id": '504', "area": '504002',
#     'network_name': 'RCE_HONDURAS'
# }
# regional = {
#     "ip_seed_router": "172.16.30.5", "process_id": '1', "area": '0',
#     'network_name': '_ospf_ufinet_regional'
# }
# guatemala = {
#     "ip_seed_router": "172.17.22.52",
#     "process_id": '502', "area": '502008', 'network_name': 'RCE_GUATEMALA'
コード例 #5
0
    def verify_password(self, password):

        return Master.decode(password, self.password_hash)
コード例 #6
0
 def hash_password(self, password):
     self.password_hash = Master.encode(password)
コード例 #7
0
from model.claseClaro import Claro
from config.Master import Master
from model.InternetServiceProvider import InternetServiceProvider as ISP
import argparse

parser = argparse.ArgumentParser(description='Interfaces report saver')
parser.add_argument('template', type=str,
                    help='template yml')
args = parser.parse_args()

isp = ISP()
isp.master = Master()
isp.save_interfaces_state_db(template=args.template)
コード例 #8
0
from model.claseClaro import Claro
from config.Master import Master
from pprint import pprint
import argparse

parser = argparse.ArgumentParser(description='Services Instance report Generator')

parser.add_argument('filename', type=str,
                    help='file_name_full_path')
parser.add_argument('devices_ip', metavar='I', type=str, nargs='+',
                    help='list of ips of devices')
args = parser.parse_args()
claro = Claro()
claro.set_master(password=Master.decode("ufinet", "w4rDjMOSw5zDisOowqbCnsOI"),
                 username=Master.decode("pinf con vrf", "w5fDjsOhw5rCicOSw50="))

claro.save_to_excel_list(list_data=claro.get_service_instance_with_pseudowires(
    claro.devices_from_ip_list(args.devices_ip)), file_name=args.filename)
コード例 #9
0
from model.Devices import Devices
from config.Master import Master
from model.Diagram import Diagram
import asyncio
import datetime

with open('hosts/interfaces/regional') as f:
    ip_lista = [line.replace('\n', '') for line in f]

master = Master()
delta_minutes = 8
diagrams = Diagram.recent_diagrams(master)
date_last_minutes = str(datetime.datetime.now() -
                        datetime.timedelta(minutes=delta_minutes))
sql = f'''SELECT net_device_uid from poll_events where timestamp>'{date_last_minutes}' '''
connection = master.db_connect()
with connection.cursor() as cursor:
    cursor.execute(sql)
    data = cursor.fetchall()
    uids = {row['net_device_uid'] for row in data}
window = 15
for diagram in diagrams:
    not_polled = set(diagram.state.devices_uid.keys()).difference(uids)
    if not_polled:
        ips = [diagram.state.devices_uid[k].ip for k in not_polled]
        ips_uid = {diagram.state.devices_uid[k].ip: k for k in not_polled}
        top_ten_ips = ips[0:window - 1] if len(ips) > window else ips
        ips_uid = {ip: ips_uid[ip] for ip in top_ten_ips}
        break

#
コード例 #10
0
from model.Devices import Devices
from config.Master import Master
from model.Diagram import Diagram
import asyncio
import datetime

top_ten_ips = ['172.16.30.247']
#
devs = Devices(master=Master(), ip_list=top_ten_ips, check_up=False)
devs.devices['172.16.30.247'].uid_db()

devs.add_snmp_event(event='interfaces', type='asyc')

devs.devices['172.16.30.247'].community = 'pnrw-all'
devs.execute(methods=['set_interfaces_snmp'])
#
#
# asyncio.get_event_loop().run_until_complete(devs.set_interfaces_snmp())

print(devs.devices['172.16.30.247'].interfaces['BVI2150'].util_in)
#
#
コード例 #11
0
 def set_master(self, username, password, logg_name="master"):
     self.master = Master(password=password,
                          username=username,
                          logg_name="master")