--
You received this message because you are subscribed to the Google Groups "Junos Python EZ" group.
To unsubscribe from this group and stop receiving emails from it, send an email to junos-python-...@googlegroups.com.
Visit this group at https://groups.google.com/group/junos-python-ez.
To view this discussion on the web visit https://groups.google.com/d/msgid/junos-python-ez/98be4e2f-ecdf-4e46-9b9d-0ef48d31f6c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Junos Python EZ" group.
To unsubscribe from this group and stop receiving emails from it, send an email to junos-python-...@googlegroups.com.
Visit this group at https://groups.google.com/group/junos-python-ez.
To view this discussion on the web visit https://groups.google.com/d/msgid/junos-python-ez/2a5e8faa-4006-4ce3-a61d-696d49a48f96%40googlegroups.com.
from jnpr.junos.op.routes import RouteTable
from jnpr.junos.jxml import remove_namespaces
root = etree.parse('routes.xml').getroot()
rt_info = root.getchildren()[0]
tbl = RouteTable()
tbl.xml = remove_namespaces(rt_info)
print tbl.items()
To view this discussion on the web visit https://groups.google.com/d/msgid/junos-python-ez/CFA87083-A0A5-41DA-BA99-65B59D5D5B30%40acm.org.
root = etree.parse('routes.xml').getroot()
rt_info = root.getchildren()[0]
tbl = RouteTable()
tbl.xml = remove_namespaces(rt_info)
print tbl.items()
tbl.savexml('<some path>/newxml.xml')new_route_table = RouteTable(path=newxml.xml').get()
print new_route_table
I've tried this and it does not seem to work when I read the file back. Is this something you would expect to work?
Thanks again
Gav
Can you replace below line in jxml.py file
>>> return NCElement(etree.tostring(reply), transform_reply)._NCElement__doc
With>>>return NCElement(reply, transform_reply)._NCElement__doc
from jnpr.junos.op.routes import RouteTable
from jnpr.junos.jxml import cscript_conf as process_reply
rpc_reply = process_reply(open('routes.xml').read())
tbl = RouteTable()
tbl.xml = rpc_reply.getchildren()[0]
tbl.savexml('newxml.xml')
new_route_table = RouteTable(path='newxml.xml').get()
--
You received this message because you are subscribed to the Google Groups "Junos Python EZ" group.
To unsubscribe from this group and stop receiving emails from it, send an email to junos-python-...@googlegroups.com.
Visit this group at https://groups.google.com/group/junos-python-ez.
To view this discussion on the web visit https://groups.google.com/d/msgid/junos-python-ez/afdd0911-4f40-43f8-aae7-6547ebabc8a4%40googlegroups.com.
from lxml import etree
from jnpr.junos.op.routetable import RouteTable
from jnpr.junos.jxml import cscript_conf as process_reply
root = etree.parse('/<path>/routes.xml').getroot()
rpc_reply = process_reply(root)
tbl = RouteTable()
tbl.xml = rpc_reply.getchildren()[0]
>>> tbl
RouteTable:None: 5 items
or
2. You can change the following function in the jnpr.junos.jxml.py file
From
def cscript_conf(reply):
try:
device_params = {'name': 'junos'}
device_handler = manager.make_device_handler(device_params)
transform_reply = device_handler.transform_reply()
return NCElement(etree.tostring(reply), transform_reply)._NCElement__doc
except:
traceback.print_exc(file=sys.stdout)
return None
To
def cscript_conf(reply):
try:
device_params = {'name': 'junos'}
device_handler = manager.make_device_handler(device_params)
transform_reply = device_handler.transform_reply()
return NCElement(reply, transform_reply)._NCElement__doc
except:
traceback.print_exc(file=sys.stdout)
return None