summaryrefslogtreecommitdiffstats
path: root/ctrl/sysrepo-plugins/hicn-plugin/test/netconf-test/test.py
diff options
context:
space:
mode:
authormhemmatp <mhemmatp@cisco.com>2019-12-16 11:07:06 +0100
committermhemmatp <mhemmatp@cisco.com>2019-12-19 10:49:25 +0100
commitcbdfa74c2f0adaf5d7ff51b6e74d75fd9b4cb0b7 (patch)
treeb809569909545ed546f5a5680b80d30235cc3bcf /ctrl/sysrepo-plugins/hicn-plugin/test/netconf-test/test.py
parenta6325a7343cc971cfca45fb50e4d7a9b9b5a2982 (diff)
[HICN-443] Adding test to hicn sysrepo plugin
Signed-off-by: mhemmatp <mhemmatp@cisco.com> Change-Id: Ib7568d9b44b94664822f3925682bab554c170e5a
Diffstat (limited to 'ctrl/sysrepo-plugins/hicn-plugin/test/netconf-test/test.py')
-rwxr-xr-xctrl/sysrepo-plugins/hicn-plugin/test/netconf-test/test.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/ctrl/sysrepo-plugins/hicn-plugin/test/netconf-test/test.py b/ctrl/sysrepo-plugins/hicn-plugin/test/netconf-test/test.py
new file mode 100755
index 000000000..7c6163521
--- /dev/null
+++ b/ctrl/sysrepo-plugins/hicn-plugin/test/netconf-test/test.py
@@ -0,0 +1,66 @@
+import sys
+import xml.etree.ElementTree as ET
+from netconf.client import connect_ssh
+
+def usage():
+ print('usage: test.py host user password operation{route_dump, face_dump, face_add, route_add, punt_add, face_del, punt_del, route_del}')
+
+def test(host,user,password,operation):
+ with connect_ssh(host, 830, user, password) as session:
+ if (operation=='face_dump'):
+ config = session.get()
+ for root in config:
+ if root.tag=="{urn:sysrepo:hicn}hicn-state":
+ for entity in root:
+ if entity.tag=="{urn:sysrepo:hicn}faces":
+ print('Faces')
+ for face in entity:
+ for elem in face:
+ print(elem.tag +" : "+ elem.text)
+ elif (operation=='state_dump'):
+ config = session.get()
+ for root in config:
+ if root.tag=="{urn:sysrepo:hicn}hicn-state":
+ for entity in root:
+ if entity.tag=="{urn:sysrepo:hicn}states":
+ print('States')
+ for state in entity:
+ print(state.tag +" : "+ state.text)
+ elif (operation=='route_dump'):
+ config = session.get()
+ for root in config:
+ if root.tag=="{urn:sysrepo:hicn}hicn-state":
+ for entity in root:
+ if entity.tag=="{urn:sysrepo:hicn}routes":
+ print('Routes')
+ for route in entity:
+ for elem in route:
+ print(elem.tag +" : "+ elem.text)
+ elif(operation=='face_add'):
+ root = ET.parse('aface.xml').getroot()
+ session.send_rpc(ET.tostring(root, encoding='utf8').decode('utf8'))
+ elif(operation=='punt_add'):
+ root = ET.parse('apunt.xml').getroot()
+ session.send_rpc(ET.tostring(root, encoding='utf8').decode('utf8'))
+ elif(operation=='route_add'):
+ root = ET.parse('aroute.xml').getroot()
+ session.send_rpc(ET.tostring(root, encoding='utf8').decode('utf8'))
+ elif(operation=='face_del'):
+ root = ET.parse('dface.xml').getroot()
+ session.send_rpc(ET.tostring(root, encoding='utf8').decode('utf8'))
+ elif(operation=='punt_del'):
+ root = ET.parse('dpunt.xml').getroot()
+ session.send_rpc(ET.tostring(root, encoding='utf8').decode('utf8'))
+ elif(operation=='route_del'):
+ root = ET.parse('droute.xml').getroot()
+ session.send_rpc(ET.tostring(root, encoding='utf8').decode('utf8'))
+ else:
+ usage()
+
+if __name__ == '__main__':
+ if(len(sys.argv)<4):
+ usage()
+ else:
+ test(sys.argv[1],sys.argv[2],sys.argv[3],sys.argv[4])
+
+