From 35cfeee96b8874800a5d3758b0b8e54a91b53873 Mon Sep 17 00:00:00 2001 From: Arturo Patino Date: Fri, 10 May 2024 10:05:52 -0600 Subject: [PATCH] Adding the following commands parsing StarOS ASR5500/VPC-SI/VPC-DI platforms: show session disconnect-reasons show active-charging charging-action all show active-charging credit-control statistics show active charing ruledef statistics all charging show alarm all show boot show bulkstats show card hardware show card table show cloud performance dinnet show cloud performance summary show config error verbose show context all show cpu table show crash list show diameter peers full show fans show hd raid verbose show ims-auth sessions summary show ip arp show ip route show license info show link-aggregation table show npu show ntp status show plugin p2p show port table show port utilization show power chassis show resources show service all show session counters historical all show session disconnect show session duration show session progress show session recovery status verbose show snmp communities show snmp notifies show snmp trap show subscribers summary show system uptime show task resources facility sessmgr all show temperature --- .../staros/show session disconnect-reasons.py | 111 +++ ...how_active-charging_charging-action_all.py | 260 ++++++ ...tive-charging_credit-control_statistics.py | 261 ++++++ ...charing_ruledef_statistics_all_charging.py | 405 +++++++++ .../libs/parser/staros/show_alarm_all.py | 203 +++++ src/genie/libs/parser/staros/show_boot.py | 84 ++ .../libs/parser/staros/show_bulkstats.py | 157 ++++ .../libs/parser/staros/show_card_hardware.py | 123 +++ .../libs/parser/staros/show_card_table.py | 80 ++ .../staros/show_cloud_performance_dinnet.py | 109 +++ .../staros/show_cloud_performance_summary.py | 192 +++++ .../staros/show_config_error_verbose.py | 726 ++++++++++++++++ .../libs/parser/staros/show_context_all.py | 70 ++ .../libs/parser/staros/show_cpu_table.py | 90 ++ .../libs/parser/staros/show_crash_list.py | 105 +++ .../parser/staros/show_diameter_peers_full.py | 298 +++++++ src/genie/libs/parser/staros/show_fans.py | 112 +++ .../parser/staros/show_hd_raid_verbose.py | 133 +++ .../staros/show_ims-auth_sessions_summary.py | 166 ++++ src/genie/libs/parser/staros/show_ip_arp.py | 78 ++ src/genie/libs/parser/staros/show_ip_route.py | 124 +++ .../libs/parser/staros/show_license_info.py | 361 ++++++++ .../staros/show_link-aggregation_table.py | 109 +++ src/genie/libs/parser/staros/show_npu.py | 105 +++ .../libs/parser/staros/show_ntp_status.py | 299 +++++++ .../libs/parser/staros/show_plugin_p2p.py | 72 ++ .../libs/parser/staros/show_port_table.py | 123 +++ .../parser/staros/show_port_utilization.py | 82 ++ .../libs/parser/staros/show_power_chassis.py | 52 ++ .../libs/parser/staros/show_resources.py | 93 ++ .../libs/parser/staros/show_service_all.py | 90 ++ .../show_session_counters_historical_all.py | 265 ++++++ .../parser/staros/show_session_disconnect.py | 101 +++ .../parser/staros/show_session_duration.py | 60 ++ .../parser/staros/show_session_progress.py | 805 ++++++++++++++++++ .../show_session_recovery_status_verbose.py | 88 ++ .../parser/staros/show_snmp_communities.py | 63 ++ .../libs/parser/staros/show_snmp_notifies.py | 281 ++++++ .../libs/parser/staros/show_snmp_trap.py | 77 ++ .../parser/staros/show_subscribers_summary.py | 123 +++ .../libs/parser/staros/show_system_uptime.py | 59 ++ ...how_task_resources_facility_sessmgr_all.py | 105 +++ .../libs/parser/staros/show_temperature.py | 75 ++ 43 files changed, 7375 insertions(+) create mode 100644 src/genie/libs/parser/staros/show session disconnect-reasons.py create mode 100644 src/genie/libs/parser/staros/show_active-charging_charging-action_all.py create mode 100644 src/genie/libs/parser/staros/show_active-charging_credit-control_statistics.py create mode 100644 src/genie/libs/parser/staros/show_active_charing_ruledef_statistics_all_charging.py create mode 100644 src/genie/libs/parser/staros/show_alarm_all.py create mode 100644 src/genie/libs/parser/staros/show_boot.py create mode 100644 src/genie/libs/parser/staros/show_bulkstats.py create mode 100644 src/genie/libs/parser/staros/show_card_hardware.py create mode 100644 src/genie/libs/parser/staros/show_card_table.py create mode 100644 src/genie/libs/parser/staros/show_cloud_performance_dinnet.py create mode 100644 src/genie/libs/parser/staros/show_cloud_performance_summary.py create mode 100644 src/genie/libs/parser/staros/show_config_error_verbose.py create mode 100644 src/genie/libs/parser/staros/show_context_all.py create mode 100644 src/genie/libs/parser/staros/show_cpu_table.py create mode 100644 src/genie/libs/parser/staros/show_crash_list.py create mode 100644 src/genie/libs/parser/staros/show_diameter_peers_full.py create mode 100644 src/genie/libs/parser/staros/show_fans.py create mode 100644 src/genie/libs/parser/staros/show_hd_raid_verbose.py create mode 100644 src/genie/libs/parser/staros/show_ims-auth_sessions_summary.py create mode 100644 src/genie/libs/parser/staros/show_ip_arp.py create mode 100644 src/genie/libs/parser/staros/show_ip_route.py create mode 100644 src/genie/libs/parser/staros/show_license_info.py create mode 100644 src/genie/libs/parser/staros/show_link-aggregation_table.py create mode 100644 src/genie/libs/parser/staros/show_npu.py create mode 100644 src/genie/libs/parser/staros/show_ntp_status.py create mode 100644 src/genie/libs/parser/staros/show_plugin_p2p.py create mode 100644 src/genie/libs/parser/staros/show_port_table.py create mode 100644 src/genie/libs/parser/staros/show_port_utilization.py create mode 100644 src/genie/libs/parser/staros/show_power_chassis.py create mode 100644 src/genie/libs/parser/staros/show_resources.py create mode 100644 src/genie/libs/parser/staros/show_service_all.py create mode 100644 src/genie/libs/parser/staros/show_session_counters_historical_all.py create mode 100644 src/genie/libs/parser/staros/show_session_disconnect.py create mode 100644 src/genie/libs/parser/staros/show_session_duration.py create mode 100644 src/genie/libs/parser/staros/show_session_progress.py create mode 100644 src/genie/libs/parser/staros/show_session_recovery_status_verbose.py create mode 100644 src/genie/libs/parser/staros/show_snmp_communities.py create mode 100644 src/genie/libs/parser/staros/show_snmp_notifies.py create mode 100644 src/genie/libs/parser/staros/show_snmp_trap.py create mode 100644 src/genie/libs/parser/staros/show_subscribers_summary.py create mode 100644 src/genie/libs/parser/staros/show_system_uptime.py create mode 100644 src/genie/libs/parser/staros/show_task_resources_facility_sessmgr_all.py create mode 100644 src/genie/libs/parser/staros/show_temperature.py diff --git a/src/genie/libs/parser/staros/show session disconnect-reasons.py b/src/genie/libs/parser/staros/show session disconnect-reasons.py new file mode 100644 index 0000000000..4a8bb2ca62 --- /dev/null +++ b/src/genie/libs/parser/staros/show session disconnect-reasons.py @@ -0,0 +1,111 @@ +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Schema + +class ShowSesDisReaSchema(MetaParser): + """Schema for show session disconnect-reasons""" + + schema = { + 'dis_rea_table': { + 'TOTAL_DISCONNECTS': str, + Any(): { + 'NUM_DISC': str, + 'PERCENTAGE': str, + }, + } + } + +class ShowSessionDiss(ShowSesDisReaSchema): + """Parser for show session disconnect-reasons""" + + cli_command = 'show session disconnect-reasons' + + """ +[local]COR-ASR5K-1# show session disconnect-reasons +Monday January 29 14:48:31 ART 2024 +Session Disconnect Statistics + +Total Disconnects: 12345249830 + +Disconnect Reason Num Disc Percentage +----------------------------------------------------- ---------- ---------- +Admin-disconnect 898190 0.00728 +Remote-disconnect 11802373713 95.60255 +Local-disconnect 3653063 0.02959 +Idle-Inactivity-timeout 414551522 3.35798 +Session-setup-timeout 384617 0.00312 +internal-error 2 0.00000 +path-failure 117515 0.00095 +Gtp-unknown-pdp-addr-or-pdp-type 28400654 0.23005 +static-ip-validation-failed 5 0.00000 +ggsn-aaa-auth-req-failed 2 0.00000 +Long-duration-timeout 11185805 0.09061 +failed-update-handoff 1212400 0.00982 +call-internal-reject 29 0.00000 +failed-auth-with-charging-svc 11891 0.00010 +ims-authorization-failed 779951 0.00632 +Auth-failed 24576425 0.19908 +Gtp-context-replacement 3179378 0.02575 +ims-authorization-revoked 5270 0.00004 +ims-auth-decision-invalid 1 0.00000 +dt-ggsn-tun-reestablish-failed 6064313 0.04912 +No-response 3459270 0.02802 +unknown-apn 2 0.00000 +gtpc-path-failure 343664 0.00278 +gtpu-path-failure 923654 0.00748 +disconnect-from-policy-server 10969 0.00009 +gtpu-err-ind 8389798 0.06796 +apn-denied-no-subscription 3 0.00000 +Sgw-context-replacement 3358732 0.02721 +ggsn-no-rsp-from-sgsn 10433802 0.08452 +invalid-qci 1 0.00000 +4Gto3G-context-replacement 615958 0.00499 +3Gto4G-context-replacement 10801712 0.08750 +Local-fallback-timeout 1 0.00000 +srvcc-ps-to-cs-handover 2 0.00000 +pgw-transaction-timeout 1 0.00000 +path-failure-s5 189532 0.00154 +path-failure-s11 570060 0.00462 +gtpu-path-failure-s5u 17299 0.00014 +gtpu-path-failure-s1u 1561 0.00001 +gtpu-err-ind-s5u 13387 0.00011 +disconnect-from-charging-server 8725676 0.07068 + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + session_dict = {} + result_dict = {} + + # initial regexp pattern + p0= re.compile(r'Total\s\Disconnects:(?P\s\d+)') + p1 = re.compile(r'((?P[\w\-*]+)\s+(?P\d+)\s+(?P\d+\.\d{5}))') + + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'dis_rea_table' not in session_dict: + result_dict = session_dict.setdefault('dis_rea_table',{}) + total_dis = m.groupdict()['total_disconnects_title'] + + result_dict['TOTAL_DISCONNECTS'] = total_dis + + m = p1.match(line) + if m: + if 'dis_rea_table' not in session_dict: + result_dict = session_dict.setdefault('dis_rea_table',{}) + disconnect = m.groupdict()['disconnect_reason'] + number_disconnected = m.groupdict()['num_disc'] + per = m.groupdict()['percentage'] + result_dict[disconnect] = {} + result_dict[disconnect]['NUM_DISC'] = number_disconnected + result_dict[disconnect]['PERCENTAGE'] = per + + return session_dict diff --git a/src/genie/libs/parser/staros/show_active-charging_charging-action_all.py b/src/genie/libs/parser/staros/show_active-charging_charging-action_all.py new file mode 100644 index 0000000000..c21a8e08b9 --- /dev/null +++ b/src/genie/libs/parser/staros/show_active-charging_charging-action_all.py @@ -0,0 +1,260 @@ +"""starOS implementation of show_active-charging_charging-action_all.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Optional + +class ShowActiveChargingSchema(MetaParser): + """Schema for show active-charging charging-action all""" + + schema = { + 'charging-action': { + Any():{ + Optional('Content ID'): int, + Optional('EGCDRs'): str, + Optional('Limit For Uplink Bandwidth'): str, + Optional('Peak Data Rate Uplink'): str, + Optional('Peak Burst Size Uplink'): str, + Optional('Limit For Downlink Bandwidth'): str, + Optional('Peak Data Rate Downlink'): str, + Optional('Peak Burst Size Downlink'): str, + Optional('Credit-Control'): str, + Optional('Xheader-Insert'): str, + Optional('Encryption Type'): str, + Optional('Encryption Key'): str, + Optional('Redirect URL'): str, + Optional('Discard'): str, + }, + } + } + + +class ShowActiveCharging(ShowActiveChargingSchema): + """Parser for show active-charging charging-action all""" + + cli_command = 'show active-charging charging-action all' + + """ + Charging Action Name: namecg + Content ID: 100 + Service ID: 0 + EDRs: Disabled + EGCDRs: Enabled + Rf: Disabled + UDRs: Enabled + Flow Idle Timeout: 300 (secs) + Limit For Flow Type: Disabled + Bandwidth ID: 0 + Limit For Uplink Bandwidth: Enabled + Peak Data Rate : 512000 bits/second + Peak Burst Size: 48000 bytes + Violate Action : Discard + Limit For Downlink Bandwidth: Enabled + Peak Data Rate : 512000 bits/second + Peak Burst Size: 48000 bytes + Violate Action : Discard + Throttle-Suppress Timeout: n/a + QoS Renegotiate Traffic-Class: Disabled + QoS Class Identifier: Not Configured + IP Type of Service: Not Configured + Tethering Block Feature: Not Configured + IP-TTL Value: n/a + Content Filtering: Enabled + Service Chain: Not Configured + UP Service Chain: Not Configured + Credit-Control: Enabled + Xheader-Insert: Xheadername + Encryption Type: rc4md5 + Encryption Key : Funa82FaCH1s3fev + Message Type: Request + Flow Action: + Redirect URL: Disabled + Redirect URL from OCS: Disabled + Redirect to Video Server: Disabled + Clear Quota Retry Timer: Disabled + Conditional Redirect: Disabled + Discard: Disabled + Terminate-Flow: Disabled + Terminate-Session: Disabled + Rulebase Change: Disabled + Billing Action: + Event Data Record: Disabled + GGSN charging Data Record: Enabled + Rf Accounting: Disabled + User Data Record: Enabled + Radius Accounting Record: Disabled + Charge Volume: ip bytes + PCO-Custom1 value: n/a + Flow-Mapping Idle Timeout: 300 (secs) + DNS Proxy Bypass: Disabled + Discard on Readdressing Failure: Disabled + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + cca_dict = {} + result_dict = {} + + # Define regular expression patterns + p0 = re.compile(r'Charging Action Name:\s+(?P\S+)') + p1 = re.compile(r'Content ID:\s+(?P\d+)') + p2 = re.compile(r'EGCDRs:\s+(?P\S+)') + p3 = re.compile(r'Limit For Uplink Bandwidth:\s+(?P\S+)') + p4 = re.compile(r'Peak Data Rate\s+:\s+(?P\S+\s+bits/second)') + p5 = re.compile(r'Peak Burst Size:\s+(?P\S+\s+bytes)') + p6 = re.compile(r'Limit For Downlink Bandwidth:\s+(?P\w+)') + p7 = re.compile(r'Peak Data Rate\s+:\s+(?P\S+\s+bits/second)') + p8 = re.compile(r'Peak Burst Size:\s+(?P\S+\s+bytes)') + p9 = re.compile(r'Credit-Control:\s+(?P\S+)') + p10 = re.compile(r'Xheader-Insert:\s+(?P\S+)') + p11 = re.compile(r'Encryption Type:\s+(?P\S+)') + p12 = re.compile(r'Encryption Key\s+:\s+(?P\S+)') + p13 = re.compile(r'Redirect URL: (?P\S+)') + p14 = re.compile(r'Discard: (?P\S+)') + + # Split output by lines and iterate + for line in out.splitlines(): + line = line.strip() + + # Charging Action Name + m = p0.match(line) + if m: + if 'charging-action' not in cca_dict: + result_dict = cca_dict.setdefault('charging-action', {}) + charging_action = m.groupdict()['name'] + result_dict[charging_action] = {} + continue + + # Content ID + m = p1.match(line) + if m: + if 'charging-action' not in cca_dict: + result_dict = cca_dict.setdefault('charging-action', {}) + content_id = m.groupdict()['content_id'] + result_dict[charging_action]["Content ID"] = int(content_id) + continue + + # EGCDRs + m = p2.match(line) + if m: + if 'charging-action' not in cca_dict: + result_dict = cca_dict.setdefault('charging-action', {}) + egcdrs = m.groupdict()['egcdrs'] + result_dict[charging_action]["EGCDRs"] = egcdrs + continue + + # Limit For Uplink Bandwidth + m = p3.match(line) + if m: + if 'charging-action' not in cca_dict: + result_dict = cca_dict.setdefault('charging-action', {}) + limit_for_uplink = m.groupdict()['enabled_ul'] + result_dict[charging_action]["Limit For Uplink Bandwidth"] = limit_for_uplink + continue + + # Peak Data Rate Uplink + m = p4.match(line) + if m: + if 'charging-action' not in cca_dict: + result_dict = cca_dict.setdefault('charging-action', {}) + peak_data_rate_ul = m.groupdict()['peak_data_rate_ul'] + result_dict[charging_action]["Peak Data Rate Uplink"] = peak_data_rate_ul + continue + + # Peak Burst Size Uplink + m = p5.match(line) + if m: + if 'charging-action' not in cca_dict: + result_dict = cca_dict.setdefault('charging-action', {}) + peak_burst_size_ul = m.groupdict()['peak_burst_size_ul'] + result_dict[charging_action]["Peak Burst Size Uplink"] = peak_burst_size_ul + continue + + # Limit For Downlink Bandwidth + m = p6.match(line) + if m: + if 'charging-action' not in cca_dict: + result_dict = cca_dict.setdefault('charging-action', {}) + limit_for_downlink = m.groupdict()['enabled_dl'] + result_dict[charging_action]["Limit For Downlink Bandwidth"] = limit_for_downlink + continue + + # Peak Data Rate Downlink + m = p7.match(line) + if m: + if 'charging-action' not in cca_dict: + result_dict = cca_dict.setdefault('charging-action', {}) + peak_data_rate_dl = m.groupdict()['peak_data_rate_dl'] + result_dict[charging_action]["Peak Data Rate Downlink"] = peak_data_rate_dl + continue + + # Peak Burst Size Downlink + m = p8.match(line) + if m: + if 'charging-action' not in cca_dict: + result_dict = cca_dict.setdefault('charging-action', {}) + peak_burst_size_dl = m.groupdict()['peak_burst_size_dl'] + result_dict[charging_action]["Peak Burst Size Downlink"] = peak_burst_size_dl + continue + + # Credit-Control + m = p9.match(line) + if m: + if 'charging-action' not in cca_dict: + result_dict = cca_dict.setdefault('charging-action', {}) + credit_control = m.groupdict()['credit_control'] + result_dict[charging_action]["Credit-Control"] = credit_control + continue + + # Xheader-Insert + m = p10.match(line) + if m: + if 'charging-action' not in cca_dict: + result_dict = cca_dict.setdefault('charging-action', {}) + xheader_insert = m.groupdict()['xheader_insert'] + result_dict[charging_action]["Xheader-Insert"] = xheader_insert + continue + + # Encryption Type + m = p11.match(line) + if m: + if 'charging-action' not in cca_dict: + result_dict = cca_dict.setdefault('charging-action', {}) + encryption_type = m.groupdict()['encryption_type'] + result_dict[charging_action]["Encryption Type"] = encryption_type + continue + + # Encryption Key + m = p12.match(line) + if m: + if 'charging-action' not in cca_dict: + result_dict = cca_dict.setdefault('charging-action', {}) + encryption_key = m.groupdict()['encryption_key'] + result_dict[charging_action]["Encryption Key"] = encryption_key + continue + + # Redirect URL + m = p13.match(line) + if m: + if 'charging-action' not in cca_dict: + result_dict = cca_dict.setdefault('charging-action', {}) + redirect_url = m.groupdict()['redirect_url'] + result_dict[charging_action]["Redirect URL"] = redirect_url + continue + + # Discard + m = p14.match(line) + if m: + if 'charging-action' not in cca_dict: + result_dict = cca_dict.setdefault('charging-action', {}) + discard = m.groupdict()['discard'] + result_dict[charging_action]["Discard"] = discard + continue + + return cca_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_active-charging_credit-control_statistics.py b/src/genie/libs/parser/staros/show_active-charging_credit-control_statistics.py new file mode 100644 index 0000000000..5e7b83464f --- /dev/null +++ b/src/genie/libs/parser/staros/show_active-charging_credit-control_statistics.py @@ -0,0 +1,261 @@ +'''starOS implementation of show active-charging credit-control statistics.py + +''' +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema, Optional + +class CreditControlSchema(MetaParser): + '''Schema for show active-charging credit-control statistics''' + + schema = { + 'cca_info': { + Any():{ + 'Assume Possitive':str, + 'Total Sessions':str, + Optional('Result Codes'):{ + Optional('2001'):str, + Optional('2002'):str, + Optional('2xxx'):str, + Optional('4001'):str, + Optional('4002'):str, + Optional('4010'):str, + Optional('4011'):str, + Optional('4012'):str, + Optional('5001'):str, + Optional('5002'):str, + Optional('5003'):str, + Optional('5004'):str, + Optional('5005'):str, + Optional('5006'):str, + Optional('5031'):str + } + } + } + } + + +class ShowCreditControl(CreditControlSchema): + '''Parser for show active-charging credit-control statistics''' + + cli_command = 'show active-charging credit-control statistics' + + ''' + Credit Control Group : Nil - (Uncorrelated) + + CC Session Stats: + Total Current Sessions: 0 + Total ECS Adds: 0 Total CC Starts: 0 + Total Session Updates: 0 Total Terminated: 214358034 + Session Switchovers: 0 + + CC Message Stats: + Total Messages Received: 0 Total Messages Sent: 2068 + Total CC Requests: 0 Total CC Answers: 0 + CCR-Initial: 0 CCA-Initial: 0 + CCA-Initial Accept: 0 CCA-Initial Reject: 0 + CCA-Initial Timeouts: 0 + CCR-Update: 0 CCA-Update: 0 + CCA-Update Timeouts: 0 + CCR-Final: 0 CCA-Final: 0 + CCA-Final Timeouts: 0 + CCR-Event: 0 CCA-Event: 0 + CCA-Event Timeouts: 0 CCR-Event Retry: 0 + ASR: 0 ASA: 0 + RAR: 2068 RAA: 2068 + CCA Dropped: 0 + + CC Message Error Stats: + Diameter Protocol Errs: 0 Transient Failures: 0 + Permanent Failures: 0 Bad Answers: 0 + Unknown Session Reqs: 0 Unknown Command Code: 0 + Request Timeouts: 0 Parse Errors: 0 + Unknown Rating Group: 0 Unknown Rulebase: 0 + Unk Failure Handling: 0 + + Backpressure Stats: + CCR-I Messages : 0 CCR-U Messages : 0 + CCR-T Messages : 0 CCR-E Messages : 0 + + CC Update Reporting Reason Stats: + Threshold: 0 QHT: 0 + Final: 0 Quota Exhausted: 0 + Validity Time: 0 Other Quota: 0 + Rating Condition Change: 0 Forced Reauthorization: 0 + + CC Termination Cause Stats: + Diameter Logout: 0 Service Not Provided: 0 + Bad Answer: 0 Administrative: 0 + Link Broken: 0 Auth Expired: 0 + User Moved: 0 Session Timeout: 0 + + CC Bad Answer Stats: + Auth-Application-Id: 0 Session-Id: 0 + CC-Request-Number: 0 CC-Request-Type: 0 + Origin-Host: 0 Origin-Realm: 0 + Parse-Message-Errors: 0 Parse-Mscc-Errors: 0 + Misc: 0 + + CC Traffic Category Stats: + Category Creates: 0 Category Deletes: 0 + Category Lookups: 0 + Hits: 0 Misses: 0 + Trigger Events: 0 Final Unit Consumed: 0 + MSCC GSU Null Grant: 0 MSCC FUI Redirect: 0 + Category Success: 0 Rating Failed: 0 + Service Denied: 0 Limit Reached: 0 + Auth Rejected: 0 Other Errors: 0 + + CCA Initial Message Stats: + Result Code 2001: 0 Result Code 5003: 0 + Result Code 4010: 0 Result Code 4011: 0 + Result Code 4012: 0 Result Code 5031: 0 + + CCA Update Message Stats: + Result Code 2001: 0 Result Code 5003: 0 + Result Code 4010: 0 Result Code 4011: 0 + Result Code 4012: 0 Result Code 5031: 0 + + CCA Event Message Stats: + Result Code 2001: 0 Other Result Codes: 0 + + Failure Handling Stats: + Action-Terminated: 0 Action-Continue: 0 + Offline Active Sessions: 0 Action-Discard: 0 + + CCA Result Code 2xxx Stats: + Result Code 2xxx: 0 Result Code 2001: 0 + Result Code 2002: 0 + + CCA Result Code 4xxx Stats: + Result Code 4001: 0 Result Code 4002: 0 + Result Code 4010: 0 Result Code 4011: 0 + Result Code 4012: 0 + + CCA Result Code 5xxx Stats: + Result Code 5001: 0 Result Code 5002: 0 + Result Code 5003: 0 Result Code 5004: 0 + Result Code 5005: 0 Result Code 5006: 0 + Result Code 5031: 0 + All Other Result Codes: 0 + + CCA Initial Experimental Result Code Stats: + Exp Result Code 5199: 0 + + OCS Unreachable Stats: + Tx-Expiry: 0 Response-TimeOut: 0 + Connection-Failure: 0 Action-Continue: 0 + Action-Terminated: 0 Server Retries: 0 + + Assumed-Positive Sessions: + Current: 0 Cumulative: 0 + ''' + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + cca_dict = {} + result_dict = {} + # initial regexp pattern + p0 = re.compile(r'^Credit\sControl\sGroup\s+.\s+(?P.*$)') + p1 = re.compile(r'Total\sCurrent\sSessions.\s*(?P\d+)') + p2 = re.compile(r'Result\sCode\s(?P2...):\s+(?P\d+)') + p2_2 = re.compile(r'.*? Result Code (?P2...).*?(?P\d+)') + p3 = re.compile(r'Result\sCode\s(?P4...):\s+(?P\d+)') + p3_2 = re.compile(r'.*? Result Code (?P4...).*?(?P\d+)') + p4 = re.compile(r'Result\sCode\s(?P5...):\s+(?P\d+)') + p4_2 = re.compile(r'.*? Result Code (?P5...).*?(?P\d+)') + p5 = re.compile(r'^Current:\s+(?P\d+)') + + for line in out.splitlines(): + line = line.strip() + m = p0.match(line) + if m: + if 'cca_info' not in cca_dict: + result_dict = cca_dict.setdefault('cca_info', {}) + ccgroup = m.groupdict()['ccgroup'] + result_dict[ccgroup] = {} + continue + m = p1.match(line) + if m: + if 'cca_info' not in cca_dict: + result_dict = cca_dict.setdefault('cca_info', {}) + sessions = m.groupdict()['sessions'] + result_dict[ccgroup]["Total Sessions"] = sessions + continue + m = p2.match(line) + if m: + if 'cca_info' not in cca_dict: + result_dict = cca_dict.setdefault('cca_info', {}) + c2xxx = m.groupdict()['C2xxx'] + C2 = m.groupdict()['C2'] + C2_list =["2xxx","2001","2002"] + if "Result Codes" not in result_dict[ccgroup]: + result_dict[ccgroup]["Result Codes"]={} + for code in C2_list: + if code in C2 and int(c2xxx)>1: + result_dict[ccgroup]["Result Codes"][code] = c2xxx + n = p2_2.match(line) + if n: + C2_2 = n.groupdict()['C2_2'] + c2xxx_2 = n.groupdict()['C2xxx_2'] + for code in C2_list: + if code in C2_2 and int(c2xxx_2)>1: + result_dict[ccgroup]["Result Codes"][code] = c2xxx_2 + continue + + m = p3.match(line) + if m: + if 'cca_info' not in cca_dict: + result_dict = cca_dict.setdefault('cca_info', {}) + c4xxx = m.groupdict()['C4xxx'] + C4 = m.groupdict()['C4'] + C4_list = ["4001","4002","4010","4011","4012"] + if "Result Codes" not in result_dict[ccgroup]: + result_dict[ccgroup]["Result Codes"]={} + for code in C4_list: + if code in C4 and int(c4xxx)>1: + result_dict[ccgroup]["Result Codes"][code] = c4xxx + n = p3_2.match(line) + if n: + C4_2 = n.groupdict()['C4_2'] + c4xxx_2 = n.groupdict()['C4xxx_2'] + for code in C4_list: + if code in C4_2 and int(c4xxx_2)>1: + result_dict[ccgroup]["Result Codes"][code] = c4xxx_2 + continue + + m = p4.match(line) + if m: + if 'cca_info' not in cca_dict: + result_dict = cca_dict.setdefault('cca_info', {}) + c5xxx = m.groupdict()['C5xxx'] + C5 = m.groupdict()['C5'] + C5_list = ["5001", "5002", "5003", "5004", "5005", "5006", "5031"] + if "Result Codes" not in result_dict[ccgroup]: + result_dict[ccgroup]["Result Codes"]={} + for code in C5_list: + if code in C5 and int(c5xxx)>1: + result_dict[ccgroup]["Result Codes"][code] = c5xxx + n = p4_2.match(line) + if n: + C5_2 = n.groupdict()['C5_2'] + c5xxx_2 = n.groupdict()['C5xxx_2'] + for code in C5_list: + if code in C5_2 and int(c5xxx_2)>1: + result_dict[ccgroup]["Result Codes"][code] = c5xxx_2 + continue + + m = p5.match(line) + if m: + if 'cca_info' not in cca_dict: + result_dict = cca_dict.setdefault('cca_info', {}) + assume = m.groupdict()['assume'] + result_dict[ccgroup]["Assume Possitive"] = assume + continue + + return cca_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_active_charing_ruledef_statistics_all_charging.py b/src/genie/libs/parser/staros/show_active_charing_ruledef_statistics_all_charging.py new file mode 100644 index 0000000000..b24f4fbe63 --- /dev/null +++ b/src/genie/libs/parser/staros/show_active_charing_ruledef_statistics_all_charging.py @@ -0,0 +1,405 @@ +"""starOS implementation of show temperature.py + +""" +from os import stat_result +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowACSchema(MetaParser): + """Schema for show active-charging ruledef statistics all charging""" + + schema = { + 'ac_table': { + Any():{ + 'PACKETS_DOWN': str, + 'BYTES_DOWN': str, + 'PACKETS_UP': str, + 'BYTES_UP': str, + 'HITS': str, + 'MATCH': str, + }, + 'Summary':{ + 'TOTAL': str, + }, + }, + } + """ + 'Summary':{ + 'TOTAL': str, + }, + + """ + +class ShowAC(ShowACSchema): + """Parser for show active-charging ruledef statistics all charging""" + + cli_command = 'show active-charging ruledef statistics all charging' + + """ +[local]ASU-ASR5K5-1# show active-charging ruledef statistics all charging +Friday December 22 20:54:18 ART 2023 + +Ruledef Name Packets-Down Bytes-Down Packets-Up Bytes-Up Hits Match-Bypassed +------------ ------------ ---------- ---------- -------- ---- -------------- +AUP-ALL-1Luis 892035245744 974546321120052 368889466072 95248711956718 1223093338260 147610659 +AUP-ALL-TETH-1 718493638 714052238036 409607331 87186689740 1104073641 266 +AUP-ALL_HTTP-1 5374442 319667816 13737843 1937516143 4516311 0 +AUP-CLARO-AUTOGESTION-1 0 0 0 0 0 0 +AUP-CLARO-CONTENEDOR-1 9656237 3175329040 11288869 4691355927 19415957 0 +AUP-CLARO-IDEAS 0 0 17 972 10 0 +AUP-CLARO-IDEAS-4 0 0 0 0 0 0 +AUP-CLARO-INTRA-1 23358 29427833 10713 1029208 33397 0 +AUP-CLARO_APP_CAC-2 0 0 0 0 0 0 +AUP-CLARO_MI-4 0 0 0 0 0 0 +AUP-CLARO_MUSICA-1 8500435 10259987593 4879595 438285802 12990862 0 +AUP-CLARO_MUSICA-13 2304765 3104446158 988536 75743706 3284379 0 +AUP-CLARO_MUSICA-14 1917 2164055 1662 114980 3362 0 +AUP-CLARO_MUSICA-16 3115096 3561026131 1393721 190809552 4311773 0 +AUP-CLARO_MUSICA-18 4678368 5826883277 2148659 210712334 6656379 0 +AUP-CLARO_MUSICA-19 4204897 5796395608 1181153 69473019 5371395 0 +AUP-CLARO_MUSICA-2 0 0 0 0 0 0 +AUP-CLARO_MUSICA-20 0 0 0 0 0 0 +AUP-CLARO_MUSICA-21 0 0 0 0 0 0 +AUP-CLARO_MUSICA-26 2786 3322693 2314 226725 4910 0 +AUP-CLARO_MUSICA-27 181 70479 205 25128 338 0 +AUP-CLARO_MUSICA-28 2556 1034495 2388 375711 4339 0 +AUP-CLARO_MUSICA-3 0 0 0 0 0 0 +AUP-CLARO_MUSICA-31 0 0 0 0 0 0 +AUP-CLARO_MUSICA-32 9138 5472909 9082 1477054 15240 0 +AUP-CLARO_MUSICA-33 0 0 0 0 0 0 +AUP-CLARO_MUSICA-35 3882 3940243 3494 276706 6619 0 +AUP-CLARO_MUSICA-36 0 0 0 0 0 0 +AUP-CLARO_MUSICA-4 0 0 0 0 0 0 +AUP-CLARO_MUSICA-51 1548 244177 2098 374851 2979 0 +AUP-CLARO_MUSICA-61 612978 517656452 478718 63333619 995349 0 +AUP-CLARO_MUSICA-76 0 0 0 0 0 0 +AUP-CLARO_MUSICA-78 0 0 0 0 0 0 +AUP-CLARO_MUSICA-82 0 0 0 0 0 0 +AUP-CLARO_MUSICA-86 51392 41538519 38685 5392385 82272 0 +AUP-CLARO_MUSICA-88 0 0 0 0 0 0 +AUP-CLARO_MUSICA-89 2002 446630 2893 602076 3524 0 +AUP-CLARO_MUSICA-90 268 116809 266 57892 466 0 +AUP-CLARO_S1GATEWAY-2 103065 86921452 93953 42554019 188256 0 +AUP-CLARO_S1GATEWAY-4 96376 86448691 78043 22992434 165817 0 +AUP-COTA-1-ESIM 5116391 1627077436 5339554 2233642304 9714065 0 +AUP-COTA-2-ESIM 12836 13693196 9189 784349 20995 0 +AUP-DATAMI-1 12 720 8 420 4 0 +AUP-DATAMI-2 0 0 0 0 0 0 +AUP-DATAMI-3 183182 254027847 160504 8531618 342918 0 +AUP-DTIGNITE-1 971 488343 1319 189878 1925 0 +AUP-DTIGNITE-2 11 5429 16 2914 23 0 +AUP-DTIGNITE-4 14389383 18674103769 4627822 756501542 18800472 0 +AUP-DTIGNITE-7 14496993 20016211686 5120216 282130351 19612220 0 +AUP-FACEBOOK-AF 0 0 0 0 0 0 +AUP-FACEBOOK-AF-2 2167410 129994375 6055698 967319941 1975312 0 +AUP-FB-FREE-1 5234026628 2163777247230 5055398428 1001961630303 9234370503 0 +AUP-FB-FREE-HE-1-IP 41280113 7316500870 44745188 5521204360 61790906 0 +AUP-FB-SP-1 7588409989 8438894654988 2328316127 534259023174 9786352259 0 +AUP-FREE-FIRE-CDN 40473387 55194645425 17404500 1085693232 57643957 0 +AUP-FREE-FIRE-LOAD-BALANCER 672 375094 823 353271 1460 0 +AUP-FREE-FIRE-PLATFORM-SERVER 326 277681 200 15321 502 0 +AUP-FREE-FIRE-SAC-GAME-SERVER 16936333 2228534201 14424076 1360218626 31322824 0 +AUP-FREE-FIRE-SAC-REGION-SERVER 0 0 67 5628 67 0 +AUP-FREE-FIRE-VOICE-SERVER 1003386857 78559442181 536882996 42982966611 1537440948 0 +AUP-GAMELOFT-1 1789167 2250039701 1012924 83037870 2679425 0 +AUP-GAMELOFT-10 233420 203416591 183927 17898189 394049 0 +AUP-GAMELOFT-11 956 127673 1229 117785 1551 0 +AUP-GAMELOFT-12 42 23080 50 7578 80 0 +AUP-GAMELOFT-2 8620052 8103190437 7649774 1002160233 15205810 0 +AUP-GAMELOFT-3 0 0 0 0 0 0 +AUP-GAMELOFT-5 0 0 0 0 0 0 +AUP-GAMELOFT-6 449624 588032024 273670 16905485 694556 0 +AUP-GAMELOFT-7 44576 41372895 39913 5538656 77508 0 +AUP-GAMELOFT-8 14543 17080196 16375 1166356 29676 0 +AUP-GAMELOFT-9 92725 108434876 77549 9013661 163432 0 +AUP-GEOLOCALIZACION-1 0 0 0 0 0 0 +AUP-GM-FOTA-1 31313482 43274740144 13510544 750599994 44782716 0 +AUP-GM-FOTA-2 0 0 0 0 0 0 +AUP-GM-FOTA-3 17981944 24954205724 8337059 447701452 26317545 0 +AUP-GM-FOTA-4 969086 1285668867 609104 44605695 1570826 0 +AUP-GM-GRANEL-1 62521407 27508830849 66231044 15141010812 112628268 0 +AUP-GM-GRANEL-10 0 0 0 0 0 0 +AUP-GM-GRANEL-11 0 0 0 0 0 0 +AUP-GM-GRANEL-13 0 0 0 0 0 0 +AUP-GM-GRANEL-14 0 0 0 0 0 0 +AUP-GM-GRANEL-15 1090660 544079121 994807 203934917 1672752 0 +AUP-GM-GRANEL-2 47372830 65410352059 15715640 857934189 63044247 0 +AUP-GM-GRANEL-3 0 0 0 0 0 0 +AUP-GM-GRANEL-4 180 54654 183 16203 331 0 +AUP-GM-GRANEL-5 0 0 0 0 0 0 +AUP-GM-GRANEL-6 0 0 0 0 0 0 +AUP-GM-GRANEL-7 28279233 11657156747 35976239 11559187467 56533338 0 +AUP-GM-GRANEL-8 50684901 20728358726 61127414 15519407130 97287962 0 +AUP-GM-GRANEL-9 17084 18342341 12148 850633 28583 0 +AUP-GM-I-1 0 0 0 0 0 0 +AUP-GM-I-2 0 0 0 0 0 0 +AUP-GM-I-3 0 0 0 0 0 0 +AUP-GM-I-4 0 0 0 0 0 0 +AUP-GM-I-6 0 0 0 0 0 0 +AUP-GM-I-7 0 0 0 0 0 0 +AUP-GOOGLE-DNS-1 16 983 20 1007 24 0 +AUP-GOOGLE-DNS-2 0 0 0 0 0 0 +AUP-GOOGLE-PLAY-P2P-1 14361057287 18092297959945 2824012326 275704681097 17106014115 0 +AUP-GOOGLE-RCS-1 1041233283 392126414162 1013912804 419893729337 2011379529 0 +AUP-INSTAGRAM-1 360694079 210723211157 320618777 213338336818 672070346 0 +AUP-INSTAGRAM-1-TLS-SNI 214215 86246848 203999 68285478 364604 0 +AUP-INSTAGRAM-2 15122105 10362078735 11419652 7351776307 26190082 0 +AUP-INSTAGRAM-3 170194051 83945221751 135190829 40386312590 278130185 0 +AUP-INSTAGRAM-3-TLS-SNI 308940928 117939984869 315137239 73275379233 567719292 0 +AUP-INSTAGRAM-4 1576669 1547966279 883342 118925213 2383697 0 +AUP-INSTAGRAM-4-TLS-SNI 444358 495072615 313597 25010598 727807 0 +AUP-INSTAGRAM-5 7182257818 8778791843246 1005398159 107400251383 8177608204 0 +AUP-INSTAGRAM-P2P-1 227367298 220880316141 154591409 24975406827 358153131 0 +AUP-MEDALLIA 3 300 5 621 5 0 +AUP-MMS-1 0 0 0 0 0 0 +AUP-MMS-5 16923 1000412 22601 27233348 37657 0 +AUP-MMS-6 71929 87108514 54998 6489297 119333 0 +AUP-PORTAL-REDIRECT-1 17071563 1024545548 44113338 5321656006 14448357 0 +AUP-PORTAL-SHOP-HTTP-1 0 0 0 0 0 0 +AUP-PORTAL-SHOP-HTTP-2 0 0 0 0 0 0 +AUP-PORTAL-SHOP-HTTPS-2 0 0 0 0 0 0 +AUP-PORTAL-SHOP-HTTPS-4 0 0 0 0 0 0 +AUP-PORTAL_APRENDE-1 33326 43866671 20961 1686613 53653 0 +AUP-PSIPHON-BLOCK 13741815 4936607226 19552348 2941141838 25869627 53267 +AUP-SAMSUNG-SINGLE 8594384 11965628954 2491915 145815791 11085681 0 +AUP-SM-SR 28321 3990661 33425 5193327 54161 0 +AUP-SMART-ADSERVER-1 0 0 0 0 0 0 +AUP-SMART-ADSERVER-2 0 0 0 0 0 0 +AUP-SMART-ADSERVER-3 186 21291 333 59187 397 0 +AUP-SMART-ADSERVER-4 0 0 0 0 0 0 +AUP-SPEEDY-MOVIL-10 0 0 2291 137460 436 0 +AUP-SPEEDY-MOVIL-11 30969 24853413 51773 5447918 69933 0 +AUP-SPEEDY-MOVIL-13 3376682 1829706436 5186953 441080541 6211048 0 +AUP-SPEEDY-MOVIL-15 0 0 0 0 0 0 +AUP-SPEEDY-MOVIL-16 6949 1674016 12719 1465878 13594 0 +AUP-SPEEDY-MOVIL-17 0 0 0 0 0 0 +AUP-SPEEDY-MOVIL-18 709781 199879991 1285547 278398024 1489438 0 +AUP-SPEEDY-MOVIL-23 0 0 0 0 0 0 +AUP-SPEEDY-MOVIL-6 0 0 1001 60060 169 0 +AUP-SPEEDY-MOVIL-7 0 0 0 0 0 0 +AUP-TIKTOK-1 6420997542 7965156381018 2980728649 386804729387 9148220504 2582 +AUP-TIKTOK-2 4101239 5513817840 1910796 143696049 5959372 0 +AUP-TWITTER-1 118668 17384481 175067 14306051 120274 0 +AUP-TWITTER-1-TLS-SNI 187 39017 186 39602 306 0 +AUP-TWITTER-13 198964 71791807 209515 45993846 382273 0 +AUP-TWITTER-14 3133 4055548 2212 151095 5285 0 +AUP-TWITTER-15 28638650 36928568097 16432015 1103465338 44306113 0 +AUP-TWITTER-2 2141587 2422510834 1282117 149186702 3337671 0 +AUP-TWITTER-3 0 0 0 0 0 0 +AUP-TWITTER-3-TLS-SNI 0 0 0 0 0 0 +AUP-TWITTER-4 114108 104290305 90510 6946367 154653 0 +AUP-TWITTER-5 14 1078 19 1580 22 0 +AUP-TWITTER-5-TLS-SNI 1125 427754 1131 123561 2044 0 +AUP-TWITTER-6 0 0 0 0 0 0 +AUP-TWITTER-7 0 0 0 0 0 0 +AUP-TWITTER-9 0 0 0 0 0 0 +AUP-TWITTER-P2P-1 169265702 195842644352 85758465 10734854588 249981967 0 +AUP-VANTIO-1 127391 23940804 150488 9181067 191992 0 +AUP-VANTIO-2 979057456 164315934748 1425202575 95639297179 2404260029 0 +AUP-VANTIO-3 0 0 0 0 0 0 +AUP-VANTIO-4 112695 15591861 126246 7872713 238941 0 +AUP-VANTIO-5 0 0 0 0 0 0 +AUP-VANTIO-6 0 0 0 0 0 0 +AUP-VANTIO-7 1961006 368293072 2367279 142076802 3075184 0 +AUP-VANTIO-8 5664723016 977327715000 6237387882 432001920296 11902110892 0 +AUP-VPN-1 93558308 72081973859 73745510 9973339173 162706610 0 +AUP-WHATSAPP-1 177913057484 214194333255907 76214556599 17861543169505 251489130473 0 +AUP-YOUTUBE-1-TLS-SNI 0 0 0 0 0 0 +AUP-YOUTUBE-10 303848943 226758752410 293290745 202090570646 597139372 0 +AUP-YOUTUBE-11 1397404 911269413 1425374 463443784 2822778 0 +AUP-YOUTUBE-12 109333 102491700 56629 13489721 165962 0 +AUP-YOUTUBE-13 4579501 5311060078 1932423 295517218 6511924 0 +AUP-YOUTUBE-14 13044214 14961475399 5305703 860215690 18349917 0 +AUP-YOUTUBE-15 12375741 6875348916 9182478 2321842137 21558219 0 +AUP-YOUTUBE-16 90 54045 84 30259 174 0 +AUP-YOUTUBE-17 1873442 906563928 1711321 519823391 3584763 0 +AUP-YOUTUBE-18 2733866 966925333 2439742 549009927 5173608 0 +AUP-YOUTUBE-19 70748 38551073 62358 20453486 133106 0 +AUP-YOUTUBE-2-TLS-SNI 3779 2732794 2400 308941 4898 0 +AUP-YOUTUBE-20 24369231 18065109399 17748144 5579094667 42117359 0 +AUP-YOUTUBE-21 1964251971 2401842702968 404197490 65604331082 2365375105 0 +AUP-YOUTUBE-22 34177006 36376094599 14413409 2170227690 48008084 0 +AUP-YOUTUBE-23 92062859 99967165601 38072329 4855698592 127105443 0 +AUP-YOUTUBE-24 232537714 139324571688 202968869 62219726205 412581446 0 +AUP-YOUTUBE-25 874549193 424851695909 866172863 439700746254 1621100398 0 +AUP-YOUTUBE-26 1914266 2221996735 975733 162900245 2889999 0 +AUP-YOUTUBE-27 3752689 2353856366 3747509 1394997490 7500198 0 +AUP-YOUTUBE-29 0 0 0 0 0 0 +AUP-YOUTUBE-30 485 234377 517 114356 1002 0 +AUP-YOUTUBE-4-TLS-SNI 2000 1433660 1295 154476 2499 0 +AUP-YOUTUBE-5-TLS-SNI 3189 3776660 1785 161335 4697 0 +AUP-YOUTUBE-6 224265 146414733 223365 74360620 447630 0 +AUP-YOUTUBE-7 57556895 58796438973 27660449 5768423118 85217335 0 +AUP-YOUTUBE-8 7068892 5118038079 6366289 2360819785 13435181 0 +AUP-YOUTUBE-9 7757311 4539064370 7039727 3440738932 14797038 0 +AUP-YOUTUBE-P2P-1 3140294281 3814725846358 1055931563 173582379501 4155811206 0 +PY-AUTOGESTION-1 0 0 1602 97020 266 0 +PY-BLOCK 365664 16749362 2233407 124279058 1409464 0 +PY-BLUE_MOVIL-1 2307 2751998 2236 194024 4331 0 +PY-BLUE_MOVIL-2 166 132364 223 38634 346 0 +PY-CENSO-1-2022 269308 364582082 190536 10591911 456900 0 +PY-CENSO-2-2022 630653 855874740 287165 20944405 910762 0 +PY-CENSO-3-2022 472329 639805172 261329 26219828 731046 0 +PY-CIBERSONS-1 0 0 0 0 0 0 +PY-CLARO-1 77144 46991508 77833 7015035 107175 0 +PY-CLARO-ABM-1 3843 1337969 512235 31348223 93761 0 +PY-CLARO-CLUB-1 29747 5305497 35081 8387349 48755 0 +PY-CLARO-CLUB-4 113962 42113476 133901 25887481 211652 0 +PY-CLARO-DOC-AUTOGESTION-1 843 411294 72670 5010773 14474 0 +PY-CLARO-EMPRESAS-1 35 1860 6422 386208 1144 0 +PY-CLARO-IDEAS-1 268825 299588330 135219 12978932 395513 0 +PY-CLARO-IDEAS-2 538655 503744792 326413 41604519 844126 0 +PY-CLARO-IDEAS-3 116429 118358423 61587 7151313 174103 0 +PY-CLARO-PORTALCOMPRAS-2 336701 72528173 384234 123375980 565117 0 +PY-CLARO-PORTALCOMPRAS-4 561234 474138149 6809909 464185015 1980883 0 +PY-CLARO-SVA-1 150305 25162358 212891 23938564 207279 0 +PY-CLAROCLUBAPPS-5 1108592 1331483238 436293 73142373 1538625 0 +PY-CLAROVIDEO-1 5652425 7198920605 3021385 257354199 8529765 0 +PY-CLARO_GIROSPDG-1 7 420 2024 119612 388 0 +PY-CLARO_INDIVIDUOS-1 0 0 0 0 0 0 +PY-CLARO_PORTAL-1 0 0 0 0 0 0 +PY-CLARO_PORTAL-3 92381 91802688 146882 10829606 146962 0 +PY-CLARO_PORTAL-4 0 0 12 720 2 0 +PY-CLARO_PORTAL-5 18187 20679942 12479 1178236 29931 0 +PY-CLARO_PORTAL-7 908 358770 130666 7886658 24767 0 +PY-CLARO_PORTALCOMERCIO-1 1925 463215 168958 10203695 32995 0 +PY-CLARO_PORTAL_DNSSNI-1 245096 148215611 284812 31775897 436610 0 +PY-CLARO_PORTAL_DNSSNI-2 86552112 90716828043 56389742 9979687806 139401869 0 +PY-CLARO_PORTAL_FREE-NO-URI-1 1076868 131673612 1300748 225711307 1726476 0 +PY-CLARO_PORTAL_FREE-NO-URI-2 2397960 1417751961 2197460 714227646 3940694 0 +PY-CLARO_S1GATEWAY-1 89841 48837102 95281 79698527 182584 0 +PY-CLARO_SUBSIDIOS-1 214 183189 192 17002 376 0 +PY-CLARO_TIENDA-1 16638 15451613 15887 1909602 25666 0 +PY-CLARO_VIAJES-1 0 0 0 0 0 0 +PY-FUNMOVILCLUB-1 8 448 10 536 8 0 +PY-GOOGLE-RCS-6 761935 225201003 831648 80014607 1091420 0 +PY-HACIENDA-1 0 0 392 23740 56 0 +PY-INTERNETQ 10 929 18 7198 22 0 +PY-LOGMEIN-1 0 0 0 0 0 0 +PY-MDI-1 0 0 2994 369104 2994 0 +PY-MEC-1 31782660 39197089065 16242176 2472539559 47354782 0 +PY-MICLARO-1 22 1288 14947 1022348 2601 0 +PY-MMSL-2 680 34768 765 696231 1246 0 +PY-MOVICLIPS-1 0 0 0 0 0 0 +PY-MSP-BS 8891718 11658054216 6924445 494094875 15679884 0 +PY-MUSICA_STORE-1 0 0 217 13020 57 0 +PY-OPRATEL-2 0 0 0 0 0 0 +PY-OPRATEL-3 1060 1017892 1060 202962 1941 0 +PY-OPRATEL-HE-1 5 836 6 863 8 0 +PY-OTA-1 958 96700 1260 119700 1903 0 +PY-PLAYTOWN-1 465188 135318705 509693 148778737 762311 0 +PY-PORTAL-SHOP-HTTP-HE-ENCRYPTED_1 0 0 0 0 0 0 +PY-PORTAL-SHOP-HTTP-HE-ENCRYPTED_2 0 0 0 0 0 0 +PY-PORTAL-SHOP-HTTP-HE-ENCRYPTED_DESARROLLO 0 0 0 0 0 0 +PY-PORTAL-SHOP-HTTPS-1 0 0 0 0 0 0 +PY-PORTAL-SHOP-HTTPS-3 0 0 0 0 0 0 +PY-PORTAL-SHOP-HTTPS-DESARROLLO 0 0 0 0 0 0 +PY-QUAD-MINDS-HTTPS 1336850 710066264 1082737 236242188 2282718 0 +PY-SALDOGIROS-1 11210 12741883 30255 1945092 22858 0 +PY-SALDOGIROS-2 0 0 0 0 0 0 +PY-SERVICIODIGITAL-1 831 954002 833 55428 1616 0 +PY-SME-COVID-1 0 0 0 0 0 0 +PY-SMT_GLOBAL-1 0 0 0 0 0 0 +PY-SOUND-1 1387 1511934 962 98691 2171 0 +PY-SOUND-2 28 6218 31 2305 44 0 +PY-SOYCLARO-1 0 0 0 0 0 0 +PY-SPIRADS_SA 36314 19188023 37160 4122215 54907 0 +PY-SPIRADS_SA-2 16028 20483416 9815 818757 25280 0 +PY-SPIRADS_SA-3 0 0 0 0 0 0 +PY-SVA_Bristol_SA-1 29594758 29406996482 21662558 3191234080 50664350 0 +PY-SVA_Bristol_SA-2 1034418 1048239812 821826 227029949 1856244 0 +PY-TMOBS-1 1304 538513 1400 230364 2196 0 +PY-TMOBS-3 5779 1482514 6110 1060521 8461 0 +PY-VOICENTER-1 10587898 3292026047 10344172 2100674466 20892853 0 +PY-VOWIFI-VEL-1 0 0 0 0 0 0 +PY-WAPPY-3 0 0 0 0 0 0 +PY-block_tunnel_fraude-2 3115 1610703 48886 5474747 8270 0 +PY-block_tunnel_fraude-5 0 0 0 0 0 0 +PY-block_tunnel_fraude-8 0 0 0 0 0 0 +PY_MOBILESPACE_HE-1 375 482083 360 22878 717 0 +WPY-AMDOCS-1 0 0 0 0 0 0 +WPY-CLARO_PORTAL-1 0 0 0 0 0 0 +AUP-GM-DOMAIN1-GM-1 0 0 0 0 0 0 +AUP-GM-DOMAIN1-GM-2 0 0 0 0 0 0 +AUP-GM-DOMAIN2-GM-2 0 0 0 0 0 0 +PY-CLARO-2 0 0 0 0 0 0 +UY-SIA-2 0 0 0 0 0 0 +PY-DIGITAL-VIRGO-1 116012 25884308 125259 19408310 180069 0 +PY-DIGITAL-VIRGO-2 0 0 0 0 0 0 +AUP-COTA2-1-ESIM 747 264812 656 166789 1303 0 +AUP-COTA2-2-ESIM 209 43463 213 147423 405 0 +AUP-COTA2-3-ESIM 0 0 0 0 0 0 +AUP-NORTON-CYKADAS-HE-1 377 66501 417 65535 577 0 +PY-AWG-HE-1 105 43212 119 17771 181 0 +PY-AWG-HE-2 11305 3934521 13127 2927824 19509 0 +PY-AWG-HE-3 127 34956 146 30242 200 0 +PY-PORTAL_DEV_NOMINATIVIDAD-HTTP 0 0 0 0 0 0 +PY-PORTAL_DEV_NOMINATIVIDAD-HTTPS 0 0 0 0 0 0 +PY-PORTAL_NOMINATIVIDAD-HTTP 85394 85570373 72956 7730944 150990 0 +PY-PORTAL_NOMINATIVIDAD-HTTPS 642715 133163332 1036857 1167895749 1672354 0 +PY-PORTAL_TEST_NOMINATIVIDAD-HTTP 0 0 0 0 0 0 +PY-PORTAL_TEST_NOMINATIVIDAD-HTTPS 0 0 0 0 0 0 +AUP-GOOGLE-RCS-2 51829558 20320190783 50869179 21468165551 100565540 0 +AUP-GOOGLE-RCS-3 26761 13195463 24726 4541125 48512 0 +AUP-GOOGLE-RCS-4 7077690 2231815950 6991061 1922807747 13058182 0 +PY-GOOGLE-RCS-6-TLSSNI 537144 310177786 467229 61093376 903681 0 +AUP-DTIGNITE-3 1255 505941 1461 794245 2471 0 +AUP-DTIGNITE-5 0 0 0 0 0 0 +AUP-DTIGNITE-6 0 0 0 0 0 0 +AUP-DTIGNITE-8 190 88170 211 151378 380 0 +AUP-DTIGNITE-9 32806 45554378 5318 293248 38118 0 +PY-CLARO-VR-HE-1 0 0 0 0 0 0 +PY-CLARO-VR-HE-2 0 0 0 0 0 0 + +Total Ruledef(s) : 309 + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + ac_dict = {} + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'((?P^\S+\-\S+)\s+(?P\d+)\s+(?P\d+)\s+(?P\d+)\s+(?P\d+)\s+(?P\d+)\s+(?P\d+))') + p1= re.compile(r'Total Ruledef\(s\) : (?P\d+)') + + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'ac_table' not in ac_dict: + result_dict = ac_dict.setdefault('ac_table',{}) + ruledef = m.groupdict()['ruledef'] + packets_down = m.groupdict()['packets_down'] + bytes_down = m.groupdict()['bytes_down'] + packets_up = m.groupdict()['packets_up'] + bytes_up = m.groupdict()['bytes_up'] + hits = m.groupdict()['hits'] + match = m.groupdict()['match'] + + result_dict[ruledef] = {} + result_dict[ruledef]['PACKETS_DOWN'] = packets_down + result_dict[ruledef]['BYTES_DOWN'] = bytes_down + result_dict[ruledef]['PACKETS_UP'] = packets_up + result_dict[ruledef]['BYTES_UP'] = bytes_up + result_dict[ruledef]['HITS'] = hits + result_dict[ruledef]['MATCH'] = match + + + m = p1.match(line) + if m: + if 'ac_table' not in ac_dict: + result_dict = ac_dict.setdefault('ac_table',{}) + if 'Summary' not in ac_dict['ac_table']: + result_dict.setdefault('Summary',{}) + total = m.groupdict()['total_ruledef'] + result_dict['Summary']['TOTAL'] = total + + return ac_dict diff --git a/src/genie/libs/parser/staros/show_alarm_all.py b/src/genie/libs/parser/staros/show_alarm_all.py new file mode 100644 index 0000000000..97835b38c0 --- /dev/null +++ b/src/genie/libs/parser/staros/show_alarm_all.py @@ -0,0 +1,203 @@ +"""starOS implementation of show_alarm_all.py + +""" +import re +import pprint +from string import capwords +from typing import Optional +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema, Optional + +class ShowAlarmAllSchema(MetaParser): + """Schema for show alarm all""" + + schema = { + 'alarms': { + Any(): { + 'Current': { + 'TOTAL': str, + 'CRITICAL': str, + 'MAJOR': str, + 'MINOR': str + }, + 'Cumulative': { + 'TOTAL': str, + 'CRITICAL': str, + 'MAJOR': str, + 'MINOR': str + }, + }, + 'LAST_AL': str, + Optional('OA'): { + Any(): { + 'SEV': str, + 'EVENT': str + }, + }, + } + } + + +class ShowAlarmAll(ShowAlarmAllSchema): + """Parser for show alarm all""" + + cli_command = 'show alarm all' + + """ +Monday June 27 11:05:49 ART 2022 +Facility Alarm Information: + +Audible Alarm OFF +Note: Audible Alarm is Disabled +All Central Office (CO) alarms are off + +Alarm Statistics: + Current Outstanding Alarms + Total: 5 + Critical: 0 + Major: 0 + Minor: 5 + Cumulative Totals + Total: 7 + Critical: 0 + Major: 0 + Minor: 7 + Last Alarm Received: Thursday June 16 15:51:31 ART 2022 + +Outstanding Alarms: + +Sev Object Event +--- ---------- -------------------------------------------------------------------------------------------- +MN Card 7 The Packet Services Card 2 in slot 7 is a single point of failure. Another Packet Services Card 2 of the same type is needed. +MN Card 10 The Packet Services Card 2 in slot 10 is a single point of failure. Another Packet Services Card 2 of the same type is needed. +MN Card 11 The Packet Services Card 2 in slot 11 is a single point of failure. Another Packet Services Card 2 of the same type is needed. +MN Port 23/1 Port link down +MN Card 26 The 10 Gig Ethernet Line Card in slot 26 is a single point of failure. A 10 Gig Ethernet Line Card is needed in slot 23 + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + alarm_dict = {} + + result_dict = {} + + # initial regexp pattern + p1 = re.compile(r'^(Current Outstanding Alarms$)') + p2 = re.compile(r'^((Total:\s+)(?P\d+))') + p3 = re.compile(r'^(Critical:\s+(?P\d+))') + p4 = re.compile(r'^(Major:\s+(?P\d+))') + p5 = re.compile(r'^(Minor:\s+(?P\d+))') + p6 = re.compile(r'^(Cumulative Totals$)') + p7 = re.compile(r'^(Last Alarm Received:\s(?P\w+\s\w+\s\d+\s\d+:\d+:\d+\s\w+\s\d+))') + p8 = re.compile(r'^((?PCR|MJ|MN)\s+\w+\s(?P\d+|\d+.\d)\s+(?P.+$))') + + i = 0 + for line in out.splitlines(): + line = line.strip() + + if i==1: + #Match en linea anterior a 'Current Outstanding Alarms' + m2 = p2.match(line) + if m2: + #Current total + if 'alarms' not in alarm_dict: + result_dict = alarm_dict.setdefault('alarms', {}).setdefault('Statistics', {}) + + curr_total = m2.groupdict()['total'] + continue + + m3 = p3.match(line) + if m3: + #Current Critical + curr_crit = m3.groupdict()['crit'] + continue + + m4 = p4.match(line) + if m4: + #Current Major + curr_maj = m4.groupdict()['maj'] + continue + + m5 = p5.match(line) + if m5: + #Current Minor + curr_min = m5.groupdict()['min'] + i = 0 + continue + + if i==2: + #Match en linea anterior a 'Cumulative Totals' + m2 = p2.match(line) + if m2: + #Cumulative total + cum_total = m2.groupdict()['total'] + continue + + m3 = p3.match(line) + if m3: + #Cumulative Critical + cum_crit = m3.groupdict()['crit'] + continue + + m4 = p4.match(line) + if m4: + #Current Major + cum_maj = m4.groupdict()['maj'] + continue + + m5 = p5.match(line) + if m5: + #Current total + cum_min = m5.groupdict()['min'] + result_dict['Current'] = {} + result_dict['Current']['TOTAL'] = curr_total + result_dict['Current']['CRITICAL'] = curr_crit + result_dict['Current']['MAJOR'] = curr_maj + result_dict['Current']['MINOR'] = curr_min + result_dict['Cumulative'] = {} + result_dict['Cumulative']['TOTAL'] = cum_total + result_dict['Cumulative']['CRITICAL'] = cum_crit + result_dict['Cumulative']['MAJOR'] = cum_maj + result_dict['Cumulative']['MINOR'] = cum_min + i=0 + continue + + m1 = p1.match(line) + if m1: + #Empiezan valores de Current Outstanding + i=1 + continue + + m6 = p6.match(line) + if m6: + #Empiezan valores de Cumulativa Totals + i=2 + continue + + m7 = p7.match(line) + #Last Alarm Received + if m7: + result_dict = alarm_dict.setdefault('alarms') + last_al = m7.groupdict()['last_alm_date'] + result_dict['LAST_AL'] = last_al + continue + + m8 = p8.match(line) + #Lista Alarm Events + if m8: + if 'OA' not in alarm_dict: + result_dict = alarm_dict.setdefault('alarms').setdefault('OA', {}) + sev = m8.groupdict()['sev'] + card = m8.groupdict()['card'] + event = m8.groupdict()['event'] + result_dict[card] = {} + result_dict[card]['SEV'] = sev + result_dict[card]['EVENT'] = event + continue + + return alarm_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_boot.py b/src/genie/libs/parser/staros/show_boot.py new file mode 100644 index 0000000000..844ae00700 --- /dev/null +++ b/src/genie/libs/parser/staros/show_boot.py @@ -0,0 +1,84 @@ +"""starOS implementation of show_boot.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowBootSchema(MetaParser): + """Schema for show boot""" + + schema = { + 'boot_prio': { + Any(): { + 'image': str, + 'config': str + }, + } + } + + +class ShowBoot(ShowBootSchema): + """Parser for show boot""" + + cli_command = 'show boot' + + """ +[local]COR-VPC-1> show boot +Monday July 11 11:05:31 ART 2022 + +boot system priority 10 \ + image /flash/qvpc-di-21.19.11.bin \ + config /flash/COR-VPC-1_Production.cfg + +boot system priority 20 \ + image /flash/qvpc-di-21.19.11.bin \ + config /flash/COR-VPC-1_Backup.cfg + +boot system priority 30 \ + image /flash/staros.bin \ + config /flash/system.cfg + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + boot_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'(boot system priority\s(?P\d+))') + p1 = re.compile(r'(image\s(?P\S*))') + p2 = re.compile(r'(config\s(?P\S*))') + + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + #boot sys priority + if m: + if 'boot_prio' not in boot_dict: + result_dict = boot_dict.setdefault('boot_prio',{}) + prio = m.groupdict()['priority'] + result_dict[prio] = {} + continue + + m = p1.match(line) + #image + if m: + image = m.groupdict()['image'] + result_dict[prio]['image'] = image + + m = p2.match(line) + #config + if m: + config = m.groupdict()['config'] + result_dict[prio]['config'] = config + continue + + return boot_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_bulkstats.py b/src/genie/libs/parser/staros/show_bulkstats.py new file mode 100644 index 0000000000..4c6aed76b1 --- /dev/null +++ b/src/genie/libs/parser/staros/show_bulkstats.py @@ -0,0 +1,157 @@ +"""starOS implementation of show bulkstats.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Schema, Any, Optional, Use, Or, ListOf + +class ShowbulkstatsSchema(MetaParser): + """Schema for show bulkstats""" + + schema = { + 'bulkstats_info': { + Any(): { + 'Records Collected': str, + 'Records Transmitted': str, + 'Last Succesful transfer':{ + Optional('Year'):str, + Optional('Month'):str, + Optional('Day'): str, + Optional('Time'):str, + }, + 'Last Attemped transfer':{ + Optional('Year'):str, + Optional('Month'):str, + Optional('Day'): str, + Optional('Time'):str, + }, + } + } + } + + +class Showbulkstats(ShowbulkstatsSchema): + """Parser for show bulkstats""" + + cli_command = 'show bulkstats' + + """ + File 2 + Remote File Format: /opt/csvdrop_matrix/%host%_bulkstats_Matrix_%localdate%_%localtime%_%localtz%_15_15.csv + File Header: Version-21.25,%ipaddr%,%date%-%time%,%localdate%-%localtime%,%localtz%,%localtzoffset%,%localdate3%-%localtime3%,%swbuild%,EPC + File Footer: EndOfFile + Bulkstats Receivers: + Primary: 10.32.250.81 using SFTP with username csvuser + File Statistics: + Records awaiting transmission: 0 + Bytes awaiting transmission: 0 + Total records collected: 40507697 + Total bytes collected: 5360711792 + Total records transmitted: 40507697 + Total bytes transmitted: 5361426812 + Total records discarded: 0 + Total bytes discarded: 0 + Last transfer time required: 0 second(s) + Last successful transfer: Monday July 25 16:00:31 CDT 2022 + Last successful tx recs: 5991 + Last successful tx bytes: 794656 + Last attempted transfer: Monday July 25 16:00:31 CDT 2022 + + File 3 + Remote File Format: /opt/csvdrop/%host%_bulkstats_%localdate%_%localtime%_%localtz%_15_15.csv + File Header: Version-21.25,%ipaddr%,%date%-%time%,%localdate%-%localtime%,%localtz%,%localtzoffset%,%localdate3%-%localtime3%,%swbuild%,EPC + File Footer: EndOfFile + Bulkstats Receivers: + Primary: 10.32.250.81 using SFTP with username csvuser + File Statistics: + Records awaiting transmission: 0 + Bytes awaiting transmission: 0 + Total records collected: 41249503 + Total bytes collected: 5458617091 + Total records transmitted: 41249503 + Total bytes transmitted: 5459331709 + Total records discarded: 0 + Total bytes discarded: 0 + Last transfer time required: 1 second(s) + Last successful transfer: Monday July 25 16:00:31 CDT 2022 + Last successful tx recs: 5991 + Last successful tx bytes: 794656 + Last attempted transfer: Monday July 25 16:00:31 CDT 2022 + + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + bulk_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'\s{2}File\s(?P\d+)') + p1 = re.compile(r'\s{6}Total\srecords\scollected:\s+(?P\d+)') + p2 = re.compile(r'\s{6}Total\srecords\stransmitted:\s+(?P\d+)') + p3 = re.compile(r'\s{6}Last\ssuccessful\stransfer:\s+\w+\s(?P\w+)\s(?P\d+)\s(?P\d+:\d+:\d+)\s\w+\s(?P\d+)|\s{6}(?PNo)\ssuccessful\sdata\stransfers') + p4 = re.compile(r'\s{6}Last\sattempted\stransfer:\s+\w+\s(?P\w+)\s(?P\d+)\s(?P\d+:\d+:\d+)\s\w+\s(?P\d+)|\s{6}(?PNo)\sattempted\sdata\stransfers') + + for line in out.splitlines(): + m = p0.match(line) + if m: + if 'bulkstats_info' not in bulk_dict: + result_dict = bulk_dict.setdefault('bulkstats_info',{}) + file = m.groupdict()['file'] + result_dict[file] = {} + + m = p1.match(line) + if m: + if 'bulkstats_info' not in bulk_dict: + result_dict = bulk_dict.setdefault('bulkstats_info',{}) + collect = m.groupdict()['collect'] + result_dict[file]['Records Collected'] = collect + m = p2.match(line) + if m: + if 'bulkstats_info' not in bulk_dict: + result_dict = bulk_dict.setdefault('bulkstats_info',{}) + transmitted = m.groupdict()['transmitted'] + result_dict[file]['Records Transmitted'] = transmitted + m = p3.match(line) + if m: + if 'bulkstats_info' not in bulk_dict: + result_dict = bulk_dict.setdefault('bulkstats_info',{}) + if 'Last Succesful transfer' not in bulk_dict['bulkstats_info'][file]: + result_dict[file].setdefault('Last Succesful transfer',{}) + s_month = m.groupdict()['s_month'] + s_day = m.groupdict()['s_day'] + s_year = m.groupdict()['s_year'] + s_time = m.groupdict()['s_time'] + no = m.groupdict()['no'] + if no: + continue + result_dict[file]['Last Succesful transfer']['Year'] = s_year + result_dict[file]['Last Succesful transfer']['Month'] = s_month + result_dict[file]['Last Succesful transfer']['Day'] = s_day + result_dict[file]['Last Succesful transfer']['Time'] = s_time + + m = p4.match(line) + if m: + if 'bulkstats_info' not in bulk_dict: + result_dict = bulk_dict.setdefault('bulkstats_info',{}) + if 'Last Attemped transfer' not in bulk_dict['bulkstats_info'][file]: + result_dict[file].setdefault('Last Attemped transfer',{}) + a_month = m.groupdict()['a_month'] + a_day = m.groupdict()['a_day'] + a_year = m.groupdict()['a_year'] + a_time = m.groupdict()['a_time'] + no= m.groupdict()['no'] + if no: + continue + result_dict[file]['Last Attemped transfer']['Year'] = a_year + result_dict[file]['Last Attemped transfer']['Month'] = a_month + result_dict[file]['Last Attemped transfer']['Day'] = a_day + result_dict[file]['Last Attemped transfer']['Time'] = a_time + + return bulk_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_card_hardware.py b/src/genie/libs/parser/staros/show_card_hardware.py new file mode 100644 index 0000000000..87836920a5 --- /dev/null +++ b/src/genie/libs/parser/staros/show_card_hardware.py @@ -0,0 +1,123 @@ +"""starOS implementation of show_card_hardware.py + +""" +from operator import contains +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowCardHardwareSchema(MetaParser): + """Schema for show card hardware""" + + schema = { + 'hardware_table': { + Any(): { + 'Card Type': str, + 'Serial Number': str, + 'Card Programmables': str, + }, + } + } + + + +class ShowCardSchema(ShowCardHardwareSchema): + """Parser for show card hardware""" + + cli_command = 'show card hardware' + + """ +Card 1: + Card Type : Data Processing Card 2 (R04) + Description : DPC2 + Cisco Part Number : 73-18817-05 A0 + UDI Serial Number : FLM21500296 + UDI Product ID : ASR55-DPC2-K9 + UDI Version ID : V04 + UDI Top Assem Num : 68-6433-05 A0 + Card Programmables : up to date + BCF2 : on-card 0.18.0 + CAF2 : on-card 0.0.15 + CPU 0 Type/Memory : Socket 0: Xeon E5-2648L v3 B1, 1800 MHz + : Socket 1: Xeon E5-2648L v3 B1, 1800 MHz + : Chipset: DH8920CC A0, 64 GB + CPU 0 DIMM-N0C0D0 P/N : 18ADF2G72PDZ-2G3B + CPU 0 DIMM-N0C1D0 P/N : 18ADF2G72PDZ-2G3B + CPU 0 DIMM-N1C0D0 P/N : 18ADF2G72PDZ-2G3B + CPU 0 DIMM-N1C1D0 P/N : 18ADF2G72PDZ-2G3B + CPU 0 BIOS : on-card-a 0.4.8, on-card-b 0.4.8 + CPU 0 i82599 : eeprom-a 0.0.3 + CPU 0 i210 : eeprom-a 0.0.2 + CPU 0 CFE Loaded : on-card 3.3.3 + CPU 0 CFE ROM : on-card-a 3.3.3, on-card-b 3.3.3 + CPU 0 DH89XXCC : on-card 0.3.4 + CPU 1 Type/Memory : Socket 0: Xeon E5-2648L v3 B1, 1800 MHz + : Socket 1: Xeon E5-2648L v3 B1, 1800 MHz + : Chipset: DH8920CC A0, 64 GB + CPU 1 DIMM-N0C0D0 P/N : 18ADF2G72PDZ-2G3B + CPU 1 DIMM-N0C1D0 P/N : 18ADF2G72PDZ-2G3B + CPU 1 DIMM-N1C0D0 P/N : 18ADF2G72PDZ-2G3B + CPU 1 DIMM-N1C1D0 P/N : 18ADF2G72PDZ-2G3B + CPU 1 BIOS : on-card-a 0.4.8, on-card-b 0.4.8 + CPU 1 i82599 : eeprom-a 0.0.3 + CPU 1 i210 : eeprom-a 0.0.2 + CPU 1 CFE Loaded : on-card 3.3.3 + CPU 1 CFE ROM : on-card-a 3.3.3, on-card-b 3.3.3 + CPU 1 DH89XXCC : on-card 0.3.4 + CPU 2 Type/Memory : Socket 0: Xeon E5-2648L v3 B1, 1800 MHz + : Socket 1: Xeon E5-2648L v3 B1, 1800 MHz + : Chipset: DH8920CC A0, 64 GB + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + card_hardware_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'(?P^Card.\d+)') + p1 = re.compile(r'(UDI.Serial.Number\s+:.(?P\w+))') + p2 = re.compile(r'(Card.Programmables\s+:(?P.*$))') + p3 = re.compile(r'(Description\s+:(?P.*$))') + + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'hardware_table' not in card_hardware_dict: + result_dict = card_hardware_dict.setdefault('hardware_table',{}) + card_id = m.groupdict()['card_id'] + result_dict[card_id] = {} + + m = p1.match(line) + if m: + if 'hardware_table' not in card_hardware_dict: + result_dict = card_hardware_dict.setdefault('hardware_table',{}) + serial_number = m.groupdict()['serial_number'] + result_dict[card_id]["Serial Number"] = serial_number + + m = p2.match(line) + if m: + if 'hardware_table' not in card_hardware_dict: + result_dict = card_hardware_dict.setdefault('hardware_table',{}) + card_prog = m.groupdict()['card_prog'] + result_dict[card_id]["Card Programmables"] = card_prog + + m = p3.match(line) + if m: + if 'hardware_table' not in card_hardware_dict: + result_dict = card_hardware_dict.setdefault('hardware_table',{}) + type = m.groupdict()['type'] + if "CHASSIS" in type: + type ="MIO" + result_dict[card_id]["Card Type"] = type + continue + + return card_hardware_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_card_table.py b/src/genie/libs/parser/staros/show_card_table.py new file mode 100644 index 0000000000..ef145c7f66 --- /dev/null +++ b/src/genie/libs/parser/staros/show_card_table.py @@ -0,0 +1,80 @@ +"""starOS implementation of show_card_table.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowCardTableSchema(MetaParser): + """Schema for show card table""" + + schema = { + 'card_table': { + Any():{ + 'TYPE': str, + 'STATE': str, + 'SPOF': str + }, + } + } + + +class ShowCardTable(ShowCardTableSchema): + """Parser for show card table""" + + cli_command = 'show card table' + + """ +Slot Card Type Oper State SPOF Attach +----------- -------------------------------------- ------------- ---- ------ + 1: DPC Data Processing Card 2 Active No + 2: DPC Data Processing Card 2 Active No + 3: DPC Data Processing Card 2 Active No + 4: DPC Data Processing Card 2 Standby - + 5: MMIO Management & 20x10Gb I/O Card Active No + 6: MMIO Management & 20x10Gb I/O Card Standby - + 7: DPC Data Processing Card 2 Active No + 8: DPC Data Processing Card 2 Active No + 9: DPC Data Processing Card 2 Active No +10: DPC Data Processing Card 2 Active No +11: SSC System Status Card Active No +12: SSC System Status Card Active No +13: FSC None - - +14: FSC Fabric & 1x400GB Storage Card Active No +15: FSC Fabric & 1x400GB Storage Card Active No +16: FSC Fabric & 1x400GB Storage Card Active No +17: FSC Fabric & 1x400GB Storage Card Active No + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + card_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'((?P\d+):\s\w+\s+(?P.*?\ )\s+(?P\w+|.)\s+(?P\w+|.))') + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'card_table' not in card_dict: + result_dict = card_dict.setdefault('card_table',{}) + slot = m.groupdict()['slot'] + card_type = m.groupdict()['card_type'] + state = m.groupdict()['state'] + spof = m.groupdict()['spof'] + + result_dict[slot] = {} + result_dict[slot]['TYPE'] = card_type + result_dict[slot]['STATE'] = state + result_dict[slot]['SPOF'] = spof + continue + + return card_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_cloud_performance_dinnet.py b/src/genie/libs/parser/staros/show_cloud_performance_dinnet.py new file mode 100644 index 0000000000..0d82775873 --- /dev/null +++ b/src/genie/libs/parser/staros/show_cloud_performance_dinnet.py @@ -0,0 +1,109 @@ +"""starOS implementation of show_card_table.py +Author: Luis Antonio Villalobos (luisvill) + +""" +import re +from genie.metaparser import MetaParser +#from genie.metaparser.util.exceptions import SchemaEmptyParserError +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowCloudDinetSchema(MetaParser): + """Schema for show cloud performance dinet""" + schema = { + 'cloud_per_dinet': { + 'Dinet': { + Any(): { + 'Current': { + 'Rx': str, + 'Tx':str, + }, + '5min': { + 'Rx': str, + 'Tx':str, + }, + '15min':{ + 'Rx': str, + 'Tx':str, + }, + }, + }, + } + } + +class ShowCloud(ShowCloudDinetSchema): +#class ShowCloud(): + """Parser for show cloud performance dinet""" + + cli_command = 'show cloud performance dinet' + + """ + ----- Average DINet Performance (in Mbps) ----- + Card Current 5min 15min + Rx Tx Rx Tx Rx Tx + ----- ------- ------- ------- ------- ------- ------- + 1 58.433 2.149 57.447 2.285 57.518 2.214 + 2 171.808 64.844 104.556 93.002 108.333 89.524 + 3 2770 2835 2728 2968 2793 2957 + 4 2807 3036 2788 2985 2747 3022 + 5 0.000 0.000 0.000 0.000 0.000 0.000 + 6 2848 2865 2712 2927 2743 2940 + 7 207.381 2856 243.307 2888 239.416 2923 + 8 2863 2861 2818 2922 2835 2938 + 9 74.205 2886 74.026 2871 73.945 2870 + 10 2809 3124 2773 3044 2762 2945 + 11 2629 2979 2713 2962 2764 2991 + 12 2545 3630 2647 3576 2628 3648 + 13 2757 1183 2900 1201 2902 1238 + 14 2790 1202 2804 1223 2841 1247 + 15 2853 1462 2965 1416 2931 1390 + 16 2885 1170 2950 1222 2948 1207 + 17 2763 1324 2807 1328 2834 1331 + """ + + def cli(self, output=None): + if output is None: + salida = self.device.execute(self.cli_command) + else: + salida = output + + # initial return dictionary + dinet_dict = {} + result_dict = {} + + # Define the regex pattern for matching the rows with values + pattern = re.compile(r'^(?P\s+\d+)\s+(?P\d+.\d+)\s+(?P\d+.\d+)\s+(?P\d+.\d+)\s+(?P\d+.\d+)\s+(?P\d+.\d+)\s+(?P\d+.\d+)', re.MULTILINE) + + for match in salida.splitlines(): + m = pattern.match(match) + if m: + if 'cloud_per_dinet' not in dinet_dict: + result_dict = dinet_dict.setdefault('cloud_per_dinet',{}) + if 'Dinet' not in dinet_dict['cloud_per_dinet']: + result_dict = dinet_dict['cloud_per_dinet'].setdefault('Dinet',{})#Setdefault lo utilizo cuando tengo las llaves definidas. + + card = m.groupdict()['Card'].strip() + current_rx = m.groupdict()['Current_Rx'].strip() + current_tx = m.groupdict()['Current_Tx'].strip() + fivemin_rx = m.groupdict()['Fivemin_Rx'].strip() + fivemin_tx = m.groupdict()['Fivemin_Tx'].strip() + fifteen_rx = m.groupdict()['Fifteenmin_Rx'].strip() + fifteen_tx = m.groupdict()['Fifteenmin_Tx'].strip() + + result_dict[card] = {}#Se utiliza cuando tengo el Any() + + if 'Current' not in result_dict[card]: + result_dict[card]['Current'] = { + 'Rx': current_rx, + 'Tx': current_tx + } + if '5min' not in result_dict[card]: + result_dict[card]['5min'] = { + 'Rx': fivemin_rx, + 'Tx': fivemin_tx + } + if '15min' not in result_dict[card]: + result_dict[card]['15min'] = { + 'Rx': fifteen_rx, + 'Tx': fifteen_tx + } + return dinet_dict diff --git a/src/genie/libs/parser/staros/show_cloud_performance_summary.py b/src/genie/libs/parser/staros/show_cloud_performance_summary.py new file mode 100644 index 0000000000..b903e0d19a --- /dev/null +++ b/src/genie/libs/parser/staros/show_cloud_performance_summary.py @@ -0,0 +1,192 @@ +"""starOS implementation of show_card_table.py +Author: Luis Antonio Villalobos (luisvill) + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowCloudSchema(MetaParser): + """Schema for show cloud performance summary""" + + schema = { + 'cloud_performance': { + 'Dinet': { + Any(): { + 'Current': { + 'Rx': str, + 'Tx':str, + }, + '5min': { + 'Rx': str, + 'Tx':str, + }, + '15min':{ + 'Rx': str, + 'Tx':str, + }, + }, + }, + 'Port': { + Any(): { + 'Current': { + 'Rx': str, + 'Tx':str, + }, + '5min': { + 'Rx': str, + 'Tx':str, + }, + '15min': { + 'Rx': str, + 'Tx':str, + }, + }, + }, + } + } + + +class ShowCloud(ShowCloudSchema): + """Parser for show cloud performance summary""" + + cli_command = 'show cloud performance summary' + + """ + ----- Average DINet Performance (in Mbps) ----- + Card Current 5min 15min + Rx Tx Rx Tx Rx Tx + ----- ------- ------- ------- ------- ------- ------- + 1 58.433 2.149 57.447 2.285 57.518 2.214 + 2 171.808 64.844 104.556 93.002 108.333 89.524 + 3 2770 2835 2728 2968 2793 2957 + 4 2807 3036 2788 2985 2747 3022 + 5 0.000 0.000 0.000 0.000 0.000 0.000 + 6 2848 2865 2712 2927 2743 2940 + 7 207.381 2856 243.307 2888 239.416 2923 + 8 2863 2861 2818 2922 2835 2938 + 9 74.205 2886 74.026 2871 73.945 2870 + 10 2809 3124 2773 3044 2762 2945 + 11 2629 2979 2713 2962 2764 2991 + 12 2545 3630 2647 3576 2628 3648 + 13 2757 1183 2900 1201 2902 1238 + 14 2790 1202 2804 1223 2841 1247 + 15 2853 1462 2965 1416 2931 1390 + 16 2885 1170 2950 1222 2948 1207 + 17 2763 1324 2807 1328 2834 1331 + + --- Average Aggregated Port Performance (in Mbps) --- + Card Current 5min 15min + Rx Tx Rx Tx Rx Tx + ----- ------- ------- ------- ------- ------- ------- + 1 0.000 0.000 0.000 0.000 0.000 0.000 + 2 0.008 0.035 0.251 21.400 0.248 21.513 + 3 2674 2583 2757 2510 2739 2553 + 4 2800 2564 2762 2554 2830 2541 + 5 2604 2440 2750 2440 2772 2474 + 6 2654 2607 2721 2482 2736 2515 + 7 2646 0.133 2672 28.039 2712 29.608 + 8 2649 2623 2715 2597 2731 2605 + 9 2736 0.040 2708 0.040 2705 0.040 + 10 2907 2564 2848 2544 2752 2545 + 11 2722 2367 2700 2435 2739 2491 + 12 3281 2377 3249 2491 3337 2486 + 13 863.871 2358 913.634 2534 942.468 2512 + 14 901.845 2418 919.626 2417 951.579 2460 + 15 1173 2476 1142 2590 1119 2563 + 16 871.308 2498 920.274 2543 913.015 2552 + 17 1039 2387 1040 2437 1045 2455 + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + cloud_dict = {} + result_dict = {} + + # Define the regex pattern for matching the header of the second table + second_table_header_pattern = re.compile(r'--- Average Aggregated Port Performance \(in Mbps\) ---') + + # Find the position where the second table starts + second_table_start = second_table_header_pattern.search(out).start() + + # Separate the data into two parts for each table + first_table_data = out[:second_table_start] # Data before the header of the second table + second_table_data = out[second_table_start:] # Data from the header of the second table and after + + # Define the regex pattern for matching the rows with values + pattern = re.compile(r'^(?P\s+\d+)\s+(?P\d+.\d+)\s+(?P\d+.\d+)\s+(?P\d+.\d+)\s+(?P\d+.\d+)\s+(?P\d+.\d+)\s+(?P\d+.\d+)', re.MULTILINE) + + for match in first_table_data.splitlines(): + m = pattern.match(match) + if m: + if 'cloud_performance' not in cloud_dict: + result_dict = cloud_dict.setdefault('cloud_performance',{}) + if 'Dinet' not in cloud_dict['cloud_performance']: + result_dict = cloud_dict['cloud_performance'].setdefault('Dinet',{})#Setdefault lo utilizo cuando tengo las llaves definidas. + + card = m.groupdict()['Card'].strip() + current_rx = m.groupdict()['Current_Rx'].strip() + current_tx = m.groupdict()['Current_Tx'].strip() + fivemin_rx = m.groupdict()['Fivemin_Rx'].strip() + fivemin_tx = m.groupdict()['Fivemin_Tx'].strip() + fifteen_rx = m.groupdict()['Fifteenmin_Rx'].strip() + fifteen_tx = m.groupdict()['Fifteenmin_Tx'].strip() + + result_dict[card] = {}#Se utiliza cuando tengo el Any() + + if 'Current' not in result_dict[card]: + result_dict[card]['Current'] = { + 'Rx': current_rx, + 'Tx': current_tx + } + if '5min' not in result_dict[card]: + result_dict[card]['5min'] = { + 'Rx': fivemin_rx, + 'Tx': fivemin_tx + } + if '15min' not in result_dict[card]: + result_dict[card]['15min'] = { + 'Rx': fifteen_rx, + 'Tx': fifteen_tx + } + + for match in second_table_data.splitlines(): + m = pattern.match(match) + if m: + if 'cloud_performance' not in cloud_dict: + result_dict = cloud_dict.setdefault('cloud_performance',{}) + if 'Port' not in cloud_dict['cloud_performance']: + result_dict = cloud_dict['cloud_performance'].setdefault('Port',{})#Setdefault lo utilizo cuando tengo las llaves definidas. + + card = m.groupdict()['Card'].strip() + current_rx = m.groupdict()['Current_Rx'].strip() + current_tx = m.groupdict()['Current_Tx'].strip() + fivemin_rx = m.groupdict()['Fivemin_Rx'].strip() + fivemin_tx = m.groupdict()['Fivemin_Tx'].strip() + fifteen_rx = m.groupdict()['Fifteenmin_Rx'].strip() + fifteen_tx = m.groupdict()['Fifteenmin_Tx'].strip() + + result_dict[card] = {}#Se utiliza cuando tengo el Any() + if 'Current' not in result_dict[card]: + result_dict[card]['Current'] = { + 'Rx': current_rx, + 'Tx': current_tx + } + if '5min' not in result_dict[card]: + result_dict[card]['5min'] = { + 'Rx': fivemin_rx, + 'Tx': fivemin_tx + } + if '15min' not in result_dict[card]: + result_dict[card]['15min'] = { + 'Rx': fifteen_rx, + 'Tx': fifteen_tx + } + + return cloud_dict + diff --git a/src/genie/libs/parser/staros/show_config_error_verbose.py b/src/genie/libs/parser/staros/show_config_error_verbose.py new file mode 100644 index 0000000000..4cd98c23b9 --- /dev/null +++ b/src/genie/libs/parser/staros/show_config_error_verbose.py @@ -0,0 +1,726 @@ +"""starOS implementation of show_config_errors_verbose.py +Author: Luis Antonio Villalobos (luisvill) + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema, Optional + + +class ShowConfigErrors(MetaParser): + schema = { + 'config_errors': { + Any(): { + 'Errors': str, + 'Warnings': str + } + } + } + + +class ShowErrorsVerbose(ShowConfigErrors): + """Parser for show configuration errors verbose""" + + cli_command = 'show configuration errors verbose' + + """ + ###################################################################################### + # Displaying Diameter Configuration errors + ###################################################################################### + Total 0 error(s) in this section ! + + Info : No routes configured under endpoint : GY_EMBLACOM + + Info : No routes configured under endpoint : Gx + + Info : No routes configured under endpoint : Gx_Labo + + Info : No routes configured under endpoint : Gx_PrePro + + Info : No routes configured under endpoint : Gy_Py + + Info : No routes configured under endpoint : Gy_Py_labo + + Info : No routes configured under endpoint : Gy_vPy + + Info : No routes configured under endpoint : Gx-PY + + Info : No Routes configured under any endpoint + + Total 9 warning(s) in this section! + + ###################################################################################### + # Displaying Active-charging system errors + ###################################################################################### + Error : Group of Ruledef has application type as POST PROCESSING which is not allowed + Error : group-of-ruledefs is not used in any rulebase. It can be a dynamically enabled ADC group and could be ignored. + Error : Ruledef is not used in any rulebase or group-of-ruledefs. It can be a dynamically enabled ADC ruledef and could be ignored. + Error : Ruledef is not used in any rulebase or group-of-ruledefs. It can be a dynamically enabled ADC ruledef and could be ignored. + Error : Ruledef is not used in any rulebase or group-of-ruledefs. It can be a dynamically enabled ADC ruledef and could be ignored. + Error : Ruledef is not used in any rulebase or group-of-ruledefs. It can be a dynamically enabled ADC ruledef and could be ignored. + Error : Ruledef is not used in any rulebase or group-of-ruledefs. It can be a dynamically enabled ADC ruledef and could be ignored. + Error : Ruledef is not used in any rulebase or group-of-ruledefs. It can be a dynamically enabled ADC ruledef and could be ignored. + Error : Post-processing group-of-ruledefs is used in the rulebase but not defined in the active-charging service . + Error : Post-processing group-of-ruledefs is used in the rulebase but not defined in the active-charging service . + Total 10 error(s) in this section ! + + Warning : Charging Ruledef uses multiple "sni" lines but does not have a "multi-line-or all-lines". + Warning : Charging Ruledef uses multiple "server-domain-name" lines but does not have a "multi-line-or all-lines". + Warning : Charging Ruledef uses multiple "server-domain-name" lines but does not have a "multi-line-or all-lines". + Warning : Charging Ruledef uses multiple "server-port" lines but does not have a "multi-line-or all-lines". + Warning : Charging Ruledef uses multiple "payload-length" lines but does not have a "multi-line-or all-lines". + Warning : Charging Ruledef uses multiple "payload-length" lines but does not have a "multi-line-or all-lines". + Warning : Charging Ruledef uses multiple "payload-length" lines but does not have a "multi-line-or all-lines". + Warning : Post-Processing Ruledef uses multiple "payload-length" lines but does not have a "multi-line-or all-lines". + Warning : Post-Processing Ruledef uses multiple "payload-length" lines but does not have a "multi-line-or all-lines". + Warning : Post-Processing Ruledef uses multiple "payload-length" lines but does not have a "multi-line-or all-lines". + Warning : Default rule (i.e. a ruledef with just the "ip any-match = TRUE" expression) is specified in the rulebase , but not at lowest priority action command. + Warning : Default rule (i.e. a ruledef with just the "ip any-match = TRUE" expression) is specified in the rulebase , but not at lowest priority action command. + Total 12 warning(s) in this section! + + ###################################################################################### + # Displaying CSCF-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying PDSN-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying HA-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying FA-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying LNS-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying LAC-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying Closed-rp-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying IPSG-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying SAMOG-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying Global AAA-configuration errors + ###################################################################################### + Total 0 error(s) in this section ! + + Warning %: NAS-IP is not configured in Group , Context . + + Warning %: NAS-IP is not configured in Group , Context . + + Warning %: NAS-IP is not configured in Group , Context . + + Warning %: NAS-IP is not configured in Group , Context . + + Warning %: NAS-IP is not configured in Group , Context . + + Warning %: NAS-IP is not configured in Group , Context . + + Warning %: NAS-IP is not configured in Group , Context . + + Warning %: NAS-IP is not configured in Group , Context . + + Warning %: Charging-agent IP <0.0.0.0> of default GTPP group is NOT ACTIVE, context + + Warning %: Charging-agent IP <0.0.0.0> of default GTPP group is NOT ACTIVE, context + + Warning %: Charging-agent IP <0.0.0.0> of default GTPP group is NOT ACTIVE, context + + Warning %: Charging-agent IP <0.0.0.0> of default GTPP group is NOT ACTIVE, context + + Warning %: Charging-agent IP <0.0.0.0> of default GTPP group is NOT ACTIVE, context + + Warning %: Charging-agent IP <0.0.0.0> of default GTPP group is NOT ACTIVE, context + + Warning %: Charging-agent IP <0.0.0.0> of default GTPP group is NOT ACTIVE, context + + Total 15 warning(s) in this section! + + ###################################################################################### + # Displaying IMSA-configuration errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying Local Subscriber-configuration errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying Policy Group system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying GGSN-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying APN-configuration errors + ###################################################################################### + Error : Rulebase configured for APN dictates generation of eGCDRs/PGWCDR's but associated GTPP group does not have a valid GTPP dictionary configuration. + + Total 1 error(s) in this section ! + + Warning : Mediation context different than context for APN + + Warning : Mediation context different than context for APN + + Total 2 warning(s) in this section! + + ###################################################################################### + # Displaying PDIF-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying PDG-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying FNG-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying IMSSH-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying Credit Control-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying SGSN-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying SGTP-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying IUPS-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying MAP-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying CAMEL-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying Sccp-Network system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying SGSN-Mode system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying Operator-Policy system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying Call-Control-Profile system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying APN-Profile system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying IMEI-Profile system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying APN-Remap-Table system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying Gs-Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying IPMS errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying MME HSS service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying GPRS-Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying CS-Network system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying PS-Network system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying HNBGW-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying cbs-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying MME Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying HSGW-Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying IMSUE-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying Accounting policy system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying QCI mapping system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying PGW-Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying SGW-Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying EGTP-Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying User-Plane-Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying Subscriber-map system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying PCC-Policy Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying PCC-Quota Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying PCC Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying Event Notification Interface errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying DNS Client system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Warning : DNS client is not configured for context + Warning : DNS client is not configured for context + Warning : DNS client is not configured for context + Warning : DNS client is not configured for context + Warning : DNS client is not configured for context + Warning : DNS client is not configured for context + Warning : DNS client is not configured for context + Warning : DNS client is not configured for context + Total 8 warning(s) in this section! + + ###################################################################################### + # Displaying Local policy Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying IPNE Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying SGS Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying HENBGW Access Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying HENBGW Network Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying ALCAP-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying SAEGW-Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying SS7RD system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying EPDG-service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying CGW-Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying Peer Map Rules system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying WSG system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying Qos Marking + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying SLS Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying SBc Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying EMBMS-Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying Throttling Override Policy errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying S102 Service system errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying BFD Linkagg Peer errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying Linkagg errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying FE (Forwarding Element) errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying UE Overload Control Profile config errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + + ###################################################################################### + # Displaying UE Overload Action Profile config errors + ###################################################################################### + Total 0 error(s) in this section ! + + Total 0 warning(s) in this section! + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + # initial return dictionary + config_errors_dict = {} + result_dict = {} + + # Define the regex pattern for matching the rows with values + errors_regex = re.compile( + r'^Total\s+(?P\d+)\s+error\S+\s+in this section', + re.MULTILINE) + warnings_regex = re.compile( + r'^Total\s+(?P\d+)\s+warning\S+\s+in this section', + re.MULTILINE) + displaying_regex = re.compile( + r'^.\s+Displaying\s+(?P(.*))', + re.MULTILINE) + # For Loop to get all the values from output + # Split a string into a list where each line is a list item + for match in out.splitlines(): + # Matching values in first_regex + first = displaying_regex.match(match) + if first: + if 'config_errors' not in config_errors_dict: + result_dict = config_errors_dict.setdefault( + 'config_errors', {} + ) + # Asigning matchings to variables + displaying = first.groupdict()['name'].strip() + + # Adding values as keys to dictionary + result_dict[displaying] = {} + second = errors_regex.match(match) + if second: + if 'config_errors' not in config_errors_dict: + result_dict = config_errors_dict.setdefault( + 'config_errors', {} + ) + # Asigning matchings to variables + errors = second.groupdict()['errors'].strip() + # Adding values to dictionary + result_dict[displaying]['Errors'] = errors + third = warnings_regex.match(match) + if third: + if 'config_errors' not in config_errors_dict: + result_dict = config_errors_dict.setdefault( + 'config_errors', {} + ) + # Asigning matchings to variables + warnings = third.groupdict()['warnings'].strip() + # Adding values to dictionary + result_dict[displaying]['Warnings'] = warnings + return (config_errors_dict) diff --git a/src/genie/libs/parser/staros/show_context_all.py b/src/genie/libs/parser/staros/show_context_all.py new file mode 100644 index 0000000000..c52f75d415 --- /dev/null +++ b/src/genie/libs/parser/staros/show_context_all.py @@ -0,0 +1,70 @@ +"""starOS implementation of show_card_table.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowContextAllSchema(MetaParser): + """Schema for show card table""" + + schema = { + 'context_table':{ + Any():{ + 'NAME': str, + 'STATE': str, + }, + } + } + + +class ShowContextAll(ShowContextAllSchema): + """Parser for show context all""" + + cli_command = 'show context all' + + """ +Context Name ContextID State Description +--------------- --------- ---------- ----------------------- +local 1 Active +SAEGW 2 Active +SGi_Internet 3 Active +SGi_VAS 4 Active +Ga 5 Active +Gy 6 Active +Gx 7 Active +Lawful_Intercept 8 Active +SGi_HPPTT 9 Active +ePDG 10 Active + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + card_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'(^(?P\w+)\s+(?P\d*)\s+(?P\w+))') + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'context_table' not in card_dict: + result_dict = card_dict.setdefault('context_table',{}) + name = m.groupdict()['name'] + idnum = m.groupdict()['id'] + state = m.groupdict()['state'] + + result_dict[idnum] = {} + result_dict[idnum]['NAME'] = name + result_dict[idnum]['STATE'] = state + continue + + return card_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_cpu_table.py b/src/genie/libs/parser/staros/show_cpu_table.py new file mode 100644 index 0000000000..35594e9352 --- /dev/null +++ b/src/genie/libs/parser/staros/show_cpu_table.py @@ -0,0 +1,90 @@ +"""starOS implementation of show_cpu_table.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowCpuTableSchema(MetaParser): + """Schema for show version""" + + schema = { + 'cpu_table': { + Any(): { + 'state': str, + 'load now': str, + 'load 5min': str, + 'load 15min': str, + 'cpu now': str, + 'cpu 5min': str, + 'cpu 15min': str, + 'mem now': str, + 'mem 5min': str, + 'mem 15min': str, + 'mem total': str, + }, + } + } + + +class ShowCpuTable(ShowCpuTableSchema): + """Parser for show cpu table""" + + cli_command = 'show cpu table' + + """ + --------Load-------- ------CPU-Usage----- ---------Memory-------- + cpu state now 5min 15min now 5min 15min now 5min 15min total +---- ----- ------ ------ ------ ------ ------ ------ ----- ----- ----- ----- + 1/0 Actve 3.51 2.90 2.57 1.1% 1.1% 0.9% 7035M 7034M 7032M 8192M + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + cpu_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'^((?P\d+.\d+)\s+(?P\S+)\s+(?P\d+.\d+)\s+(?P\d+.\d+)\s+(?P\d+.\d+)\s+(?P\d+.\d+%)\s+(?P\d+.\d+%)\s+(?P\d+.\d+%)\s+(?P\d+.\d+(M|G))\s+(?P\d+.\d+(M|G))\s+(?P\d+.\d+(M|G))\s+(?P\d+.\d+(M|G)))') + + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'cpu_table' not in cpu_dict: + result_dict = cpu_dict.setdefault('cpu_table',{}) + cpu = m.groupdict()['cpu_id'] + state = m.groupdict()['state'] + load_now = m.groupdict()['load_now'] + load_5min = m.groupdict()['load_5min'] + load_15min = m.groupdict()['load_5min'] + CPU_now = m.groupdict()['CPU_now'] + CPU_5min = m.groupdict()['CPU_5min'] + CPU_15min = m.groupdict()['CPU_15min'] + Mem_now = m.groupdict()['Mem_now'] + Mem_5min = m.groupdict()['Mem_5min'] + Mem_15min = m.groupdict()['Mem_15min'] + Mem_total = m.groupdict()['Mem_total'] + + result_dict[cpu] = {} + result_dict[cpu]['state'] = state + result_dict[cpu]['load now'] = load_now + result_dict[cpu]['load 5min'] = load_5min + result_dict[cpu]['load 15min'] = load_15min + result_dict[cpu]['cpu now'] = CPU_now + result_dict[cpu]['cpu 5min'] = CPU_5min + result_dict[cpu]['cpu 15min'] = CPU_15min + result_dict[cpu]['mem now'] = Mem_now + result_dict[cpu]['mem 5min'] = Mem_5min + result_dict[cpu]['mem 15min'] = Mem_15min + result_dict[cpu]['mem total'] = Mem_total + continue + + return cpu_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_crash_list.py b/src/genie/libs/parser/staros/show_crash_list.py new file mode 100644 index 0000000000..379d01fa34 --- /dev/null +++ b/src/genie/libs/parser/staros/show_crash_list.py @@ -0,0 +1,105 @@ +"""starOS implementation of show_crash_list.py + +""" +import re +from tokenize import Number +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowCrashListSchema(MetaParser): + """Schema for show crash list""" + + schema = { + 'crash_table': { + Any(): { + 'Date': str, + 'Instance': str, + 'CARD/CPU/PID': str, + 'SW Version': str, + 'MIO': str, + }, + } + } +class ShowCrashList(ShowCrashListSchema): + """Parser for show crash list""" + + cli_command = 'show crash list' + + """ +=== ==================== ======== ========== =============== ======================= +# Time Process Card/CPU/ SW HW_SER_NUM + PID VERSION MIO / Crash Card +=== ==================== ======== ========== =============== ======================= + +1 2020-Oct-15+13:57:40 sessmgr 01/0/48672 21.13.1 FLM2236045H/FLM21500296 +2 2020-Oct-15+14:06:56 sessmgr 01/0/48672 21.13.1 FLM2236045H/FLM21500296 +3 2020-Oct-15+14:11:29 sessmgr 01/0/48672 21.13.1 FLM2236045H/FLM21500296 + +[local]COR-VPC-1# show crash list +Monday February 05 02:44:49 ART 2024 +=== ==================== ======== ========== =============== ======================= +# Time Process Card/CPU/ SW HW_SER_NUM + PID VERSION CF / Crash Card +=== ==================== ======== ========== =============== ======================= + +1 2020-Aug-03+04:07:26 sessmgr 08/0/11914 21.15.28 NA +2 2020-Aug-03+18:07:10 sessmgr 08/0/12007 21.15.28 NA +3 2020-Aug-03+18:07:23 sessmgr 07/0/12017 21.15.28 NA +4 2020-Aug-12+13:21:04 sessmgr 10/0/17154 21.15.28 NA +5 2020-Aug-12+13:21:37 sessmgr 10/0/20541 21.15.28 NA +6 2020-Sep-21+17:27:26 sessmgr 06/0/13426 21.15.28 NA +7 2020-Sep-21+17:55:18 egtpinmg 04/0/12642 21.15.28 NA +8 2020-Sep-22+00:47:29 sessmgr 10/0/13441 21.15.28 NA +9 2020-Sep-22+00:48:31 sessmgr 08/0/11726 21.15.28 NA +10 2020-Sep-22+11:08:54 egtpinmg 04/0/12642 21.15.28 NA +11 2020-Sep-22+11:10:55 sessmgr 09/0/11999 21.15.28 NA +12 2020-Nov-14+21:07:39 sessmgr 05/0/11848 21.15.28 NA +13 2020-Nov-20+01:02:35 sessmgr 05/0/24099 21.15.28 NA +14 2020-Dec-06+23:32:09 sessmgr 03/0/11985 21.15.28 NA +15 2022-Oct-17+00:02:11 sessmgr 03/0/07509 21.19.11 NA +16 2022-Oct-17+17:37:00 sessmgr 07/0/11509 21.19.11 NA +17 2022-Oct-23+23:41:41 sessmgr 10/0/00684 21.19.11 NA +18 2022-Dec-05+23:53:33 sessmgr 09/0/06495 21.25.10 NA +19 2022-Dec-07+06:10:38 sessmgr 06/0/01122 21.25.10 NA +20 2022-Dec-15+00:34:16 cli 01/0/18359 21.25.10 NA +21 2024-Feb-01+12:44:40 vpnmgr 02/0/08392 21.25.10 NA + +Total Crashes : 240 + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + crash_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'(?P\d+)\s+(?P\d{4}-[A-Za-z]{3}-\d{2}\+\d{2}:\d{2}:\d{2})\s+(?P[a-z]+)\s+(?P\d{2}\/\d{1}\/\d{5})\s+(?P[\d\.]+)\s+(?P[A-Z\d\/]+)') + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'crash_table' not in crash_dict: + result_dict = crash_dict.setdefault('crash_table',{}) + Number = m.groupdict()['Number'] + Date = m.groupdict()['Date'] + Instance = m.groupdict()['Instance'] + Card_CPU_PID = m.groupdict()['Card_CPU_PID'] + SW_Version = m.groupdict()['SW_Version'] + card = m.groupdict()['card'] + + result_dict[Number] = {} + result_dict[Number]['Date'] = Date + result_dict[Number]['Instance'] = Instance + result_dict[Number]['CARD/CPU/PID'] = Card_CPU_PID + result_dict[Number]['SW Version'] = SW_Version + result_dict[Number]['MIO'] = card + continue + + return crash_dict diff --git a/src/genie/libs/parser/staros/show_diameter_peers_full.py b/src/genie/libs/parser/staros/show_diameter_peers_full.py new file mode 100644 index 0000000000..2537f82411 --- /dev/null +++ b/src/genie/libs/parser/staros/show_diameter_peers_full.py @@ -0,0 +1,298 @@ +"""starOS implementation of show diameter peers full.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Schema, Any, Optional, Use, Or, ListOf + +class ShowDiameterSchema(MetaParser): + """Schema for show diameter peers full""" + + schema = { + 'diameter_info': { + Any(): { + 'Peer Hostname': str, + 'Local Hostname': str, + 'Peer Realm': str, + 'Local Realm': str, + 'Priority channel': str, + 'DSCP configured': str, + Optional('Peer Address'): ListOf(str), + Optional('Local Address'): ListOf(str), + 'State': str, + 'Task': str, + 'Admin Status': str, + }, + 'Peer Summary':{ + 'OPEN':str, + 'CLOSED':str, + 'INTERMEDIATE':str, + }, + }, + } + + +class ShowDiameter(ShowDiameterSchema): + """Parser for show diameter peers full""" + + cli_command = 'show diameter peers full' + + """ + Peer Hostname: s6b.nz.1dra01.mty.ims.mnc050.mcc334.3gppnetwork.org + Local Hostname: s6b.sz.2pgw07.leo.ims.mnc050.mcc334.3gppnetwork.org + Peer Realm: ims.mnc050.mcc334.3gppnetwork.org + Local Realm: ims.mnc050.mcc334.3gppnetwork.org + Priority channel: No + DSCP configured: 0x28 + Peer Address: 10.194.65.36:3869 + Local Address: 10.33.10.198:52302 + State: OPEN [TCP] + CPU: 8/0 Task: diamproxy-2 + Messages Out/Queued: N/A + Supported Vendor IDs: 10415 + Admin Status: Enable + DPR Disconnect: N/A + Peer Backoff Timer running:N/A + + Peer Hostname: s6b.nz.1dra01.mty.ims.mnc050.mcc334.3gppnetwork.org + Local Hostname: s6b.sz.2pgw02.leo.ims.mnc050.mcc334.3gppnetwork.org + Peer Realm: ims.mnc050.mcc334.3gppnetwork.org + Local Realm: ims.mnc050.mcc334.3gppnetwork.org + Priority channel: No + DSCP configured: 0x28 + Peer Address: 10.194.65.36:3869 + Local Address: 10.33.10.193:55533 + State: OPEN [TCP] + CPU: 10/0 Task: diamproxy-3 + Messages Out/Queued: N/A + Supported Vendor IDs: 10415 + Admin Status: Enable + DPR Disconnect: N/A + Peer Backoff Timer running:N/A + + Peer Hostname: s6b.nz.1dra01.mty.ims.mnc050.mcc334.3gppnetwork.org + Local Hostname: s6b.sz.2pgw06.leo.ims.mnc050.mcc334.3gppnetwork.org + Peer Realm: ims.mnc050.mcc334.3gppnetwork.org + Local Realm: ims.mnc050.mcc334.3gppnetwork.org + Priority channel: No + DSCP configured: 0x28 + Peer Address: 10.194.65.36:3869 + Local Address: 10.33.10.197:40193 + State: OPEN [TCP] + CPU: 3/0 Task: diamproxy-4 + Messages Out/Queued: N/A + Supported Vendor IDs: 10415 + Admin Status: Enable + DPR Disconnect: N/A + Peer Backoff Timer running:N/A + + Peer Hostname: s6b.nz.1dra01.mty.ims.mnc050.mcc334.3gppnetwork.org + Local Hostname: s6b.sz.2pgw04.leo.ims.mnc050.mcc334.3gppnetwork.org + Peer Realm: ims.mnc050.mcc334.3gppnetwork.org + Local Realm: ims.mnc050.mcc334.3gppnetwork.org + Priority channel: No + DSCP configured: 0x28 + Peer Address: 10.194.65.36:3869 + Local Address: 10.33.10.195:47995 + State: OPEN [TCP] + CPU: 1/0 Task: diamproxy-5 + Messages Out/Queued: N/A + Supported Vendor IDs: 10415 + Admin Status: Enable + DPR Disconnect: N/A + Peer Backoff Timer running:N/A + + Peer Hostname: s6b.nz.1dra01.mty.ims.mnc050.mcc334.3gppnetwork.org + Local Hostname: s6b.sz.2pgw03.leo.ims.mnc050.mcc334.3gppnetwork.org + Peer Realm: ims.mnc050.mcc334.3gppnetwork.org + Local Realm: ims.mnc050.mcc334.3gppnetwork.org + Priority channel: No + DSCP configured: 0x28 + Peer Address: 10.194.65.36:3869 + Local Address: 10.33.10.194:44689 + State: OPEN [TCP] + CPU: 2/0 Task: diamproxy-6 + Messages Out/Queued: N/A + Supported Vendor IDs: 10415 + Admin Status: Enable + DPR Disconnect: N/A + Peer Backoff Timer running:N/A + + Peer Hostname: s6b.nz.1dra01.mty.ims.mnc050.mcc334.3gppnetwork.org + Local Hostname: s6b.sz.2pgw05.leo.ims.mnc050.mcc334.3gppnetwork.org + Peer Realm: ims.mnc050.mcc334.3gppnetwork.org + Local Realm: ims.mnc050.mcc334.3gppnetwork.org + Priority channel: No + DSCP configured: 0x28 + Peer Address: 10.194.65.36:3869 + Local Address: 10.33.10.196:40478 + State: OPEN [TCP] + CPU: 7/0 Task: diamproxy-7 + Messages Out/Queued: N/A + Supported Vendor IDs: 10415 + Admin Status: Enable + DPR Disconnect: N/A + Peer Backoff Timer running:N/A + + Peers Summary: + Peers in OPEN state: 70 + Peers in CLOSED state: 0 + Peers in intermediate state: 0 + Total peers matching specified criteria: 70 + + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + diameter_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'Peer\sHostname:\s(?P.+$)') + p1 = re.compile(r'Local\sHostname:\s(?P.+$)') + p2 = re.compile(r'Peer\sRealm:\s(?P.+$)') + p3 = re.compile(r'Local\sRealm:\s(?P.+$)') + p4 = re.compile(r'Priority\schannel:\s(?P.+$)') + p5 = re.compile(r'DSCP\sconfigured:\s(?P.+$)') + p6 = re.compile(r'Peer\sAddress:\s(?P
.+$)') + p7 = re.compile(r'Local\sAddress:\s(?P.+$)') + p8 = re.compile(r'State:\s(?P\w+)') + p9 = re.compile(r'CPU:\s+(?P\d+.\d+)\s+Task:\s+(?P.+$)') + p10 = re.compile(r'Admin\sStatus:\s+(?P\w+)') + p11 = re.compile(r'Peers\sin\sOPEN\sstate:\s(?P\d+)') + p12 = re.compile(r'Peers\sin\sCLOSED\sstate:\s(?P\d+)') + p13 = re.compile(r'Peers\sin\sintermediate\sstate:\s(?P\d+)') + p14 = re.compile(r'Context:\s\w+\s*Endpoint:\s(?P\w+)') + e_number=1 + for line in out.splitlines(): + line = line.strip() + m = p14.match(line) + if m: + if 'diameter_info' not in diameter_dict: + result_dict = diameter_dict.setdefault('diameter_info',{}) + endpoint = m.groupdict()['endpoint'] + if e_number>1: + e_number =1 + + m = p9.match(line) + if m: + if 'diameter_info' not in diameter_dict: + result_dict = diameter_dict.setdefault('diameter_info',{}) + task = m.groupdict()['task'] + result_dict[endpoint_num]['Task']= task + + m = p0.match(line) + if m: + if 'diameter_info' not in diameter_dict: + result_dict = diameter_dict.setdefault('diameter_info',{}) + hostname = m.groupdict()['hostname'] + endpoint_num = str(e_number)+"_"+endpoint + result_dict[endpoint_num] = {} + e_number+=1 + result_dict[endpoint_num]['Peer Hostname'] = hostname + + m = p1.match(line) + if m: + if 'diameter_info' not in diameter_dict: + result_dict = diameter_dict.setdefault('diameter_info',{}) + l_hostname = m.groupdict()['l_hostname'] + result_dict[endpoint_num]['Local Hostname'] = l_hostname + + m = p2.match(line) + if m: + if 'diameter_info' not in diameter_dict: + result_dict = diameter_dict.setdefault('diameter_info',{}) + realm = m.groupdict()['realm'] + result_dict[endpoint_num]['Peer Realm'] = realm + + m = p3.match(line) + if m: + if 'diameter_info' not in diameter_dict: + result_dict = diameter_dict.setdefault('diameter_info',{}) + l_realm = m.groupdict()['l_realm'] + result_dict[endpoint_num]['Local Realm'] = l_realm + + m = p4.match(line) + if m: + if 'diameter_info' not in diameter_dict: + result_dict = diameter_dict.setdefault('diameter_info',{}) + channel = m.groupdict()['channel'] + result_dict[endpoint_num]['Priority channel'] = channel + + m = p5.match(line) + if m: + if 'diameter_info' not in diameter_dict: + result_dict = diameter_dict.setdefault('diameter_info',{}) + dscp = m.groupdict()['dscp'] + result_dict[endpoint_num]['DSCP configured'] = dscp + + m = p6.match(line) + if m: + if 'diameter_info' not in diameter_dict: + result_dict = diameter_dict.setdefault('diameter_info',{}) + + if "Peer Address" not in result_dict[endpoint_num]: + result_dict[endpoint_num]['Peer Address'] = [] + + address = m.groupdict()['address'] + result_dict[endpoint_num]['Peer Address'].append(address) + + m = p7.match(line) + if m: + if 'diameter_info' not in diameter_dict: + result_dict = diameter_dict.setdefault('diameter_info',{}) + + if "Local Address" not in result_dict[endpoint_num]: + result_dict[endpoint_num]['Local Address'] = [] + + l_address = m.groupdict()['l_address'] + result_dict[endpoint_num]['Local Address'].append(l_address) + + m = p8.match(line) + if m: + if 'diameter_info' not in diameter_dict: + result_dict = diameter_dict.setdefault('diameter_info',{}) + state = m.groupdict()['state'] + result_dict[endpoint_num]['State'] = state + + m = p10.match(line) + if m: + if 'diameter_info' not in diameter_dict: + result_dict = diameter_dict.setdefault('diameter_info',{}) + status = m.groupdict()['status'] + result_dict[endpoint_num]['Admin Status'] = status + + m = p11.match(line) + if m: + if 'diameter_info' not in diameter_dict: + result_dict = diameter_dict.setdefault('diameter_info',{}) + if 'Peer Summary' not in diameter_dict['diameter_info']: + result_dict.setdefault('Peer Summary',{}) + open = m.groupdict()['open'] + result_dict['Peer Summary']['OPEN'] = open + + m = p12.match(line) + if m: + if 'diameter_info' not in diameter_dict: + result_dict = diameter_dict.setdefault('diameter_info',{}) + if 'Peer Summary' not in diameter_dict['diameter_info']: + result_dict.setdefault('Peer Summary',{}) + closed = m.groupdict()['closed'] + result_dict['Peer Summary']['CLOSED'] = closed + + m = p13.match(line) + if m: + if 'diameter_info' not in diameter_dict: + result_dict = diameter_dict.setdefault('diameter_info',{}) + if 'Peer Summary' not in diameter_dict['diameter_info']: + result_dict.setdefault('Peer Summary',{}) + inter = m.groupdict()['inter'] + result_dict['Peer Summary']['INTERMEDIATE'] = inter + + return diameter_dict diff --git a/src/genie/libs/parser/staros/show_fans.py b/src/genie/libs/parser/staros/show_fans.py new file mode 100644 index 0000000000..0da2a8f157 --- /dev/null +++ b/src/genie/libs/parser/staros/show_fans.py @@ -0,0 +1,112 @@ +"""starOS implementation of show_fans.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class fanSchema(MetaParser): + """Schema for show fans""" + + schema = { + 'fan_info': { + Any():{ + 'State':str, + 'Speed':str, + 'Temperature':str + } + }, + } + + +class Showfan(fanSchema): + """Parser for show fans""" + + cli_command = 'show fans' + + """ + GGSN Service: + In Use : 298335 + Max Used : 479038 ( Wednesday July 06 00:55:50 CDT 2022 ) + Limit : 10000000 + License Status : Within Acceptable Limits + PGW Service: + In Use : 0 + Max Used : 0 ( Never ) + Limit : 10000000 + License Status : Within Acceptable Limits + SGW Service: + In Use : 0 + Max Used : 0 ( Never ) + Limit : 10000000 + License Status : Within Acceptable Limits + SAEGW Service: + In Use : 1582684 + Max Used : 2866327 ( Wednesday July 06 01:17:00 CDT 2022 ) + Limit : 10000000 + License Status : Within Acceptable Limits + ECS Information: + Enhanced Charging Service: + In Use : 1823158 + Max Used : 3116637 ( Wednesday July 06 01:12:00 CDT 2022 ) + Limit : 16900000 + License Status : Within Acceptable Limits + P2P information: + P2P Service: + In Use : 1571450 + Max Used : 2720328 ( Wednesday July 06 01:11:30 CDT 2022 ) + Limit : 6900000 + License Status : Within Acceptable Limits + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + fan_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'(?P\w+\s\w+\s)\w+\s\w+:$') + p1 = re.compile(r'State:\s+(?P\w+)') + p2 = re.compile(r'Speed:\s+(?P\w+.)') + p3 = re.compile(r'Temperature:\s+(?P\w+.)') + + + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'fan_info' not in fan_dict: + result_dict = fan_dict.setdefault('fan_info',{}) + fan = m.groupdict()['fan'] + result_dict[fan] = {} + + m = p1.match(line) + if m: + if 'fan_info' not in fan_dict: + result_dict = fan_dict.setdefault('fan_info',{}) + state = m.groupdict()['state'] + result_dict[fan]['State'] = state + + m = p2.match(line) + if m: + if 'fan_info' not in fan_dict: + result_dict = fan_dict.setdefault('fan_info',{}) + speed = m.groupdict()['speed'] + result_dict[fan]['Speed'] = speed + + m = p3.match(line) + if m: + if 'fan_info' not in fan_dict: + result_dict = fan_dict.setdefault('fan_info',{}) + temp = m.groupdict()['temp'] + result_dict[fan]['Temperature'] = temp + continue + + return fan_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_hd_raid_verbose.py b/src/genie/libs/parser/staros/show_hd_raid_verbose.py new file mode 100644 index 0000000000..0063cb6e9b --- /dev/null +++ b/src/genie/libs/parser/staros/show_hd_raid_verbose.py @@ -0,0 +1,133 @@ +"""starOS implementation of show_hd_raid_verbose.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowHDRaidSchema(MetaParser): + """Schema for show hd raid verbose""" + + schema = { + 'raid_table': { + 'STATE': str, + 'DEGRADED': str, + Any(): { + 'CARD_STATE': str, + } + }, + } + + +class Showhdraid(ShowHDRaidSchema): + """Parser for show hd raid verbose""" + + cli_command = 'show hd raid verbose' + + """ +HD RAID: + State : Available (clean) + Degraded : No + UUID : 63f3b330:e16ca170:49b8ac9b:4c75d758 + Size : 1.2TB (1200000073728 bytes) + Action : Idle + Card 14 + State : In-sync card + Created : Thu Jan 17 14:15:53 2019 + Updated : Thu Jul 21 11:52:52 2022 + Events : 198076 + Description : FSC14 FLM2223022H + Size : 400GB (400088457216 bytes) + Disk hd14a + State : In-sync component + Model : MICRON S650DC-400 M018 + Serial Number : ZB015QCZ0000822150Z3 + Size : 400GB (400088457216 bytes) + Card 15 + State : In-sync card + Created : Thu Jan 17 14:15:53 2019 + Updated : Thu Jul 21 11:52:52 2022 + Events : 198076 + Description : FSC15 FLM22230226 + Size : 400GB (400088457216 bytes) + Disk hd15a + State : In-sync component + Model : MICRON S650DC-400 M018 + Serial Number : ZB015QG90000822150Z3 + Size : 400GB (400088457216 bytes) + Card 16 + State : In-sync card + Created : Thu Jan 17 14:15:53 2019 + Updated : Thu Jul 21 11:52:52 2022 + Events : 198076 + Description : FSC16 FLM2217064P + Size : 400GB (400088457216 bytes) + Disk hd16a + State : In-sync component + Model : MICRON S650DC-400 M018 + Serial Number : ZB0160MB0000822150Z3 + Size : 400GB (400088457216 bytes) + Card 17 + State : In-sync card + Created : Thu Jan 17 14:15:53 2019 + Updated : Thu Jul 21 11:52:52 2022 + Events : 198076 + Description : FSC17 FLM2223022D + Size : 400GB (400088457216 bytes) + Disk hd17a + State : In-sync component + Model : MICRON S650DC-400 M018 + Serial Number : ZB015Q5D0000822150Z3 + Size : 400GB (400088457216 bytes) + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + raid_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'^State\s+.\s(?PAvailable.+$)') + p1 = re.compile(r'Degraded\s+.\s(?P.+$)') + p2 = re.compile(r'\w+\s(?P\d+$)') + p3 = re.compile(r'State\s+:\s(?P.+card$)') + for line in out.splitlines(): + line = line.strip() + m = p0.match(line) + if m: + if 'raid_table' not in raid_dict: + result_dict = raid_dict.setdefault('raid_table',{}) + state = m.groupdict()['state'] + result_dict['STATE'] = state + continue + + m = p1.match(line) + if m: + if 'raid_table' not in raid_dict: + result_dict = raid_dict.setdefault('raid_table',{}) + degrad = m.groupdict()['degrad'] + result_dict['DEGRADED'] = degrad + continue + + m = p2.match(line) + if m: + if 'raid_table' not in raid_dict: + result_dict = raid_dict.setdefault('raid_table',{}) + card = m.groupdict()['card'] + result_dict[card] = {} + continue + + m = p3.match(line) + if m: + if 'raid_table' not in raid_dict: + result_dict = raid_dict.setdefault('raid_table',{}) + card_state = m.groupdict()['card_state'] + result_dict[card]['CARD_STATE'] = card_state + + return raid_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_ims-auth_sessions_summary.py b/src/genie/libs/parser/staros/show_ims-auth_sessions_summary.py new file mode 100644 index 0000000000..781c484734 --- /dev/null +++ b/src/genie/libs/parser/staros/show_ims-auth_sessions_summary.py @@ -0,0 +1,166 @@ +"""starOS implementation of show_ims-auth_sessions_summary.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowImsSchema(MetaParser): + """Schema for show ims-auth sessions summary""" + + schema = { + 'ims': { + 'total': str, + 'authorizing': str, + 'pending': str, + 'issued': str, + 'done': str, + 'reauthorizing': str, + 'abort': str, + 'release': str, + 'state': str, + 'reconnecting': str, + 'reconnect': str, + 'update': str, + 'revoke': str, + 'preservation': str, + 'preservation_done': str, + 'reactivation': str, + 'fallback': str + } + } + + +class ShowIms(ShowImsSchema): + """Parser for show ims-auth sessions summary""" + + cli_command = 'show ims-auth sessions summary' + + """ + Total IMS Auth sessions: 3 + +Session State: +Authorizing: 0 Auth Pending: 0 + +Auth Issued: 0 Auth Done: 3 + +Reauthorizing: 0 Abort Issued: 0 + +Pending Release: 0 Last State: 0 + +Reconnecting: 0 Reconnect Pending: 0 + +Pending Update: 0 Revoke Issued: 0 + +Preservation Issued: 0 Preservation Done: 0 + +Reactivation Issued: 0 Local Fallback: 0 + + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + ims_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'Total\sIMS\sAuth\ssessions:\s(?P\d+)') + p1 = re.compile(r'Authorizing:\s+(?P\d+)\s+Auth\sPending:\s+(?P\d+)') + p2 = re.compile(r'Auth\sIssued:\s+(?P\d+)\s+Auth\sDone:\s+(?P\d+)') + p3 = re.compile(r'Reauthorizing:\s+(?P\d+)\s+Abort\sIssued:\s+(?P\d+)') + p4 = re.compile(r'Pending\sRelease:\s+(?P\d+)\s+Last\sState:\s+(?P\d+)') + p5 = re.compile(r'Reconnecting:\s+(?P\d+)\s+Reconnect\sPending:\s+(?P\d+)') + p6 = re.compile(r'Pending\sUpdate:\s+(?P\d+)\s+Revoke\sIssued:\s+(?P\d+)') + p7 = re.compile(r'Preservation\sIssued:\s+(?P\d+)\s+Preservation\sDone:\s+(?P\d+)') + p8 = re.compile(r'Reactivation\sIssued:\s+(?P\d+)\s+Local\sFallback:\s+(?P\d+)') + + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'ims' not in ims_dict: + result_dict = ims_dict.setdefault('ims',{}) + total = m.groupdict()['total_IMS'] + result_dict['total'] = total + + m = p1.match(line) + if m: + if 'ims' not in ims_dict: + result_dict = ims_dict.setdefault('ims',{}) + authorizing = m.groupdict()['auth'] + result_dict['authorizing'] = authorizing + pending = m.groupdict()['auth_pending'] + result_dict['pending'] = pending + + m = p2.match(line) + if m: + if 'ims' not in ims_dict: + result_dict = ims_dict.setdefault('ims',{}) + issued = m.groupdict()['auth_issued'] + result_dict['issued'] = issued + done = m.groupdict()['auth_done'] + result_dict['done'] = done + + m = p3.match(line) + if m: + if 'ims' not in ims_dict: + result_dict = ims_dict.setdefault('ims',{}) + reauthorizing = m.groupdict()['reauth'] + result_dict['reauthorizing'] = reauthorizing + abort = m.groupdict()['abort_issued'] + result_dict['abort'] = abort + + m = p4.match(line) + if m: + if 'ims' not in ims_dict: + result_dict = ims_dict.setdefault('ims',{}) + release = m.groupdict()['pending_release'] + result_dict['release'] = release + state = m.groupdict()['last_state'] + result_dict['state'] = state + + m = p5.match(line) + if m: + if 'ims' not in ims_dict: + result_dict = ims_dict.setdefault('ims',{}) + reconnecting = m.groupdict()['reconnecting'] + result_dict['reconnecting'] = reconnecting + reconnect = m.groupdict()['reconnect_pending'] + result_dict['reconnect'] = reconnect + + m = p6.match(line) + if m: + if 'ims' not in ims_dict: + result_dict = ims_dict.setdefault('ims',{}) + update = m.groupdict()['pending_update'] + result_dict['update'] = update + revoke = m.groupdict()['revoke_issued'] + result_dict['revoke'] = revoke + + m = p7.match(line) + if m: + if 'ims' not in ims_dict: + result_dict = ims_dict.setdefault('ims',{}) + preservation = m.groupdict()['preserv_issued'] + result_dict['preservation'] = preservation + preservation_done = m.groupdict()['preserv_done'] + result_dict['preservation_done'] = preservation_done + + m = p8.match(line) + if m: + if 'ims' not in ims_dict: + result_dict = ims_dict.setdefault('ims',{}) + reactivation = m.groupdict()['react_issued'] + result_dict['reactivation'] = reactivation + fallback = m.groupdict()['local_fallback'] + result_dict['fallback'] = fallback + continue + + return ims_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_ip_arp.py b/src/genie/libs/parser/staros/show_ip_arp.py new file mode 100644 index 0000000000..1c699a5a5f --- /dev/null +++ b/src/genie/libs/parser/staros/show_ip_arp.py @@ -0,0 +1,78 @@ + +"""starOS implementation of show_ip_arp.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowIpArpSchema(MetaParser): + """Schema for show ip arp""" + + schema = { + 'ip_arp': { + Any(): { + 'ipaddr': str, + 'linktype': str, + 'macaddr': str, + 'flag': str, + 'interface': str + }, + } + } + + +class ShowIpArp(ShowIpArpSchema): + """Parser for show ip arp""" + + cli_command = 'show ip arp' + + """ +Flags codes: +I - Incomplete, R - Reachable, M - Permanent, S - Stale, +D - Delay, P - Probe, F - Failed +# Indicate vpn and npu audit result is success +^ Indicate vpn and npu audit result is failure + + Address Link Type Link Address Flags Mask Interface + 172.16.224.34 ether A0:E0:AF:13:B2:77 R 5/11-S5S8 + 172.16.224.32 ether A0:E0:AF:14:04:F7 R 5/10-S5S8 +Total number of arps: 2 + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + arp_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'((?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(?P\w\w+)\s+(?P[0-9a-fA-F][0-9a-fA-F]\:[0-9a-fA-F][0-9a-fA-F]\:[0-9a-fA-F][0-9a-fA-F]\:[0-9a-fA-F][0-9a-fA-F]\:[0-9a-fA-F][0-9a-fA-F]\:[0-9a-fA-F][0-9a-fA-F])\s+(?P[a-zA-Z])\s+(?P\w\w+))') + + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'ip_arp' not in arp_dict: + result_dict = arp_dict.setdefault('ip_arp',{}) + arp = m.groupdict()['ipaddr'] + ip_address = m.groupdict()['ipaddr'] + link_type = m.groupdict()['linktype'] + mac_address = m.groupdict()['macaddr'] + flag = m.groupdict()['flag'] + interface = m.groupdict()['interface'] + result_dict[arp] = {} + result_dict[arp]['ipaddr'] = ip_address + result_dict[arp]['linktype'] = link_type + result_dict[arp]['macaddr'] = mac_address + result_dict[arp]['flag'] = flag + result_dict[arp]['interface'] = interface + continue + + return arp_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_ip_route.py b/src/genie/libs/parser/staros/show_ip_route.py new file mode 100644 index 0000000000..5eb1216a6c --- /dev/null +++ b/src/genie/libs/parser/staros/show_ip_route.py @@ -0,0 +1,124 @@ +"""starOS implementation of show_ip_route.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowIpRouteSchema(MetaParser): + """Schema ip route""" + + schema = { + 'ip_route': { + Any():{ + 'DESTINATION': str, + 'NEXTHOP': str, + 'PROTOCOL': str, + 'PREC': str, + 'COST': str, + 'INTERFACE': str, + }, + 'Summary':{ + 'TOTAL': str, + 'UNIQUE': str, + 'CONNECTED': str, + 'STATIC': str, + }, + }, + } + + +class ShowIpRoute(ShowIpRouteSchema): + """Parser for show ip route""" + + cli_command = 'show ip route' + + """ +[local]ASU-ASR5K5-1# show ip route +Friday December 22 20:56:24 ART 2023 +"*" indicates the Best or Used route. S indicates Stale. + + Destination Nexthop Protocol Prec Cost Interface +*0.0.0.0/0 192.168.45.137 static 1 0 LOCAL1 +*192.168.45.136/29 0.0.0.0 connected 0 0 LOCAL1 +*192.168.45.140/32 0.0.0.0 connected 0 0 LOCAL1 + +Total route count : 3 +Unique route count: 3 +Connected: 2 (Framed Route: 0) Static: 1 + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + ip_route_dict = {} + + result_dict = {} + + # initial regexp pattern + #p0 = re.compile(r'((?P.\d+\.\d+\.\d+\.\d+\/\d+)\s+(?P\d+\.\d+\.\d+\.\d+)\s+(?P\S+)\s+(?P\d+)\s+(?P\d+)\s+(?P\S+)|(?PTotal route count\s*:\s*(\d+))|(?PUnique route count\s*:\s*(\d+))|(?PConnected:\s*(\d+))|(?PStatic:\s*(\d+)))') + p0 = re.compile(r'((?P.\d+\.\d+\.\d+\.\d+\/\d+)\s+(?P\d+\.\d+\.\d+\.\d+)\s+(?P\S+)\s+(?P\d+)\s+(?P\d+)\s+(?P\S+))') + p1 = re.compile(r'(Total\sroute\scount\s:\s+(?P\d+))') + p2 = re.compile(r'(Unique\sroute\scount:\s+(?P\d+))') + p3 = re.compile(r'(Connected:\s+(?P\d+)\s+\S+\s\S+\s+\S+\sStatic:\s+(?P\S))') + + contador = 1 + + for line in out.splitlines(): + #Quita espacios al inicio y al final + line = line.strip() + + m = p0.match(line) + if m: + if 'ip_route' not in ip_route_dict: + result_dict = ip_route_dict.setdefault('ip_route',{}) + destination = m.groupdict()['destination'] + result_dict[contador] = {} + result_dict[contador]['DESTINATION'] = destination + nexthop = m.groupdict()['nexthop'] + result_dict[contador]['NEXTHOP'] = nexthop + protocol = m.groupdict()['protocol'] + result_dict[contador]['PROTOCOL'] = protocol + prec = m.groupdict()['prec'] + result_dict[contador]['PREC'] = prec + cost = m.groupdict()['cost'] + result_dict[contador]['COST'] = cost + interface = m.groupdict()['interface'] + result_dict[contador]['INTERFACE'] = interface + contador += 1 + + m = p1.match(line) + if m: + if 'ip_route' not in ip_route_dict: + result_dict = ip_route_dict.setdefault('ip_route',{}) + if 'Summary' not in ip_route_dict['ip_route']: + result_dict.setdefault('Summary',{}) + totalroute = m.groupdict()['total_route'] + result_dict['Summary']['TOTAL'] = totalroute + + m = p2.match(line) + if m: + if 'ip_route' not in ip_route_dict: + result_dict = ip_route_dict.setdefault('ip_route',{}) + if 'Summary' not in ip_route_dict['ip_route']: + result_dict.setdefault('Summary',{}) + uniqueroute = m.groupdict()['unique_route'] + result_dict['Summary']['UNIQUE'] = uniqueroute + + + m = p3.match(line) + if m: + if 'ip_route' not in ip_route_dict: + result_dict = ip_route_dict.setdefault('ip_route',{}) + if 'Summary' not in ip_route_dict['ip_route']: + result_dict.setdefault('Summary',{}) + connected = m.groupdict()['connected'] + result_dict['Summary']['CONNECTED'] = connected + static = m.groupdict()['static'] + result_dict['Summary']['STATIC'] = static + + return ip_route_dict diff --git a/src/genie/libs/parser/staros/show_license_info.py b/src/genie/libs/parser/staros/show_license_info.py new file mode 100644 index 0000000000..68fc0e3242 --- /dev/null +++ b/src/genie/libs/parser/staros/show_license_info.py @@ -0,0 +1,361 @@ +"""starOS implementation of show_license_info.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema, Optional, ListOf + +class LicenseSchema(MetaParser): + """Schema for show license information""" + + schema = { + 'license_info': + { + 'information': + { + 'Comment': str, + Optional('Chassis SN'): str, + 'Issued': + { + 'Year':str, + 'Month':str, + 'Day':str, + }, + Optional('Expires'): + { + Optional('Year'):str, + Optional('Month'):str, + Optional('Day'):str, + }, + 'Key Number':str, + 'Session Limits': + { + Any():{ + 'Sessions':str, + } + }, + 'Status': + { + 'Chassis':ListOf(str), + 'Status':str, + }, + }, + }, + } + + +class ShowLicense(LicenseSchema): + """Parser for show license information""" + + cli_command = 'show license information' + + """ +Key Information (installed key): + Comment SWIFT License + Chassis SN FLM2039N9QG + Issued Monday March 28 18:22:43 CST 2022 + Expires Wednesday September 28 19:22:43 CDT 2022 + Issued By Cisco Systems + Key Number 214140 +Enabled Features: + Feature Applicable Part Numbers + -------------------------------------------------- ----------------------------- + GGSN: [ ASR5K-00-GN10SESS / ASR5K-00-GN01SESS ] + + DHCP [ ASR5K-00-CSXXDHCP ] + IPv4 Routing Protocols [ none ] + Enhanced Charging Bundle 2: [ ASR5K-00-CS01ECG2 ] + + DIAMETER Closed-Loop Charging Interface [ ASR5K-00-CSXXDCLI ] + + Enhanced Charging Bundle 1 [ ASR5K-00-CS01ECG1 ] + IPSec [ ASR5K-00-CS01I-K9 / ASR5K-00-CS10I-K9 ] + Session Recovery [ ASR5K-00-PN01REC / ASR5K-00-HA01REC + ASR5K-00-00000000 / ASR5K-00-GN01REC + ASR5K-00-SN01REC / ASR5K-00-IS10PXY + ASR5K-00-IS01PXY / ASR5K-00-HWXXSREC + ASR5K-00-PW01REC / ASR5K-00-SY01R-K9 + ASR5K-00-IG01REC / ASR5K-00-PC10SR + ASR5K-00-EG01SR / ASR5K-00-FY01SR + ASR5K-00-CS01LASR / ASR5K-00-FY01USR + ASR5K-00-EW01SR / ASR5K-00-SM01SR + ASR5K-00-S301SR ] + Proxy MIP: [ ASR5K-00-PN01PMIP / ASR5K-00-GN01PMIP + ASR5K-00-GN10PMIP ] + + FA [ ASR5K-00-FAXXFA ] + IPv6 [ N/A / N/A ] + Lawful Intercept [ ASR5K-00-CSXXLI ] + TACACS+ [ ASR5K-00-CSXXTACA ] + Inter-Chassis Session Recovery [ ASR5K-00-HA10GEOR / ASR5K-00-HA01GEOR + ASR5K-00-GN10ICSR / ASR5K-00-GN01ICSR + ASR5K-00-PW01ICSR / ASR5K-00-IGXXICSR + ASR5K-00-PC10GR / ASR5K-00-SW01ICSR + ASR5K-00-SG01ICSR / ASR5K-00-EG01ICSR + ASR5K-00-EG10ICSR / ASR5K-00-SM01ICSR + ASR5K-00-SM10ICSR / ASR5K-00-ME01ICSR + QVPCA-00-ME10ICSR ] + RADIUS AAA Server Groups [ ASR5K-00-CSXXAAA ] + Intelligent Traffic Control: [ ASR5K-00-CS01ITC ] + + Dynamic Radius extensions (CoA and PoD) [ ASR5K-00-CSXXDYNR ] + + Per-Subscriber Traffic Policing/Shaping [ ASR5K-00-CSXXTRPS ] + Enhanced Lawful Intercept [ ASR5K-00-CS01ELI / ASR5K-00-CS10ELI ] + Dynamic Policy Interface: [ ASR5K-00-CS01PIF ] + + DIAMETER Closed-Loop Charging Interface [ ASR5K-00-CSXXDCLI ] + Application Detection and Control [ ASR5K-00-CS01P2PD ] + MPLS [ ASR5K-00-CS01MPLS / ASR5K-00-CS10MPLS ] + PGW [ ASR5K-00-PW10GTWY / ASR5K-00-PW01LIC ] + SGW [ ASR5K-00-SW10LIC / ASR5K-00-SW01BASE ] + ULI Reporting [ ASR5K-00-CSXXULIR ] + Always On Licensing [ ASR5K-00-GNXXAOL ] + Smartphone Tethering Detection [ ASR5K-00-CD01STD ] + SGSN S4 Interface [ ASR5K-00-SN01S4 / ASR5K-00-SN10S4 ] + Local Policy Decision Engine [ ASR5K-00-PWXXDEC ] + EPDG [ ASR5K-00-EG01S-K9 / ASR5K-00-EG10S-K9 ] + HTTP Header Enrichment and Encryption [ ASR5K-00-CS01E-K9 ] + DNS Snooping [ ASR5K-00-CS01DNSS ] + SAE GW Bundle [ ASR5K-00-SG01 / ASR5K-00-SG10 ] + AT&T Only License Suppression [ ASR5K-12-PNXXLICS ] + Persistent Lawful Intercept [ ASR5K-00-CS10PLI ] + Rate Limiting Function (Throttling) [ ASR5K-00-CSXGTDT ] + Flow Aware Packet Acceleration Per ASR5500-U Syste [ ASR55-00-CSXFAPU ] + EPC Gw VoLTE enhancements [ ASR5K-00-EP01VLE ] + Simultaneous EPC procedures per System [ ASR5K-00-EPXSCUBR ] + NPLI for IMS Calls, per System [ ASR5K-00-MPSXNPLI ] + Separate Paging Profile for IMS Calls, 1K Sessions [ ASR5K-00-SW01SPP ] + EPC Support for GTP Overload Control, Per System [ ASR5K-00-EPXGTPO ] + EPC-GW Support for Wi-Fi Integration, 1K Sessions [ ASR5K-00-EP01WIFI ] + 5G NSA Enablement Fee, Network Wide [ ASR5K-00-EP51NSE / LIF5K-00-EP51NSE + QVPCA-00-EP51NSE / QVPCF-00-EP51NSE ] + 5G NSA Feature Set 100K Sess VPCSW Active [ ASR5K-00-EP51NSLP / LIF5K-00-EP51NSLP + QVPCA-00-EP51NSLP / QVPCF-00-EP51NSLP ] +Session Limits: + Sessions Session Type + ---------- ----------------------- + 10000000 GGSN + 10000000 ECS + 6500000 Application Detection and Control + 10000000 PGW + 10000000 SGW + 10000 EPDG + 10000000 SAE GW Bundle + 1000 5G NSA Feature Set 100K Sess VPCSW Active +CARD License Counts: + [none] +Status: + Chassis MEC SN Matches + License Status Good + +#Virtual +Key Information (installed key): + Comment SWIFT License + Device 1 None Specified + Device 2 None Specified + Chassis Type Any Hardware + Issued Wednesday March 29 05:24:21 ART 2023 + Issued By Cisco Systems + Key Number 810295 +Enabled Features: + Feature Applicable Part Numbers + -------------------------------------------------- ----------------------------- + GGSN: [ ASR5K-00-GN10SESS / ASR5K-00-GN01SESS ] + + DHCP [ ASR5K-00-CSXXDHCP ] + IPv4 Routing Protocols [ none ] + Enhanced Charging Bundle 2: [ ASR5K-00-CS01ECG2 ] + + DIAMETER Closed-Loop Charging Interface [ ASR5K-00-CSXXDCLI ] + + Enhanced Charging Bundle 1 [ ASR5K-00-CS01ECG1 ] + IPSec [ ASR5K-00-CS01I-K9 / ASR5K-00-CS10I-K9 ] + Proxy MIP: [ ASR5K-00-PN01PMIP / ASR5K-00-GN01PMIP + ASR5K-00-GN10PMIP ] + + FA [ ASR5K-00-FAXXFA ] + IPv6 [ N/A / N/A ] + Lawful Intercept [ ASR5K-00-CSXXLI ] + Layer 2 Traffic Management [ ASR5K-00-CS01VLAN ] + GGSN Dynamic QoS Renegotiation [ ASR5K-00-GN01DQSR ] + Inter-Chassis Session Recovery [ ASR5K-00-HA10GEOR / ASR5K-00-HA01GEOR + ASR5K-00-GN10ICSR / ASR5K-00-GN01ICSR + ASR5K-00-PW01ICSR / ASR5K-00-IGXXICSR + ASR5K-00-PC10GR / ASR5K-00-SW01ICSR + ASR5K-00-SG01ICSR / ASR5K-00-EG01ICSR + ASR5K-00-EG10ICSR / ASR5K-00-SM01ICSR + ASR5K-00-SM10ICSR / ASR5K-00-ME01ICSR + QVPCA-00-ME10ICSR ] + RADIUS AAA Server Groups [ ASR5K-00-CSXXAAA ] + Intelligent Traffic Control: [ ASR5K-00-CS01ITC ] + + Dynamic Radius extensions (CoA and PoD) [ ASR5K-00-CSXXDYNR ] + + Per-Subscriber Traffic Policing/Shaping [ ASR5K-00-CSXXTRPS ] + Dynamic Policy Interface: [ ASR5K-00-CS01PIF ] + + DIAMETER Closed-Loop Charging Interface [ ASR5K-00-CSXXDCLI ] + Application Detection and Control [ ASR5K-00-CS01P2PD ] + Per Subscriber Stateful Firewall [ ASR5K-00-CS01FW ] + SGSN Software License [ ASR5K-00-SN10SESS / ASR5K-00-SN01SESS ] + PGW [ ASR5K-00-PW10GTWY / ASR5K-00-PW01LIC ] + SGW [ ASR5K-00-SW10LIC / ASR5K-00-SW01BASE ] + MME license: [ ASR5K-00-ME01BASE / ASR5K-00-ME10LIC ] + + Session Recovery [ ASR5K-00-PN01REC / ASR5K-00-HA01REC + ASR5K-00-00000000 / ASR5K-00-GN01REC + ASR5K-00-SN01REC / ASR5K-00-IS10PXY + ASR5K-00-IS01PXY / ASR5K-00-HWXXSREC + ASR5K-00-PW01REC / ASR5K-00-SY01R-K9 + ASR5K-00-IG01REC / ASR5K-00-PC10SR + ASR5K-00-EG01SR / ASR5K-00-FY01SR + ASR5K-00-CS01LASR / ASR5K-00-FY01USR + ASR5K-00-EW01SR / ASR5K-00-SM01SR + ASR5K-00-S301SR ] + + Enhanced Lawful Intercept [ ASR5K-00-CS01ELI / ASR5K-00-CS10ELI ] + NAT/PAT with DPI [ ASR5K-00-CS01NAT ] + GRE Interface Tunneling [ ASR5K-00-CS10GRET / ASR5K-00-CS01GRET ] + Optimized Paging [ ASR5K-00-CSXXOPTP ] + MME Resiliency Bundle [ ASR5K-00-MEXXRES ] + Local Policy Decision Engine [ ASR5K-00-PWXXDEC ] + EPDG [ ASR5K-00-EG01S-K9 / ASR5K-00-EG10S-K9 ] + HTTP Header Enrichment and Encryption [ ASR5K-00-CS01E-K9 ] + DNS Snooping [ ASR5K-00-CS01DNSS ] + SAE GW Bundle [ ASR5K-00-SG01 / ASR5K-00-SG10 ] + Flow Aware Packet Acceleration Per ASR5500-U Syste [ ASR55-00-CSXFAPU ] + MTC Feature Set [ ASR5K-00-ME01CNG ] + EPC-GW Support for Wi-Fi Integration, 1K Sessions [ ASR5K-00-EP01WIFI ] + ADC Trigger Over Gx, 1K Sessions [ ASR5K-00-CS01ADGX ] + EPC-GW Non-Standard QCI Support, 1K Sessions [ ASR5K-00-EP01QCNS ] + Per Subscriber Traffic Shaping APN-AMBR, 1K Sessio [ ASR5K-00-PW01TSPS ] + SGSN Direct Tunnel [ ASR5K-00-SN01DIRT ] + SGSN Iu/Gb Flex and Pooling [ ASR5K-00-SN01FLEX ] + 5G NSA Enablement Fee, Network Wide [ ASR5K-00-EP51NSE / LIF5K-00-EP51NSE + QVPCA-00-EP51NSE / QVPCF-00-EP51NSE ] + 5G NSA Feature Set 100K Sess VPCSW Active [ ASR5K-00-EP51NSLP / LIF5K-00-EP51NSLP + QVPCA-00-EP51NSLP / QVPCF-00-EP51NSLP ] +Session Limits: + Sessions Session Type + ---------- ----------------------- + 7000000 GGSN + 10000000 ECS + 7000000 Application Detection and Control + 7000000 Per Subscriber Stateful Firewall + 9100000 PGW + 9100000 SGW + 7000000 MME license + 7000000 EPDG + 2100000 SAE GW Bundle + 7000000 SGSN Direct Tunnel + 7000000 SGSN Iu/Gb Flex and Pooling + 7000000 5G NSA Feature Set 100K Sess VPCSW Active +CARD License Counts: + [none] +NOTICE: The above features and limits have been reduced because this + license includes capabilities beyond what the scale supports. +Status: + Chassis Type qvpc-di (Any Hardware) + License Status Good (Any Hardware) + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + license_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'Comment\s+(?P.+$)') + p1= re.compile(r'Chassis\sSN\s+(?P.+$)') + p2 = re.compile(r'Issued\s+\w+\s(?P\w+)\s(?P\d+)\s\d+:\d+:\d+\s\w+\s(?P\d+$)') + p3 = re.compile(r'Expires\s+\w+\s(?P\w+)\s(?P\d+)\s\d+:\d+:\d+\s\w+\s(?P\d+$)') + p4 = re.compile(r'Key\sNumber\s+(?P\d+$)') + p5 = re.compile(r'^\s*(?P(\d+))\s+(?P(.+$))') + p6 = re.compile(r'(Chassis MEC SN\s+(?P.+)|Chassis Type\s+(?P.+)$)') + p7 = re.compile(r'License\sStatus\s+(?P.*$)') + + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'license_info' not in license_dict: + result_dict = license_dict.setdefault('license_info',{}) + comment = m.groupdict()['comment'] + result_dict['information']={} + result_dict['information']['Comment'] = comment + continue + + m = p1.match(line) + if m: + if 'license_info' not in license_dict: + result_dict = license_dict.setdefault('license_info',{}) + chassis = m.groupdict()['chassis'] + result_dict['information']['Chassis SN'] = chassis + continue + + m = p2.match(line) + if m: + if 'license_info' not in license_dict: + result_dict = license_dict.setdefault('license_info',{}) + month_issued = m.groupdict()['month_issued'] + year_issued = m.groupdict()['year_issued'] + day_issued = m.groupdict()['day_issued'] + result_dict['information']['Issued'] = {} + result_dict['information']['Issued']['Month'] = month_issued + result_dict['information']['Issued']['Year'] = year_issued + result_dict['information']['Issued']['Day'] = day_issued + continue + + m = p3.match(line) + if m: + if 'license_info' not in license_dict: + result_dict = license_dict.setdefault('license_info',{}) + month_exp = m.groupdict()['month_exp'] + year_exp = m.groupdict()['year_exp'] + day_exp = m.groupdict()['day_exp'] + result_dict['information']['Expires'] = {} + result_dict['information']['Expires']['Month'] = month_exp + result_dict['information']['Expires']['Year'] = year_exp + result_dict['information']['Expires']['Day'] = day_exp + continue + + m = p4.match(line) + if m: + if 'license_info' not in license_dict: + result_dict = license_dict.setdefault('license_info',{}) + key_number = m.groupdict()['key_number'] + result_dict['information']['Key Number'] = key_number + continue + + m = p5.match(line) + if m: + if 'license_info' not in license_dict: + result_dict = license_dict.setdefault('license_info',{}) + if 'Session Limits' not in license_dict['license_info']['information']: + result_dict['information'].setdefault('Session Limits',{}) + sessions = m.groupdict()['sessions'] + type = m.groupdict()['type'] + result_dict['information']['Session Limits'][type] = {} + result_dict['information']['Session Limits'][type]['Sessions'] = sessions + continue + + m = p6.match(line) + if m: + if 'license_info' not in license_dict: + result_dict = license_dict.setdefault('license_info',{}) + ch_type = m.groupdict()['chassis_type'] + chassis_mec = m.groupdict()['chassis_mec'] + #result_dict['information']['Status'] = {} + #result_dict['information']['Status']['Chassis MEC'] = chassis_mec + #ch_type = str(m.groupdict()['chassis_type']) + if 'Status' not in result_dict['information']: + result_dict['information']['Status'] = {'Chassis': []} + if ch_type: + #result_dict['information']['Status'] = {} + result_dict['information']['Status']['Chassis'].append(ch_type) + #result_dict['information']['Status'] = {} + if chassis_mec: + result_dict['information']['Status']['Chassis'].append(chassis_mec) + continue + + m = p7.match(line) + if m: + if 'license_info' not in license_dict: + result_dict = license_dict.setdefault('license_info',{}) + status = m.groupdict()['status'] + result_dict['information']['Status']['Status'] = status + continue + + return license_dict diff --git a/src/genie/libs/parser/staros/show_link-aggregation_table.py b/src/genie/libs/parser/staros/show_link-aggregation_table.py new file mode 100644 index 0000000000..0c8269a9a0 --- /dev/null +++ b/src/genie/libs/parser/staros/show_link-aggregation_table.py @@ -0,0 +1,109 @@ +"""starOS implementation of show_link-aggregation_table.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowTableSchema(MetaParser): + """Schema for show link-aggregation table""" + + schema = { + 'link-aggregation_table': { + Any(): { + 'GRP': str, + 'TYPES': str, + 'ADMIN': str, + 'OPER': str, + 'LINK': str, + 'STATE': str, + 'PAIR': str, + 'REDUNDANT': str + }, + } + } + + +class ShowTable(ShowTableSchema): + """Parser for show link-aggregation table""" + + cli_command = 'show link-aggregation table' + + """ + Grp Port Type Admin Oper Link State Pair Redundant + ---- ----- ------------------------ -------- ---- ---- ------- ----- --------- + 232 5/10 10G Ethernet Enabled - Up - 6/10 LA+ 5/10 + 232 5/12 10G Ethernet Enabled Up Up Active 6/12 LA+ 5/10 + 232 5/15 10G Ethernet Enabled Up Up Active 6/15 LA+ 5/10 + 232 5/17 10G Ethernet Enabled Up Up Active 6/17 LA+ 5/10 + 232 5/20 10G Ethernet Enabled Up Up Active 6/20 LA+ 5/10 + 232 5/22 10G Ethernet Enabled Up Up Active 6/22 LA+ 5/10 + 232 5/25 10G Ethernet Enabled Up Up Active 6/25 LA+ 5/10 + 232 5/27 10G Ethernet Enabled Up Up Active 6/27 LA+ 5/10 + 232 6/10 10G Ethernet Enabled - Up - 5/10 LA+ 5/10 + 232 6/12 10G Ethernet Enabled Up Up Active 5/12 LA+ 5/10 + 232 6/15 10G Ethernet Enabled Up Up Active 5/15 LA+ 5/10 + 232 6/17 10G Ethernet Enabled Up Up Active 5/17 LA+ 5/10 + 232 6/20 10G Ethernet Enabled Up Up Active 5/20 LA+ 5/10 + 232 6/22 10G Ethernet Enabled Up Up Active 5/22 LA+ 5/10 + 232 6/25 10G Ethernet Enabled Up Up Active 5/25 LA+ 5/10 + 232 6/27 10G Ethernet Enabled Up Up Active 5/27 LA+ 5/10 + 233 5/11 10G Ethernet Enabled - Up - 6/11 LA+ 5/11 + 233 5/13 10G Ethernet Enabled Up Up Active 6/13 LA+ 5/11 + 233 5/16 10G Ethernet Enabled Up Up Active 6/16 LA+ 5/11 + 233 5/18 10G Ethernet Enabled Up Up Active 6/18 LA+ 5/11 + 233 5/21 10G Ethernet Enabled Up Up Active 6/21 LA+ 5/11 + 233 5/23 10G Ethernet Enabled Up Up Active 6/23 LA+ 5/11 + 233 5/26 10G Ethernet Enabled Up Up Active 6/26 LA+ 5/11 + 233 5/28 10G Ethernet Enabled Up Up Active 6/28 LA+ 5/11 + 233 6/11 10G Ethernet Enabled - Up - 5/11 LA+ 5/11 + 233 6/13 10G Ethernet Enabled Up Up Active 5/13 LA+ 5/11 + 233 6/16 10G Ethernet Enabled Up Up Active 5/16 LA+ 5/11 + 233 6/18 10G Ethernet Enabled Up Up Active 5/18 LA+ 5/11 + 233 6/21 10G Ethernet Enabled Up Up Active 5/21 LA+ 5/11 + 233 6/23 10G Ethernet Enabled Up Up Active 5/23 LA+ 5/11 + 233 6/26 10G Ethernet Enabled Up Up Active 5/26 LA+ 5/11 + 233 6/28 10G Ethernet Enabled Up Up Active 5/28 LA+ 5/11 + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + recovery_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'(?P^\d..)\s+(?P\d.\d.)\s+(?P\w+\s\w+)\s+(?P\w+)\s+(?P\S+)\s+(?P\S+)\s+(?P\S+)\s+(?P\d.\d.)\s+(?P\w+.\s+\d.\d.)') + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'link-aggregation_table' not in recovery_dict: + result_dict = recovery_dict.setdefault('link-aggregation_table',{}) + grp = m.groupdict()['grp'] + port = m.groupdict()['port'] + types = m.groupdict()['types'] + admin = m.groupdict()['admin'] + oper = m.groupdict()['oper'] + link = m.groupdict()['link'] + state = m.groupdict()['state'] + pair = m.groupdict()['pair'] + redundant = m.groupdict()['redundant'] + result_dict[port] = {} + result_dict[port]['GRP'] = grp + result_dict[port]['TYPES'] = types + result_dict[port]['ADMIN'] = admin + result_dict[port]['OPER'] = oper + result_dict[port]['LINK'] = link + result_dict[port]['STATE'] = state + result_dict[port]['PAIR'] = pair + result_dict[port]['REDUNDANT'] = redundant + continue + + return recovery_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_npu.py b/src/genie/libs/parser/staros/show_npu.py new file mode 100644 index 0000000000..a782860813 --- /dev/null +++ b/src/genie/libs/parser/staros/show_npu.py @@ -0,0 +1,105 @@ +"""starOS implementation of show_npu_utilization_table.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowNpuSchema(MetaParser): + """Schema for show npu utilization table""" + + schema = { + 'npu_utilization_table': { + Any(): { + 'NPU NOW': str, + 'NPU MIN5': str, + 'NPU MIN15': str + }, + } + } + + +class ShowNpu(ShowNpuSchema): + """Parser for show npu utilization table""" + + cli_command = 'show npu utilization table' + + """ + ---------npu-------- + npu now 5min 15min +-------- ------ ------ ------ + 05/0/01 0% 0% 0% + 05/0/02 0% 0% 0% + 05/0/03 0% 0% 0% + 05/0/04 0% 0% 0% + 06/0/01 0% 0% 0% + 06/0/02 0% 0% 0% + 06/0/03 0% 0% 0% + 06/0/04 0% 0% 0% + + ---------npu-------- +card now 5min 15min +---- ------ ------ ------ + 1 0% 0% 0% + 2 57% 59% 59% + 3 56% 57% 57% + 4 60% 58% 58% + 5 58% 58% 58% + 6 57% 58% 58% + 7 58% 57% 57% + 10 49% 48% 49% + 11 48% 47% 47% + 12 47% 47% 47% + 13 49% 48% 48% + 14 47% 46% 46% + 15 45% 47% 46% + 16 0% 0% 0% + + """ + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command).strip() + else: + out = output + + # initial return dictionary + npu_dict = {} + result_dict = {} + + # Define the regex pattern for matching the rows with values + pattern = re.compile(r'^(?P\s+\d+.\d+.\d+.)\s+(?P\d+.)\s+(?P\d+.)\s+(?P\d+.)', re.MULTILINE) + pattern2 = re.compile(r'^(?P\s+\d+)\s+(?P\d+.)\s+(?P\d+.)\s+(?P\d+.)', re.MULTILINE) + + for line in out.splitlines(): #Split a string into a list where each line is a list item + m = pattern.match(line) + if m: + if 'npu_utilization_table' not in npu_dict: + result_dict = npu_dict.setdefault('npu_utilization_table',{}) + #Assigning values based on regex groups + npu = m.groupdict()['npu'] + npu_now = m.groupdict()['npu_now'] + npu_min5 = m.groupdict()['npu_min5'] + npu_min15 = m.groupdict()['npu_min15'] + + #Writing in dictionary + result_dict[npu] = {} + result_dict[npu]['NPU NOW'] = npu_now + result_dict[npu]['NPU MIN5'] = npu_min5 + result_dict[npu]['NPU MIN15'] = npu_min15 + + m1= pattern2.match(line) + if m1: + if 'npu_utilization_table' not in npu_dict: + result_dict = npu_dict.setdefault('npu_utilization_table',{}) + #Assigning values based on regex groups + npu = m1.groupdict()['npu'] + npu_now = m1.groupdict()['npu_now'] + npu_min5 = m1.groupdict()['npu_min5'] + npu_min15 = m1.groupdict()['npu_min15'] + + #Writing in dictionary + result_dict[npu] = {} + result_dict[npu]['NPU NOW'] = npu_now + result_dict[npu]['NPU MIN5'] = npu_min5 + result_dict[npu]['NPU MIN15'] = npu_min15 + return npu_dict diff --git a/src/genie/libs/parser/staros/show_ntp_status.py b/src/genie/libs/parser/staros/show_ntp_status.py new file mode 100644 index 0000000000..7dd9e476a4 --- /dev/null +++ b/src/genie/libs/parser/staros/show_ntp_status.py @@ -0,0 +1,299 @@ +"""starOS implementation of show_ntp_status.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowNtpStatusSchema(MetaParser): + """Schema for show ntp status""" + + schema = { + 'ntp': { + Any(): { + 'peer_mode': str, + 'leap': str, + 'stratum': str, + 'precision': str, + 'root_dist': str, + 'root_disper': str, + 'ref_time': str, + 'sys_flags': str, + 'jitter': str, + 'stability': str, + 'brcast_delay': str, + 'authdelay': str, + 'pll_offset': str, + 'pll_freq': str, + 'max_error': str, + 'estim_error': str, + 'status': str, + 'pll_time_cst': str, + 'pll_prec': str, + 'precision': str, + 'freq_tol': str, + 'offset': str, + 'freq': str, + 'poll_adj': str, + 'wtcdog_timer': str + }, + } + } + + +class ShowNtpStatusTable(ShowNtpStatusSchema): + """Parser for show ntp status""" + + cli_command = 'show ntp status' + + """ +[local]LABO-ASR5K> show ntp status +Monday July 11 17:21:01 ART 2022 +system peer: 10.93.11.40 +system peer mode: client +leap indicator: 00 +stratum: 3 +precision: -21 +root distance: 0.01794 s +root dispersion: 0.05183 s +reference ID: [10.93.11.40] +reference time: e677026f.63c9832c Mon, Jul 11 2022 17:11:27.389 +system flags: auth monitor ntp kernel +jitter: 0.000137 s +stability: 0.037 ppm +broadcastdelay: -0.049988 s +authdelay: 0.000000 s +pll offset: 0.000158703 s +pll frequency: -70.051 ppm +maximum error: 0.000339204 s +estimated error: 1.35e-07 s +status: 6001 pll nano mode=fll +pll time constant: 10 +precision: 1e-09 s +frequency tolerance: 500 ppm +offset: 0.000183 s +frequency: -70.051 ppm +poll adjust: 30 +watchdog timer: 574 s + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + ntp_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'^(system peer:\s+(?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))') + p1 = re.compile(r'^(system peer mode:\s+(?P\w+))') + p2 = re.compile(r'^(leap indicator:\s+(?P\d+))') + p3 = re.compile(r'^(stratum:\s+(?P\d+))') + p4 = re.compile(r'^(precision:\s+(?P(([|-])\d+)))') + p5 = re.compile(r'^(root distance:\s+(?P\d+.\d+\ss))') + p6 = re.compile(r'^(root dispersion:\s+(?P\d+.\d+\ss))') + p7 = re.compile(r'^(reference time:\s+.+\s\s(?P.+))') + p8 = re.compile(r'^(system flags:\s+(?P.+))') + p9 = re.compile(r'^(jitter:\s+(?P\d+.\d+\ss))') + p10 = re.compile(r'^(stability:\s+(?P\d+.\d+\sppm))') + p11 = re.compile(r'^(broadcastdelay:\s+(?P[|-]\d+.\d+\ss))') + p12 = re.compile(r'^(authdelay:\s+(?P\d+.\d+\ss))') + p13 = re.compile(r'^(pll offset:\s+(?P\d+.\d+\ss))') + p14 = re.compile(r'^(pll frequency:\s+(?P[|-]\d+.\d+\sppm))') + p15 = re.compile(r'^(maximum error:\s+(?P\d+.\d+\ss))') + p16 = re.compile(r'^(estimated error:\s+(?P\d+.\d+e-\d+\ss))') + p17 = re.compile(r'^(status:\s+(?P\d+.+))') + p18 = re.compile(r'^(pll time constant:\s+(?P\d+))') + p19 = re.compile(r'^(precision:\s+(?P\d+e-\d+\ss))') + p20 = re.compile(r'^(frequency tolerance:\s+(?P\d+\sppm))') + p21 = re.compile(r'^(offset:\s+(?P\d+.\d+\ss))') + p22 = re.compile(r'^(frequency:\s+(?P[|-]\d+.\d+\sppm))') + p23 = re.compile(r'^(poll adjust:\s+(?P\d+))') + p24 = re.compile(r'^(watchdog timer:\s+(?P\d+\ss))') + + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + #system peer: 10.93.11.40 + if m: + if 'ntp' not in ntp_dict: + result_dict = ntp_dict.setdefault('ntp',{}) + peer = m.groupdict()['peer'] + result_dict[peer] = {} + continue + + m = p1.match(line) + #system peer mode: client + if m: + peer_mode = m.groupdict()['peer_mode'] + result_dict[peer]['peer_mode'] = peer_mode + continue + + m = p2.match(line) + #leap indicator: 00 + if m: + leap = m.groupdict()['leap'] + result_dict[peer]['leap'] = leap + continue + + m = p3.match(line) + #stratum: 3 + if m: + stratum = m.groupdict()['stratum'] + result_dict[peer]['stratum'] = stratum + continue + + m = p4.match(line) + #precision: -21 + if m: + precision = m.groupdict()['precision'] + result_dict[peer]['precision'] = precision + continue + + m = p5.match(line) + #root distance: 0.01794 s + if m: + root_dist = m.groupdict()['root_dist'] + result_dict[peer]['root_dist'] = root_dist + continue + + m = p6.match(line) + #root dispersion: 0.05183 s + if m: + root_disper = m.groupdict()['root_disper'] + result_dict[peer]['root_disper'] = root_disper + continue + + m = p7.match(line) + #reference time: e677026f.63c9832c Mon, Jul 11 2022 17:11:27.389 + if m: + ref_time = m.groupdict()['ref_time'] + result_dict[peer]['ref_time'] = ref_time + continue + + m = p8.match(line) + #system flags: auth monitor ntp kernel + if m: + sys_flags = m.groupdict()['sys_flags'] + result_dict[peer]['sys_flags'] = sys_flags + continue + + m = p9.match(line) + #jitter: 0.000137 s + if m: + jitter = m.groupdict()['jitter'] + result_dict[peer]['jitter'] = jitter + continue + + m = p10.match(line) + #stability: 0.037 ppm + if m: + stability = m.groupdict()['stability'] + result_dict[peer]['stability'] = stability + continue + + m = p11.match(line) + #broadcastdelay: -0.049988 s + if m: + brcast_delay = m.groupdict()['brcast_delay'] + result_dict[peer]['brcast_delay'] = brcast_delay + continue + + m = p12.match(line) + #broadcastdelay: -0.049988 s + if m: + authdelay = m.groupdict()['authdelay'] + result_dict[peer]['authdelay'] = authdelay + continue + + m = p13.match(line) + #pll offset: 0.000158703 s + if m: + pll_offset = m.groupdict()['pll_offset'] + result_dict[peer]['pll_offset'] = pll_offset + continue + + m = p14.match(line) + #pll frequency: -70.051 ppm + if m: + pll_freq = m.groupdict()['pll_freq'] + result_dict[peer]['pll_freq'] = pll_freq + continue + + m = p15.match(line) + #maximum error: 0.000339204 s + if m: + max_error = m.groupdict()['max_error'] + result_dict[peer]['max_error'] = max_error + continue + + m = p16.match(line) + #estimated error: 1.35e-07 s + if m: + estim_error = m.groupdict()['estim_error'] + result_dict[peer]['estim_error'] = estim_error + continue + + m = p17.match(line) + #status: 6001 pll nano mode=fll + if m: + status = m.groupdict()['status'] + result_dict[peer]['status'] = status + continue + + m = p18.match(line) + #pll time constant: 10 + if m: + pll_time_cst = m.groupdict()['pll_time_cst'] + result_dict[peer]['pll_time_cst'] = pll_time_cst + continue + + m = p19.match(line) + #precision: 1e-09 s + if m: + pll_prec = m.groupdict()['pll_prec'] + result_dict[peer]['pll_prec'] = pll_prec + continue + + m = p20.match(line) + #frequency tolerance: 500 ppm + if m: + freq_tol = m.groupdict()['freq_tol'] + result_dict[peer]['freq_tol'] = freq_tol + continue + + m = p21.match(line) + #offset: 0.000183 s + if m: + offset = m.groupdict()['offset'] + result_dict[peer]['offset'] = offset + continue + + m = p22.match(line) + #frequency: -70.051 ppm + if m: + freq = m.groupdict()['freq'] + result_dict[peer]['freq'] = freq + continue + + m = p23.match(line) + #poll adjust: 30 + if m: + poll_adj = m.groupdict()['poll_adj'] + result_dict[peer]['poll_adj'] = poll_adj + continue + + m = p24.match(line) + #watchdog timer: 574 s + if m: + wtcdog_timer = m.groupdict()['wtcdog_timer'] + result_dict[peer]['wtcdog_timer'] = wtcdog_timer + continue + + return ntp_dict + diff --git a/src/genie/libs/parser/staros/show_plugin_p2p.py b/src/genie/libs/parser/staros/show_plugin_p2p.py new file mode 100644 index 0000000000..2521905845 --- /dev/null +++ b/src/genie/libs/parser/staros/show_plugin_p2p.py @@ -0,0 +1,72 @@ +"""starOS implementation of show_plugin_p2p.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowPluginP2PSchema(MetaParser): + """Schema for show plugin p2p""" + + schema = { + 'plugin_p2p': { + 'patch-directory': str, + 'base-directory': str, + 'base-version': str + } + } + + +class ShowPluginP2P(ShowPluginP2PSchema): + """Parser for show plugin p2p""" + + cli_command = 'show plugin p2p' + + """ +plugin p2p + patch-directory /var/opt/lib + base-directory /lib + base-version 2.41.1091 + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + plugin_p2p_dict = {} + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'^(patch-directory (?P\S+))') + p1 = re.compile(r'^(base-directory (?P\S+))') + p2 = re.compile(r'^(base-version (?P\S+))') + + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'plugin_p2p' not in plugin_p2p_dict: + result_dict = plugin_p2p_dict.setdefault('plugin_p2p',{}) + modulePriority = m.groupdict()['patch_directory'] + result_dict['patch-directory'] = modulePriority + + m = p1.match(line) + if m: + if 'plugin_p2p' not in plugin_p2p_dict: + result_dict = plugin_p2p_dict.setdefault('plugin_p2p',{}) + pluginVersion = m.groupdict()['base_directory'] + result_dict['base-directory'] = pluginVersion + + m = p2.match(line) + if m: + if 'plugin_p2p' not in plugin_p2p_dict: + result_dict = plugin_p2p_dict.setdefault('plugin_p2p',{}) + pluginVersion = m.groupdict()['base_version'] + result_dict['base-version'] = pluginVersion + continue + + return plugin_p2p_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_port_table.py b/src/genie/libs/parser/staros/show_port_table.py new file mode 100644 index 0000000000..eb32f17285 --- /dev/null +++ b/src/genie/libs/parser/staros/show_port_table.py @@ -0,0 +1,123 @@ +"""starOS implementation of show port table.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowPortSchema(MetaParser): + """Schema for show port table""" + + schema = { + 'port_table': { + Any(): { + 'Role': str, + 'Type': str, + 'Admin': str, + 'Operation': str, + 'Link': str, + 'State': str, + 'Pair': str, + 'Redundant': str + }, + } + } + + +class ShowPort(ShowPortSchema): + """Parser for show port table""" + + cli_command = 'show port table' + + """ +Port Role Type Admin Oper Link State Pair Redundant +----- ---- ------------------------ -------- ---- ---- ------- ----- --------- +5/1 Mgmt 1000 Ethernet Enabled Up Up Active 6/1 L2 Link +5/2 Mgmt 1000 Ethernet Disabled Down Down Active 6/2 L2 Link +5/3 Mgmt RS232 Serial Console Enabled Down Down Active 6/3 L2 Link +5/10 Srvc 10G Ethernet Enabled - Up - 6/10 LA+ 5/10 +5/11 Srvc 10G Ethernet Enabled - Up - 6/11 LA+ 5/11 +5/12 Srvc 10G Ethernet Enabled Up Up Active 6/12 LA+ 5/10 +5/13 Srvc 10G Ethernet Enabled Up Up Active 6/13 LA+ 5/11 +5/14 Srvc 10G Ethernet Disabled Down Down Active 6/14 L2 Link +5/15 Srvc 10G Ethernet Enabled Up Up Active 6/15 LA+ 5/10 +5/16 Srvc 10G Ethernet Enabled Up Up Active 6/16 LA+ 5/11 +5/17 Srvc 10G Ethernet Enabled Up Up Active 6/17 LA+ 5/10 +5/18 Srvc 10G Ethernet Enabled Up Up Active 6/18 LA+ 5/11 +5/19 Srvc 10G Ethernet Disabled Down Down Active 6/19 L2 Link +5/20 Srvc 10G Ethernet Enabled Up Up Active 6/20 LA+ 5/10 +5/21 Srvc 10G Ethernet Enabled Up Up Active 6/21 LA+ 5/11 +5/22 Srvc 10G Ethernet Enabled Up Up Active 6/22 LA+ 5/10 +5/23 Srvc 10G Ethernet Enabled Up Up Active 6/23 LA+ 5/11 +5/24 Srvc 10G Ethernet Disabled Down Down Active 6/24 L2 Link +5/25 Srvc 10G Ethernet Enabled Up Up Active 6/25 LA+ 5/10 +5/26 Srvc 10G Ethernet Enabled Up Up Active 6/26 LA+ 5/11 +5/27 Srvc 10G Ethernet Enabled Up Up Active 6/27 LA+ 5/10 +5/28 Srvc 10G Ethernet Enabled Up Up Active 6/28 LA+ 5/11 +5/29 Srvc 10G Ethernet Disabled Down Down Active 6/29 L2 Link +6/1 Mgmt 1000 Ethernet Enabled Down Up Standby 5/1 L2 Link +6/2 Mgmt 1000 Ethernet Disabled Down Down Standby 5/2 L2 Link +6/3 Mgmt RS232 Serial Console Enabled Down Down Standby 5/3 L2 Link +6/10 Srvc 10G Ethernet Enabled - Up - 5/10 LA+ 5/10 +6/11 Srvc 10G Ethernet Enabled - Up - 5/11 LA+ 5/11 +6/12 Srvc 10G Ethernet Enabled Up Up Active 5/12 LA+ 5/10 +6/13 Srvc 10G Ethernet Enabled Up Up Active 5/13 LA+ 5/11 +6/14 Srvc 10G Ethernet Disabled Down Down Standby 5/14 L2 Link +6/15 Srvc 10G Ethernet Enabled Up Up Active 5/15 LA+ 5/10 +6/16 Srvc 10G Ethernet Enabled Up Up Active 5/16 LA+ 5/11 +6/17 Srvc 10G Ethernet Enabled Up Up Active 5/17 LA+ 5/10 +6/18 Srvc 10G Ethernet Enabled Up Up Active 5/18 LA+ 5/11 +6/19 Srvc 10G Ethernet Disabled Down Down Standby 5/19 L2 Link +6/20 Srvc 10G Ethernet Enabled Up Up Active 5/20 LA+ 5/10 +6/21 Srvc 10G Ethernet Enabled Up Up Active 5/21 LA+ 5/11 +6/22 Srvc 10G Ethernet Enabled Up Up Active 5/22 LA+ 5/10 +6/23 Srvc 10G Ethernet Enabled Up Up Active 5/23 LA+ 5/11 +6/24 Srvc 10G Ethernet Disabled Down Down Standby 5/24 L2 Link +6/25 Srvc 10G Ethernet Enabled Up Up Active 5/25 LA+ 5/10 +6/26 Srvc 10G Ethernet Enabled Up Up Active 5/26 LA+ 5/11 +6/27 Srvc 10G Ethernet Enabled Up Up Active 5/27 LA+ 5/10 +6/28 Srvc 10G Ethernet Enabled Up Up Active 5/28 LA+ 5/11 + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + port_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'^(?P\d+.\d+)\s+(?P\w+)\s(?P.*?)\s{3}\s+(?P\w+)\s+(?P\w+|-)\s+(?P\w+|-)\s+(?P\w+|-)\s+(?P\d+.\d+)\s+(?P.*?)\s') + + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'port_table' not in port_dict: + result_dict = port_dict.setdefault('port_table',{}) + port = m.groupdict()['port'] + role = m.groupdict()['role'] + type = m.groupdict()['type'] + admin = m.groupdict()['admin'] + oper = m.groupdict()['oper'] + link = m.groupdict()['link'] + state = m.groupdict()['state'] + pair = m.groupdict()['pair'] + redundant = m.groupdict()['redundant'] + result_dict[port] = {} + result_dict[port]['Role'] = role + result_dict[port]['Type'] = type + result_dict[port]['Admin'] = admin + result_dict[port]['Operation'] = oper + result_dict[port]['Link'] = link + result_dict[port]['State'] = state + result_dict[port]['Pair'] = pair + result_dict[port]['Redundant'] = redundant + continue + + return port_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_port_utilization.py b/src/genie/libs/parser/staros/show_port_utilization.py new file mode 100644 index 0000000000..69f031eb4e --- /dev/null +++ b/src/genie/libs/parser/staros/show_port_utilization.py @@ -0,0 +1,82 @@ +"""starOS implementation of show_port_utilization.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowPortUtilizationSchema(MetaParser): + """Schema for show port utilization table""" + + schema = { + 'port_table': { + Any(): { + 'current_rx': str, + 'current_tx': str, + '5min_rx': str, + '5min_tx': str, + '15min_rx': str, + '15min_tx': str + }, + } + } + + +class ShowPortUtilization(ShowPortUtilizationSchema): + """Parser for show port utilization table""" + + cli_command = 'show port utilization table' + + """ + ------ Average Port Utilization (in mbps) ------ +Port Type Current 5min 15min + Rx Tx Rx Tx Rx Tx +----- ------------------------ ------- ------- ------- ------- ------- ------- + 1/1 Virtual Ethernet 0 0 0 0 0 0 + 1/10 Virtual Ethernet 0 0 0 0 0 0 + 1/11 Virtual Ethernet 0 0 0 0 0 0 + 1/12 Virtual Ethernet 0 0 0 0 0 0 + 1/13 Virtual Ethernet 0 0 0 0 0 0 + 1/14 Virtual Ethernet 0 0 0 0 0 0 + 1/15 Virtual Ethernet 0 0 0 0 0 0 + 1/16 Virtual Ethernet 0 0 0 0 0 0 + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + port_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'((?P\d+.\d+)\s+(10G|Virtual)\sEthernet\s+(?P\d+)\s+(?P\d+)\s+(?P\d+)\s+(?P\d+)\s+(?P\d+)\s+(?P\d+))') + + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'port_table' not in port_dict: + result_dict = port_dict.setdefault('port_table',{}) + port = m.groupdict()['port_id'] + rx_cur = m.groupdict()['rx_cur'] + tx_cur = m.groupdict()['tx_cur'] + rx_5min = m.groupdict()['rx_5min'] + tx_5min = m.groupdict()['tx_5min'] + rx_15min = m.groupdict()['rx_15min'] + tx_15min = m.groupdict()['tx_15min'] + result_dict[port] = {} + result_dict[port]['current_rx'] = rx_cur + result_dict[port]['current_tx'] = tx_cur + result_dict[port]['5min_rx'] = rx_5min + result_dict[port]['5min_tx'] = tx_5min + result_dict[port]['15min_rx'] = rx_15min + result_dict[port]['15min_tx'] = tx_15min + continue + + return port_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_power_chassis.py b/src/genie/libs/parser/staros/show_power_chassis.py new file mode 100644 index 0000000000..3e7b926d59 --- /dev/null +++ b/src/genie/libs/parser/staros/show_power_chassis.py @@ -0,0 +1,52 @@ +"""starOS implementation of show_power_chassis.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class PowerSchema(MetaParser): + """Schema for show power chassis""" + + schema = { + 'power_info': { + 'Message': str + }, + } + + +class ShowPowerVersion(PowerSchema): + """Parser for show power chassis""" + + cli_command = 'show power chassis' + + """ +All power sources are good + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + power_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'(?P^All power sources are good$)') + + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'power_info' not in power_dict: + result_dict = power_dict.setdefault('power_info',{}) + info = m.groupdict()['info'] + result_dict['Message'] = info + continue + + return power_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_resources.py b/src/genie/libs/parser/staros/show_resources.py new file mode 100644 index 0000000000..921f75dd16 --- /dev/null +++ b/src/genie/libs/parser/staros/show_resources.py @@ -0,0 +1,93 @@ +"""starOS implementation of show_resources.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ResourcesSchema(MetaParser): + """Schema for show resources""" + + schema = { + 'resources_info': { + Any():{ + 'License':str + }, + } + } + + +class ShowResources(ResourcesSchema): + """Parser for show resources""" + + cli_command = 'show resources' + + """ + GGSN Service: + In Use : 298335 + Max Used : 479038 ( Wednesday July 06 00:55:50 CDT 2022 ) + Limit : 10000000 + License Status : Within Acceptable Limits + PGW Service: + In Use : 0 + Max Used : 0 ( Never ) + Limit : 10000000 + License Status : Within Acceptable Limits + SGW Service: + In Use : 0 + Max Used : 0 ( Never ) + Limit : 10000000 + License Status : Within Acceptable Limits + SAEGW Service: + In Use : 1582684 + Max Used : 2866327 ( Wednesday July 06 01:17:00 CDT 2022 ) + Limit : 10000000 + License Status : Within Acceptable Limits + ECS Information: + Enhanced Charging Service: + In Use : 1823158 + Max Used : 3116637 ( Wednesday July 06 01:12:00 CDT 2022 ) + Limit : 16900000 + License Status : Within Acceptable Limits + P2P information: + P2P Service: + In Use : 1571450 + Max Used : 2720328 ( Wednesday July 06 01:11:30 CDT 2022 ) + Limit : 6900000 + License Status : Within Acceptable Limits + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + resources_dict = {} + + result_dict = {} + + # initial regexp pattern + p2 = re.compile(r'^(?P\w+)\sService:') + p3 = re.compile(r'^License\sStatus\s+:\s(?P.+$)') + + for line in out.splitlines(): + line = line.strip() + + m = p2.match(line) + if m: + if 'resources_info' not in resources_dict: + result_dict = resources_dict.setdefault('resources_info',{}) + service = m.groupdict()['service'] + result_dict[service] = {} + + m = p3.match(line) + if m: + if 'resources_info' not in resources_dict: + result_dict = resources_dict.setdefault('resources_info',{}) + license = m.groupdict()['license'] + result_dict[service]['License'] = license + continue + + return resources_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_service_all.py b/src/genie/libs/parser/staros/show_service_all.py new file mode 100644 index 0000000000..df7b3145ef --- /dev/null +++ b/src/genie/libs/parser/staros/show_service_all.py @@ -0,0 +1,90 @@ +"""starOS implementation of show_service_all.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowServiceSchema(MetaParser): + """Schema for show service all""" + + schema = { + 'service_all': { + Any(): { + 'CONTEXTID': str, + 'SERVICEID': str, + 'CONTEXTNAME': str, + 'STATE': str, + 'SESSIONS': str, + 'TYPES': str + }, + } + } + + +class ShowService(ShowServiceSchema): + """Parser for show service all""" + + cli_command = 'show service all' + + """ +ContextID ServiceID ContextName ServiceName State Sessions Type +--------- --------- ----------- ----------- ---------- ----------- ---- +2 1 SAEGW GTPU_ePDG Started 0 gtpu +2 2 SAEGW PGW-S5 Started 0 gtpu +2 3 SAEGW SGW-S1u Started 0 gtpu +2 4 SAEGW SGW-S5 Started 0 gtpu +2 5 SAEGW GGSN Started 12000000 ggsn +2 6 SAEGW EGTP_ePDG Started 0 egtp +2 7 SAEGW PGW-S5 Started 0 egtp +2 8 SAEGW SGW-S11 Started 0 egtp +2 9 SAEGW SGW-S5 Started 0 egtp +2 10 SAEGW PGW-SVC Started 10000000 pgw +2 11 SAEGW SGW-SVC Started 10000000 sgw +2 12 SAEGW SAEGW Started 10000000 saegw +7 1 Gx Gxd-IUSA Started 0 imsa +7 2 Gx Gxd-Nextel Started 0 imsa +7 3 Gx IMS-IPv6 Started 0 imsa +7 4 Gx IMS_SOS Started 0 imsa +7 5 Gx IMS_VOLTE_ORACLE Started 0 imsa +10 13 ePDG ePDG Initialized 0 epdg + + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + recovery_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'(?P^\d+)\s+(?P\d+)\s+(?P\w+)\s+(?P.*?)\s+(?P\w+)\s+(?P\d+)\s+(?P\w+)') + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'service_all' not in recovery_dict: + result_dict = recovery_dict.setdefault('service_all',{}) + contextid = m.groupdict()['contextid'] + serviceid = m.groupdict()['serviceid'] + contextname = m.groupdict()['contextname'] + servicename = m.groupdict()['servicename'] + state = m.groupdict()['state'] + sessions = m.groupdict()['sessions'] + types = m.groupdict()['types'] + result_dict[servicename] = {} + result_dict[servicename]['CONTEXTID'] = contextid + result_dict[servicename]['SERVICEID'] = serviceid + result_dict[servicename]['CONTEXTNAME'] = contextname + result_dict[servicename]['STATE'] = state + result_dict[servicename]['SESSIONS'] = sessions + result_dict[servicename]['TYPES'] = types + continue + + return recovery_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_session_counters_historical_all.py b/src/genie/libs/parser/staros/show_session_counters_historical_all.py new file mode 100644 index 0000000000..11c76a7134 --- /dev/null +++ b/src/genie/libs/parser/staros/show_session_counters_historical_all.py @@ -0,0 +1,265 @@ +"""starOS implementation of show_session_counters_historical_all.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowCountersSchema(MetaParser): + """Schema for show session counters historical all""" + + schema = { + 'session_counters_historical_all': { + Any(): { + 'TIMESTAMP': str, + 'ARRIVED': str, + 'REJECTED': str, + 'CONNECTED': str, + 'DISCONN': str, + 'FAILED': str + }, + } + } + + +class ShowCounters(ShowCountersSchema): + """Parser for show session counters historical all""" + + cli_command = 'show session counters historical all' + + """ + ------------------- Number of Calls ------------------ (A+R+D+F+H+R) +Intv Timestamp Arrived Rejected Connected Disconn Failed Handoffs Renewals CallOps +---- ------------------- ---------- ---------- ---------- ---------- ---------- ------------- ------------- ------------- + 1 2022:07:22:07:30:00 2 0 2 2 0 1 0 5 + 2 2022:07:22:07:15:00 0 0 0 0 0 0 0 0 + 3 2022:07:22:07:00:00 1 0 1 1 0 0 0 2 + 4 2022:07:22:06:45:00 1 0 1 1 0 0 0 2 + 5 2022:07:22:06:30:00 0 0 0 0 0 0 0 0 + 6 2022:07:22:06:15:00 1 0 1 1 0 0 0 2 + 7 2022:07:22:06:00:00 1 0 1 1 0 0 0 2 + 8 2022:07:22:05:45:00 0 0 0 0 0 0 0 0 + 9 2022:07:22:05:30:00 2 0 2 2 0 0 0 4 + 10 2022:07:22:05:15:00 0 0 0 0 0 0 0 0 + 11 2022:07:22:05:00:00 1 0 1 1 0 0 0 2 + 12 2022:07:22:04:45:00 1 0 1 1 0 0 0 2 + 13 2022:07:22:04:30:00 0 0 0 0 0 0 0 0 + 14 2022:07:22:04:15:00 1 0 1 1 0 0 0 2 + 15 2022:07:22:04:00:00 1 0 1 1 0 0 0 2 + 16 2022:07:22:03:45:00 0 0 0 0 0 0 0 0 + 17 2022:07:22:03:30:00 1 0 1 1 0 0 0 2 + 18 2022:07:22:03:15:00 0 0 0 0 0 0 0 0 + 19 2022:07:22:03:00:00 1 0 1 1 0 0 0 2 + 20 2022:07:22:02:45:00 1 0 1 1 0 0 0 2 + 21 2022:07:22:02:30:00 0 0 0 0 0 0 0 0 + 22 2022:07:22:02:15:00 1 0 1 1 0 0 0 2 + 23 2022:07:22:02:00:00 1 0 1 1 0 0 0 2 + 24 2022:07:22:01:45:00 0 0 0 0 0 0 0 0 + 25 2022:07:22:01:30:00 1 0 1 1 0 0 0 2 + 26 2022:07:22:01:15:00 0 0 0 0 0 0 0 0 + 27 2022:07:22:01:00:00 1 0 1 1 0 0 0 2 + 28 2022:07:22:00:45:00 1 0 1 1 0 0 0 2 + 29 2022:07:22:00:30:00 2 0 2 1 0 0 0 3 + 30 2022:07:22:00:15:00 1 0 1 1 0 0 0 2 + 31 2022:07:22:00:00:00 1 0 1 1 0 0 0 2 + 32 2022:07:21:23:45:00 0 0 0 0 0 0 0 0 + 33 2022:07:21:23:30:00 1 0 1 1 0 0 0 2 + 34 2022:07:21:23:15:00 0 0 0 0 0 0 0 0 + 35 2022:07:21:23:00:00 2 0 2 2 0 0 0 4 + 36 2022:07:21:22:45:00 2 0 2 2 0 0 0 4 + 37 2022:07:21:22:30:00 0 0 0 0 0 0 0 0 + 38 2022:07:21:22:15:00 2 0 2 2 0 0 0 4 + 39 2022:07:21:22:00:00 2 0 1 1 0 2 0 5 + 40 2022:07:21:21:45:00 1 0 1 1 0 0 0 2 + 41 2022:07:21:21:30:00 2 0 2 2 0 0 0 4 + 42 2022:07:21:21:15:00 0 0 0 0 0 0 0 0 + 43 2022:07:21:21:00:00 2 0 2 3 0 3 0 8 + 44 2022:07:21:20:45:00 2 0 2 2 0 0 0 4 + 45 2022:07:21:20:30:00 0 0 0 0 0 1 0 1 + 46 2022:07:21:20:15:00 2 0 2 2 0 0 0 4 + 47 2022:07:21:20:00:00 1 0 1 1 0 0 0 2 + 48 2022:07:21:19:45:00 2 0 2 1 0 2 0 5 + 49 2022:07:21:19:30:00 2 0 2 2 0 0 0 4 + 50 2022:07:21:19:15:00 1 0 0 0 0 2 0 3 + 51 2022:07:21:19:00:00 2 0 2 1 0 2 0 5 + 52 2022:07:21:18:45:00 1 0 1 2 0 1 0 4 + 53 2022:07:21:18:30:00 1 0 1 1 0 1 0 3 + 54 2022:07:21:18:15:00 2 0 1 1 0 1 0 4 + 55 2022:07:21:18:00:00 2 0 2 2 0 5 0 9 + 56 2022:07:21:17:45:00 0 0 0 0 0 0 0 0 + 57 2022:07:21:17:30:00 3 0 3 2 0 0 0 5 + 58 2022:07:21:17:15:00 1 0 1 1 0 0 0 2 + 59 2022:07:21:17:00:00 1 0 1 1 0 0 0 2 + 60 2022:07:21:16:45:00 2 0 2 2 0 0 0 4 + 61 2022:07:21:16:30:00 1 0 1 1 0 0 0 2 + 62 2022:07:21:16:15:00 1 0 1 1 0 0 0 2 + 63 2022:07:21:16:00:00 2 0 2 2 0 0 0 4 + 64 2022:07:21:15:45:00 1 0 1 1 0 0 0 2 + 65 2022:07:21:15:30:00 3 0 3 3 0 0 0 6 + 66 2022:07:21:15:15:00 2 0 2 2 0 0 0 4 + 67 2022:07:21:15:00:00 2 0 2 3 0 0 0 5 + 68 2022:07:21:14:45:00 3 0 3 3 0 0 0 6 + 69 2022:07:21:14:30:00 1 0 1 1 0 0 0 2 + 70 2022:07:21:14:15:00 2 0 2 2 0 0 0 4 + 71 2022:07:21:14:00:00 3 0 3 3 0 0 0 6 + 72 2022:07:21:13:45:00 0 0 0 0 0 0 0 0 + 73 2022:07:21:13:30:00 3 0 3 3 0 0 0 6 + 74 2022:07:21:13:15:00 2 0 2 2 0 0 0 4 + 75 2022:07:21:13:00:00 1 0 1 1 0 0 0 2 + 76 2022:07:21:12:45:00 3 0 3 4 0 0 0 7 + 77 2022:07:21:12:30:00 1 0 1 0 0 4 0 5 + 78 2022:07:21:12:15:00 2 0 2 2 0 0 0 4 + 79 2022:07:21:12:00:00 2 0 2 2 0 0 0 4 + 80 2022:07:21:11:45:00 0 0 0 1 0 5 0 6 + 81 2022:07:21:11:30:00 2 0 2 1 0 0 0 3 + 82 2022:07:21:11:15:00 2 0 2 2 0 0 0 4 + 83 2022:07:21:11:00:00 1 0 1 1 0 0 0 2 + 84 2022:07:21:10:45:00 1 0 1 1 0 0 0 2 + 85 2022:07:21:10:30:00 1 0 1 1 0 0 0 2 + 86 2022:07:21:10:15:00 2 0 2 2 0 0 0 4 + 87 2022:07:21:10:00:00 3 0 2 2 0 2 0 7 + 88 2022:07:21:09:45:00 1 0 1 1 0 0 0 2 + 89 2022:07:21:09:30:00 2 0 2 2 0 0 0 4 + 90 2022:07:21:09:15:00 1 0 1 1 0 0 0 2 + 91 2022:07:21:09:00:00 1 0 1 1 0 0 0 2 + 92 2022:07:21:08:45:00 1 0 1 1 0 0 0 2 + 93 2022:07:21:08:30:00 1 0 1 1 0 0 0 2 + 94 2022:07:21:08:15:00 2 0 2 2 0 0 0 4 + 95 2022:07:21:08:00:00 1 0 1 1 0 2 0 4 + 96 2022:07:21:07:45:00 1 0 1 1 0 2 0 4 + 97 2022:07:21:07:30:00 2 0 2 2 0 0 0 4 + 98 2022:07:21:07:15:00 1 0 1 1 0 2 0 4 + 99 2022:07:21:07:00:00 1 0 1 1 0 0 0 2 + 100 2022:07:21:06:45:00 1 0 1 1 0 0 0 2 + 101 2022:07:21:06:30:00 1 0 1 1 0 0 0 2 + 102 2022:07:21:06:15:00 2 0 2 2 0 2 0 6 + 103 2022:07:21:06:00:00 1 0 1 1 0 0 0 2 + 104 2022:07:21:05:45:00 1 0 1 1 0 0 0 2 + 105 2022:07:21:05:30:00 2 0 2 2 0 0 0 4 + 106 2022:07:21:05:15:00 1 0 1 1 0 0 0 2 + 107 2022:07:21:05:00:00 1 0 1 1 0 0 0 2 + 108 2022:07:21:04:45:00 1 0 1 1 0 0 0 2 + 109 2022:07:21:04:30:00 1 0 1 1 0 0 0 2 + 110 2022:07:21:04:15:00 2 0 2 2 0 0 0 4 + 111 2022:07:21:04:00:00 1 0 1 1 0 2 0 4 + 112 2022:07:21:03:45:00 1 0 1 1 0 0 0 2 + 113 2022:07:21:03:30:00 2 0 2 2 0 0 0 4 + 114 2022:07:21:03:15:00 1 0 1 1 0 0 0 2 + 115 2022:07:21:03:00:00 1 0 1 1 0 0 0 2 + 116 2022:07:21:02:45:00 1 0 1 1 0 0 0 2 + 117 2022:07:21:02:30:00 1 0 1 1 0 0 0 2 + 118 2022:07:21:02:15:00 2 0 2 2 0 0 0 4 + 119 2022:07:21:02:00:00 1 0 1 1 0 0 0 2 + 120 2022:07:21:01:45:00 1 0 1 1 0 0 0 2 + 121 2022:07:21:01:30:00 2 0 2 2 0 0 0 4 + 122 2022:07:21:01:15:00 1 0 1 1 0 0 0 2 + 123 2022:07:21:01:00:00 1 0 1 1 0 0 0 2 + 124 2022:07:21:00:45:00 1 0 1 2 0 0 0 3 + 125 2022:07:21:00:30:00 1 0 1 1 0 0 0 2 + 126 2022:07:21:00:15:00 2 0 2 2 0 0 0 4 + 127 2022:07:21:00:00:00 1 0 1 1 0 0 0 2 + 128 2022:07:20:23:45:00 1 0 1 1 0 0 0 2 + 129 2022:07:20:23:30:00 2 0 2 2 0 0 0 4 + 130 2022:07:20:23:15:00 1 0 1 1 0 0 0 2 + 131 2022:07:20:23:00:00 1 0 1 1 0 0 0 2 + 132 2022:07:20:22:45:00 1 0 1 1 0 0 0 2 + 133 2022:07:20:22:30:00 2 0 1 2 0 2 0 6 + 134 2022:07:20:22:15:00 4 0 3 3 0 5 0 12 + 135 2022:07:20:22:00:00 2 0 2 2 0 1 0 5 + 136 2022:07:20:21:45:00 3 0 2 2 0 4 0 9 + 137 2022:07:20:21:30:00 3 0 2 2 0 2 0 7 + 138 2022:07:20:21:15:00 2 0 2 2 0 2 0 6 + 139 2022:07:20:21:00:00 2 0 2 2 0 4 0 8 + 140 2022:07:20:20:45:00 1 0 1 1 0 5 0 7 + 141 2022:07:20:20:30:00 2 0 2 2 0 1 0 5 + 142 2022:07:20:20:15:00 4 0 3 2 0 3 0 9 + 143 2022:07:20:20:00:00 2 0 2 2 0 1 0 5 + 144 2022:07:20:19:45:00 2 0 2 2 0 2 0 6 + 145 2022:07:20:19:30:00 3 0 3 3 0 0 0 6 + 146 2022:07:20:19:15:00 1 0 1 1 0 0 0 2 + 147 2022:07:20:19:00:00 1 0 1 1 0 0 0 2 + 148 2022:07:20:18:45:00 1 0 1 1 0 0 0 2 + 149 2022:07:20:18:30:00 1 0 1 1 0 0 0 2 + 150 2022:07:20:18:15:00 2 0 2 2 0 0 0 4 + 151 2022:07:20:18:00:00 1 0 1 1 0 0 0 2 + 152 2022:07:20:17:45:00 3 0 3 3 0 2 0 8 + 153 2022:07:20:17:30:00 1 0 1 1 0 8 0 10 + 154 2022:07:20:17:15:00 2 0 2 1 0 0 0 3 + 155 2022:07:20:17:00:00 0 0 0 0 0 0 0 0 + 156 2022:07:20:16:45:00 4 0 4 4 0 0 0 8 + 157 2022:07:20:16:30:00 1 0 1 2 0 0 0 3 + 158 2022:07:20:16:15:00 6 0 6 5 0 0 0 11 + 159 2022:07:20:16:00:00 3 0 3 3 0 0 0 6 + 160 2022:07:20:15:45:00 0 0 0 0 0 0 0 0 + 161 2022:07:20:15:30:00 3 0 3 3 0 0 0 6 + 162 2022:07:20:15:15:00 3 0 3 3 0 0 0 6 + 163 2022:07:20:15:00:00 0 0 0 0 0 0 0 0 + 164 2022:07:20:14:45:00 5 0 5 5 0 0 0 10 + 165 2022:07:20:14:30:00 0 0 0 0 0 0 0 0 + 166 2022:07:20:14:15:00 4 0 4 4 0 0 0 8 + 167 2022:07:20:14:00:00 2 0 2 2 0 0 0 4 + 168 2022:07:20:13:45:00 1 0 1 1 0 0 0 2 + 169 2022:07:20:13:30:00 4 0 4 4 0 0 0 8 + 170 2022:07:20:13:15:00 2 0 2 2 0 0 0 4 + 171 2022:07:20:13:00:00 5 0 5 5 0 2 0 12 + 172 2022:07:20:12:45:00 8 0 8 8 0 0 0 16 + 173 2022:07:20:12:30:00 0 0 0 0 0 2 0 2 + 174 2022:07:20:12:15:00 3 0 3 3 0 3 0 9 + 175 2022:07:20:12:00:00 3 0 3 1 0 6 0 10 + 176 2022:07:20:11:45:00 0 0 0 1 0 7 0 8 + 177 2022:07:20:11:30:00 1 0 1 3 0 1 0 5 + 178 2022:07:20:11:15:00 6 0 6 6 0 8 0 20 + 179 2022:07:20:11:00:00 4 0 4 4 0 5 0 13 + 180 2022:07:20:10:45:00 1 0 1 1 0 1 0 3 + 181 2022:07:20:10:30:00 3 0 3 2 0 0 0 5 + 182 2022:07:20:10:15:00 4 0 4 3 0 0 0 7 + 183 2022:07:20:10:00:00 2 0 2 2 0 0 0 4 + 184 2022:07:20:09:45:00 4 0 2 2 0 6 0 12 + 185 2022:07:20:09:30:00 2 0 2 2 0 0 0 4 + 186 2022:07:20:09:15:00 2 0 2 2 0 0 0 4 + 187 2022:07:20:09:00:00 2 0 2 2 0 2 0 6 + 188 2022:07:20:08:45:00 1 0 1 1 0 0 0 2 + 189 2022:07:20:08:30:00 2 0 2 2 0 0 0 4 + 190 2022:07:20:08:15:00 3 0 3 3 0 2 0 8 + 191 2022:07:20:08:00:00 1 0 1 1 0 2 0 4 + 192 2022:07:20:07:45:00 2 0 2 2 0 2 0 6 + + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + recovery_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'(?P\d+)\s+(?P\d+.\d+.\d+.\d+.\d+.\d+)\s+(?P\d+)\s+(?P\d+)\s+(?P\d+)\s+(?P\d+)\s+(?P\d+)') + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'session_counters_historical_all' not in recovery_dict: + result_dict = recovery_dict.setdefault('session_counters_historical_all',{}) + intv = m.groupdict()['intv'] + timestamp = m.groupdict()['timestamp'] + arrived = m.groupdict()['arrived'] + rejected = m.groupdict()['rejected'] + connected = m.groupdict()['connected'] + disconn = m.groupdict()['disconn'] + failed = m.groupdict()['failed'] + result_dict[intv] = {} + result_dict[intv]['TIMESTAMP'] = timestamp + result_dict[intv]['ARRIVED'] = arrived + result_dict[intv]['REJECTED'] = rejected + result_dict[intv]['CONNECTED'] = connected + result_dict[intv]['DISCONN'] = disconn + result_dict[intv]['FAILED'] = failed + continue + + return recovery_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_session_disconnect.py b/src/genie/libs/parser/staros/show_session_disconnect.py new file mode 100644 index 0000000000..e8ec5d75de --- /dev/null +++ b/src/genie/libs/parser/staros/show_session_disconnect.py @@ -0,0 +1,101 @@ +"""starOS implementation of show_show_session_disconnect-reasons_buckets.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Schema + +class ShowSessionSchema(MetaParser): + """Schema for show session disconnect-reasons buckets""" + + schema = { + 'show_session_disconnect-reasons_buckets': { + Any(): { + 'NUM DISC': str, + 'PERCENTAGE': str, + 'NUM DISC2': str, + 'PERCENTAGE2': str, + 'NUM DISC3': str, + 'PERCENTAGE3': str, + 'NUM DISC4': str, + 'PERCENTAGE4': str + }, + } + } + + +class ShowSession(ShowSessionSchema): + """Parser for show session disconnect-reasons buckets""" + + cli_command = 'show session disconnect-reasons buckets' + + """ +Disconnect Reason Num Disc Percentage Num Disc Percentage Num Disc Percentage Num Disc Percentage +----------------------------------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- +Admin-disconnect 72 0.14377 72 0.14377 72 0.14377 72 0.14377 +Remote-disconnect 29173 58.25163 29173 58.25163 29172 58.25196 29172 58.25196 +Local-disconnect 1 0.00200 1 0.00200 1 0.00200 1 0.00200 +No-resource 4 0.00799 4 0.00799 4 0.00799 4 0.00799 +Pool-IP-address-not-valid 2 0.00399 2 0.00399 2 0.00399 2 0.00399 +Idle-Inactivity-timeout 9141 18.25243 9141 18.25243 9140 18.25116 9140 18.25116 +Absolute-timeout 4090 8.16677 4090 8.16677 4090 8.16710 4090 8.16710 +Invalid-source-IP-address 314 0.62698 314 0.62698 314 0.62701 314 0.62701 +lpool-ip-validation-failed 53 0.10583 53 0.10583 53 0.10583 53 0.10583 +failed-update-handoff 5 0.00998 5 0.00998 5 0.00998 5 0.00998 +failed-auth-with-charging-svc 4961 9.90595 4961 9.90595 4961 9.90635 4961 9.90635 +ims-authorization-failed 17 0.03395 17 0.03395 17 0.03395 17 0.03395 +Gtp-context-replacement 164 0.32747 164 0.32747 164 0.32748 164 0.32748 +ims-authorization-revoked 4 0.00799 4 0.00799 4 0.00799 4 0.00799 +unknown-apn 17 0.03395 17 0.03395 17 0.03395 17 0.03395 +disconnect-from-policy-server 1325 2.64571 1325 2.64571 1325 2.64582 1325 2.64582 +gtpu-err-ind 36 0.07188 36 0.07188 36 0.07189 36 0.07189 +Sgw-context-replacement 19 0.03794 19 0.03794 19 0.03794 19 0.03794 +ggsn-no-rsp-from-sgsn 19 0.03794 19 0.03794 19 0.03794 19 0.03794 +4Gto3G-context-replacement 55 0.10982 55 0.10982 55 0.10983 55 0.10983 +3Gto4G-context-replacement 35 0.06989 35 0.06989 35 0.06989 35 0.06989 +srvcc-ps-to-cs-handover 74 0.14776 74 0.14776 74 0.14777 74 0.14777 +disconnect-from-charging-server 500 0.99838 500 0.99838 500 0.99842 500 0.99842 + + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + recovery_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'(?P^\w+.+[a-z])\s+(?P\d+)\s+(?P\d+.\d+)\s+(?P\d+)\s+(?P\d+.\d+)\s+(?P\d+)\s+(?P\d+.\d+)\s+(?P\d+)\s+(?P\d+.\d+)') + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'show_session_disconnect-reasons_buckets' not in recovery_dict: + result_dict = recovery_dict.setdefault('show_session_disconnect-reasons_buckets',{}) + disconnect_reason = m.groupdict()['disconnect_reason'] + num_disc = m.groupdict()['numdisc'] + percentage = m.groupdict()['percentage'] + num_disc2 = m.groupdict()['numdisc2'] + percentage2 = m.groupdict()['percentage2'] + num_disc3 = m.groupdict()['numdisc3'] + percentage3 = m.groupdict()['percentage3'] + num_disc4 = m.groupdict()['numdisc4'] + percentage4 = m.groupdict()['percentage4'] + result_dict[disconnect_reason] = {} + result_dict[disconnect_reason]['NUM DISC'] = num_disc + result_dict[disconnect_reason]['PERCENTAGE'] = percentage + result_dict[disconnect_reason]['NUM DISC2'] = num_disc2 + result_dict[disconnect_reason]['PERCENTAGE2'] = percentage2 + result_dict[disconnect_reason]['NUM DISC3'] = num_disc3 + result_dict[disconnect_reason]['PERCENTAGE3'] = percentage3 + result_dict[disconnect_reason]['NUM DISC4'] = num_disc4 + result_dict[disconnect_reason]['PERCENTAGE4'] = percentage4 + continue + + return recovery_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_session_duration.py b/src/genie/libs/parser/staros/show_session_duration.py new file mode 100644 index 0000000000..94f6c24c2c --- /dev/null +++ b/src/genie/libs/parser/staros/show_session_duration.py @@ -0,0 +1,60 @@ +"""starOS implementation of show_session_duration.py +Author: Luis Antonio Villalobos (luisvill) + +""" +import re +from genie.metaparser import MetaParser +#from genie.metaparser.util.exceptions import SchemaEmptyParserError +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowSessionDurationSchema(MetaParser): + """Schema for show session duration""" + schema = { + 'duration' :{ + Any(): str + } + } + +class ShowSessDur(ShowSessionDurationSchema): + """Parser for show session duration""" + cli_command = 'show session duration' + + """ + In-Progress Call Duration Statistics + <1min 39644 + <2min 29938 + <5min 70274 + <15min 161509 + <1hr 416526 + <4hr 739682 + <12hr 607613 + <24hr 226358 + >24hr 129947 + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + duration_dict = {} + result_dict = {} + + # Define the regex pattern for matching the rows with values + pattern = re.compile(r'^\s+(?P[<>]\d\w+)\s+(?P\d+)', re.MULTILINE) + + #For Loop to get all the values from output + for match in out.splitlines(): #Split a string into a list where each line is a list item + m= pattern.match(match) + if m: + if 'duration' not in duration_dict: + result_dict = duration_dict.setdefault('duration', {}) + + #Defining a variable that contains the value of the regex + call = m.groupdict()['calls'].strip() + tiempo = m.groupdict()['duration'].strip() + + result_dict[tiempo] = call + return duration_dict diff --git a/src/genie/libs/parser/staros/show_session_progress.py b/src/genie/libs/parser/staros/show_session_progress.py new file mode 100644 index 0000000000..1176fc130b --- /dev/null +++ b/src/genie/libs/parser/staros/show_session_progress.py @@ -0,0 +1,805 @@ +"""starOS implementation of show_session_progress.py +Author: Luis Antonio Villalobos (luisvill) + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowSessionProgressSchema(MetaParser): + """Schema for show session progress""" + schema = { + 'session': { + 'In-progress_calls': str, + 'In-progress_active_calls': str, + 'In-progress_dormant_calls': str, + 'In-progress_alwayson_calls': str, + 'ARRIVED': str, + 'CSCF-CALL-ARRIVED': str, + 'CSCF-REGISTERING': str, + 'CSCF-REGISTERED': str, + 'LCP-NEG': str, + 'LCP-UP': str, + 'AUTHENTICATING': str, + 'BCMCS_SERVICE_AUTHENTICATING': str, + 'AUTHENTICATED': str, + 'PDG_AUTHORIZING': str, + 'PDG_AUTHORIZED': str, + 'IMS_AUTHORIZING': str, + 'IMS_AUTHORIZED': str, + 'MBMS_UE_AUTHORIZING': str, + 'MBMS_BEARER_AUTHORIZING': str, + 'DHCP_PENDING': str, + 'L2TP-LAC_CONNECTING': str, + 'MBMS_BEARER_CONNECTING': str, + 'CSCF-CALL-CONNECTING': str, + 'IPCP-UP': str, + 'NON-ANCHOR_CONNECTED': str, + 'AUTH-ONLY_CONNECTED': str, + 'SIMPLE-IPv4_CONNECTED': str, + 'SIMPLE-IPv6_CONNECTED': str, + 'SIMPLE-IPv4+IPv6_CONNECTED': str, + 'MOBILE-IPv4_CONNECTED': str, + 'MOBILE-IPv6_CONNECTED': str, + 'GTP_CONNECTING': str, + 'GTP_CONNECTED': str, + 'PROXY-MOBILE-IP_CONNECTING': str, + 'PROXY-MOBILE-IP_CONNECTED': str, + 'EPDG_RE-AUTHORIZING': str, + 'HA-IPSEC_CONNECTED': str, + 'L2TP-LAC_CONNECTED': str, + 'HNBGW_CONNECTED': str, + 'PDP-TYPE-PPP_CONNECTED': str, + 'IPSG_CONNECTED': str, + 'BCMCS_CONNECTED': str, + 'PCC_CONNECTED': str, + 'MBMS_UE_CONNECTED': str, + 'MBMS_BEARER_CONNECTED': str, + 'PAGING_CONNECTED': str, + 'PDN-TYPE-IPv4_CONNECTED': str, + 'PDN-TYPE-IPv6_CONNECTED': str, + 'PDN-TYPE-IPv4+IPv6_CONNECTED': str, + 'PDN-TYPE-Non-IP_CONNECTED': str, + 'CSCF-CALL-CONNECTED': str, + 'MME_ATTACHED': str, + 'HENBGW_CONNECTED': str, + 'CSCF-CALL-DISCONNECTING': str, + 'DISCONNECTING': str + } + } + +class ShowSessionSchema(ShowSessionProgressSchema): + """Parser for show session progress""" + + cli_command = 'show session progress' + + """ + [local]COR-VPC-1# show session progress +Wednesday April 03 13:46:22 ART 2024 + 2384060 In-progress calls + 2384060 In-progress active calls + 0 In-progress dormant calls + 0 In-progress always-on calls + 61 In-progress calls @ ARRIVED state + 0 In-progress calls @ CSCF-CALL-ARRIVED state + 0 In-progress calls @ CSCF-REGISTERING state + 0 In-progress calls @ CSCF-REGISTERED state + 0 In-progress calls @ LCP-NEG state + 0 In-progress calls @ LCP-UP state + 0 In-progress calls @ AUTHENTICATING state + 0 In-progress calls @ BCMCS SERVICE AUTHENTICATING state + 0 In-progress calls @ AUTHENTICATED state + 0 In-progress calls @ PDG AUTHORIZING state + 0 In-progress calls @ PDG AUTHORIZED state + 29 In-progress calls @ IMS AUTHORIZING state + 15 In-progress calls @ IMS AUTHORIZED state + 0 In-progress calls @ MBMS UE AUTHORIZING state + 0 In-progress calls @ MBMS BEARER AUTHORIZING state + 0 In-progress calls @ DHCP PENDING state + 0 In-progress calls @ L2TP-LAC CONNECTING state + 0 In-progress calls @ MBMS BEARER CONNECTING state + 0 In-progress calls @ CSCF-CALL-CONNECTING state + 0 In-progress calls @ IPCP-UP state + 0 In-progress calls @ NON-ANCHOR CONNECTED state + 0 In-progress calls @ AUTH-ONLY CONNECTED state + 0 In-progress calls @ SIMPLE-IPv4 CONNECTED state + 0 In-progress calls @ SIMPLE-IPv6 CONNECTED state + 0 In-progress calls @ SIMPLE-IPv4+IPv6 CONNECTED state + 0 In-progress calls @ MOBILE-IPv4 CONNECTED state + 0 In-progress calls @ MOBILE-IPv6 CONNECTED state + 0 In-progress calls @ GTP CONNECTING state + 0 In-progress calls @ GTP CONNECTED state + 0 In-progress calls @ PROXY-MOBILE-IP CONNECTING state + 0 In-progress calls @ PROXY-MOBILE-IP CONNECTED state + 0 In-progress calls @ EPDG RE-AUTHORIZING state + 0 In-progress calls @ HA-IPSEC CONNECTED state + 0 In-progress calls @ L2TP-LAC CONNECTED state + 0 In-progress calls @ HNBGW CONNECTED state + 0 In-progress calls @ PDP-TYPE-PPP CONNECTED state + 0 In-progress calls @ IPSG CONNECTED state + 0 In-progress calls @ BCMCS CONNECTED state + 0 In-progress calls @ PCC CONNECTED state + 0 In-progress calls @ MBMS UE CONNECTED state + 0 In-progress calls @ MBMS BEARER CONNECTED state + 0 In-progress calls @ PAGING CONNECTED state + 1974827 In-progress calls @ PDN-TYPE-IPv4 CONNECTED state + 645499 In-progress calls @ PDN-TYPE-IPv6 CONNECTED state + 3 In-progress calls @ PDN-TYPE-IPv4+IPv6 CONNECTED state + 0 In-progress calls @ PDN-TYPE-Non-IP CONNECTED state + 0 In-progress calls @ CSCF-CALL-CONNECTED state + 0 In-progress calls @ MME ATTACHED state + 0 In-progress calls @ HENBGW CONNECTED state + 0 In-progress calls @ CSCF-CALL-DISCONNECTING state + 43 In-progress calls @ DISCONNECTING state + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + session_dict = {} + result_dict = {} + + # Define the regex pattern for matching the rows with values + pattern1 = re.compile(r'^\s+(?P\d+)\sIn-progress calls$' , re.MULTILINE) + pattern2 = re.compile(r'^\s+(?P\d+)\sIn-progress active calls$' , re.MULTILINE) + pattern3= re.compile(r'^\s+(?P\d+)\sIn-progress dormant calls$' , re.MULTILINE) + pattern4= re.compile(r'^\s+(?P\d+)\sIn-progress always-on calls$' , re.MULTILINE) + pattern5= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ ARRIVED state$' , re.MULTILINE) + pattern6= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ CSCF-CALL-ARRIVED state' , re.MULTILINE) + pattern7= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ CSCF-REGISTERING state' , re.MULTILINE) + pattern8= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ CSCF-REGISTERED state' , re.MULTILINE) + pattern9= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ LCP-NEG state' , re.MULTILINE) + pattern10= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ LCP-UP state' , re.MULTILINE) + pattern11= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ AUTHENTICATING state' , re.MULTILINE) + pattern12= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ BCMCS SERVICE AUTHENTICATING state' , re.MULTILINE) + pattern13= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ AUTHENTICATED state' , re.MULTILINE) + pattern14= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ PDG AUTHORIZING state' , re.MULTILINE) + pattern15= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ PDG AUTHORIZED state' , re.MULTILINE) + pattern16= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ IMS AUTHORIZING state' , re.MULTILINE) + pattern17= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ IMS AUTHORIZED state' , re.MULTILINE) + pattern18= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ MBMS UE AUTHORIZING state' , re.MULTILINE) + pattern19= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ MBMS BEARER AUTHORIZING state' , re.MULTILINE) + pattern20= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ DHCP PENDING state' , re.MULTILINE) + pattern21= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ L2TP-LAC CONNECTING state' , re.MULTILINE) + pattern22= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ MBMS BEARER CONNECTING state' , re.MULTILINE) + pattern23= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ CSCF-CALL-CONNECTING state' , re.MULTILINE) + pattern24= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ IPCP-UP state' , re.MULTILINE) + pattern25= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ NON-ANCHOR CONNECTED state' , re.MULTILINE) + pattern26= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ AUTH-ONLY CONNECTED state' , re.MULTILINE) + pattern27= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ SIMPLE-IPv4 CONNECTED state' , re.MULTILINE) + pattern28= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ SIMPLE-IPv6 CONNECTED state' , re.MULTILINE) + pattern29= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ SIMPLE-IPv4\+IPv6 CONNECTED state' , re.MULTILINE) + pattern30= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ MOBILE-IPv4 CONNECTED state' , re.MULTILINE) + pattern31= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ MOBILE-IPv6 CONNECTED state' , re.MULTILINE) + pattern32= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ GTP CONNECTING state' , re.MULTILINE) + pattern33= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ GTP CONNECTED state' , re.MULTILINE) + pattern34= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ PROXY-MOBILE-IP CONNECTING state' , re.MULTILINE) + pattern35= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ PROXY-MOBILE-IP CONNECTED state' , re.MULTILINE) + pattern36= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ EPDG RE-AUTHORIZING state' , re.MULTILINE) + pattern37= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ HA-IPSEC CONNECTED state' , re.MULTILINE) + pattern38= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ L2TP-LAC CONNECTED state' , re.MULTILINE) + pattern39= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ HNBGW CONNECTED state' , re.MULTILINE) + pattern40= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ PDP-TYPE-PPP CONNECTED state' , re.MULTILINE) + pattern41= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ IPSG CONNECTED state' , re.MULTILINE) + pattern42= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ BCMCS CONNECTED state' , re.MULTILINE) + pattern43= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ PCC CONNECTED state' , re.MULTILINE) + pattern44= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ MBMS UE CONNECTED state' , re.MULTILINE) + pattern45= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ MBMS BEARER CONNECTED state' , re.MULTILINE) + pattern46= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ PAGING CONNECTED state' , re.MULTILINE) + pattern47= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ PDN-TYPE-IPv4 CONNECTED state' , re.MULTILINE) + pattern48= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ PDN-TYPE-IPv6 CONNECTED state' , re.MULTILINE) + pattern49= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ PDN-TYPE-IPv4\+IPv6 CONNECTED state' , re.MULTILINE) + pattern50= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ PDN-TYPE-Non-IP CONNECTED state' , re.MULTILINE) + pattern51= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ CSCF-CALL-CONNECTED state' , re.MULTILINE) + pattern52= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ MME ATTACHED state' , re.MULTILINE) + pattern53= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ HENBGW CONNECTED state' , re.MULTILINE) + pattern54= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ CSCF-CALL-DISCONNECTING state' , re.MULTILINE) + pattern55= re.compile(r'^\s+(?P\d+)\sIn-progress calls @ DISCONNECTING state' , re.MULTILINE) + + #For Loop to get all the values from output + for match in out.splitlines(): #Split a string into a list where each line is a list item + m= pattern1.match(match) #Matching values in pattern1 + if m: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m.groupdict()['Calls'].strip() + result_dict['In-progress_calls']= call + continue + m1= pattern2.match(match) #Matching values in pattern2 + if m1: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m1.groupdict()['Calls'].strip() + + result_dict['In-progress_active_calls']= call + continue + m2= pattern3.match(match) #Matching values in pattern3 + if m2: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m2.groupdict()['Calls'].strip() + + result_dict['In-progress_dormant_calls']= call + continue + m3= pattern4.match(match) #Matching values in pattern4 + if m3: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m3.groupdict()['Calls'].strip() + + result_dict['In-progress_alwayson_calls']= call + + continue + m4= pattern5.match(match) #Matching values in pattern5 + if m4: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m4.groupdict()['Calls'].strip() + + result_dict['ARRIVED']= call + + continue + m5= pattern6.match(match) #Matching values in pattern6 + if m5: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m5.groupdict()['Calls'].strip() + + result_dict['CSCF-CALL-ARRIVED']= call + + continue + m6= pattern7.match(match) #Matching values in pattern7 + if m6: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m6.groupdict()['Calls'].strip() + + result_dict['CSCF-REGISTERING']= call + + continue + m7= pattern8.match(match) #Matching values in pattern8 + if m7: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m7.groupdict()['Calls'].strip() + + result_dict['CSCF-REGISTERED']= call + + continue + m8= pattern9.match(match) #Matching values in pattern9 + if m8: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m8.groupdict()['Calls'].strip() + + result_dict['LCP-NEG']= call + + continue + m9= pattern10.match(match) #Matching values in pattern10 + if m9: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m9.groupdict()['Calls'].strip() + + result_dict['LCP-UP']= call + + continue + m10= pattern11.match(match) #Matching values in pattern11 + if m10: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m10.groupdict()['Calls'].strip() + + result_dict['AUTHENTICATING']= call + + continue + m11= pattern12.match(match) #Matching values in pattern12 + if m11: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m11.groupdict()['Calls'].strip() + + result_dict['BCMCS_SERVICE_AUTHENTICATING']= call + + continue + m12= pattern13.match(match) #Matching values in pattern13 + if m12: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m12.groupdict()['Calls'].strip() + + result_dict['AUTHENTICATED']= call + + continue + m13= pattern14.match(match) #Matching values in pattern14 + if m13: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m13.groupdict()['Calls'].strip() + + result_dict['PDG_AUTHORIZING']= call + + continue + m14= pattern15.match(match) #Matching values in pattern15 + if m14: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m14.groupdict()['Calls'].strip() + + result_dict['PDG_AUTHORIZED']= call + + continue + m15= pattern16.match(match) #Matching values in pattern16 + if m15: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m15.groupdict()['Calls'].strip() + + result_dict['IMS_AUTHORIZING']= call + + continue + m16= pattern17.match(match) #Matching values in pattern17 + if m16: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m16.groupdict()['Calls'].strip() + + result_dict['IMS_AUTHORIZED']= call + + continue + m17= pattern18.match(match) #Matching values in pattern18 + if m17: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m17.groupdict()['Calls'].strip() + + result_dict['MBMS_UE_AUTHORIZING']= call + + continue + m18= pattern19.match(match) #Matching values in pattern19 + if m18: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m18.groupdict()['Calls'].strip() + + result_dict['MBMS_BEARER_AUTHORIZING']= call + + continue + m19= pattern20.match(match) #Matching values in pattern20 + if m19: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m19.groupdict()['Calls'].strip() + + result_dict['DHCP_PENDING']= call + + continue + m20= pattern21.match(match) #Matching values in pattern21 + if m20: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m20.groupdict()['Calls'].strip() + + result_dict['L2TP-LAC_CONNECTING']= call + + continue + m21= pattern22.match(match) #Matching values in pattern22 + if m21: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m21.groupdict()['Calls'].strip() + + result_dict['MBMS_BEARER_CONNECTING']= call + + continue + m22= pattern23.match(match) #Matching values in pattern23 + if m22: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m22.groupdict()['Calls'].strip() + + result_dict['CSCF-CALL-CONNECTING']= call + + continue + m23= pattern24.match(match) #Matching values in pattern24 + if m23: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m23.groupdict()['Calls'].strip() + + result_dict['IPCP-UP']= call + + continue + m24= pattern25.match(match) #Matching values in pattern25 + if m24: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m24.groupdict()['Calls'].strip() + + result_dict['NON-ANCHOR_CONNECTED']= call + + continue + m25= pattern26.match(match) #Matching values in pattern26 + if m25: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m25.groupdict()['Calls'].strip() + + result_dict['AUTH-ONLY_CONNECTED']= call + + continue + m26= pattern27.match(match) #Matching values in pattern27 + if m26: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m26.groupdict()['Calls'].strip() + + result_dict['SIMPLE-IPv4_CONNECTED']= call + + continue + m27= pattern28.match(match) #Matching values in pattern28 + if m27: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m27.groupdict()['Calls'].strip() + + result_dict['SIMPLE-IPv6_CONNECTED']= call + + continue + m28= pattern29.match(match) #Matching values in pattern29 + if m28: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m28.groupdict()['Calls'].strip() + + result_dict['SIMPLE-IPv4+IPv6_CONNECTED']= call + + continue + m29= pattern30.match(match) #Matching values in pattern30 + if m29: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m29.groupdict()['Calls'].strip() + + result_dict['MOBILE-IPv4_CONNECTED']= call + + continue + m30= pattern31.match(match) #Matching values in pattern31 + if m30: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m30.groupdict()['Calls'].strip() + + result_dict['MOBILE-IPv6_CONNECTED']= call + + continue + m31= pattern32.match(match) #Matching values in pattern32 + if m31: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m31.groupdict()['Calls'].strip() + + result_dict['GTP_CONNECTING']= call + + continue + m32= pattern33.match(match) #Matching values in pattern33 + if m32: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m32.groupdict()['Calls'].strip() + + result_dict['GTP_CONNECTED']= call + + continue + m33= pattern34.match(match) #Matching values in pattern34 + if m33: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m33.groupdict()['Calls'].strip() + + result_dict['PROXY-MOBILE-IP_CONNECTING']= call + + continue + m34= pattern35.match(match) #Matching values in pattern35 + if m34: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m34.groupdict()['Calls'].strip() + + result_dict['PROXY-MOBILE-IP_CONNECTED']= call + + continue + m35= pattern36.match(match) #Matching values in pattern36 + if m35: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m35.groupdict()['Calls'].strip() + + result_dict['EPDG_RE-AUTHORIZING']= call + + continue + m36= pattern37.match(match) #Matching values in pattern37 + if m36: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m36.groupdict()['Calls'].strip() + + result_dict['HA-IPSEC_CONNECTED']= call + + continue + m37= pattern38.match(match) #Matching values in pattern38 + if m37: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m37.groupdict()['Calls'].strip() + + result_dict['L2TP-LAC_CONNECTED']= call + + continue + m38= pattern39.match(match) #Matching values in pattern39 + if m38: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m38.groupdict()['Calls'].strip() + + result_dict['HNBGW_CONNECTED']= call + + continue + m39= pattern40.match(match) #Matching values in pattern40 + if m39: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m39.groupdict()['Calls'].strip() + + result_dict['PDP-TYPE-PPP_CONNECTED']= call + + continue + m40= pattern41.match(match) #Matching values in pattern41 + if m40: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m40.groupdict()['Calls'].strip() + + result_dict['IPSG_CONNECTED']= call + + continue + m41= pattern42.match(match) #Matching values in pattern42 + if m41: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m41.groupdict()['Calls'].strip() + + result_dict['BCMCS_CONNECTED']= call + + continue + m42= pattern43.match(match) #Matching values in pattern43 + if m42: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m42.groupdict()['Calls'].strip() + + result_dict['PCC_CONNECTED']= call + + continue + m43= pattern44.match(match) #Matching values in pattern44 + if m43: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m43.groupdict()['Calls'].strip() + + result_dict['MBMS_UE_CONNECTED']= call + + continue + m44= pattern45.match(match) #Matching values in pattern45 + if m44: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m44.groupdict()['Calls'].strip() + + result_dict['MBMS_BEARER_CONNECTED']= call + + continue + m45= pattern46.match(match) #Matching values in pattern46 + if m45: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m45.groupdict()['Calls'].strip() + + result_dict['PAGING_CONNECTED']= call + + continue + m46= pattern47.match(match) #Matching values in pattern47 + if m46: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m46.groupdict()['Calls'].strip() + + result_dict['PDN-TYPE-IPv4_CONNECTED']= call + + continue + m47= pattern48.match(match) #Matching values in pattern48 + if m47: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m47.groupdict()['Calls'].strip() + + result_dict['PDN-TYPE-IPv6_CONNECTED']= call + + continue + m48= pattern49.match(match) #Matching values in pattern49 + if m48: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m48.groupdict()['Calls'].strip() + + result_dict['PDN-TYPE-IPv4+IPv6_CONNECTED']= call + + continue + m49= pattern50.match(match) #Matching values in pattern50 + if m49: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m49.groupdict()['Calls'].strip() + + result_dict['PDN-TYPE-Non-IP_CONNECTED']= call + + continue + m50= pattern51.match(match) #Matching values in pattern51 + if m50: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m50.groupdict()['Calls'].strip() + + result_dict['CSCF-CALL-CONNECTED']= call + + continue + m51= pattern52.match(match) #Matching values in pattern52 + if m51: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m51.groupdict()['Calls'].strip() + + result_dict['MME_ATTACHED']= call + + continue + m52= pattern53.match(match) #Matching values in pattern53 + if m52: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m52.groupdict()['Calls'].strip() + + result_dict['HENBGW_CONNECTED']= call + + continue + m53= pattern54.match(match) #Matching values in pattern54 + if m53: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m53.groupdict()['Calls'].strip() + + result_dict['CSCF-CALL-DISCONNECTING']= call + + continue + m54= pattern55.match(match) #Matching values in pattern55 + if m54: + if 'session' not in session_dict: + result_dict = session_dict.setdefault('session',{}) + + #Defining a variable that contains the value of the regex + call = m54.groupdict()['Calls'].strip() + + result_dict['DISCONNECTING']= call + continue + return session_dict diff --git a/src/genie/libs/parser/staros/show_session_recovery_status_verbose.py b/src/genie/libs/parser/staros/show_session_recovery_status_verbose.py new file mode 100644 index 0000000000..9e471368c6 --- /dev/null +++ b/src/genie/libs/parser/staros/show_session_recovery_status_verbose.py @@ -0,0 +1,88 @@ +"""starOS implementation of show_session_recovery_status_verbose.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowVerboseSchema(MetaParser): + """Schema for show session recovery status verbose""" + + schema = { + 'session_recovery_table': { + Any(): { + 'STATE': str, + 'SESSMGR ACTIVE': str, + 'SESSMGR STANDBY': str, + 'AAAMGR ACTIVE': str, + 'AAAMGR STANDBY': str, + 'DEMUX ACTIVE': str, + 'STATUS': str + }, + } + } + + +class ShowRecovery(ShowVerboseSchema): + """Parser for show session recovery status verbose""" + + cli_command = 'show session recovery status verbose' + + """ + cpu state active standby active standby active status +---- ------- ------ ------- ------ ------- ------ ------------------------- + 1/0 Active 48 1 48 1 0 Good + 1/1 Active 48 1 47 1 0 Good + 1/2 Active 48 1 49 1 0 Good + 2/0 Active 48 1 48 1 0 Good + 2/1 Active 48 1 48 1 0 Good + 2/2 Active 48 1 48 1 0 Good + 3/0 Active 48 1 48 1 0 Good + 3/1 Active 48 1 48 1 0 Good + 3/2 Active 48 1 48 1 0 Good + 4/0 Standby 0 48 0 49 0 Good + 4/1 Standby 0 48 0 48 0 Good + 4/2 Standby 0 48 0 49 0 Good + 5/0 Active 0 0 0 0 14 Good (Demux) + + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + recovery_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'(?P\d.\d)\s+(?P\w+)\s+(?P\d+)\s+(?P\d+)\s+(?P\d+)\s+(?P\d+)\s+(?P\d+)\s+(?P\w+)') + for line in out.splitlines(): + line = line.strip() + + m = p0.match(line) + if m: + if 'session_recovery_table' not in recovery_dict: + result_dict = recovery_dict.setdefault('session_recovery_table',{}) + cpu = m.groupdict()['cpu'] + state = m.groupdict()['state'] + s_active = m.groupdict()['s_active'] + s_standby = m.groupdict()['s_standby'] + a_active = m.groupdict()['a_active'] + a_standby = m.groupdict()['a_standby'] + demux = m.groupdict()['demux'] + status = m.groupdict()['status'] + result_dict[cpu] = {} + result_dict[cpu]['STATE'] = state + result_dict[cpu]['SESSMGR ACTIVE'] = s_active + result_dict[cpu]['SESSMGR STANDBY'] = s_standby + result_dict[cpu]['AAAMGR ACTIVE'] = a_active + result_dict[cpu]['AAAMGR STANDBY'] = a_standby + result_dict[cpu]['DEMUX ACTIVE'] = demux + result_dict[cpu]['STATUS'] = status + continue + + return recovery_dict \ No newline at end of file diff --git a/src/genie/libs/parser/staros/show_snmp_communities.py b/src/genie/libs/parser/staros/show_snmp_communities.py new file mode 100644 index 0000000000..671d4a8123 --- /dev/null +++ b/src/genie/libs/parser/staros/show_snmp_communities.py @@ -0,0 +1,63 @@ +"""starOS implementation of show snmp communities.py +Author: Luis Antonio Villalobos(luisvill) +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowSNMPSchema(MetaParser): + """Schema for show snmp communities""" + + schema = { + 'snmp_communities': { + Any(): { + 'Community Name' : str, + 'Access Level': str, + }, + } + } + + +class ShowSNMP(ShowSNMPSchema): + """Parser for show snmp communities""" + + cli_command = 'show snmp communities' + + """ +[local]COR-VPC-1# show snmp communities +Thursday March 14 18:43:40 ART 2024 +Community Name Access Level +-------------------------------- ------------ +nm5r0c0m read-write +public read-only +readonly read-only + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + communities_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'^(?P(\S+)\s+)(?P(read\-write|read\-only))$') + + for line in out.splitlines(): + line = line.strip() + m = p0.match(line) + if m: + if 'snmp_communities' not in communities_dict: + result_dict = communities_dict.setdefault('snmp_communities',{}) + community = m.groupdict()['community'] + access = m.groupdict()['access'] + + result_dict[community] = {} + result_dict[community]["Community Name"]= community + result_dict[community]["Access Level"]= access + + return communities_dict diff --git a/src/genie/libs/parser/staros/show_snmp_notifies.py b/src/genie/libs/parser/staros/show_snmp_notifies.py new file mode 100644 index 0000000000..6b5489a1d6 --- /dev/null +++ b/src/genie/libs/parser/staros/show_snmp_notifies.py @@ -0,0 +1,281 @@ +"""starOS implementation of show_snmp_notifies.py +Author: Luis Antonio Villalobos (luisvill) + +""" +import re +from genie.metaparser import MetaParser +#from genie.metaparser.util.exceptions import SchemaEmptyParserError +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowSNMPNotifiesSchema(MetaParser): + """Schema for show snmp notifies""" + schema = { + 'statistics': { + 'summary': { + 'Total number of notifications' : str, + 'Last notification sent' : str, + 'Notification sending is' : str, + 'Notifications last disabled': str, + 'Notifications in current period' : str, + 'Notifications in previous period' : str, + 'Notification monitor period' : str, + 'Total number of notifications Disabled' : str, + }, + 'traps': { + Any(): { + 'Gen': str, + 'Disc': str, + 'Disable': str, + 'Last Generated': str, + }, + }, + } + } + +class ShowNotifies(ShowSNMPNotifiesSchema): + """Parser for show cloud performance dinet""" + + cli_command = 'show snmp notifies' + + """ + SNMP Notification Statistics: + Total number of notifications : 4030051 + Last notification sent : Thursday April 04 14:41:03 ART 2024 + Notification sending is : enabled + Notifications last disabled : Wednesday January 03 14:46:04 ART 2024 + Notifications have never been cleared + Notifications in current period : 0 + Notifications in previous period: 0 + Notification monitor period : 300 seconds + + Trap Name #Gen #Disc Disable Last Generated + ----------------------------------- ----- ----- ------- -------------------- + CardRebootRequest 8 0 0 2024:03:20:00:48:43 + CardUp 55 0 0 2024:03:20:01:08:18 + CardRemoved 8 0 0 2024:03:06:00:17:41 + CardInserted 23 0 0 2024:03:06:00:38:46 + CardBootFailed 1 0 0 2022:10:25:21:14:21 + PortLinkDown 954 0 0 2024:03:20:01:08:10 + PortLinkUp 1234 0 0 2024:03:20:01:08:19 + CLISessionStart 788368 62669 6564 2024:04:04:14:48:10 + CLISessionEnd 788523 62675 6506 2024:04:04:14:46:35 + CardActive 74 0 0 2024:03:20:01:08:10 + CardDown 32 0 0 2024:03:20:01:08:10 + GGSNServiceStart 1 0 0 2022:10:25:21:17:45 + LongDurTimerExpiry 19486297 19486297 0 2024:04:04:14:48:07 + ManagerFailure 234 0 0 2024:03:06:00:12:39 + NTPPeerUnreachable 2 0 0 2022:11:17:23:38:15 + NTPSyncLost 6 0 0 2023:08:18:01:47:45 + CardStandby 54 0 0 2024:03:20:01:08:18 + NTPPeerReachable 20 0 0 2024:02:01:12:44:48 + NTPSyncEstablished 9 0 0 2024:02:01:12:44:52 + BGPPeerSessionUp 166 0 0 2024:01:03:03:53:15 + BGPPeerSessionDown 82 0 9 2024:01:03:03:27:31 + CardSPOFAlarm 323 54 0 2024:03:20:00:54:47 + CardSPOFClear 323 0 0 2024:03:20:01:08:22 + LoginFailure 1304 228 10 2024:04:04:06:03:05 + TaskFailed 222 0 0 2024:02:01:12:44:42 + TaskRestart 216 0 0 2024:02:01:12:44:42 + Heartbeat 5795 0 0 2024:04:04:14:40:57 + SessMgrRecoveryComplete 247 0 0 2024:02:08:19:37:24 + DiameterPeerDown 6568 0 106 2024:04:03:22:39:54 + DiameterPeerUp 6459 0 160 2024:04:03:22:39:55 + ThreshStorageUtilization 9 0 0 2024:03:21:00:58:00 + ThreshClearStorageUtilization 9 0 0 2024:03:21:09:09:00 + PortDown 113 0 0 2024:03:20:01:08:10 + PortUp 145 0 0 2024:03:20:01:08:19 + SystemStartup 1 0 0 2022:10:25:21:17:44 + DiameterCapabilitiesExchangeSuccess 6459 0 160 2024:04:03:22:39:55 + CertValid 1 0 0 2022:10:25:21:16:28 + FTPFailure 1441627 0 1032998 2024:04:04:14:41:03 + StorageFailed 1 0 0 2023:09:27:08:27:51 + RaidStarted 4 0 0 2023:09:27:08:36:27 + RaidDegraded 6 0 0 2023:12:13:00:12:50 + RaidRecovered 4 0 0 2023:12:13:08:58:08 + PGWServiceStart 1 0 0 2022:10:25:21:17:45 + SGWServiceStart 1 0 0 2022:10:25:21:17:45 + EGTPServiceStart 3 0 0 2022:10:25:21:17:46 + ManagerRestart 315 0 0 2024:02:08:19:37:35 + EGTPCPathFail 155306 24108 4643 2024:04:04:14:48:07 + EGTPCPathFailClear 283126 31050 11185 2024:04:04:14:45:35 + EGTPUPathFail 1564181 207498 23408 2024:04:04:14:45:58 + EGTPUPathFailClear 469457 17507 4345 2024:04:04:14:40:06 + LocalUserAdded 4 0 0 2022:10:25:21:17:17 + TestModeEntered 10 0 0 2023:10:10:03:53:04 + CPUWarn 97 0 1 2024:03:22:00:11:42 + CPUWarnClear 97 0 1 2024:03:22:00:12:02 + CPUOver 3 0 0 2024:01:21:16:08:02 + CPUOverClear 3 0 0 2024:01:21:16:08:32 + SwitchoverStart 1 0 0 2023:09:27:08:34:02 + SwitchoverComplete 3 0 0 2023:09:27:08:34:04 + MigrateStart 17 0 0 2024:03:20:00:54:43 + MigrateComplete 17 0 0 2024:03:20:01:08:10 + BFDSessionUp 1266 0 0 2024:03:22:20:17:14 + BFDSessionDown 1040 0 0 2024:03:22:20:17:12 + BGPPeerSessionIPv6Up 22 0 0 2024:01:03:03:53:22 + BGPPeerSessionIPv6Down 10 0 1 2024:01:03:03:27:20 + CapacityReached 6 0 0 2022:12:07:06:14:03 + DisabledEventIDs 1 0 0 2023:08:17:17:27:27 + NicBondChange 61 0 0 2024:03:21:02:08:45 + ServiceLossDetected 25 0 0 2022:12:07:06:12:39 + CiscoMwsServiceStart 9 0 0 2022:10:25:21:17:46 + EntStateOperEnabled 200 0 14 2024:03:20:01:08:19 + EntStateOperDisabled 98 0 0 2024:03:20:01:08:10 + CiscoFruInserted 23 0 23 2024:03:06:00:38:46 + CiscoFruRemoved 8 0 8 2024:03:06:00:17:41 + CiscoFlashCopyCompletionTrap 2 0 2 2023:12:06:09:56:59 + CiscoFlashMiscOpCompletionTrap 44 0 44 2024:01:22:11:41:18 + CseHaRestartNotify 2 0 2 2024:02:01:12:44:42 + CseFailSwCoreNotify 254 0 254 2024:03:31:10:59:19 + CseFailSwCoreNotifyExtended 254 0 254 2024:03:31:10:59:19 + + Total number of notifications Disabled : 1090698 + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + notifications_dict = {} + result_dict = {} + + # Define the regex pattern for matching the rows with values + pattern1 = re.compile(r'^\s+Total number of notifications\s+:\s+(?P\d+)' , re.MULTILINE) + pattern2 = re.compile(r'^\s+Last notification sent\s+:\s+(?P\w+\s+\w+\s+\d+\s+\d+:\d+:\d+\s+\w+\s+\d+)' , re.MULTILINE) + pattern3 = re.compile(r'^\s+Notification sending is\s+:\s+(?P\w+)' , re.MULTILINE) + pattern4 = re.compile(r'^\s+Notifications last disabled\s+:\s+(?P\w+\s+\w+\s+\d+\s+\d+:\d+:\d+\s+\w+\s+\d+)' , re.MULTILINE) + pattern5 = re.compile(r'^\s+Notifications in current period\s+:\s+(?P\d+)' , re.MULTILINE) + pattern6 = re.compile(r'^\s+Notifications in previous period:\s+(?P\d+)' , re.MULTILINE) + pattern7 = re.compile(r'^\s+Notification monitor period\s+:\s+(?P\d+\s+\w+)' , re.MULTILINE) + pattern8 = re.compile(r'^Total number of notifications Disabled\s+:\s+(?P\d+)' , re.MULTILINE) + pattern9= re.compile(r'^\s*(?P\w[\w\s]*\w|\w)\s+(?P\d+)\s+(?P\d+)\s+(?P\d+)\s+(?P\d{4}:\d{2}:\d{2}:\d{2}:\d{2}:\d{2})\s*$' , re.MULTILINE) + + #For Loop to get all the values from output + for match in out.splitlines(): #Split a string into a list where each line is a list item + m= pattern1.match(match) #Matching values in pattern1 + if m: + if 'statistics' not in notifications_dict: + result_dict = notifications_dict.setdefault('statistics',{}) + if 'summary' not in notifications_dict['statistics']: + result_dict = notifications_dict['statistics'].setdefault('summary',{}) + + #Defining variables that get values matched for every regex + total_notifications = m.groupdict()['Total'].strip() + + result_dict['Total number of notifications']= total_notifications + continue + m= pattern2.match(match) #Matching values in pattern2 + if m: + if 'statistics' not in notifications_dict: + result_dict = notifications_dict.setdefault('statistics',{}) + if 'summary' not in notifications_dict['statistics']: + result_dict = notifications_dict['statistics'].setdefault('summary',{}) + + #Defining variables that get values matched for every regex + last_not_sent = m.groupdict()['Last_sent'].strip() + + result_dict['Last notification sent']= last_not_sent + continue + + m= pattern3.match(match) #Matching values in pattern3 + if m: + if 'statistics' not in notifications_dict: + result_dict = notifications_dict.setdefault('statistics',{}) + if 'summary' not in notifications_dict['statistics']: + result_dict = notifications_dict['statistics'].setdefault('summary',{}) + + #Defining variables that get values matched for every regex + notif_sending = m.groupdict()['Sending'].strip() + + result_dict['Notification sending is']= notif_sending + continue + + m= pattern4.match(match) #Matching values in pattern4 + if m: + if 'statistics' not in notifications_dict: + result_dict = notifications_dict.setdefault('statistics',{}) + if 'summary' not in notifications_dict['statistics']: + result_dict = notifications_dict['statistics'].setdefault('summary',{}) + + #Defining variables that get values matched for every regex + notif_last_dis = m.groupdict()['Last_disable'].strip() + + result_dict['Notifications last disabled']= notif_last_dis + continue + + m= pattern5.match(match) #Matching values in pattern5 + if m: + if 'statistics' not in notifications_dict: + result_dict = notifications_dict.setdefault('statistics',{}) + if 'summary' not in notifications_dict['statistics']: + result_dict = notifications_dict['statistics'].setdefault('summary',{}) + + #Defining variables that get values matched for every regex + notif_curr_period = m.groupdict()['Current_period'].strip() + + result_dict['Notifications in current period']= notif_curr_period + continue + + m= pattern6.match(match) #Matching values in pattern6 + if m: + if 'statistics' not in notifications_dict: + result_dict = notifications_dict.setdefault('statistics',{}) + if 'summary' not in notifications_dict['statistics']: + result_dict = notifications_dict['statistics'].setdefault('summary',{}) + + #Defining variables that get values matched for every regex + notif_pre_period = m.groupdict()['Previous_period'].strip() + + result_dict['Notifications in previous period']= notif_pre_period + continue + + m= pattern7.match(match) #Matching values in pattern7 + if m: + if 'statistics' not in notifications_dict: + result_dict = notifications_dict.setdefault('statistics',{}) + if 'summary' not in notifications_dict['statistics']: + result_dict = notifications_dict['statistics'].setdefault('summary',{}) + + #Defining variables that get values matched for every regex + notif_mon_period = m.groupdict()['Monitor_period'].strip() + + result_dict['Notification monitor period']= notif_mon_period + continue + + m= pattern8.match(match) #Matching values in pattern8 + if m: + if 'statistics' not in notifications_dict: + result_dict = notifications_dict.setdefault('statistics',{}) + if 'summary' not in notifications_dict['statistics']: + result_dict = notifications_dict['statistics'].setdefault('summary',{}) + + #Defining variables that get values matched for every regex + total_not_disabled = m.groupdict()['Notif_disabled'].strip() + + notifications_dict['statistics']['summary']['Total number of notifications Disabled'] = total_not_disabled + continue + + m= pattern9.match(match) #Matching values in pattern8 + if m: + if 'statistics' not in notifications_dict: + result_dict = notifications_dict.setdefault('statistics',{}) + if 'traps' not in notifications_dict['statistics']: + result_dict = notifications_dict['statistics'].setdefault('traps',{}) + + #Defining variables that get values matched for every regex + trap = m.groupdict()['Trap'].strip() + generated = m.groupdict()['Gen'].strip() + disc = m.groupdict()['Disc'].strip() + disable = m.groupdict()['Disable'].strip() + last_generated = m.groupdict()['Last_Generated'].strip() + + result_dict[trap] = {#Last entry for the dictionary + 'Gen' : generated, + 'Disc' : disc, + 'Disable' : disable, + 'Last Generated': last_generated + } + return notifications_dict diff --git a/src/genie/libs/parser/staros/show_snmp_trap.py b/src/genie/libs/parser/staros/show_snmp_trap.py new file mode 100644 index 0000000000..7c163b2808 --- /dev/null +++ b/src/genie/libs/parser/staros/show_snmp_trap.py @@ -0,0 +1,77 @@ +"""starOS implementation of show snmp trap.py + +""" +import re +from genie.metaparser import MetaParser +from genie.metaparser.util.schemaengine import Any, Or, Schema + +class ShowSNMPSchema(MetaParser): + """Schema for show port table""" + + schema = { + 'snmp_info': { + Any(): { + 'Date': str, + 'Time': str, + 'Trap': str + }, + } + } + + +class ShowSNMP(ShowSNMPSchema): + """Parser for show snmp trap history""" + + cli_command = 'show snmp trap history' + + """ +Wed Aug 10 09:45:04 2022 Internal trap notification 53 (CLISessionEnd) user CERT_digidata_ASR privilege level Security Administrator ttyname /dev/pts/5 +Wed Aug 10 09:45:32 2022 Internal trap notification 1215 (CPUWarn) facility cli instance 5008255 card 5 cpu 0 allocated 600 used 546 +Wed Aug 10 09:46:42 2022 Internal trap notification 1220 (CPUOverClear) facility vpnctrl instance 0 card 5 cpu 0 allocated 150 used 58 +Wed Aug 10 09:46:42 2022 Internal trap notification 1216 (CPUWarnClear) facility vpnctrl instance 0 card 5 cpu 0 allocated 150 used 58 +Wed Aug 10 09:47:12 2022 Internal trap notification 52 (CLISessionStart) user ag796c privilege level Security Administrator ttyname /dev/pts/5 +Wed Aug 10 09:49:20 2022 Internal trap notification 53 (CLISessionEnd) user m47902 privilege level Security Administrator ttyname +Wed Aug 10 09:52:02 2022 Internal trap notification 52 (CLISessionStart) user CERT_PRIME privilege level Security Administrator ttyname /dev/pts/2 +Wed Aug 10 09:52:21 2022 Internal trap notification 53 (CLISessionEnd) user CERT_PRIME privilege level Security Administrator ttyname /dev/pts/2 +Wed Aug 10 09:54:02 2022 Internal trap notification 52 (CLISessionStart) user CERT_PRIME privilege level Security Administrator ttyname /dev/pts/2 +Wed Aug 10 09:54:22 2022 Internal trap notification 53 (CLISessionEnd) user CERT_PRIME privilege level Security Administrator ttyname /dev/pts/2 +Wed Aug 10 09:54:41 2022 Internal trap notification 1113 (EGTPCPathFailClear) context SAEGW, service SGW-S5, interface type sgw-egress, self address 201.175.153.170, peer address 217.168.3.33, peer restart counter 2, peer session count 3, clear reason echo-req +Wed Aug 10 09:54:52 2022 Internal trap notification 1112 (EGTPCPathFail) context SAEGW, service SGW-S5, interface type sgw-egress, self address 201.175.153.170, peer address 186.37.245.1, peer old restart counter 5, peer new restart counter 5, peer session count 4, failure reason no-response-from-peer, path failure detection Enabled +Wed Aug 10 09:54:54 2022 Internal trap notification 1112 (EGTPCPathFail) context SAEGW, service SGW-S5, interface type sgw-egress, self address 201.175.153.170, peer address 190.91.232.132, peer old restart counter 6, peer new restart counter 6, peer session count 5, failure reason no-response-from-peer, path failure detection Enabled +Wed Aug 10 09:55:09 2022 Internal trap notification 1112 (EGTPCPathFail) context SAEGW, service SGW-S5, interface type sgw-egress, self address 201.175.153.170, peer address 186.37.245.35, peer old restart counter 16, peer new restart counter 16, peer session count 1, failure reason no-response-from-peer, path failure detection Enabled +Wed Aug 10 09:56:05 2022 Internal trap notification 1113 (EGTPCPathFailClear) context SAEGW, service SGW-S5, interface type sgw-egress, self address 201.175.153.170, peer address 186.37.245.1, peer restart counter 5, peer session count 2, clear reason echo-req +Wed Aug 10 09:56:06 2022 Internal trap notification 1184 (TestModeEntered) context local user dv503s ttyname /dev/pts/4 address type IPV4 remote ip address 10.32.1.144 +Wed Aug 10 09:57:21 2022 Internal trap notification 53 (CLISessionEnd) user dv503s privilege level Security Administrator ttyname /dev/pts/4 + """ + + def cli(self, output=None): + if output is None: + out = self.device.execute(self.cli_command) + else: + out = output + + # initial return dictionary + trap_dict = {} + + result_dict = {} + + # initial regexp pattern + p0 = re.compile(r'\w+\s(?P\w+\s\d+)\s(?P