From 5b23b663630e46460892b65cf8879537acb61c55 Mon Sep 17 00:00:00 2001 From: wtaverni Date: Mon, 20 Jun 2016 12:26:21 +0200 Subject: [PATCH] Fix to service chaining driven by dummy GK. --- misc/sonata-demo-docker.son | Bin 5040 -> 5085 bytes src/emuvim/api/sonata/dummygatekeeper.py | 31 ++++++++++++------ .../examples/sonata_y1_demo_topology_1.py | 3 +- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/misc/sonata-demo-docker.son b/misc/sonata-demo-docker.son index 8cf77c0b68119d1fcb2cfe3a00338384276c49bf..8a0c48b56e35e55c392032ba4c1cd987d7d8cbfd 100644 GIT binary patch delta 915 zcmV;E18n@TC*3Eo0M!BZT7TWvL05t{VfP*Cs6JOWE-~ z5sg$Nn zj)uX4=Wx`h)HN z(^&!wH~VQ4O8Q75eb(WWOjR6n>UKX(yqX`)DrA@^=95l%h2>3?Vc7p*HCVL4N||@T z8$OG1uW*jaMi?pknGS1%wlPBL?S`TGK;Bh%%^p}SC((o}!f zW>d!wJ?+sB%uIZHK0AZX^xh~q!AqK-t(k|(Ky%Zv?@ShRY__wrpRRaFp=kS0Vs{Nlr^Yf?dK=cT6;rTJ*Mdzi zhdH>ro8gw}eZCfNaz)IceYq8FncNE3D<@+ai?Z?pp pYtr~n?Z?ppYtr~n?Z?ppP)h{{000002>=NIq5=Q_B@qAs008AHp%nlC delta 872 zcmV-u1DE{WC$J~5Fc7`x zS6JanP+>pS!)m*$-n#6ey+>{`2CIo}*$!R){f-?cPDp`9Y6KGa&BvQJGlsvpxDOBW_h7u|VW?7a*#`yuX;Zod^biKMsljH!Rlp4Q6vocapOEbX^t59neJ=4Tx zM#Es`Dov9Z?q;<~la>X38}nF_?fq}^K%Wh{Z?sg9_LRKykA#1a^y#wH4Bx2rQ0OJP zb^3C#J0~Ja<&?r=yWRphP|amy`h=_zh2!En&P|u!S##r4NCPFd+v^>i^4{qdiDcv; zSk6l<-hJpOq>iJ9-c~x|LEg?W!?OqubzY~_biVZ2xxClBL}Bh`rwV=-l8ySaeMHrT z0Ix4mk_(Hik$!&yoQ-U(;Uy64Lsj~wMDyI6ho*Sq*r9q?+cvR1Dqp*>SUfEt9occA zns*r@gR_?7QRCV+v?3L*uW9cDZx{%pnXjtkjDZGW2ZftZxi2up$z7abaj~+_@xbjd z51j6^hr4ZrM+)T{e98haoPV;xGiqV|80u$MU7WIoG9=3KxW>al&( zY622j_)}!jmGqHB`mAwEB4m0MC!9I}X$3VumQ_qWAU18`gjYC6TCLm1vSR01#YG#f z6qEXu>eAi$J5ANTU66R1`_r%_Y?pUC%XT;GHn?c&XVAH1Ifydc7i4n+jW>>b?y54D z+XjR^HHd$-$2%~d_;@~@!3a%9A%fF>OqmI0-Wtd=`+Rad%Gm$fMR^sq`$2f7Mhf3D z# zx6gCKU7`2odc4tSTxR!mX0$8hzP)cUu0;8sB>w>cvn3HR0+SpP2p)r@qDVMS)+qY| y007(z001KZ0000000000Ab_-ilYA2=7EntC1^@s600{sI0Db}h02~nj0001*6q}O( diff --git a/src/emuvim/api/sonata/dummygatekeeper.py b/src/emuvim/api/sonata/dummygatekeeper.py index b210083..c5de3cc 100755 --- a/src/emuvim/api/sonata/dummygatekeeper.py +++ b/src/emuvim/api/sonata/dummygatekeeper.py @@ -14,6 +14,7 @@ import yaml from docker import Client as DockerClient from flask import Flask, request import flask_restful as fr +from collections import defaultdict logging.basicConfig() LOG = logging.getLogger("sonata-dummy-gatekeeper") @@ -31,8 +32,7 @@ BUILD_DOCKERFILE = False GK_STANDALONE_MODE = False # should a new version of an image be pulled even if its available -FORCE_PULL = True - +FORCE_PULL = False class Gatekeeper(object): @@ -78,6 +78,7 @@ class Service(object): self.local_docker_files = dict() self.remote_docker_image_urls = dict() self.instances = dict() + self.vnfname2num = dict() def onboard(self): """ @@ -126,22 +127,30 @@ class Service(object): self.instances[instance_uuid]["vnf_instances"].append(vnfi) # 3. Configure the chaining of the network functions (currently only E-Line links supported) + nfid2name = defaultdict(lambda :"NotExistingNode", + reduce(lambda x,y: dict(x, **y), + map(lambda d:{d["vnf_id"]:d["vnf_name"]}, + self.nsd["network_functions"]))) + vlinks = self.nsd["virtual_links"] fwd_links = self.nsd["forwarding_graphs"][0]["constituent_virtual_links"] eline_fwd_links = [l for l in vlinks if (l["id"] in fwd_links) and (l["connectivity_type"] == "E-Line")] - LOG.debug("eline_fwd_links %r" % eline_fwd_links) - + cookie = 1 # not clear why this is needed - to check with Steven for link in eline_fwd_links: src_node, src_port = link["connection_points_reference"][0].split(":") dst_node, dst_port = link["connection_points_reference"][1].split(":") - LOG.debug("vnfds.keys: %r" % list(self.vnfds.iterkeys())) + srcname = nfid2name[src_node] + dstname = nfid2name[dst_node] + LOG.debug("src name: "+srcname+" dst name: "+dstname) - if src_node in self.vnfds: - network = self.vnfds[src_node].get("dc").net # there should be a cleaner way to find the DCNetwork - ret = network.setChain(src_node, dst_node, vnf_src_interface=src_port, vnf_dst_interface=dst_port) - LOG.debug("setChain return: %r" % ret) + if (srcname in self.vnfds) and (dstname in self.vnfds) : + network = self.vnfds[srcname].get("dc").net # there should be a cleaner way to find the DCNetwork + src_vnf = self.vnfname2num[srcname] + dst_vnf = self.vnfname2num[dstname] + ret = network.setChain(src_vnf, dst_vnf, vnf_src_interface=src_port, vnf_dst_interface=dst_port, bidirectional = True, cmd="add-flow", cookie = cookie) + cookie += 1 LOG.info("Service started. Instance id: %r" % instance_uuid) return instance_uuid @@ -168,7 +177,9 @@ class Service(object): # 3. do the dc.startCompute(name="foobar") call to run the container # TODO consider flavors, and other annotations intfs = vnfd.get("connection_points") - vnfi = target_dc.startCompute(GK.get_next_vnf_name(), network=intfs, image=docker_name, flavor_name="small") + self.vnfname2num[vnf_name] = GK.get_next_vnf_name() + LOG.info("VNF "+vnf_name+" mapped to "+self.vnfname2num[vnf_name]+" on dc "+str(vnfd.get("dc"))) + vnfi = target_dc.startCompute(self.vnfname2num[vnf_name], network=intfs, image=docker_name, flavor_name="small") # 6. store references to the compute objects in self.instances return vnfi diff --git a/src/emuvim/examples/sonata_y1_demo_topology_1.py b/src/emuvim/examples/sonata_y1_demo_topology_1.py index 6ea568a..0236b8d 100755 --- a/src/emuvim/examples/sonata_y1_demo_topology_1.py +++ b/src/emuvim/examples/sonata_y1_demo_topology_1.py @@ -9,13 +9,14 @@ from mininet.log import setLogLevel from emuvim.dcemulator.net import DCNetwork from emuvim.api.zerorpc.compute import ZeroRpcApiEndpoint from emuvim.api.sonata import SonataDummyGatekeeperEndpoint +from mininet.node import RemoteController logging.basicConfig(level=logging.INFO) def create_topology1(): # create topology - net = DCNetwork() + net = DCNetwork(controller=RemoteController, monitor=False, enable_learning = False) dc1 = net.addDatacenter("dc1") dc2 = net.addDatacenter("dc2") s1 = net.addSwitch("s1") -- 2.25.1