コード例 #1
0
yuma.init()

print("Loading schema module python-yuma-example.yang")

(res, mod) = yuma.schema_module_load("python-yuma-example.yang")
if(res!=0):
    print("Error: python-yuma-example.yang failed to load!")
    sys.exit(1)

(res, root_val) = yuma.cfg_load("python-yuma-example.xml")
if(res!=0):
    print("Error: python-yuma-example.xml failed to load!")
    sys.exit(1)

(res, python_yuma_example_val) = yuma.val_find_child(root_val, "python-yuma-example", "python-yuma-example")
if(res!=0):
    print("Error: Missing /python-yuma-example container!")
    sys.exit(1)

(res, message_val) = yuma.val_find_child(python_yuma_example_val, "python-yuma-example", "message")
if(res!=0):
    print("Error: Missing /python-yuma-example/message leaf!")
    sys.exit(1)

print(yuma.val_string(message_val))

yuma.val_dump_value(root_val,1)

print("Done.")
コード例 #2
0
import yuma
import yangrpc
import sys

conn = yangrpc.connect("127.0.0.1", 830, "root", "mysecretpass","/root/.ssh/id_rsa","/root/.ssh/id_rsa.pub")
if(conn==None):
    print("Error: yangrpc failed to connect!")
    sys.exit(1)

(res, rpc_val) = yangrpc.parse_cli(conn, "xget /interfaces-state")
if(res!=0):
    print("Error: yangrpc failed to parse cli command!")
    sys.exit(1)

yuma.val_dump_value(rpc_val,1)

(res, reply_val) = yangrpc.rpc(conn, rpc_val)
if(res!=0):
    print("Error: yangrpc failed to execute rpc!")
    sys.exit(1)

yuma.val_dump_value(reply_val,1)

print("Done.")
コード例 #3
0
yuma.init()

print("Loading schema module python-yuma-example.yang")

(res, mod) = yuma.schema_module_load("python-yuma-example.yang")
if(res!=0):
    print("Error: python-yuma-example.yang failed to load!")
    sys.exit(1)

obj = yuma.ncx_find_object(mod,"python-yuma-example")
assert(obj!=None)
val = yuma.val_new_value()
res = yuma.val_set_cplxval_obj(val, obj,"""
{
  "python-yuma-example:python-yuma-example": {
    "message": "hello world"
  }
}
""")

val = yuma.val_new_value()
res = yuma.val_set_cplxval_obj(val, obj,"""
  <python-yuma-example xmlns="http://yuma123.org/ns/python-yuma-example">
      <message>hello world</message>
  </python-yuma-example>
""")

yuma.val_dump_value(val,1)

print("Done.")
コード例 #4
0
print("Loading schema module python-yuma-example.yang")

(res, mod) = yuma.schema_module_load("python-yuma-example.yang")
if (res != 0):
    print("Error: python-yuma-example.yang failed to load!")
    sys.exit(1)

(res, root_val) = yuma.cfg_load("python-yuma-example.xml")
if (res != 0):
    print("Error: python-yuma-example.xml failed to load!")
    sys.exit(1)

(res, python_yuma_example_val) = yuma.val_find_child(root_val,
                                                     "python-yuma-example",
                                                     "python-yuma-example")
if (res != 0):
    print("Error: Missing /python-yuma-example container!")
    sys.exit(1)

(res, message_val) = yuma.val_find_child(python_yuma_example_val,
                                         "python-yuma-example", "message")
if (res != 0):
    print("Error: Missing /python-yuma-example/message leaf!")
    sys.exit(1)

print(yuma.val_string(message_val))

yuma.val_dump_value(root_val, 1)

print("Done.")
コード例 #5
0
import yuma
import yangrpc
import sys

conn = yangrpc.connect("127.0.0.1", 830, "root", "mysecretpass",
                       "/root/.ssh/id_rsa", "/root/.ssh/id_rsa.pub")
if (conn == None):
    print("Error: yangrpc failed to connect!")
    sys.exit(1)

(res, rpc_val) = yangrpc.parse_cli(conn, "xget /interfaces-state")
if (res != 0):
    print("Error: yangrpc failed to parse cli command!")
    sys.exit(1)

yuma.val_dump_value(rpc_val, 1)

(res, reply_val) = yangrpc.rpc(conn, rpc_val)
if (res != 0):
    print("Error: yangrpc failed to execute rpc!")
    sys.exit(1)

yuma.val_dump_value(reply_val, 1)

print("Done.")