Skip to content

Commit

Permalink
First commit to github.
Browse files Browse the repository at this point in the history
  • Loading branch information
jebpublic committed Feb 25, 2015
1 parent 78981d0 commit ef9a143
Show file tree
Hide file tree
Showing 14 changed files with 672 additions and 0 deletions.
Empty file added __init__.py
Empty file.
12 changes: 12 additions & 0 deletions cfg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Controller specification
ctrlIpAddr: "172.22.18.186"
ctrlPortNum: "8181"
ctrlUname: 'admin'
ctrlPswd: 'admin'

# NetconfNode specification
nodeName: "vRouter"
nodeIpAddr: "172.22.17.107"
nodePortNum: 830
nodeUname: "vyatta"
nodePswd: "vyatta"
49 changes: 49 additions & 0 deletions mount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/python

import sys
import pybvc

from pybvc.controller.netconfnode import NetconfNode
from pybvc.common.status import STATUS
from pybvc.controller.controller import Controller
from pybvc.common.utils import load_dict_from_file


if __name__ == "__main__":

f = "cfg.yml"
d = {}
if(load_dict_from_file(f, d) == False):
print("Config file '%s' read error: " % f)
exit()

try:
ctrlIpAddr = d['ctrlIpAddr']
ctrlPortNum = d['ctrlPortNum']
ctrlUname = d['ctrlUname']
ctrlPswd = d['ctrlPswd']

nodeName = d['nodeName']
nodeIpAddr = d['nodeIpAddr']
nodePortNum = d['nodePortNum']
nodeUname = d['nodeUname']
nodePswd = d['nodePswd']
except:
print ("Failed to get Controller device attributes")
exit(0)

ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
node = NetconfNode(ctrl, nodeName, nodeIpAddr, nodePortNum, nodeUname, nodePswd)

print (">>> Adding '%s' to the Controller '%s'" % (nodeName, ctrlIpAddr))
result = ctrl.add_netconf_node(node)
status = result[0]
if(status.eq(STATUS.OK) == True):
print ("'%s' was successfully added to the Controller" % nodeName)
else:
print ("\n")
print ("!!!Failed, reason: %s" % status.brief().lower())
exit(0)

print "\n"

52 changes: 52 additions & 0 deletions show_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/python

import sys
import json
import pybvc

from pybvc.netconfdev.vrouter.vrouter5600 import VRouter5600
from pybvc.common.status import STATUS
from pybvc.controller.controller import Controller
from pybvc.common.utils import load_dict_from_file


if __name__ == "__main__":

f = "cfg.yml"
d = {}
if(load_dict_from_file(f, d) == False):
print("Config file '%s' read error: " % f)
exit()

try:
ctrlIpAddr = d['ctrlIpAddr']
ctrlPortNum = d['ctrlPortNum']
ctrlUname = d['ctrlUname']
ctrlPswd = d['ctrlPswd']

nodeName = d['nodeName']
nodeIpAddr = d['nodeIpAddr']
nodePortNum = d['nodePortNum']
nodeUname = d['nodeUname']
nodePswd = d['nodePswd']
except:
print ("Failed to get Controller device attributes")
exit(0)

ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
vrouter = VRouter5600(ctrl, nodeName, nodeIpAddr, nodePortNum, nodeUname, nodePswd)
print ("<<< 'Controller': %s, '%s': %s" % (ctrlIpAddr, nodeName, nodeIpAddr))

print("\n")
result = vrouter.get_cfg()
status = result[0]
if(status.eq(STATUS.OK) == True):
print ("'%s' configuration:" % nodeName)
cfg = result[1]
data = json.loads(cfg)
print json.dumps(data, indent=4)
else:
print ("\n")
print ("Failed, reason: %s" % status.brief().lower())
print ("%s" % status.detail())
exit(0)
50 changes: 50 additions & 0 deletions show_dpifcfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/python

import sys
import json
import pybvc

from pybvc.netconfdev.vrouter.vrouter5600 import VRouter5600
from pybvc.common.status import STATUS
from pybvc.controller.controller import Controller
from pybvc.common.utils import load_dict_from_file


if __name__ == "__main__":

f = "cfg.yml"
d = {}
if(load_dict_from_file(f, d) == False):
print("Config file '%s' read error: " % f)
exit()

try:
ctrlIpAddr = d['ctrlIpAddr']
ctrlPortNum = d['ctrlPortNum']
ctrlUname = d['ctrlUname']
ctrlPswd = d['ctrlPswd']

nodeName = d['nodeName']
nodeIpAddr = d['nodeIpAddr']
nodePortNum = d['nodePortNum']
nodeUname = d['nodeUname']
nodePswd = d['nodePswd']
except:
print ("Failed to get Controller device attributes")
exit(0)

ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
vrouter = VRouter5600(ctrl, nodeName, nodeIpAddr, nodePortNum, nodeUname, nodePswd)
print ("<<< 'Controller': %s, '%s': %s" % (ctrlIpAddr, nodeName, nodeIpAddr))

result = vrouter.get_dataplane_interfaces_cfg()
status = result[0]
if(status.eq(STATUS.OK) == True):
print "Dataplane interfaces config:"
dpIfCfg = result[1]
print json.dumps(dpIfCfg, indent=4)
else:
print ("\n")
print ("!!!Failed, reason: %s" % status.brief().lower())
print ("%s" % status.detail())
exit(0)
49 changes: 49 additions & 0 deletions show_dpiflist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/python

import sys
import json
import pybvc

from pybvc.netconfdev.vrouter.vrouter5600 import VRouter5600
from pybvc.common.status import STATUS
from pybvc.controller.controller import Controller
from pybvc.common.utils import load_dict_from_file

if __name__ == "__main__":

f = "cfg.yml"
d = {}
if(load_dict_from_file(f, d) == False):
print("Config file '%s' read error: " % f)
exit()

try:
ctrlIpAddr = d['ctrlIpAddr']
ctrlPortNum = d['ctrlPortNum']
ctrlUname = d['ctrlUname']
ctrlPswd = d['ctrlPswd']

nodeName = d['nodeName']
nodeIpAddr = d['nodeIpAddr']
nodePortNum = d['nodePortNum']
nodeUname = d['nodeUname']
nodePswd = d['nodePswd']
except:
print ("Failed to get Controller device attributes")
exit(0)

ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
vrouter = VRouter5600(ctrl, nodeName, nodeIpAddr, nodePortNum, nodeUname, nodePswd)
print ("<<< 'Controller': %s, '%s': %s" % (ctrlIpAddr, nodeName, nodeIpAddr))

result = vrouter.get_dataplane_interfaces_list()
status = result[0]
if(status.eq(STATUS.OK) == True):
print "Dataplane interfaces:"
dpIfList = result[1]
print json.dumps(dpIfList, indent=4)
else:
print ("\n")
print ("!!!Failed, reason: %s" % status.brief().lower())
print ("%s" % status.detail())
exit(0)
54 changes: 54 additions & 0 deletions show_firewallcfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/python

import sys
import json
import pybvc

from pybvc.netconfdev.vrouter.vrouter5600 import VRouter5600
from pybvc.common.status import STATUS
from pybvc.controller.controller import Controller
from pybvc.common.utils import load_dict_from_file


if __name__ == "__main__":

f = "cfg.yml"
d = {}
if(load_dict_from_file(f, d) == False):
print("Config file '%s' read error: " % f)
exit()

try:
ctrlIpAddr = d['ctrlIpAddr']
ctrlPortNum = d['ctrlPortNum']
ctrlUname = d['ctrlUname']
ctrlPswd = d['ctrlPswd']

nodeName = d['nodeName']
nodeIpAddr = d['nodeIpAddr']
nodePortNum = d['nodePortNum']
nodeUname = d['nodeUname']
nodePswd = d['nodePswd']
except:
print ("Failed to get Controller device attributes")
exit(0)

ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
vrouter = VRouter5600(ctrl, nodeName, nodeIpAddr, nodePortNum, nodeUname, nodePswd)
print ("<<< 'Controller': %s, '%s': %s" % (ctrlIpAddr, nodeName, nodeIpAddr))


print("\n")
print ("<<< Show firewalls configuration on the '%s'" % nodeName)
result = vrouter.get_firewalls_cfg()
status = result[0]
if(status.eq(STATUS.OK) == True):
print ("'%s' firewalls config:" % nodeName)
cfg = result[1]
data = json.loads(cfg)
print json.dumps(data, indent=4)
else:
print ("\n")
print ("!!!Failed, reason: %s" % status.brief().lower())
print ("%s" % status.detail())
exit(0)
51 changes: 51 additions & 0 deletions show_iflist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/python

import sys
import json
import pybvc

from pybvc.netconfdev.vrouter.vrouter5600 import VRouter5600
from pybvc.common.status import STATUS
from pybvc.controller.controller import Controller
from pybvc.common.utils import load_dict_from_file


if __name__ == "__main__":

f = "cfg.yml"
d = {}
if(load_dict_from_file(f, d) == False):
print("Config file '%s' read error: " % f)
exit()

try:
ctrlIpAddr = d['ctrlIpAddr']
ctrlPortNum = d['ctrlPortNum']
ctrlUname = d['ctrlUname']
ctrlPswd = d['ctrlPswd']

nodeName = d['nodeName']
nodeIpAddr = d['nodeIpAddr']
nodePortNum = d['nodePortNum']
nodeUname = d['nodeUname']
nodePswd = d['nodePswd']
except:
print ("Failed to get Controller device attributes")
exit(0)

ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
vrouter = VRouter5600(ctrl, nodeName, nodeIpAddr, nodePortNum, nodeUname, nodePswd)
print ("<<< 'Controller': %s, '%s': %s" % (ctrlIpAddr, nodeName, nodeIpAddr))

result = vrouter.get_interfaces_list()
status = result[0]
if(status.eq(STATUS.OK) == True):
print "Interfaces:"
ifList = result[1]
print json.dumps(ifList, indent=4)
else:
print ("\n")
print ("!!!Failed, reason: %s" % status.brief().lower())
print ("%s" % status.detail())
sys.exit(0)

50 changes: 50 additions & 0 deletions show_lbifcfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/python

import sys
import json
import pybvc

from pybvc.netconfdev.vrouter.vrouter5600 import VRouter5600
from pybvc.common.status import STATUS
from pybvc.controller.controller import Controller
from pybvc.common.utils import load_dict_from_file


if __name__ == "__main__":

f = "cfg.yml"
d = {}
if(load_dict_from_file(f, d) == False):
print("Config file '%s' read error: " % f)
exit()

try:
ctrlIpAddr = d['ctrlIpAddr']
ctrlPortNum = d['ctrlPortNum']
ctrlUname = d['ctrlUname']
ctrlPswd = d['ctrlPswd']

nodeName = d['nodeName']
nodeIpAddr = d['nodeIpAddr']
nodePortNum = d['nodePortNum']
nodeUname = d['nodeUname']
nodePswd = d['nodePswd']
except:
print ("Failed to get Controller device attributes")
exit(0)

ctrl = Controller(ctrlIpAddr, ctrlPortNum, ctrlUname, ctrlPswd)
vrouter = VRouter5600(ctrl, nodeName, nodeIpAddr, nodePortNum, nodeUname, nodePswd)
print ("<<< 'Controller': %s, '%s': %s" % (ctrlIpAddr, nodeName, nodeIpAddr))

result = vrouter.get_loopback_interfaces_cfg()
status = result[0]
if(status.eq(STATUS.OK) == True):
print "Loopback interfaces config:"
dpIfCfg = result[1]
print json.dumps(dpIfCfg, indent=4)
else:
print ("\n")
print ("!!!Failed, reason: %s" % status.brief().lower())
print ("%s" % status.detail())
sys.exit(0)
Loading

0 comments on commit ef9a143

Please sign in to comment.