Sorry, I was wrong. Please ignore my previous post.
I have only ever used jsc.emit_change(content,'change',format) in commit script. "format" is only support XML.
I don't know of any cases where functions other than jsc.XXX() have been used in a commit script.
------------------------------
RYOTA KOSAKA
------------------------------
Original Message:
Sent: 05-21-2025 02:28
From: RYOTA KOSAKA
Subject: Using PyEZ in on-box commit scripts
Hi
From my understanding, you can't do that.
PyEZ uses netconf, which in turn uses the Junos XML API to manipulate devices.
If you want to use "set commands", you will need to use a ssh-based or telnet-based library to operate the device for accessing CLI.
(I don't recommend it from an error handling perspective.)
------------------------------
RYOTA KOSAKA
Original Message:
Sent: 05-20-2025 14:38
From: Anonymous
Subject: Using PyEZ in on-box commit scripts
This message was posted by a user wishing to remain anonymous
Does anyone know whether it's possible to commit configuration using a Python based commit script, using PyEZ with set commands?
LLMs are hallucinating telling me it's possible, but I'm struggling to find resources pointing to PyEZ's usage on box, despite it being outlined as a supported library https://www.juniper.net/documentation/us/en/software/junos/automation-scripting/topics/concept/junos-python-modules-on-device.html and with most examples I can find point to jcs.emit_change() where only XML based changes are possible.
In essence, I wish to do the below, where change is any valid set command, but I seem to hit an issue that I assume is essentially related to the commit script itself locking the database, and then an attempt made within the commit script to lock the database.
Should I be trying to use an ephemeral database instead, or taking another approach? Does anyone have a working, on-box, pyez example?
Thanks in advance.
with Device() as dev:
with Config(dev, mode='private') as cfg:
cfg.load(change,format="set", merge=True)
cfg.commit(comment="pyez load attempt")