configuration
switchmap classes that manage various configurations.
ConfigDashboard Objects
class ConfigDashboard(ConfigAPIClient, ConfigAPI)
Class gathers all configuration information.
__init__
def __init__()
Intialize the class.
Arguments:
None
Returns:
None
api_bind_port
def api_bind_port()
Get api_bind_port.
Arguments:
None
Returns:
result- result
username
def username()
Get username.
Arguments:
None
Returns:
result- result
uri
switchmap dashboard URIs.
dashboard
def dashboard()
Create the dashboard page URI.
Arguments:
None
Returns:
result- result
historical_dashboard
def historical_dashboard(idx_root=1)
Create the dashboard page URI.
Arguments:
idx_root- Root index
Returns:
result- result
devices
def devices(idx_device)
Create the device page URI.
Arguments:
idx_device- IDX of the device in the database
Returns:
result- result
events
def events()
Create the event page URI.
Arguments:
None
Returns:
result- result
events_by_idx_root
def events_by_idx_root(idx_root=1)
Create the filtered event page URI.
Arguments:
idx_root- Index of the root in the DB
Returns:
result- result
search_dashboard_server
def search_dashboard_server()
Create the device page URI.
Arguments:
None
Returns:
result- result
search_api_server
def search_api_server()
Create the device page URI.
Arguments:
None
Returns:
result- result
graphql_filters
switchmap GraphQL filter operators.
or_operator
def or_operator(key, items)
Create a GraphQL filter string for OR operations.
Arguments:
key- GraphQL key to run the OR operation againstitems- List of iitems for filtering
Returns:
result- result
__init__
Module of switchmap DASHBOARD routes.
Contains all routes that switchmap.s Flask webserver uses
inject
@DASHBOARD.context_processor
def inject()
Inject global variables for use by templates.
Arguments:
None
Returns:
result- Dict of url_home and url_static values for Flask to porcess
data
Define the switchmap.dashboard.data package.
Arguments:
None
Returns:
None
data.interface
Module for parsing interface data from GraphQL JSON.
Interface Objects
class Interface()
Class to create an InterfaceDataRow data.
__init__
def __init__(interface)
Instantiate the class.
Arguments:
interface- Interface dict
Returns:
None
row
def row()
Get Row data.
Arguments:
None
Returns:
result- InterfaceDataRow object
cdp
def cdp()
Return port CDP HTML string.
Arguments:
None
Returns:
value- required string
duplex
def duplex()
Return port duplex string.
Arguments:
None
Returns:
duplex- Duplex string
lldp
def lldp()
Return port LLDP HTML string.
Arguments:
None
Returns:
value- required string
speed
def speed()
Return port speed.
Arguments:
None
Returns:
result- Port speed
state
def state()
Return InterfaceState object.
Arguments:
None
Returns:
state- InterfaceState object
ts_idle
def ts_idle()
Return idle time.
Arguments:
None
Returns:
result- idle time
vlan
def vlan()
Return VLAN number.
Arguments:
None
Returns:
result- VlanState object
data.mac
Module for parsing Mac address related data from GraphQL JSON.
Mac Objects
class Mac()
Class to create an InterfaceDataRow data.
__init__
def __init__(interface)
Instantiate the class.
Arguments:
interface- Interface dict
Returns:
None
macs
def macs()
Get the MacState of the interface.
Arguments:
None
Returns:
result- List of MacState objects
ips
def ips()
Get the IpState of the interface.
Arguments:
None
Returns:
result- List of IpState objects
macips
def macips()
Get the MacIpState of the interface.
Arguments:
None
Returns:
result- List of MacIpState objects
macips
def macips(interface)
Get the MacIpState of the interface.
Arguments:
interface- IDX of the interface in the DB
Returns:
result- List of MacIpState objects
data.system
Class for creating device web pages.
System Objects
class System()
Class that creates the data to be presented for the device's ports.
__init__
def __init__(system_data)
Instantiate the class.
Arguments:
system_data- Dictionary of system data
Returns:
None
rows
def rows()
Return data for the device's system information.
Arguments:
None
Returns:
rows- List of Col objects
hostname
def hostname()
Return hostname.
Arguments:
None
Returns:
result- hostname
last_polled
def last_polled()
Return last_polled.
Arguments:
None
Returns:
result- last_polled
sysdescription
def sysdescription()
Return sysdescription.
Arguments:
None
Returns:
result- sysdescription
sysname
def sysname()
Return sysname.
Arguments:
None
Returns:
result- sysname
sysobjectid
def sysobjectid()
Return sysobjectid.
Arguments:
None
Returns:
result- sysobjectid
sysuptime
def sysuptime()
Return sysuptime.
Arguments:
None
Returns:
result- sysuptime
net
Define the switchmap.dashboard.net package.
Arguments:
None
Returns:
None
net.routes.pages.search
Module of switchmap.webserver routes.
Contains all routes that switchmap.s Flask webserver uses
search
@SEARCH.route("/search", methods=["POST"])
def search()
Create the search page.
Arguments:
None
Returns:
render_template- HTML
get_tables
def get_tables(_interfaces)
Convert interface information to HTML.
Arguments:
_interfaces- List of interface data dicts
Returns:
result- HTML
net.routes.pages.events
Module of switchmap.webserver routes.
Contains all routes that switchmap.s Flask webserver uses
events
@EVENT.route("/events")
def events()
Create the events page.
Arguments:
None
Returns:
render_template- HTML
net.routes.pages.devices
Module of switchmap.webserver routes.
Contains all routes that switchmap.s Flask webserver uses
devices
@DEVICES.route("/devices/<int:idx_device>")
def devices(idx_device)
Crerate device tables.
Arguments:
idx_device- Device index
Returns:
render_template- HTML
net.routes.pages
Define the switchmap.dashboard.net.routes.pages package.
Arguments:
None
Returns:
None
net.routes.pages.index
Module of switchmap.webserver routes.
Contains all routes that switchmap.s Flask webserver uses
dashboard
@INDEX.route("/")
def dashboard()
Create the dashboard home page.
Arguments:
None
Returns:
_dashboard- HTML via function
historical_dashboard
@INDEX.route("/<int:idx_root>")
def historical_dashboard(idx_root)
Create the dashboard home page for a specific event index.
Arguments:
idx_root- Event index
Returns:
_dashboard- HTML via function
net.routes
Define the switchmap.dashboard.net.routes package.
Arguments:
None
Returns:
None
net.routes.api.api
Module of switchmap.webserver routes.
Contains all routes that switchmap.s Flask webserver uses
dashboard
@API.route("/dashboard", methods=["GET"])
def dashboard()
Get dashboard data.
Arguments:
None
Returns:
html- Webpage HTML
historical_dashboard
@API.route("/dashboard/<int:idx_root>", methods=["GET"])
def historical_dashboard(idx_root)
Get dashboard data.
Arguments:
idx_root- IDX of the root in the DB
Returns:
html- Webpage HTML
event_by_idx_root
@API.route("/events/<int:idx_root>", methods=["GET"])
def event_by_idx_root(idx_root)
Get event data.
Arguments:
idx_root- IDX of the root in the DB
Returns:
result- JSON of zone data
events
@API.route("/events", methods=["GET"])
def events()
Get event data.
Arguments:
None
Returns:
result- JSON of zone data
devices
@API.route("/devices/<int:idx_device>", methods=["GET"])
def devices(idx_device)
Get device data.
Arguments:
idx_device- IDX of the DB device table
Returns:
result- JSON of zone data
search
@API.route("/search", methods=["POST"])
def search()
Get device data.
Arguments:
None
Returns:
result- JSON of zone data
roots_filter
def roots_filter(idx_root=False)
Get event data.
Arguments:
idx_root- IDX of the DB root
Returns:
roots- JSON of zone data
net.routes.api
Define the switchmap.dashboard.net.routes.api package.
Arguments:
None
Returns:
None
net.html.pages.device
Class for creating device web pages.
Device Objects
class Device()
Class that creates the device's various HTML tables.
__init__
def __init__(data)
Initialize the class.
Arguments:
data- Device dictionary
Returns:
None
hostname
def hostname()
Get the system hostname.
Arguments:
None
Returns:
result- The system hostname
interfaces
def interfaces()
Create the ports table for the device.
Arguments:
None
Returns:
html- HTML table string
system
def system()
Create summary table for the devie.
Arguments:
None
Returns:
html- HTML table string
net.html.pages.search
Class for creating search web pages.
SearchPage Objects
class SearchPage()
Class that creates the search's various HTML tables.
__init__
def __init__(data, hostname=None)
Initialize the class.
Arguments:
data- Search dictionaryhostname- The name of the Device
Returns:
None
html
def html()
Create the ports table for the search.
Arguments:
None
Returns:
html- HTML table string
net.html.pages.events
Class for creating home web pages.
EventPage Objects
class EventPage()
Class that creates the homepages's various HTML tables.
__init__
def __init__(_events)
Initialize the class.
Arguments:
_events- Events to process
Returns:
None
html
def html()
Create HTML table for the events.
Arguments:
None
Returns:
result- HTML table string
net.html.pages.layouts
Module of page layout functions.
table_wrapper
def table_wrapper(title, table, strip=True)
Wrap the data in HTML stuff.
Arguments:
title- titletable- Table HTMLstrip- Strip the thead if True
Returns:
result- HTML
remove_thead
def remove_thead(data)
Remove line in HTML code containing the 'thead'.
Arguments:
data- HTML code
Returns:
result- HTML
net.html.pages
Define the switchmap.dashboard.net.html.pages package.
Arguments:
None
Returns:
None
net.html.pages.index
Class for creating home web pages.
IndexPage Objects
class IndexPage()
Class that creates the homepages's various HTML tables.
__init__
def __init__(zones)
Initialize the class.
Arguments:
zones- List of zones
Returns:
None
html
def html()
Create HTML table for the devices.
Arguments:
None
Returns:
result- HTML table string
net.html
Define the switchmap.dashboard.net.html package.
Arguments:
None
Returns:
None
table
Define the switchmap.dashboard.table package.
Arguments:
None
Returns:
None
table.device
Class for creating device web pages.
Device Objects
class Device()
Class that creates the device's various HTML tables.
__init__
def __init__(data)
Initialize the class.
Arguments:
data- Device dictionary
Returns:
None
interfaces
def interfaces()
Create the ports table for the device.
Arguments:
None
Returns:
table- Interface table
system
def system()
Create summary table for the devie.
Arguments:
None
Returns:
table- System table
table.search
Class for creating search web pages.
Search Objects
class Search()
Class that creates the search's various HTML tables.
__init__
def __init__(data)
Initialize the class.
Arguments:
data- Search dictionary
Returns:
None
interfaces
def interfaces()
Create the ports table for the search.
Arguments:
None
Returns:
table- Interface table
table.interfaces
Class for creating device web pages.
_RawCol Objects
class _RawCol(Col)
Class outputs whatever it is given and will not escape it.
td_format
def td_format(content)
Format the column content without escaping.
Arguments:
content- The content to be displayed in the column
Returns:
content- The unmodified content
InterfaceTable Objects
class InterfaceTable(Table)
Declaration of the columns in the Ports table.
get_tr_attrs
def get_tr_attrs(item)
Apply CSS class attributes to regular table row.
Arguments:
item- Row data object containing interface information
Returns:
dict- CSS class mapping based on interface state
InterfaceRow Objects
class InterfaceRow()
Declaration of the rows in the Interfaces table.
__init__
def __init__(row)
Initialize the class.
Arguments:
row- List of row valuesport- Interface name stringvlan- VLAN of port stringstate- State of port stringdays_inactive- Number of days the port's inactive stringspeed- Speed of port stringduplex- Duplex of port stringlabel- Label given to the port by the network managertrunk- Whether a trunk or notcdp- CDP data stringlldp- LLDP data stringmac_address- MAC Addressorganization- Name of the organization
Returns:
None
active
def active()
Determine if the interface is active.
Arguments:
None
Returns:
bool- True if interface state is 'Active', False otherwise
enabled
def enabled()
Determine if the interface is enabled.
Arguments:
None
Returns:
bool- True if interface state is not 'Disabled', False otherwise boolean value of state if is not Disabled.
table
def table(_interfaces)
Get Interface data from the device.
Arguments:
_interfaces- Interface dict
Returns:
table- InterfaceTable object
table.events
Class for creating home web pages.
_RawCol Objects
class _RawCol(Col)
Class outputs whatever it is given and will not escape it.
Extends the Col class to provide raw HTML output without escaping.
td_format
def td_format(content)
Format the column content without escaping.
Arguments:
content- The content to be displayed in the column
Returns:
content- The unmodified content
EventTable Objects
class EventTable(Table)
Declaration of the columns in the Events table.
EventsRow Objects
class EventsRow()
Declaration of the rows in the Events table.
__init__
def __init__(row_data)
Initialize the class.
Arguments:
row_data- List containing the data for each column in the row
Returns:
None
table
def table(events)
Return data for the event's information.
Creates a formatted table object from a list of events.
Arguments:
events- List of EventMeta objects
Returns:
result- EventTable object or False if no valid rows
table.system
Class for creating device web pages.
_RawCol Objects
class _RawCol(Col)
Class outputs whatever it is given and will not escape it.
td_format
def td_format(content)
Format the column content without escaping.
Arguments:
content- The content to be displayed in the column
Returns:
content- The unmodified content
SystemTable Objects
class SystemTable(Table)
Declaration of the columns in the Systems table.
SystemRow Objects
class SystemRow()
Declaration of the rows in the Systems table.
__init__
def __init__(row)
Initialize the class.
Arguments:
row- SystemDataRow object containing parameter and value
Returns:
None
table
def table(data)
Create summary table for the devie.
Arguments:
data- Dictionary containing system information data
Returns:
html- HTML table string or None if no rows are present
table.index
Class for creating home web pages.
_RawCol Objects
class _RawCol(Col)
Class outputs whatever it is given and will not escape it.
td_format
def td_format(content)
Fix the column formatting.
Arguments:
content- Content to parse
Returns:
content- Content to parse
tables
def tables(zones)
Create HTML table for the devices.
Arguments:
zones- List of Zones
Returns:
results- List of ZoneTable objects
ZoneTable Objects
class ZoneTable(Table)
Declaration of the columns in the Devices table.
ZoneRow Objects
class ZoneRow()
Declaration of the rows in the Devices table.
__init__
def __init__(row_data)
Initialize the class.
Arguments:
row_data- Row data
Returns:
None
rows
def rows(devices)
Return data for the device's system information.
Arguments:
devices- List of DeviceMeta objects
Returns:
rows- List of Col objects