Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return sr.SR_ERR_OK
# Notable difference between c implementation is using exception mechanism for open handling unexpected events.
# Here it is useful because `Conenction`, `Session` and `Subscribe` could throw an exception.
try:
module_name = "ietf-interfaces"
if len(sys.argv) > 1:
module_name = sys.argv[1]
else:
print ("\nYou can pass the module name to be subscribed as the first argument")
print ("Application will watch for changes in " + module_name + "\n")
# connect to sysrepo
conn = sr.Connection(sr.SR_CONN_DEFAULT)
# start session
sess = sr.Session(conn)
# subscribe for changes in running config */
subscribe = sr.Subscribe(sess)
subscribe.module_change_subscribe(module_name, module_change_cb, None)
print ("\n\n ========== READING RUNNING CONFIG: ==========\n")
try:
print_current_config(sess, module_name);
except Exception as e:
print (e)
sr.global_loop()
print_current_config(sess, module_name)
return sr.SR_ERR_OK
# Notable difference between c implementation is using exception mechanism for open handling unexpected events.
# Here it is useful because `Conenction`, `Session` and `Subscribe` could throw an exception.
try:
module_name = "ietf-interfaces"
if len(sys.argv) > 1:
module_name = sys.argv[1]
else:
print ("\nYou can pass the module name to be subscribed as the first argument")
# connect to sysrepo
conn = sr.Connection(sr.SR_CONN_DEFAULT)
# start session
sess = sr.Session(conn)
# subscribe for changes in running config */
subscribe = sr.Subscribe(sess)
subscribe.module_change_subscribe(module_name, module_change_cb, None, None, 0, sr.SR_SUBSCR_DONE_ONLY)
print ("\n\n ========== READING RUNNING CONFIG: ==========\n")
try:
print_current_config(sess, module_name)
except Exception as e:
print (e)
sr.global_loop()
except Exception as e:
print (e)
return sr.SR_ERR_OK
return sr.SR_ERR_OK
# Notable difference between c implementation is using exception mechanism for open handling unexpected events.
# Here it is useful because `Conenction`, `Session` and `Subscribe` could throw an exception.
try:
module_name = "ietf-interfaces"
if len(sys.argv) > 1:
module_name = sys.argv[1]
else:
print ("\nYou can pass the module name to be subscribed as the first argument")
# connect to sysrepo
conn = sr.Connection(sr.SR_CONN_DEFAULT)
# start session
sess = sr.Session(conn)
# subscribe for changes in running config */
subscribe = sr.Subscribe(sess)
print ("\nApplication will provide data of " + module_name + " module\n")
#try:
subscribe.oper_get_items_subscribe(module_name, "/ietf-interfaces:interfaces-state", oper_get_items_cb1)
#except Exception as e:
# print (e)
sr.global_loop()