2019-07-07 02:49:54 -07:00
|
|
|
"""
|
|
|
|
Global Constants for hyperglass
|
|
|
|
"""
|
|
|
|
|
2019-07-15 02:30:42 -07:00
|
|
|
protocol_map = {80: "http", 8080: "http", 443: "https", 8443: "https"}
|
|
|
|
|
2019-09-13 00:36:58 -07:00
|
|
|
afi_nos_map = {
|
|
|
|
"default": {
|
2019-09-30 07:51:17 -07:00
|
|
|
"ipv4_global": "ipv4",
|
|
|
|
"ipv6_global": "ipv6",
|
2019-09-13 00:36:58 -07:00
|
|
|
"ipv4_vpn": "vpnv4",
|
|
|
|
"ipv6_vpn": "vpnv6",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-07 02:49:54 -07:00
|
|
|
|
|
|
|
class Supported:
|
|
|
|
"""
|
|
|
|
Defines items supported by hyperglass.
|
|
|
|
|
|
|
|
query_types: Supported query types used to validate Flask input.
|
|
|
|
|
|
|
|
rest: Supported REST API platforms
|
|
|
|
|
|
|
|
scrape: Supported "scrape" platforms which will be accessed via
|
|
|
|
Netmiko. List updated 07/2019.
|
|
|
|
"""
|
|
|
|
|
2019-09-09 12:18:26 -07:00
|
|
|
query_parameters = ("query_location", "query_type", "query_target", "query_vrf")
|
|
|
|
|
2019-07-07 02:49:54 -07:00
|
|
|
query_types = ("bgp_route", "bgp_community", "bgp_aspath", "ping", "traceroute")
|
|
|
|
|
|
|
|
rest = ("frr", "bird")
|
|
|
|
|
|
|
|
scrape = (
|
|
|
|
"a10",
|
|
|
|
"accedian",
|
|
|
|
"alcatel_aos",
|
|
|
|
"alcatel_sros",
|
|
|
|
"apresia_aeos",
|
|
|
|
"arista_eos",
|
|
|
|
"aruba_os",
|
|
|
|
"avaya_ers",
|
|
|
|
"avaya_vsp",
|
|
|
|
"brocade_fastiron",
|
|
|
|
"brocade_netiron",
|
|
|
|
"brocade_nos",
|
|
|
|
"brocade_vdx",
|
|
|
|
"brocade_vyos",
|
|
|
|
"checkpoint_gaia",
|
|
|
|
"calix_b6",
|
|
|
|
"ciena_saos",
|
|
|
|
"cisco_asa",
|
|
|
|
"cisco_ios",
|
|
|
|
"cisco_nxos",
|
|
|
|
"cisco_s300",
|
|
|
|
"cisco_tp",
|
|
|
|
"cisco_wlc",
|
|
|
|
"cisco_xe",
|
|
|
|
"cisco_xr",
|
|
|
|
"coriant",
|
|
|
|
"dell_dnos9",
|
|
|
|
"dell_force10",
|
|
|
|
"dell_os6",
|
|
|
|
"dell_os9",
|
|
|
|
"dell_os10",
|
|
|
|
"dell_powerconnect",
|
|
|
|
"dell_isilon",
|
|
|
|
"eltex",
|
|
|
|
"enterasys",
|
|
|
|
"extreme",
|
|
|
|
"extreme_ers",
|
|
|
|
"extreme_exos",
|
|
|
|
"extreme_netiron",
|
|
|
|
"extreme_nos",
|
|
|
|
"extreme_slx",
|
|
|
|
"extreme_vdx",
|
|
|
|
"extreme_vsp",
|
|
|
|
"extreme_wing",
|
|
|
|
"f5_ltm",
|
|
|
|
"f5_tmsh",
|
|
|
|
"f5_linux",
|
|
|
|
"fortinet",
|
|
|
|
"generic_termserver",
|
|
|
|
"hp_comware",
|
|
|
|
"hp_procurve",
|
|
|
|
"huawei",
|
|
|
|
"huawei_vrpv8",
|
|
|
|
"ipinfusion_ocnos",
|
|
|
|
"juniper",
|
|
|
|
"juniper_junos",
|
|
|
|
"linux",
|
|
|
|
"mellanox",
|
|
|
|
"mrv_optiswitch",
|
|
|
|
"netapp_cdot",
|
|
|
|
"netscaler",
|
|
|
|
"ovs_linux",
|
|
|
|
"paloalto_panos",
|
|
|
|
"pluribus",
|
|
|
|
"quanta_mesh",
|
|
|
|
"rad_etx",
|
|
|
|
"ruckus_fastiron",
|
|
|
|
"ubiquiti_edge",
|
|
|
|
"ubiquiti_edgeswitch",
|
|
|
|
"vyatta_vyos",
|
|
|
|
"vyos",
|
|
|
|
"oneaccess_oneos",
|
|
|
|
)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def is_supported(nos):
|
|
|
|
"""
|
|
|
|
Returns boolean state of input Network Operating System against
|
|
|
|
rest OR scrape tuples.
|
|
|
|
"""
|
2019-07-07 22:38:46 -07:00
|
|
|
return bool(nos in Supported.rest + Supported.scrape)
|
2019-07-07 02:49:54 -07:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def is_scrape(nos):
|
|
|
|
"""
|
|
|
|
Returns boolean state of input Network Operating System against
|
|
|
|
scrape tuple.
|
|
|
|
"""
|
|
|
|
return bool(nos in Supported.scrape)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def is_rest(nos):
|
|
|
|
"""
|
|
|
|
Returns boolean state of input Network Operating System against
|
|
|
|
rest tuple.
|
|
|
|
"""
|
|
|
|
return bool(nos in Supported.rest)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def is_supported_query(query_type):
|
|
|
|
"""
|
|
|
|
Returns boolean state of input Network Operating System against
|
|
|
|
query_type tuple.
|
|
|
|
"""
|
|
|
|
return bool(query_type in Supported.query_types)
|
2019-07-15 02:30:42 -07:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def map_transport(nos):
|
|
|
|
"""
|
|
|
|
Returns "scrape" if input nos is in Supported.scrape tuple, or
|
|
|
|
"rest" if input nos is in Supported.rest tuple.
|
|
|
|
"""
|
|
|
|
transport = None
|
|
|
|
if nos in Supported.scrape:
|
|
|
|
transport = "scrape"
|
|
|
|
elif nos in Supported.rest:
|
|
|
|
transport = "rest"
|
|
|
|
return transport
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def map_rest(nos):
|
|
|
|
uri_map = {"frr": "frr", "bird": "bird"}
|
|
|
|
return uri_map.get(nos)
|