From d2ca67127dba881a0cf950d7e795bebe13646f3a Mon Sep 17 00:00:00 2001 From: Katerina Kubecova Date: Thu, 16 Nov 2023 12:56:14 +0100 Subject: [PATCH] added yang & json show_protocols and show_protocols_all --- yang/show_protocols.json | 11 + yang/show_protocols.yang | 40 +++ yang/show_protocols_all.json | 165 ++++++++++++ yang/show_protocols_all.yang | 482 +++++++++++++++++++++++++++++++++++ 4 files changed, 698 insertions(+) create mode 100644 yang/show_protocols.json create mode 100644 yang/show_protocols.yang create mode 100644 yang/show_protocols_all.json create mode 100644 yang/show_protocols_all.yang diff --git a/yang/show_protocols.json b/yang/show_protocols.json new file mode 100644 index 00000000..bc6e9631 --- /dev/null +++ b/yang/show_protocols.json @@ -0,0 +1,11 @@ +{ + "show_protocols:message": { + "table": [ + {"name": "device1", "proto": "Device", "table": "---", "state": 1, "since": "2020-10-10T10:10:10+00:00", "info": "" }, + {"name": "kernel4", "proto": "Kernel", "table": "master4", "state": 1, "since": "2020-10-10T10:10:10+00:00", "info": "" }, + {"name": "ospf4", "proto": "OSPF", "table": "master4", "state": 1, "since": "2020-10-10T10:10:10+00:00", "info": "Running" }, + {"name": "ebgp4_1", "proto": "BGP", "table": "---", "state": 1, "since": "2020-10-10T10:10:10+00:00", "info": "Established" } + ] + } +} + diff --git a/yang/show_protocols.yang b/yang/show_protocols.yang new file mode 100644 index 00000000..96fcfc13 --- /dev/null +++ b/yang/show_protocols.yang @@ -0,0 +1,40 @@ +module show_protocols { + + namespace "."; + + prefix "protocols"; + + description "cli show protocols format"; + + typedef date-and-time { + type string { + pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?' + + '(Z|[\+\-]\d{2}:\d{2})'; + } + } + + container message { + list table { + key "name"; + leaf name { + type string; + } + leaf proto { + type string; + } + leaf table { + type string; + } + leaf state { + type int8; + } + leaf since { + type date-and-time; + } + leaf info { + type string; + } + } + } +} + diff --git a/yang/show_protocols_all.json b/yang/show_protocols_all.json new file mode 100644 index 00000000..722caaea --- /dev/null +++ b/yang/show_protocols_all.json @@ -0,0 +1,165 @@ +{ + "show_protocols_all:message": { + "table": [ + {"name": "device1", "proto": "Device", "table": "---", "state": "up", "since": "2020-10-10T10:10:10+00:00"}, + {"name": "kernel4", "proto": "Kernel", "table": "master4", "state": "up", "since": "2020-10-10T10:10:10+00:00", + "channels": [ + { + "name": "ipv4", + "state": "up", + "table": "master4", + "preference": 10, + "input_filter": "ACCEPT", + "output_filter": "(unnamed)", + "channel_show_stats": { + "routes": { + "imported": 0, + "exported": 12, + "preferred": 0 + }, + "route_stats": { + "import_updates": {"received": 0, "rejected": 0, "filtered": 0, "ignored": 0, "accepted": 0}, + "import_withdraws": {"received": 0, "rejected": 0, "ignored": 0, "accepted": 0}, + "export_updates": {"received": 828, "rejected": 816, "filtered": 0, "accepted": 12}, + "export_withdraws": {"received": 197, "accepted": 0} + } + } + } + ] + }, + {"name": "ebgp4_1", "proto": "BGP", "table": "---", "state": "up", "since": "2020-10-10T10:10:10+00:00", "info": "Established", + "bgp": { + "bgp_status":"established", + "neighbor_range": "10.255.253.250", + "neighbor_as": 8496, + "local_as": 92449, + "neighbour_id": "10.255.255.5", + "local_capabilities": { + "any_mp_bgp": { + "multiprotocol": [null], + "af_announced": {"afl1": "ipv4", "afn1": ""} + }, + "route_refresh": [null], + "graceful_restart": [null], + "as4_support": [null], + "enhanced_refresh": [null], + "long_lived_gr_restart": [null] + }, + "neighbour_capabilities": { + "any_mp_bgp": { + "multiprotocol": [null], + "af_announced": {"afl1": "ipv4", "afn1": ""} + }, + "route_refresh": [null], + "graceful_restart": [null], + "as4_support": [null], + "enhanced_refresh": [null], + "long_lived_gr_restart": [null] + }, + "session": { + "in_ex_ternal": "external", + "route_server": [null], + "as4": [null] + }, + "source_address": "10.255.253.250", + "hold_timer": { + "remains": "132.432", + "count_time": 240 + }, + "keepalive_timer": { + "remains": "39.890", + "count_time": 80 + }, + "bgp_next_hop": "10.255.253.250" + }, + "channels": [ + { + "name": "ipv4", + "state": "up", + "table": "master4", + "preference": 100, + "input_filter": "bgp_import", + "output_filter": "(unnamed)", + "channel_show_stats": { + "routes": { + "imported": 68, + "exported": 203, + "preferred": 16 + }, + "route_stats": { + "import_updates": {"received": 249, "rejected": 0, "filtered": 56, "ignored": 68, "accepted": 124}, + "import_withdraws": {"received": 0, "rejected": 0, "ignored": 0, "accepted": 54}, + "export_updates": {"received": 828, "rejected": 122, "filtered": 12, "accepted": 704}, + "export_withdraws": {"received": 179, "accepted": 201} + } + } + } + ] + }, + {"name": "rpki_66", "proto": "RPKI", "table": "---", "state": "up", "since": "2020-10-10T10:10:10+00:00", "info": "Established", + "rpki": { + "cache_server": "10.255.66.2", + "cache_port": 8282, + "status": "established", + "transport": "unprotected over TCP", + "protocol_version": 2, + "session_id": 64442, + "serial_num": 6, + "last_update": "99.230", + "refresh_timer": { + "remains": "3500.789", + "count_time": 3600 + }, + "expire_timer": { + "remains": "7100.783", + "count_time": 7200 + } + }, + "channels": [ + { + "name": "ro4", + "state": "up", + "table": "rt4", + "preference": 100, + "input_filter": "ACCEPT", + "output_filter": "REJECT", + "channel_show_stats": { + "routes": { + "imported": 10, + "exported": 0, + "preferred": 10 + }, + "route_stats": { + "import_updates": {"received": 10, "rejected": 0, "filtered": 0, "ignored": 0, "accepted": 10}, + "import_withdraws": {"received": 0, "rejected": 0, "ignored": 0, "accepted": 0}, + "export_updates": {"received": 0, "rejected": 0, "filtered": 0, "accepted": 0}, + "export_withdraws": {"received": 0, "accepted": 0} + } + } + }, + { + "name": "ro6", + "state": "up", + "table": "rt6", + "preference": 100, + "input_filter": "ACCEPT", + "output_filter": "REJECT", + "channel_show_stats": { + "routes": { + "imported": 0, + "exported": 0, + "preferred": 0 + }, + "route_stats": { + "import_updates": {"received": 0, "rejected": 0, "filtered": 0, "ignored": 0, "accepted": 10}, + "import_withdraws": {"received": 0, "rejected": 0, "ignored": 0, "accepted": 0}, + "export_updates": {"received": 0, "rejected": 0, "filtered": 0, "accepted": 0}, + "export_withdraws": {"received": 0, "accepted": 0} + } + } + } + ] + } + ] + } +} diff --git a/yang/show_protocols_all.yang b/yang/show_protocols_all.yang new file mode 100644 index 00000000..4655bd6e --- /dev/null +++ b/yang/show_protocols_all.yang @@ -0,0 +1,482 @@ +module show_protocols_all { + + namespace "."; + + prefix "protocols_all"; + + description "cli show protocols all format"; + + typedef date-and-time { + type string { + pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?' + + '(Z|[\+\-]\d{2}:\d{2})'; + } + } + + + typedef ip-address { + type union { + type ipv4-address; + type ipv6-address; + } + } + + typedef ipv4-address { + type string { + pattern + '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' + + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])' + + '(%[\p{N}\p{L}]+)?'; + } + } + + typedef ipv6-address { + type string { + pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' + + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' + + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}' + + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))' + + '(%[\p{N}\p{L}]+)?'; + pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' + + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)' + + '(%.+)?'; + } + } + + typedef status { + type enumeration { + enum idle; + enum connect; + enum active; + enum openSent; + enum openConfirm; + enum established; + enum close; + } + } + + typedef state { + type enumeration { + enum up; + enum down; + } + } + + grouping afis { + leaf afl1 { + type string; + } + leaf afn1 { + type string; + } + } + + grouping timer { + leaf remains { + type decimal64 { + fraction-digits 3; + } + } + leaf count_time { + type uint32; + } + } + + grouping limits { + leaf dsc { + type string; + } + leaf limit { + type int32; + } + leaf hit { + type empty; + } + leaf action { + type string; + } + } + + grouping bgp_capabilities { + container any_mp_bgp { + leaf multiprotocol { + type empty; + } + container af_announced { + uses afis; + } + } + leaf route_refresh { + type empty; + } + container any_ext_nexthop { + leaf extended_nexthop { + type empty; + } + container nexthop { + uses afis; + } + } + leaf extended_message { + type empty; + } + leaf graceful_restart { + type empty; + } + container is_gr_able { + leaf restart_time { + type uint32; + } + leaf restart_recovery { + type empty; + } + container af_supported { + uses afis; + } + container af_preserved { + uses afis; + } + } + leaf as4_support { + type empty; + } + container is_add_path { + leaf add_path { + type empty; + } + container af_rx { + uses afis; + } + container af_tx { + uses afis; + } + } + leaf enhanced_refresh { + type empty; + } + leaf long_lived_gr_restart { + type empty; + } + container is_llgr_able { + leaf stale_time { + type uint32; + } + container af_supported { + uses afis; + } + container af_preserved { + uses afis; + } + } + leaf hostname { + type string; + } + leaf role { + type string; + } + } + + grouping bgp_details { + leaf bgp_status { + type status; + } + choice is_dynamic { + case dynamic { + leaf neighbor_range { + type ip-address; + } + } + case nondinamic { + leaf neighbor_address { + type ip-address; + } + } + } + leaf port_num { + type int16; + } + leaf neighbor_as { + type int32; + } + leaf local_as { + type int32; + } + leaf neighbor_gr_restarting { + type empty; + } + choice proto_state { + mandatory false; + case start_state { + container error_wait { + leaf remains { + type date-and-time; + } + leaf delay { + type uint32; + } + } + container bs_active { + leaf remains { + type date-and-time; + } + leaf delay { + type uint32; + } + } + container restart { + leaf restart_timer{ + type date-and-time; + } + } + } + case up { + leaf neighbour_id { + type string; + } + container local_capabilities { + uses bgp_capabilities; + } + container neighbour_capabilities { + uses bgp_capabilities; + } + container session { + leaf in_ex_ternal { + type enumeration { + enum internal; + enum external; + } + } + leaf multihop { + type empty; + } + leaf route_reflector { + type empty; + } + leaf route_server { + type empty; + } + leaf as4 { + type empty; + } + } + leaf source_address { + type ip-address; + } + container hold_timer { + uses timer; + } + container keepalive_timer { + uses timer; + } + container last_error { + leaf err1 { + type string; + } + leaf err2 { + type string; + } + } + list bgp_channels { + key neighbor_gr; + leaf neighbor_gr { + type string; + } + leaf ll_stale_timer { + type date-and-time; + } + container ipa_zero { + leaf next_hop_addr { + type ip-address; + } + leaf link_addr { + type ip-address; + } + } + leaf ipv4_table { + type string; + } + leaf ipv6_table { + type string; + } + leaf base_table { + type string; + } + } + } + } + leaf bgp_next_hop { + type ip-address; + } + } + + grouping rpki_details { + leaf cache_server { + type string; + } + leaf cache_port { + type uint32; + } + leaf status { + type status; + } + leaf transport { + type string; + } + leaf protocol_version { + type uint32; + } + leaf session_id { + type uint32; + } + leaf serial_num { + type uint32; + } + leaf last_update { + type decimal64 { + fraction-digits 3; + } + } + container refresh_timer { + uses timer; + } + container retry_timer { + uses timer; + } + container expire_timer { + uses timer; + } + leaf no_roa4_channel { + type empty; + } + leaf no_roa6_channel { + type empty; + } + } + + grouping stats_line { + leaf received { + type int32; + } + leaf rejected { + type int32; + } + leaf filtered { + type int32; + } + leaf ignored { + type int32; + } + leaf accepted { + type int32; + } + } + + container message { + list table { + key "name"; + leaf name { + type string; + } + leaf proto { + type string; + } + leaf table { + type string; + } + leaf state { + type state; + } + leaf since { + type date-and-time; + } + leaf info { + type string; + } + + choice details { + mandatory false; + + case bgp { + container bgp { + uses bgp_details; + } + } + case rpki { + container rpki { + uses rpki_details; + } + } + case todo_does_anything_else_exist {} + } + list channels { + key name; + leaf name { + type string; + } + leaf state { + type state; + } + leaf table { + type string; + } + leaf preference { + type int32; + } + leaf input_filter { + type string; + } + leaf output_filter { + type string; + } + container gr_restart { + leaf pending { + type empty; + } + leaf waiting { + type empty; + } + } + container receive_limit { + uses limits; + } + container import_limit { + uses limits; + } + container export_limit { + uses limits; + } + container channel_show_stats { + container routes { + leaf imported { + type uint32; + } + leaf filtered { + type uint32; + } + leaf exported { + type uint32; + } + leaf preferred { + type uint32; + } + } + container route_stats { + container import_updates { + uses stats_line; + } + container import_withdraws { + uses stats_line; + } + container export_updates { + uses stats_line; + } + container export_withdraws { + uses stats_line; + } + } + } + } + } + } +} +