diff options
Diffstat (limited to 'examples/examples-pcvs/src/main/resources/examples/scripts')
13 files changed, 691 insertions, 0 deletions
diff --git a/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/LinkMonitor.py b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/LinkMonitor.py new file mode 100644 index 000000000..907dd22cb --- /dev/null +++ b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/LinkMonitor.py @@ -0,0 +1,214 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +import http.client +import json +import time +from kafka import KafkaConsumer, KafkaProducer + +class StaticFlowPusher(object): + + def __init__(self, server): + self.server = server + + def get(self, data): + ret = self.rest_call({}, 'GET') + return json.loads(ret[2]) + + def set(self, data): + ret = self.rest_call(data, 'POST') + return ret[0] == 200 + + def remove(self, objtype, data): + ret = self.rest_call(data, 'DELETE') + return ret[0] == 200 + + def getControllerSummary(self, data): + ret = self.rest_call_controller_summary({}, 'GET') + return json.loads(ret[2]) + + def getLinks(self, data): + ret = self.rest_call_links({}, 'GET') + return json.loads(ret[2].decode()) + + def rest_call(self, data, action): + path = '/wm/staticflowpusher/json' + headers = { + 'Content-type': 'application/json', + 'Accept': 'application/json', + } + body = json.dumps(data) + conn = http.client.HTTPConnection(self.server, 8080) + conn.request(action, path, body, headers) + response = conn.getresponse() + ret = (response.status, response.reason, response.read()) + print(ret) + conn.close() + return ret + + def rest_call_controller_summary(self, data, action): + path = '/wm/core/controller/summary/json' + headers = { + 'Content-type': 'application/json', + 'Accept': 'application/json', + } + body = json.dumps(data) + conn = http.client.HTTPConnection(self.server, 8080) + conn.request(action, path, body, headers) + response = conn.getresponse() + ret = (response.status, response.reason, response.read()) + print(ret) + conn.close() + return ret + + def rest_call_links(self, data, action): + path = '/wm/topology/links/json' + headers = { + 'Content-type': 'application/json', + 'Accept': 'application/json', + } + body = json.dumps(data) + conn = http.client.HTTPConnection(self.server, 8080) + conn.request(action, path, body, headers) + response = conn.getresponse() + ret = (response.status, response.reason, response.read()) + conn.close() + return ret + +pusher = StaticFlowPusher('127.0.1.1') + + +def parseLinks(links): + #print("\n\n\n",links) + result = [] + for link in links: + list = [] + #print("\n\n\n",link) + #print("\nsrc-switch : s", link['src-switch'][len(link['src-switch'])-1]) + #print("\ndst-switch : s", link['dst-switch'][len(link['dst-switch'])-1]) + list.append("s") + list.append(link['src-switch'][len(link['src-switch'])-1]) + list.append("-s") + list.append(link['dst-switch'][len(link['dst-switch'])-1]) + result.append(''.join(list)) + #print(result, "\n") + return result + + + +counter =0 +healthyList = [] +testableList = [] +healthyLinks = "" +testableLinks = "" +producer = KafkaProducer(bootstrap_servers='localhost:9092') +while(True): + time.sleep(30) + switchLinks = pusher.getLinks({}) + if counter == 0: + healthyList = parseLinks(switchLinks) + #Build All Links + print("READING LINKS FROM MININET\n") + for l in healthyList: + link = "" + #print(l, "\n") + #Links between switches [s6-s7 is ignored so it matches VPN SCENARIO] + if(l == "s1-s5"): + link = "{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'EdgeContextEventIn','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy_EdgeContext','status': true,'edgeName': 'L05', 'start': 'A1CO','end': 'BBL'}" + producer.send("apex-in-0", bytes(link, encoding="ascii")) + if(l == "s5-s6"): + link = "{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'EdgeContextEventIn','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy_EdgeContext','status': true,'edgeName': 'L09', 'start': 'BBL','end': 'BBR'}" + producer.send("apex-in-0", bytes(link, encoding="ascii")) + if(l == "s2-s6"): + link = "{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'EdgeContextEventIn','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy_EdgeContext','status': true,'edgeName': 'L07', 'start': 'A2CO','end': 'BBR'}" + producer.send("apex-in-0", bytes(link, encoding="ascii")) + if(l == "s5-s7"): + link = "{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'EdgeContextEventIn','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy_EdgeContext','status': true,'edgeName': 'L10', 'start': 'BBR','end': 'BBL'}" + producer.send("apex-in-0", bytes(link, encoding="ascii")) + if(l == "s3-s5"): + link = "{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'EdgeContextEventIn','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy_EdgeContext','status': true,'edgeName': 'L06', 'start': 'B1CO','end': 'BBL'}" + producer.send("apex-in-0", bytes(link, encoding="ascii")) + if(l == "s4-s6"): + link = "{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'EdgeContextEventIn','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy_EdgeContext','status': true,'edgeName': 'L08', 'start': 'B2CO','end': 'BBR'}" + producer.send("apex-in-0", bytes(link, encoding="ascii")) + #Links between switches and hosts [NoT SENT IN FROM FLOODLIGHT] + producer.send("apex-in-0", b"{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'EdgeContextEventIn','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy_EdgeContext','status': true,'edgeName': 'L01', 'start': 'A1','end': 'A1CO'}") + producer.send("apex-in-0", b"{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'EdgeContextEventIn','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy_EdgeContext','status': true,'edgeName': 'L02', 'start': 'B1','end': 'B1CO'}") + producer.send("apex-in-0", b"{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'EdgeContextEventIn','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy_EdgeContext','status': true,'edgeName': 'L03', 'start': 'A2','end': 'A2CO'}") + producer.send("apex-in-0", b"{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'EdgeContextEventIn','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy_EdgeContext','status': true,'edgeName': 'L04', 'start': 'B2','end': 'B2CO'}") + print("LINKS HAVE BEEN SENT TO APEX\n") + + #Build Customers + print("BUILDING CUSTOMERS\n") + producer.send("apex-in-0", b"{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'CustomerContextEventIn','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy_CustomerContext','dtYTD': 10,'dtSLA': 180,'links': 'L01 L05 L09 L10','customerName': 'A', 'priority': true,'satisfaction': 80}") + producer.send("apex-in-0", b"{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'CustomerContextEventIn','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy_CustomerContext','dtYTD': 120,'dtSLA': 180,'links': 'L02 L07 L09 L10','customerName': 'B', 'priority': false,'satisfaction': 99}") + print("CUSTOMERS HAVE BEEN SENT TO APEX\n") + healthyLinks = switchLinks + myfile = open('LinkInfo.json', 'a') + myfile.write(str(healthyLinks)) + myfile.write('\n') + myfile.close() + print("We start off with", len(healthyLinks), "healthy Links!\n") + else: + testableList = parseLinks(switchLinks) + issueLink = ""; + for h in healthyList: + issueLink = h + for t in testableList: + if t == h: + issueLink = "" + if issueLink != "": + print("There is an issue with the links! ", issueLink, " \n") + if(issueLink == "s1-s5"): + link = "{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'VpnSlaTrigger','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy','status': 'DOWN','edgeName': 'L05'}" + producer.send("apex-in-0", bytes(link, encoding="ascii")) + if(issueLink == "s5-s6"): + link = "{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'VpnSlaTrigger','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy','status': 'DOWN','edgeName': 'L09'}" + producer.send("apex-in-0", bytes(link, encoding="ascii")) + if(issueLink == "s2-s6"): + link = "{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'VpnSlaTrigger','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy','status': 'DOWN','edgeName': 'L07'}" + producer.send("apex-in-0", bytes(link, encoding="ascii")) + if(issueLink == "s5-s7"): + link = "{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'VpnSlaTrigger','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy','status': 'DOWN','edgeName': 'L10'}" + producer.send("apex-in-0", bytes(link, encoding="ascii")) + if(issueLink == "s3-s5"): + link = "{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'VpnSlaTrigger','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy','status': 'DOWN','edgeName': 'L06'}" + producer.send("apex-in-0", bytes(link, encoding="ascii")) + if(issueLink == "s4-s6"): + link = "{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'VpnSlaTrigger','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy','status': 'DOWN','edgeName': 'L08'}" + producer.send("apex-in-0", bytes(link, encoding="ascii")) + break + if issueLink == "": + print("All Links are working\n") + producer.send("apex-in-0", b"{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'VpnSlaTrigger','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy','status': 'UP','edgeName': 'L01'}") + producer.send("apex-in-0", b"{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'VpnSlaTrigger','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy','status': 'UP','edgeName': 'L02'}") + producer.send("apex-in-0", b"{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'VpnSlaTrigger','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy','status': 'UP','edgeName': 'L03'}") + producer.send("apex-in-0", b"{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'VpnSlaTrigger','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy','status': 'UP','edgeName': 'L04'}") + producer.send("apex-in-0", b"{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'VpnSlaTrigger','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy','status': 'UP','edgeName': 'L05'}") + producer.send("apex-in-0", b"{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'VpnSlaTrigger','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy','status': 'UP','edgeName': 'L06'}") + producer.send("apex-in-0", b"{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'VpnSlaTrigger','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy','status': 'UP','edgeName': 'L07'}") + producer.send("apex-in-0", b"{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'VpnSlaTrigger','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy','status': 'UP','edgeName': 'L08'}") + producer.send("apex-in-0", b"{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'VpnSlaTrigger','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy','status': 'UP','edgeName': 'L09'}") + producer.send("apex-in-0", b"{'nameSpace': 'org.onap.policy.apex.examples.pcvs.vpnsla','name': 'VpnSlaTrigger','version': '1.0.0','source': 'LinkMonitor.py','target': 'VpnSlaPolicy','status': 'UP','edgeName': 'L10'}") + + testableLinks = switchLinks + myfile = open('LinkInfo.json', 'a') + myfile.write(str(testableLinks)) + myfile.write('\n') + myfile.close() + counter += 1 diff --git a/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/MininetTopology.py b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/MininetTopology.py new file mode 100644 index 000000000..4d6aea8f5 --- /dev/null +++ b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/MininetTopology.py @@ -0,0 +1,216 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +#Add Mininet to PATH +import sys +sys.path.insert(0, "/~/mininet") + +#Kafka +import httplib +import json +import time +from kafka import KafkaConsumer, KafkaProducer + +#Mininet +from mininet.clean import * +from mininet.cli import * +from mininet.link import * +from mininet.log import * +from mininet.net import * +from mininet.node import * +from mininet.nodelib import * +from mininet.topo import * +from mininet.topolib import * + +class StaticFlowPusher(object): + def __init__(self, server): + self.server = server + + def enableFirewall(self, data): + path = "/wm/firewall/module/enable/json" + headers = {'Content-Type': 'application/json','Accept': 'application/json',} + body = json.dumps(data) + conn = httplib.HTTPConnection(self.server, 8080) + conn.request("PUT", path, "") + response = conn.getresponse() + ret = (response.status, response.reason, response.read()) + conn.close() + return ret + + def addRule(self, data): + path = '/wm/firewall/rules/json' + headers = {'Content-Type': 'application/json','Accept': 'application/json',} + body = json.dumps(data) + conn = httplib.HTTPConnection(self.server, 8080) + conn.request('POST', path, body, headers) + response = conn.getresponse() + ret = (response.status, response.reason, response.read()) + conn.close() + return ret + + def deleteRule(self, data): + path = '/wm/firewall/rules/json' + headers = {'Content-Type': 'application/json','Accept': 'application/json',} + body = json.dumps(data) + conn = httplib.HTTPConnection(self.server, 8080) + conn.request('DELETE', path, body, headers) + response = conn.getresponse() + ret = (response.status, response.reason, response.read()) + conn.close() + return ret + +#Build Pusher(REST/IN) +pusher = StaticFlowPusher('127.0.0.1') + +net = Mininet(link=TCLink) + +#Create Customers +customerA1 = net.addHost( 'A1' ) +customerA2 = net.addHost( 'A2' ) +customerB1 = net.addHost( 'B1' ) +customerB2 = net.addHost( 'B2' ) + +#Create Switches +switchA1CO = net.addSwitch( 's1' ) +switchA2CO = net.addSwitch( 's2' ) +switchB1CO = net.addSwitch( 's3' ) +switchB2CO = net.addSwitch( 's4' ) +switchBBL = net.addSwitch( 's5' ) +switchBBR = net.addSwitch( 's6' ) +# we need an extra switch here because Mininet does not allow two links between two switches +switchEx = net.addSwitch( 's7' ) + +#Create Links +net.addLink( customerA1, switchA1CO ) +net.addLink( customerA2, switchA2CO ) +net.addLink( customerB1, switchB1CO ) +net.addLink( customerB2, switchB2CO ) +net.addLink( switchA1CO, switchBBL ) +net.addLink( switchB1CO, switchBBL ) +net.addLink( switchA2CO, switchBBR ) +net.addLink( switchB2CO, switchBBR ) +net.addLink( switchBBL, switchBBR) +net.addLink( switchBBR, switchEx, bw=1.2 ) +net.addLink( switchEx, switchBBL ) + +#Create Controller +floodlightController = net.addController(name='c0' , controller=RemoteController , ip='127.0.0.1', port=6653) + +net.start() + +if pusher.enableFirewall({})[0] == 200: + print("Firewall enabled!") + +#print(pusher.addRule({"switchid": "00:00:00:00:00:00:00:01"})[2]) +s1id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:01"})[2])['rule-id'] +s2id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:02"})[2])['rule-id'] +s3id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:03"})[2])['rule-id'] +s4id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:04"})[2])['rule-id'] +s5id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:05"})[2])['rule-id'] +s6id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:06"})[2])['rule-id'] +s7id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:07"})[2])['rule-id'] + + +result = 100 +while result!=0: + result = net.pingAll(None) +print("Network Simulation Complete") + +#Assume control and when finished "exit" +cli = CLI( net ) + +consumer = KafkaConsumer(bootstrap_servers='localhost:9092',auto_offset_reset='latest') +consumer.subscribe(['apex-out']) +print("Starting Message Loop") +for message in consumer: + myOutput = json.loads(message.value.decode()) + action = "" + try: + print("Checking Message") + #print("SWITCHES= ",net.switches) + #print("LINKS= ",net.links) + #print("VALUES= ",net.values) + if myOutput['edgeName'] != '': + print("Message Received: ",myOutput['edgeName']) + pusher.deleteRule({"ruleid": s1id}) + pusher.deleteRule({"ruleid": s2id}) + pusher.deleteRule({"ruleid": s3id}) + pusher.deleteRule({"ruleid": s4id}) + pusher.deleteRule({"ruleid": s5id}) + pusher.deleteRule({"ruleid": s6id}) + pusher.deleteRule({"ruleid": s7id}) + s1id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:01"})[2])['rule-id'] + s2id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:02"})[2])['rule-id'] + s3id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:03"})[2])['rule-id'] + s4id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:04"})[2])['rule-id'] + s5id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:05"})[2])['rule-id'] + s6id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:06"})[2])['rule-id'] + s7id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:07"})[2])['rule-id'] + if myOutput['edgeName'] == "L01": + action = "link s1 s5 down" + #net.configLinkStatus('s1', 's5', "down") + pusher.deleteRule({"ruleid": s1id}) + s1id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:01", "action": "DENY"})[2])['rule-id'] + if myOutput['edgeName'] == "L02": + action = "link s3 s5 down" + #net.configLinkStatus('s3', 's5', "down") + pusher.deleteRule({"ruleid": s3id}) + s3id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:03", "action": "DENY"})[2])['rule-id'] + if myOutput['edgeName'] == "L03": + action = "link s2 s6 down" + #net.configLinkStatus('s2', 's6', "down") + pusher.deleteRule({"ruleid": s1id}) + s1id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:01", "action": "DENY"})[2])['rule-id'] + if myOutput['edgeName'] == "L04": + action = "link s4 s6 down" + #net.configLinkStatus('s4', 's6', "down") + pusher.deleteRule({"ruleid": s3id}) + s3id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:03", "action": "DENY"})[2])['rule-id'] + if myOutput['edgeName'] == "L05": + action = "link s1 s5 down" + #net.configLinkStatus('s1', 's5', "down") + pusher.deleteRule({"ruleid": s1id}) + s1id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:01", "action": "DENY"})[2])['rule-id'] + if myOutput['edgeName'] == "L06": + action = "link s3 s5 down" + #net.configLinkStatus('s3', 's5', "down") + pusher.deleteRule({"ruleid": s3id}) + s3id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:03", "action": "DENY"})[2])['rule-id'] + if myOutput['edgeName'] == "L07": + action = "link s2 s6 down" + #net.configLinkStatus('s2', 's6', "down") + pusher.deleteRule({"ruleid": s2id}) + s2id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:02", "action": "DENY"})[2])['rule-id'] + if myOutput['edgeName'] == "L08": + action = "link s4 s6 down" + #net.configLinkStatus('s4', 's6', "down") + pusher.deleteRule({"ruleid": s4id}) + s4id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:04", "action": "DENY"})[2])['rule-id'] + if myOutput['edgeName'] == "L09": + action = "link s5 s6 down" + #net.configLinkStatus('s5', 's6', "down") + pusher.deleteRule({"ruleid": s7id}) + s7id = json.loads(pusher.addRule({"switchid": "00:00:00:00:00:00:00:07", "action": "DENY"})[2])['rule-id'] + if myOutput['edgeName'] == "L10": + print("L10") + #print(action) + #print("3") + except KeyError: + print(myOutput) +print("HA") +net.stop() diff --git a/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/configure.sh b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/configure.sh new file mode 100644 index 000000000..0579dcce5 --- /dev/null +++ b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/configure.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +cp $APEX_HOME/etc/logback-logic.xml $APEX_HOME/etc/logback.xml +cp $APEX_HOME/examples/scripts/pcvs/vpnsla/LinkMonitor.py $src_dir/kafka-python + diff --git a/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/env.sh b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/env.sh new file mode 100644 index 000000000..7d8542f5a --- /dev/null +++ b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/env.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +export src_dir=/usr/local/src +export APEX_HOME=/opt/app/policy/apex-pdp +export APEX_USER=apexuser diff --git a/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/start-apex.sh b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/start-apex.sh new file mode 100644 index 000000000..dd2f77d88 --- /dev/null +++ b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/start-apex.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +(cd $APEX_HOME; ./bin/apexApps.sh engine -c examples/config/pcvs/vpnsla/kafka2kafka.json) diff --git a/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/start-floodlight.sh b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/start-floodlight.sh new file mode 100644 index 000000000..a2f6ba417 --- /dev/null +++ b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/start-floodlight.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +(cd $src_dir/floodlight-master; java -jar target/floodlight.jar) diff --git a/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/start-kafka-zk.sh b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/start-kafka-zk.sh new file mode 100644 index 000000000..37321a6f2 --- /dev/null +++ b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/start-kafka-zk.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +/opt/Kafka/kafka_2.12-1.0.0/bin/kafka-server-start.sh /opt/Kafka/kafka_2.12-1.0.0/config/server.properties
\ No newline at end of file diff --git a/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/start-linkmonitor.sh b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/start-linkmonitor.sh new file mode 100644 index 000000000..2a166bc87 --- /dev/null +++ b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/start-linkmonitor.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +(cd $src_dir; python3 $src_dir/kafka-python/LinkMonitor.py)
\ No newline at end of file diff --git a/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/start-mininet.sh b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/start-mininet.sh new file mode 100644 index 000000000..ba6e343b2 --- /dev/null +++ b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/start-mininet.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +mn -c && python $APEX_HOME/examples/scripts/pcvs/vpnsla/MininetTopology.py diff --git a/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/streams/a1.sh b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/streams/a1.sh new file mode 100644 index 000000000..1e709bb53 --- /dev/null +++ b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/streams/a1.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +MOD_SCRIPT_NAME=`basename $0` + +if [ $# -eq 0 ]; then + echo "" + echo "$MOD_SCRIPT_NAME - run VLC that streams video" + echo "" + echo " Usage: $MOD_SCRIPT_NAME [video file]" + echo "" + exit +fi + +vlc-wrapper -vvv $1 --sout "#duplicate{dst=rtp{dst=10.0.0.2,port=5004,mux=ts},dst=display}" --sout-keep -q + diff --git a/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/streams/a2.sh b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/streams/a2.sh new file mode 100644 index 000000000..b00bca2c6 --- /dev/null +++ b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/streams/a2.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +vlc-wrapper rtp://@:5004 -q + diff --git a/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/streams/b1.sh b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/streams/b1.sh new file mode 100644 index 000000000..8de02941a --- /dev/null +++ b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/streams/b1.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +MOD_SCRIPT_NAME=`basename $0` + +if [ $# -eq 0 ]; then + echo "" + echo "$MOD_SCRIPT_NAME - run VLC that streams video" + echo "" + echo " Usage: $MOD_SCRIPT_NAME [video file]" + echo "" + exit +fi + +vlc-wrapper -vvv $1 --sout "#duplicate{dst=rtp{dst=10.0.0.4,port=5004,mux=ts},dst=display}" --sout-keep -q + diff --git a/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/streams/b2.sh b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/streams/b2.sh new file mode 100644 index 000000000..b00bca2c6 --- /dev/null +++ b/examples/examples-pcvs/src/main/resources/examples/scripts/pcvs/vpnsla/streams/b2.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +vlc-wrapper rtp://@:5004 -q + |