jsnapy icon indicating copy to clipboard operation
jsnapy copied to clipboard

Nested command in the same test

Open 3fr61n opened this issue 8 years ago • 3 comments

Hi

I would like to know if there is any way for (of plan to include) nested commands, or nested test, in the way that output from the parent command will help the child command to validate information.

An Example could be...... I would like to see that 'all isis interfaces has also mpls enabled', so I first need to get the list of isis interfaces, then for each one, check their mpls state.

Not sure if the best way to define the test would be ...

check_mpls_on_isis_interfaces:
  - command: show isis interface 
  - iterate:
      xpath: //isis-interface
      id: './interface-name'
      execute:
        - command: show mpls interface
        - item:
            xpath: //mpls-interface[interface-name = "{{ id }}"]
            tests:
              - is-equal: mpls-interface-state, Up      

Thanks in advance Efrain

3fr61n avatar Jul 06 '16 14:07 3fr61n

Hi @3fr61n

I agree there is a need for nested commands but I'm not sure it it's needed in your case as you are executing the same command twice.

In your case, I think you should be able to create 1 XPath request that return ISIS interface with MPLS enabled directly

Could you share a sample XML ?

Damien

dgarros avatar Jul 06 '16 16:07 dgarros

@3fr61n If needed can be used via ansible modules. Check this out https://github.com/Juniper/ansible-junos-stdlib/blob/jsnapy/library/junos_jsnapy

I got a video for this module reference. trying to upload it, will share once sharing is done.

vnitinv avatar Jul 06 '16 17:07 vnitinv

Thanks Damien/Nitin

@dgarros I just noticed the 'nested command was a copy/paste error' the second command is 'show mpls interfaces' (I just edited)

@vnitinv I'll take a look, but this implies using ansible for the whole testing/validation process. So far we used Robot Framework instead, so we need to double check how to receive the test/failed signal properly from jsnapy through ansible until Robot Framework

Thanks

3fr61n avatar Jul 07 '16 08:07 3fr61n