|
1 | | -import re |
2 | 1 | import pytest |
3 | 2 | import time |
4 | 3 | import logging |
@@ -522,82 +521,78 @@ def add_delete_auto_techsupport_feature(duthost, feature, action=None, state=DEF |
522 | 521 | def parse_show_auto_techsupport_global(duthost): |
523 | 522 | """ |
524 | 523 | Parse output for cmd "show auto-techsupport global" |
525 | | - STATE RATE LIMIT INTERVAL (sec) MAX TECHSUPPORT LIMIT (%) MAX CORE LIMIT (%) SINCE |
526 | | - ------- --------------------------- --------------------------- -------------------- ---------- |
527 | | - enabled 180 10 5 2 days ago |
| 524 | + STATE RATE LIMIT INTERVAL (sec) MAX TECHSUPPORT LIMIT (%) MAX CORE LIMIT (%) AVAILABLE MEM THRESHOLD (%) MIN AVAILABLE MEM (Kb) SINCE |
| 525 | + ------- --------------------------- --------------------------- -------------------- --------------------------- ---------------------- ------------ |
| 526 | + enabled 180 10 5 10 200 2 days ago |
528 | 527 | :param duthost: duthost object |
529 | 528 | :return: dictionary with parsed result, example: {'state': 'enabled', 'rate_limit_interval': '180', |
530 | | - 'max_techsupport_limit': '10', 'max_core_size': '5', 'since': '2 days ago'} |
| 529 | + 'max_techsupport_limit': '10', 'max_core_size': '5', 'available_mem_thresh': '10', |
| 530 | + 'min_available_mem': '200', 'since': '2 days ago'} |
531 | 531 | """ |
532 | 532 | with allure.step('Parsing "show auto-techsupport global" output'): |
533 | | - regexp = r'(enabled|disabled)\s+(\d+)\s+(\d+.\d+|\d+)\s+(\d+.\d+|\d+)\s+(.*)' |
534 | | - cmd_output = duthost.shell('show auto-techsupport global')['stdout'] |
535 | | - state, rate_limit_interval, max_techsupport_limit, max_core_size, since = re.search(regexp, cmd_output).groups() |
536 | | - result_dict = {'state': state, 'rate_limit_interval': rate_limit_interval, |
537 | | - 'max_techsupport_limit': max_techsupport_limit, 'max_core_size': max_core_size, 'since': since} |
| 533 | + cmd_output = duthost.show_and_parse('show auto-techsupport global')[0] |
| 534 | + result_dict = {'state': cmd_output['state'], 'rate_limit_interval': cmd_output['rate limit interval (sec)'], |
| 535 | + 'max_techsupport_limit': cmd_output['max techsupport limit (%)'], 'max_core_size': cmd_output['max core limit (%)'], |
| 536 | + 'available_mem_thresh': cmd_output.get('available mem threshold (%)', None), 'min_available_mem': cmd_output.get('min available mem (kb)', None), |
| 537 | + 'since': cmd_output['since']} |
538 | 538 | return result_dict |
539 | 539 |
|
540 | 540 |
|
541 | 541 | def parse_show_auto_techsupport_feature(duthost): |
542 | 542 | """ |
543 | 543 | Parse output for cmd "show auto-techsupport-feature" |
544 | | - FEATURE NAME STATE RATE LIMIT INTERVAL (sec) |
545 | | - -------------- ------- --------------------------- |
546 | | - bgp enabled 600 |
547 | | - database enabled 600 |
548 | | - dhcp_relay enabled 600 |
549 | | - lldp enabled 600 |
550 | | - macsec enabled 600 |
551 | | - mgmt-framework enabled 600 |
552 | | - mux enabled 600 |
553 | | - nat enabled 600 |
554 | | - pmon enabled 600 |
555 | | - radv enabled 600 |
556 | | - sflow enabled 600 |
557 | | - snmp enabled 600 |
558 | | - swss enabled 600 |
559 | | - syncd enabled 600 |
560 | | - teamd enabled 600 |
561 | | - telemetry enabled 600 |
| 544 | + FEATURE NAME STATE RATE LIMIT INTERVAL (sec) AVAILABLE MEM THRESHOLD (%) |
| 545 | + -------------- ------- --------------------------- --------------------------- |
| 546 | + bgp enabled 600 10.0 |
| 547 | + database enabled 600 10.0 |
| 548 | + dhcp_relay enabled 600 N/A |
| 549 | + lldp enabled 600 10.0 |
| 550 | + macsec enabled 600 N/A |
| 551 | + mgmt-framework enabled 600 10.0 |
| 552 | + mux enabled 600 10.0 |
| 553 | + nat enabled 600 10.0 |
| 554 | + pmon enabled 600 10.0 |
| 555 | + radv enabled 600 10.0 |
| 556 | + sflow enabled 600 10.0 |
| 557 | + snmp enabled 600 10.0 |
| 558 | + swss enabled 600 10.0 |
| 559 | + syncd enabled 600 10.0 |
| 560 | + teamd enabled 600 10.0 |
| 561 | + telemetry enabled 600 10.0 |
562 | 562 | :param duthost: duthost object |
563 | | - :return: dictionary with parsed result, example: {'bgp': {'status': 'enabled', 'rate_limit_interval': '600'}, |
| 563 | + :return: dictionary with parsed result, example: {'bgp': {'status': 'enabled', 'rate_limit_interval': '600', 'available_mem_thresh': 10.0}, |
564 | 564 | 'database': {'status': 'enabled', 'rate_limit_interval': '600'}, ...} |
565 | 565 | """ |
566 | 566 | with allure.step('Parsing "show auto-techsupport-feature" output'): |
567 | 567 | result_dict = {} |
568 | | - regexp = r'(\w+-\w+|\w+)\s+(enabled|disabled)\s+(\d+)' |
569 | | - cmd_output = duthost.shell('show auto-techsupport-feature')['stdout'] |
570 | | - |
571 | | - name_index = 0 |
572 | | - state_index = 1 |
573 | | - rate_limit_index = 2 |
574 | | - for feature in re.findall(regexp, cmd_output): |
575 | | - result_dict[feature[name_index]] = {'status': feature[state_index], |
576 | | - 'rate_limit_interval': feature[rate_limit_index]} |
| 568 | + cmd_output = duthost.show_and_parse('show auto-techsupport-feature') |
| 569 | + for feature in cmd_output: |
| 570 | + feature_name = feature['feature name'] |
| 571 | + result_dict[feature_name] = {'status': feature['state'], |
| 572 | + 'rate_limit_interval': feature['rate limit interval (sec)'], |
| 573 | + 'available_mem_thresh': feature.get('available mem threshold (%)', None)} |
577 | 574 | return result_dict |
578 | 575 |
|
579 | 576 |
|
580 | 577 | def parse_show_auto_techsupport_history(duthost): |
581 | 578 | """ |
582 | 579 | Parse output for cmd "show auto-techsupport history" |
583 | | - TECHSUPPORT DUMP TRIGGERED BY CORE DUMP |
584 | | - ---------------------------------------- -------------- ----------------------------- |
585 | | - sonic_dump_r-lionfish-16_20210901_221402 bgp bgpcfgd.1630534439.55.core.gz |
| 580 | + TECHSUPPORT DUMP TRIGGERED BY EVENT TYPE CORE DUMP |
| 581 | + ---------------------------------------- -------------- ------------ ---------------- |
| 582 | + sonic_dump_r-lionfish-16_20210901_221402 bgp core bgpcfgd.1630534439.55.core.gz |
586 | 583 | :param duthost: duthost object |
587 | 584 | :return: dictionary with parsed result, example: {'sonic_dump_r-lionfish-16_20210901_221402': |
588 | | - {'triggered_by': 'bgp', 'core_dump': 'bgpcfgd.1630534439.55.core.gz'}, ...} |
| 585 | + {'triggered_by': 'bgp', 'event_type': 'core', 'core_dump': 'bgpcfgd.1630534439.55.core.gz'}, ...} |
589 | 586 | """ |
590 | 587 | with allure.step('Parsing "show auto-techsupport history" output'): |
591 | 588 | result_dict = {} |
592 | | - regexp = r'(sonic_dump_.*)\s+(\w+|\w+\W\w+)\s+(\w+\.\d+\.\d+\.core\.gz)' |
593 | | - cmd_output = duthost.shell('show auto-techsupport history')['stdout'] |
594 | | - |
595 | | - dump_name_index = 0 |
596 | | - triggered_by_index = 1 |
597 | | - core_dump_index = 2 |
598 | | - for dump in re.findall(regexp, cmd_output): |
599 | | - result_dict[dump[dump_name_index].strip()] = {'triggered_by': dump[triggered_by_index], |
600 | | - 'core_dump': dump[core_dump_index]} |
| 589 | + cmd_output = duthost.show_and_parse('show auto-techsupport history') |
| 590 | + if cmd_output: |
| 591 | + for dump in cmd_output: |
| 592 | + dump_name = dump['techsupport dump'] |
| 593 | + result_dict[dump_name] = {'triggered_by': dump['triggered by'], |
| 594 | + 'event_type': dump.get('event type', None), |
| 595 | + 'core_dump': dump['core dump']} |
601 | 596 | return result_dict |
602 | 597 |
|
603 | 598 |
|
|
0 commit comments