Exemplo n.º 1
0
def test_scFuction(controller_ip):
    sc_func = SvcChain(controller_ip)
    init_connection(sc_func)
    sc_func.set_vnf_type("s2", const.FIREWALL)
    sc_func.set_vnf_type("s3", const.NAT)
    sc_func.set_vnf_type("s4", const.LOADBALANCE)
    tplt = sc_func.define_sc_tplt(
        ":".join([const.FIREWALL, const.NAT, const.LOADBALANCE]), "template_1")
    tpId = tplt.id
    print(tpId)
    inst = sc_func.define_sc_inst(tpId, "tcp", 80)
    print(inst.id)
    sc_func.define_sc_app("host:10.0.0.1", inst.id)
Exemplo n.º 2
0
class myView(object):
    def __init__(self, db_str, ctr_ip):
        self.controller_ip = ctr_ip
        self.sc_func = SvcChain(self.controller_ip)
        
    def showNodes(self, request):
        nodes= self.sc_func.get_all_ofnods()
        tem = loader.get_template('scNodes.html')
        header = Context({'nodes':nodes})
        return HttpResponse(tem.render(header))
    
    def showTemplate(self, request):
        sctmps = self.sc_func.get_all_templates()
        tem = loader.get_template('scTem.html')
        header = Context({'sctmps':sctmps})
        return HttpResponse(tem.render(header));
    
    def showInstance(self, request):
        scInss = self.sc_func.get_all_instances()
        tem = loader.get_template('scIns.html')
        header = Context({'scInss':scInss})
        return HttpResponse(tem.render(header))
    
    def showBinding(self, request):
        binds = self.sc_func.get_all_apps()
        tem = loader.get_template('scBind.html')
        header = Context({'binds':binds})
        return HttpResponse(tem.render(header));
    
    @csrf_exempt
    def addtemplate(self, request):
        tplt_id = request.POST['id']
        tplt_name = request.POST['name']
        tplt_pipe = request.POST['pipe']
        tplt = self.sc_func.define_sc_tplt(pipeline=tplt_pipe, tpltName=tplt_name,tpltID=tplt_id)
        return HttpResponseRedirect('/showtemp')
    
    @csrf_exempt
    def addins(self, request):
        inst_id = request.POST['scInsID']
        tplt_id = request.POST['scTemID']
        inst_proto = request.POST['protocol']
        inst_port = request.POST['port']
        inst = self.sc_func.define_sc_inst(tplt_id, inst_proto, inst_port,inst_id)
        return HttpResponseRedirect('/showins')
    
    @csrf_exempt
    def addbind(self, request):
        node_id = request.POST['NodeID']
        inst_id = request.POST['scID']
        self.sc_func.define_sc_app_by_id(node_id, inst_id)
        return HttpResponseRedirect('/showbind')
    
    @csrf_exempt
    def updateType(self, request):
        id = request.POST['NodeID']
        type = request.POST['type']
        print id, type
        self.sc_func.update_node_type(id,type)
        
        return HttpResponseRedirect('/shownodes')
Exemplo n.º 3
0
def test_scFuction(controller_ip):
    sc_func = SvcChain(controller_ip)
    init_connection(sc_func)
    sc_func.set_vnf_type("s2",const.FIREWALL)
    sc_func.set_vnf_type("s3",const.NAT)
    sc_func.set_vnf_type("s4",const.LOADBALANCE)
    tplt = sc_func.define_sc_tplt(":".join([const.FIREWALL,const.NAT,const.LOADBALANCE]),"template_1")
    tpId = tplt.id
    print(tpId)
    inst = sc_func.define_sc_inst(tpId, "tcp", 80)
    print(inst.id)
    sc_func.define_sc_app("host:10.0.0.1", inst.id)
Exemplo n.º 4
0
 def __init__(self, db_str, ctr_ip):
     self.controller_ip = ctr_ip
     self.sc_func = SvcChain(self.controller_ip)