Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"interface-information": {
"physical-interface": {
Optional("description"): str,
"local-index": str,
"snmp-index": str,
"name": str,
"oper-status": str,
"queue-counters": {
"interface-cos-summary": {
"intf-cos-forwarding-classes-in-use": str,
"intf-cos-forwarding-classes-supported": str,
"intf-cos-num-queues-in-use": str,
"intf-cos-num-queues-supported": str,
"intf-cos-queue-type": str
},
"queue": Use(validate_queue)
}
}
}
}
# =======================================================
# Parser for 'show interfaces queue {interface}'
# =======================================================
class ShowInterfacesQueue(ShowInterfacesQueueSchema):
"""
Parser for:
* show interfaces queue {interface}
"""
cli_command = 'show interfaces queue {interface}'
"via": str,
Optional("weight"): str
})
# Validate each dictionary in list
for item in value:
nh_schema.validate(item)
return value
protocol_nh_schema = Schema({
Optional("@junos:indent"): str,
Optional("forwarding-nh-count"): str,
"indirect-nh": str,
Optional("label-ttl-action"): str,
Optional("load-balance-label"): str,
Optional("metric"): str,
Optional("mpls-label"): str,
Optional("nh"): Use(validate_nh_list),
Optional("nh-index"): str,
Optional("nh-type"): str,
Optional("output"): str,
"to": str
})
# Validate each dictionary in list
for item in value:
protocol_nh_schema.validate(item)
return value
rt_entry_schema = Schema({
Optional("rt-destination"): str,
"rt-entry": {
Optional("active-tag"): str,
"age": {
"#text": str,
Optional("@junos:seconds"): str
},
Optional('as-path'): str,
Optional("current-active"): str,
Optional("last-active"): str,
Optional("learned-from"): str,
Optional("local-preference"): str,
Optional("med"): str,
Optional("metric"): str,
Optional("metric2"): str,
Optional("nh"): Use(validate_nh_list),
Optional('nh-type'): str,
"preference": str,
Optional("preference2"): str,
"protocol-name": str,
Optional('rt-tag'): str,
Optional("validation-state"): str
}
})
# Validate each dictionary in list
for item in value:
rt_schema.validate(item)
return value
def validate_chassis_hardware_extensive_list(value):
# Pass firmware list as value
if not isinstance(value, list):
raise SchemaTypeError('chassis module is not a list')
chassis_hardware_detail_schema = Schema({
Optional("chassis-re-disk-module"): {
"description": str,
"disk-size": str,
"model": str,
"name": str,
"serial-number": str
},
Optional("chassis-sub-module"): Use(ShowChassisHardwareExtensive.validate_inner_chassis_hardware_detail_list),
Optional("description"): str,
Optional("i2c-information"): {
"assembly-flags": str,
"assembly-identifier": str,
"assembly-version": str,
"board-information-record": str,
"eeprom-version": str,
Optional("i2c-data"): list,
Optional("i2c-identifier"): Or(str, None),
"i2c-version": Or(str, None),
"jedec-code": str,
"manufacture-date": str,
"part-number": Or(str, None),
Optional("serial-number"): Or(str,None)
},
"name": str,
Optional("alarm-not-present"): bool,
},
},
Optional("interface-transmit-statistics"): str,
Optional("logical-interface"): Use(validate_logical_interface_list)
}
)
for item in value:
physical_interface_schema.validate(item)
return value
schema = {
"interface-information": {
"physical-interface": Use(validate_physical_interface_list)
}
}
class ShowInterfacesStatistics(ShowInterfacesStatisticsSchema):
""" Parser for:
* show interfaces statistics
* show interfaces statistics {interface}
"""
cli_command = [
"show interfaces statistics",
"show interfaces statistics {interface}"
]
def cli(self, interface=None, output=None):
"ospf3-prefix-options": list,
},
Optional("ospf3-router-lsa"): {
Optional("bits"):
str,
Optional("ospf3-options"):
str,
Optional("ospf3-link"):
Use(ShowOspf3DatabaseExtensive.validate_ospf3_link_list),
Optional("ospf3-lsa-topology"): {
"ospf-topology-id":
str,
"ospf-topology-name":
str,
"ospf3-lsa-topology-link":
Use(ShowOspf3DatabaseExtensive.
validate_ospf3_lsa_topology_link_list),
},
},
Optional("ospf3-link-lsa"): {
"linklocal-address": str,
"ospf3-options": str,
Optional("ospf3-prefix"): str,
Optional("ospf3-prefix-options"): str,
"prefix-count": str,
"router-priority": str,
},
Optional("ospf3-external-lsa"): {
"metric": str,
"ospf3-prefix": str,
"ospf3-prefix-options": str,
"type-value": str,
instance_rib_schema.validate(item)
return value
def validate_interface_name_list(value):
if not isinstance(value, list):
raise SchemaTypeError('interface-name is not a list')
instance_rib_schema = Schema({
"interface-name": str
})
# Validate each dictionary in list
for item in value:
instance_rib_schema.validate(item)
return value
instance_core_schema = Schema({
Optional("instance-interface"): Use(validate_interface_name_list),
"instance-name": str,
Optional("instance-rib"): Use(validate_instance_rib_list),
Optional("instance-state"): str,
Optional("instance-type"): str,
Optional("router-id"): str
})
# Validate each dictionary in list
for item in value:
instance_core_schema.validate(item)
return value
"prefix-count": str,
"router-priority": str
},
Optional("our-entry"): bool,
"sequence-number": str
})
for item in value:
ospf3_database_schema.validate(item)
return value
schema = {
Optional("@xmlns:junos"): str,
"ospf3-database-information": {
Optional("@xmlns"): str,
"ospf3-database": Use(validate_ospf3_database_list),
"ospf3-intf-header": Use(validate_ospf3_intf_list)
}
}
class ShowOspf3DatabaseLinkAdvertisingRouter(
ShowOspf3DatabaseLinkAdvertisingRouterSchema):
""" Parser for:
* show ospf3 database link advertising-router {ipaddress} detail
"""
cli_command = 'show ospf3 database link advertising-router {ipaddress} detail'
def cli(self, ipaddress=None, output=None):
if not output:
if ipaddress:
cmd = self.cli_command.format(ipaddress=ipaddress)
else:
if not isinstance(value, list):
raise SchemaTypeError('route-table-summary is not a list')
# Create route-table-summary Schema
route_table_summary_schema = Schema({
"route-count": str,
"route-table-type": str
})
# Validate each dictionary in list
for item in value:
route_table_summary_schema.validate(item)
return value
# Create route-table-summary Schema
route_table_schema = Schema({
"address-family": str,
Optional("enabled-protocols"): str,
"route-table-summary": Use(validate_route_table_summary_list),
"table-name": str
})
# Validate each dictionary in list
for item in value:
route_table_schema.validate(item)
return value
if not isinstance(value, list):
raise SchemaTypeError('ospf-database-summary is not a list')
neighbor_schema = Schema({
Optional("@external-heading"): str,
Optional("ospf-area"): Or(list, str),
Optional("ospf-intf"): list,
Optional("ospf-lsa-count"): Or(list, str),
Optional("ospf-lsa-type"): Or(list, str)
})
for item in value:
neighbor_schema.validate(item)
return value
schema = {
'ospf-database-information': {
'ospf-database-summary': Use(validate_neighbor_database_summary_list)
}
}
'''
Parser for:
* show ospf database
'''
class ShowOspfDatabaseSummary(ShowOspfDatabaseSummarySchema):
cli_command = 'show ospf database summary'
def cli(self, output=None):
if not output:
out = self.device.execute(self.cli_command)
else:
out = output
ret_dict = {}