Automation

 View Only
last person joined: 2 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  Trying to use Pyez with

    Posted 05-20-2024 20:15
    Edited by spuluka 30 days ago
    Summary
    I am trying to switch my python paramiko scripts to use pyez
    Description
    I am trying to parse show security nat resource-usage source-pool all but it only returns 1 line
    (venv) [serveradmin@RHEL8-20230921 junos-pyezP311]$ ./pyextest.py
    False
    cli -c "show security nat resource-usage source-pool all" node0:
    --------------------------------------------------------------------------
     PAT pools(including address-shared pool) port utilization:
    Pool Address Used Avail Total Usage
    gos_src_pool_198_169_34_113 1 1106 63406 64512 1%
    Here is the code below , any ideas?
    #!/home/serveradmin/code/junos-pyezP311/venv/bin/python
    from jnpr.junos import Device
    from pprint import pprint
    from jnpr.junos.utils.start_shell import StartShell
    dev = Device(host='10.228.9.75', user='xxxxxxx', password='yyyyyyy')
    dev.open()
    ss=StartShell(dev)
    ss.open() 
    result = ss.run('cli -c "show security nat resource-usage source-pool all"')
    ss.close()
     for line in result:
           print( line)



    ------------------------------
    ROB MERRITT
    ------------------------------



  • 2.  RE: Trying to use Pyez with

    Posted 05-21-2024 05:20
    Edited by spuluka 30 days ago

    Hi Rob,
    the line: "ss=StartShell(dev) ss.open()" should be
    ss=StartShell(dev)
    ss.open()

    Maybe it was only a typo.
    After I changed this, it worked well.
    If you still have problem, check that you use the latest pyez



    ------------------------------
    Kalle Andersson
    ------------------------------



  • 3.  RE: Trying to use Pyez with

    Posted 22 days ago

    yup that is what I have, but it still only get the first line back from pools

    [serveradmin@RHEL8-20230921 junos-pyezP311]$ cat pyextest.py
    #!/home/serveradmin/code/junos-pyezP311/venv/bin/python


    from jnpr.junos import Device
    from pprint import pprint
    from jnpr.junos.utils.start_shell import StartShell

    dev = Device(host='10.228.9.75', user='nodebkup', password='s@vem3')
    dev.open()
    ss=StartShell(dev)
    ss.open()
    result = ss.run('cli -c "show security nat resource-usage source-pool all"')
    ss.close()

    print(result)
    print("-----------------------------------------------------------------------------")
    for line in result:
         print(line)
    [serveradmin@RHEL8-20230921 junos-pyezP311]$ ./pyextest.py
    (False, 'cli -c "show security nat resource-usage source-pool all"\r\r\nnode0:\r\n--------------------------------------------------------------------------\r\n\r\nPAT pools(including address-shared pool) port utilization:\r\n  Pool                                Address      Used     Avail     Total Usage\r\n  gos_src_pool_198_169_34_113               1      2059     62453     64512    3%\r\n')
    -----------------------------------------------------------------------------
    False
    cli -c "show security nat resource-usage source-pool all"
    node0:
    --------------------------------------------------------------------------

    PAT pools(including address-shared pool) port utilization:
      Pool                                Address      Used     Avail     Total Usage
      gos_src_pool_198_169_34_113               1      2059     62453     64512    3%



    ------------------------------
    ROB MERRITT
    ------------------------------