Juniper / py-junos-eznc

Python library for Junos automation
https://www.juniper.net/documentation/en_US/junos-pyez/information-products/pathway-pages/junos-pyez-developer-guide.html
Apache License 2.0
670 stars 344 forks source link

EVO software package delete RPC doesn't return full output #1196

Closed harshitakapadia closed 1 year ago

harshitakapadia commented 2 years ago

I came across kind of issue while executing RPC’s : From REST API Explorer API when I test RPC request from explorer, I do get to see the entire output but when I do it via script the output from the device is only limited to the first line between the first tag of

Here is the execution code :

dev = Device(host= user='username', password='password', port=) 
dev.open()

try :

sw = dev.rpc.request_package_delete(archived=True, dev_timeout=3600)

 except Exception as error:

print(error)


print(type(sw))
 print(etree.tostring(sw,method='html',with_tail=False))

REST_API_explorer_output PYEZ_execution_output

chidanandpujar commented 1 year ago

Hi,

Could you please check with following options .


from jnpr.junos import Device
import xml.etree.ElementTree as etree 

dev = Device(host='xx.xx.xx.xx', user='xyz', password='xyz', port=22)
dev.open()

try :
    sw = dev.rpc.request_package_delete(package_name="na-telemetry", dev_timeout=3600)
except Exception as error:
    print(error)

print(type(sw))
print(etree.tostring(sw,method='html'))

<class 'lxml.etree._Element'>
b'<output>\nNOTICE: Validating configuration against absence of na-telemetry\nInitializing...\nMounting os-libs-11-x86-64-20210722.b0da34e0_builder_stable_11-204ab\nMounting os-runtime-x86-64-20210722.b0da34e0_builder_stable_11-204ab\nMounting os-zoneinfo-20210722.b0da34e0_builder_stable_11-204ab\nMounting junos-net-prd-x86-64-20211110.173530_builder_junos_202_r3_s3\nMounting junos-libs-x86-64-20211110.173530_builder_junos_202_r3_s3\nMounting os-libs-compat32-11-x86-64-20210722.b0da34e0_builder_stable_11-204ab\nMounting os-compat32-x86-64-20210722.b0da34e0_builder_stable_11-204ab\nMounting junos-libs-compat32-x86-64-20211110.173530_builder_junos_202_r3_s3\nMounting junos-runtime-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting jsim-pfe-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting sflow-mx-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting py-extensions2-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting py-extensions-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting py-base2-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting py-base-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting os-vmguest-x86-64-20210722.b0da34e0_builder_stable_11-204ab\nMounting os-crypto-x86-64-20210722.b0da34e0_builder_stable_11-204ab\nMounting junos-secintel-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting junos-libs-compat32-mx-x86-64-20211110.173530_builder_junos_202_r3_s3\nMounting junos-runtime-mx-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting junos-rpd-telemetry-application-x86-64-20.2R3-S3.6\nMounting junos-redis-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting junos-platform-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting junos-openconfig-x86-32-20.2R3-S3.6\nMounting junos-modules-x86-64-20211110.173530_builder_junos_202_r3_s3\nMounting junos-modules-mx-x86-64-20211110.173530_builder_junos_202_r3_s3\nMounting junos-libs-mx-x86-64-20211110.173530_builder_junos_202_r3_s3\nMounting junos-jsqlsync-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting junos-dp-crypto-support-mtx-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting junos-daemons-x86-64-20211110.173530_builder_junos_202_r3_s3\nMounting junos-daemons-mx-x86-64-20211110.173530_builder_junos_202_r3_s3\nMounting jsim-wrlinux-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting jsim-pfe-vmx-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting jsim-pfe-internal-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting jsdn-x86-32-20.2R3-S3.6\nMounting jsd-x86-32-20.2R3-S3.6-jet-1\nMounting jpfe-wrlinux9-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting jpfe-wrlinux-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting jpfe-spc3-mx-x86-32-20.2R3-S3.6\nMounting jpfe-X960-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting jpfe-common-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting jpfe-aft-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting jpfe-X-x86-32-20211110.173530_builder_junos_202_r3_s3\nMounting jmrt-base-x86-64-20211110.173530_builder_junos_202_r3_s3\nMounting jinsight-x86-32-20.2R3-S3.6\nMounting jfirmware-x86-32-20.2R3-S3.6\nMounting jdocs-x86-32-20211110.173530_builder_junos_202_r3_s3\nHardware Database regeneration succeeded\nValidating against /config/juniper.conf.gz\nmgd: commit complete\nValidation succeeded\n/packages/db/na-telemetry-x86-32-20.2R3-S3.6\nRebuilding schema and Activating configuration...\nmgd: commit complete\nRestarting MGD ...\n</output>'
chidanandpujar commented 1 year ago

Hi ,

issue is reproducible only on EVO ,

python issue_1196.py <class 'lxml.etree._Element'> b'\nSoftware delete in progress...'

Netconf trace logs :

Dec 6 05:38:43 [NETCONF] - [20029] Incoming: Received ']]>]]>' token which is split in two consecutive streams or has leading/trailing spaces/tabs or both. Dec 6 05:38:44 [NETCONF] - [20029] Incoming: <?xml version="1.0" encoding="UTF-8"?></nc:rpc>]]>]]> Dec 6 05:38:44 [NETCONF] - [20029] Outgoing: Dec 5 21:38:45 [NETCONF] - [20029] Outgoing: Dec 5 21:38:45 [NETCONF] - [20029] Outgoing: Software delete in progress... Dec 5 21:38:45 [NETCONF] - [20029] Outgoing: Dec 5 21:38:48 [NETCONF] - [20029] Outgoing: Dec 5 21:38:48 [NETCONF] - [20029] Outgoing: re0: Executing Software delete... Dec 5 21:38:48 [NETCONF] - [20029] Outgoing: Dec 5 21:38:50 [NETCONF] - [20029] Outgoing: Dec 5 21:38:50 [NETCONF] - [20029] Outgoing: re0: Removing external packages for junos-evo-install-ptx-x86-64-... Dec 5 21:38:50 [NETCONF] - [20029] Outgoing: Dec 5 21:38:50 [NETCONF] - [20029] Outgoing: Dec 5 21:38:50 [NETCONF] - [20029] Outgoing: re0: Done. Dec 5 21:38:50 [NETCONF] - [20029] Outgoing: Dec 5 21:38:57 [NETCONF] - [20029] Outgoing: Dec 5 21:38:57 [NETCONF] - [20029] Outgoing: re1: Removing external packages for junos-evo-install-ptx-x86-64-2... Dec 5 21:38:57 [NETCONF] - [20029] Outgoing: Dec 5 21:38:57 [NETCONF] - [20029] Outgoing: Dec 5 21:38:57 [NETCONF] - [20029] Outgoing: re1: Done. Dec 5 21:38:57 [NETCONF] - [20029] Outgoing: Dec 5 21:39:01 [NETCONF] - [20029] Outgoing: Dec 5 21:39:01 [NETCONF] - [20029] Outgoing: Image deletion succeeded. Dec 5 21:39:01 [NETCONF] - [20029] Outgoing: Dec 5 21:39:01 [NETCONF] - [20029] Outgoing: Dec 5 21:39:01 [NETCONF] - [20029] Outgoing: ]]>]]> Dec 5 21:39:01 [NETCONF] - [20029] Incoming: Received ']]>]]>' token which is split in two consecutive streams or has leading/trailing spaces/tabs or both. Dec 5 21:39:01 [NETCONF] - [20029] Outgoing:

Thanks Chidanand

chidanandpujar commented 1 year ago

Hi,

please check following solution ,

from jnpr.junos import Device
import xml.etree.ElementTree as etree

dev = Device(host='xx.xx.xx.xx', user='xyz', password='xyz', port=22)
dev.open()

try :
    sw = dev.rpc.request_package_delete(archived=True, dev_timeout=3600)
except Exception as error:
    print(error)

print(etree.tostring(sw.getparent()))

python issue_1196.py 
b'<rpc-reply message-id="urn:uuid:e50fbdaf-f7a8-4643-999b-9152f41dfe3c"><output>\nSoftware delete in progress...</output><output>\nre0: Executing Software delete...</output><output>\nre0: Removing external packages for junos-evo-install-ptx-x86-64-...</output><output>\nre0: Done.</output><output>\nre1: Removing external packages for junos-evo-install-ptx-x86-64-...</output><output>\nre1: Done.</output><output>\nImage deletion succeeded.</output></rpc-reply>'

Thanks Chidanand

harshitakapadia commented 1 year ago

Thank you Chidanand for fixing the issue. Appreciate it!

Thanks, Harshita

From: chidanandpujar @.> Date: Tuesday, December 6, 2022 at 3:33 AM To: Juniper/py-junos-eznc @.> Cc: Harshita Sunilkumar Kapadia @.>, Author @.> Subject: Re: [Juniper/py-junos-eznc] EVO software package delete RPC doesn't return full output (Issue #1196) [External Email. Be cautious of content]

Hi,

please check following solution ,

from jnpr.junos import Device import xml.etree.ElementTree as etree

dev = Device(host='xx.xx.xx.xx', user='xyz', password='xyz', port=22) dev.open()

try : sw = dev.rpc.request_package_delete(archived=True, dev_timeout=3600) except Exception as error: print(error)

print(etree.tostring(sw.getparent()))

python issue_1196.py b'\nSoftware delete in progress...\nre0: Executing Software delete...\nre0: Removing external packages for junos-evo-install-ptx-x86-64-...\nre0: Done.\nre1: Removing external packages for junos-evo-install-ptx-x86-64-...\nre1: Done.\nImage deletion succeeded.'

Thanks Chidanand

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/Juniper/py-junos-eznc/issues/1196*issuecomment-1338962847__;Iw!!NEt6yMaO-gk!G457yXL1XwcM2lyJQ4Fz35Rjn8rrrQL248apZI_v4AgHCAZ4pd6eJEKQ4Bj3DlYwN66BdhBYGmQpr-QvFrmPR2gAWQ$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/A2ICITKVQQWBAGAAEOKFYJ3WL326FANCNFSM54ZWMRDA__;!!NEt6yMaO-gk!G457yXL1XwcM2lyJQ4Fz35Rjn8rrrQL248apZI_v4AgHCAZ4pd6eJEKQ4Bj3DlYwN66BdhBYGmQpr-QvFrkauX72ZA$. You are receiving this because you authored the thread.Message ID: @.***>

Juniper Business Use Only