Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

juniper_junos_command returning inconsistent results between JSON and text #401

Closed
dpizzle opened this issue Sep 28, 2018 · 3 comments
Closed

Comments

@dpizzle
Copy link

dpizzle commented Sep 28, 2018

Issue Type

  • Bug Report

Module Name

juniper_junos_command

ansible 2.6.4
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

Juniper.junos, 2.1.0

OS / Environment

SRX300
15.1X49-D120.3-domestic

Summary

The SRX300 has a primary and backup partition. I am looking for the juniper_junos_command command to return the JUNOS version of both partition. It does with formats: text, but with formats: json it only returns details for the primary partition.

Steps to reproduce

- name: show system snapshot
  juniper_junos_command:
    provider: '{{ conn_netconf }}'
    commands:
      - show system snapshot media internal
      - show system snapshot media internal
    formats:
      - json
      - text
  register: cmd_output_environment

- debug:
    msg: '{{ cmd_output_environment }}'

Expected results

formats: json to return output for both the primary and backup partitions, not just the primary.

Actual results

In the debug output below, the first result if from formats: json and the second is from formats: text for comparison.

PLAY [all] ******************************************************************************************************************************************************************************************************************************

TASK [jnpr_system_snapshot : show system snapshot] ***********************************************************************************************************************************************************************************
ok: [srx300-01]

TASK [jnpr_system_snapshot : debug] ****************************************************************************************************************************************************************************************************
ok: [srx300-01] => {
    "msg": {
        "changed": false,
        "failed": false,
        "results": [
            {
                "changed": false,
                "command": "show system snapshot media internal",
                "failed": false,
                "format": "json",
                "msg": "The command executed successfully.",
                "parsed_output": {
                    "snapshot-information": [
                        {
                            "creation-date": [
                                {
                                    "data": "Sep 13 17:01:13 2018"
                                }
                            ],
                            "snapshot-medium": [
                                {
                                    "data": "      internal (/dev/da0s2a) (primary)"
                                }
                            ],
                            "software-version": [
                                {
                                    "package": [
                                        {
                                            "package-name": [
                                                {
                                                    "data": "junos"
                                                }
                                            ],
                                            "package-version": [
                                                {
                                                    "data": "15.1X49-D120.3-domestic"
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                },
                "stdout": "{u'snapshot-information': [{u'snapshot-medium': [{u'data': u'      internal (/dev/da0s2a) (primary)'}], u'software-version': [{u'package': [{u'package-name': [{u'data': u'junos'}], u'package-version': [{u'data': u'15.1X49-D120.3-domestic'}]}]}], u'creation-date': [{u'data': u'Sep 13 17:01:13 2018'}]}]}",
                "stdout_lines": [
                    "{u'snapshot-information': [{u'snapshot-medium': [{u'data': u'      internal (/dev/da0s2a) (primary)'}], u'software-version': [{u'package': [{u'package-name': [{u'data': u'junos'}], u'package-version': [{u'data': u'15.1X49-D120.3-domestic'}]}]}], u'creation-date': [{u'data': u'Sep 13 17:01:13 2018'}]}]}"
                ]
            },
            {
                "changed": false,
                "command": "show system snapshot media internal",
                "failed": false,
                "format": "text",
                "msg": "The command executed successfully.",
                "stdout": "\nInformation for snapshot on       internal (/dev/da0s1a) (backup)\nCreation date: Sep 3 22:19:31 2017\nJUNOS version on snapshot:\n  junos  : 15.1X49-D70.3-domestic\nInformation for snapshot on       internal (/dev/da0s2a) (primary)\nCreation date: Sep 13 17:01:13 2018\nJUNOS version on snapshot:\n  junos  : 15.1X49-D120.3-domestic\n",
                "stdout_lines": [
                    "",
                    "Information for snapshot on       internal (/dev/da0s1a) (backup)",
                    "Creation date: Sep 3 22:19:31 2017",
                    "JUNOS version on snapshot:",
                    "  junos  : 15.1X49-D70.3-domestic",
                    "Information for snapshot on       internal (/dev/da0s2a) (primary)",
                    "Creation date: Sep 13 17:01:13 2018",
                    "JUNOS version on snapshot:",
                    "  junos  : 15.1X49-D120.3-domestic"
                ]
            }
        ]
    }
}

PLAY RECAP ******************************************************************************************************************************************************************************************************************************
srx300-01          : ok=2    changed=0    unreachable=0    failed=0
@stacywsmith
Copy link
Contributor

What's the output of executing show system snapshot media internal | display json from the CLI of your SRX300?

@dpizzle
Copy link
Author

dpizzle commented Sep 28, 2018

user@srx300-01> show system snapshot media internal | display json
{
    "snapshot-information" : [
    {
        "snapshot-medium" : [
        {
            "data" : "      internal (/dev/da0s1a) (backup)\n  "
        }
        ],
        "creation-date" : [
        {
            "data" : "Sep 3 22:19:31 2017\n  "
        }
        ],
        "software-version" : [
        {
            "package" : [
            {
                "package-name" : [
                {
                    "data" : "junos"
                }
                ],
                "package-version" : [
                {
                    "data" : "15.1X49-D70.3-domestic"
                }
                ]
            }
            ]
        }
        ],
        "snapshot-medium" : [
        {
            "data" : "      internal (/dev/da0s2a) (primary)\n  "
        }
        ],
        "creation-date" : [
        {
            "data" : "Sep 13 17:01:13 2018\n  "
        }
        ],
        "software-version" : [
        {
            "package" : [
            {
                "package-name" : [
                {
                    "data" : "junos"
                }
                ],
                "package-version" : [
                {
                    "data" : "15.1X49-D120.3-domestic"
                }
                ]
            }
            ]
        }
        ]
    }
    ]
}

@rahkumar651991
Copy link
Contributor

The issue seem to have be due to json duplicate keys not converted to list.
There is another issue #562 for the same. Closing this, will track the issue from the other one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants