hook up delete flow
diff --git a/web/ons-demo/assets/delete.svg b/web/ons-demo/assets/delete.svg
new file mode 100644
index 0000000..a32a278
--- /dev/null
+++ b/web/ons-demo/assets/delete.svg
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ id="Layer_1"
+ x="0px"
+ y="0px"
+ width="283.465px"
+ height="283.465px"
+ viewBox="0 0 283.465 283.465"
+ enable-background="new 0 0 283.465 283.465"
+ xml:space="preserve"
+ inkscape:version="0.48.0 r9654"
+ sodipodi:docname="delete.svg"><metadata
+ id="metadata9"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
+ id="defs7" /><sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="721"
+ inkscape:window-height="480"
+ id="namedview5"
+ showgrid="false"
+ inkscape:zoom="0.92427638"
+ inkscape:cx="141.7325"
+ inkscape:cy="141.7325"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="0"
+ inkscape:current-layer="Layer_1" />
+<path
+ fill="#772953"
+ d="M141.733,198.425c-15.143,0-29.38-5.897-40.088-16.605c-10.708-10.708-16.605-24.945-16.605-40.088 c0-15.142,5.897-29.378,16.605-40.086c10.708-10.708,24.945-16.605,40.088-16.605c15.142,0,29.379,5.896,40.087,16.604 c10.708,10.708,16.605,24.946,16.605,40.089c0,15.143-5.897,29.381-16.605,40.088C171.112,192.528,156.875,198.425,141.733,198.425 L141.733,198.425z M141.733,99.213c-11.357,0-22.035,4.423-30.067,12.454c-8.031,8.031-12.454,18.708-12.454,30.064 c0,11.357,4.423,22.035,12.454,30.065c8.032,8.031,18.709,12.455,30.067,12.455c11.356,0,22.034-4.423,30.064-12.453 c8.031-8.03,12.455-18.709,12.455-30.066s-4.424-22.036-12.455-30.067C163.768,103.636,153.09,99.213,141.733,99.213L141.733,99.213 z M151.703,141.79l10.021-10.022c2.768-2.768,2.768-7.254,0-10.021c-2.767-2.767-7.255-2.767-10.021,0l-10.022,10.021 l-10.021-10.021c-2.767-2.767-7.255-2.767-10.022,0c-2.768,2.768-2.768,7.254,0,10.021l10.022,10.022l-10.023,10.023 c-2.768,2.768-2.768,7.254,0,10.021c1.383,1.384,3.197,2.076,5.011,2.076c1.813,0,3.627-0.692,5.011-2.076l10.023-10.023 l10.022,10.021c1.383,1.384,3.197,2.076,5.011,2.076s3.627-0.692,5.011-2.076c2.768-2.768,2.768-7.254,0-10.021L151.703,141.79z"
+ id="path3"
+ style="fill:#ffffff;fill-opacity:1" />
+</svg>
\ No newline at end of file
diff --git a/web/ons-demo/css/skin.default.css b/web/ons-demo/css/skin.default.css
index e9bb1d7..d88814e 100644
--- a/web/ons-demo/css/skin.default.css
+++ b/web/ons-demo/css/skin.default.css
@@ -151,7 +151,7 @@
}
-.flowId, .srcDPID, .dstDPID, .iperf {
+.flowId, .srcDPID, .dstDPID, .iperf, #deleteFlow, .deleteFlow {
display: -webkit-box;
-webkit-box-pack: center;
-webkit-box-align: center;
@@ -164,7 +164,7 @@
}
-.srcDPID, .dstDPID {
+.srcDPID, .dstDPID, .deleteFlow, #deleteFlow {
border-right: 1px solid #AAA;
}
@@ -204,6 +204,14 @@
background-position: .25em center;
}
+.deleteFlow {
+ height: 100%;
+ background-image: url('../assets/delete.svg');
+ background-size: auto 150%;
+ background-repeat: no-repeat;
+ background-position: center;
+}
+
#logo {
height: 50px;
}
diff --git a/web/ons-demo/index.html b/web/ons-demo/index.html
index d157ecc..55237ac 100644
--- a/web/ons-demo/index.html
+++ b/web/ons-demo/index.html
@@ -38,6 +38,7 @@
</div>
</div>
<div id='selectedFlowsHeader'>
+ <div id='deleteFlow'></div>
<div id='showFlowChooser' class='flowId'><div class='white-eye'></div></div>
<div class='srcDPID'>src</div>
<div class='dstDPID'>dst</div>
diff --git a/web/ons-demo/js/app.js b/web/ons-demo/js/app.js
index 7d6774c..02dbc5d 100644
--- a/web/ons-demo/js/app.js
+++ b/web/ons-demo/js/app.js
@@ -18,7 +18,9 @@
var svg;
var updateTopology;
var pendingLinks = {};
-var pendingFlows = {};
+var selectedFlows = [];
+
+var pendingTimeout = 10000;
var colors = [
'color1',
@@ -66,8 +68,6 @@
attr('id', 'viewbox').append('svg:g').attr('transform', 'translate(500 500)');
}
-var selectedFlows = [null, null, null];
-
function updateSelectedFlowsTopology() {
// DRAW THE FLOWS
var flows = d3.select('svg').selectAll('.flow').data(selectedFlows);
@@ -88,7 +88,7 @@
return;
}
var pts = [];
- if (d.pending) {
+ if (!d.dataPath.flowEntries) {
// create a temporary vector to indicate the pending flow
var s1 = d3.select(document.getElementById(d.dataPath.srcPort.dpid.value));
var s2 = d3.select(document.getElementById(d.dataPath.dstPort.dpid.value));
@@ -139,6 +139,7 @@
function updateSelectedFlowsTable() {
function rowEnter(d) {
var row = d3.select(this);
+ row.append('div').classed('deleteFlow', true);
row.append('div').classed('flowId', true);
row.append('div').classed('srcDPID', true);
row.append('div').classed('dstDPID', true);
@@ -160,6 +161,22 @@
function rowUpdate(d) {
var row = d3.select(this);
+ row.select('.deleteFlow').on('click', function () {
+ if (d) {
+ var prompt = 'Delete flow ' + d.flowId.value + '?';
+ if (confirm(prompt)) {
+ deleteFlow(d);
+ d.pending = true;
+ updateSelectedFlows();
+
+ setTimeout(function () {
+ d.pending = false;
+ updateSelectedFlows();
+ }, pendingTimeout)
+ };
+ }
+ });
+
row.select('.flowId')
.text(function (d) {
if (d) {
@@ -228,6 +245,9 @@
});
selectedFlows = newSelectedFlows;
}
+ while (selectedFlows.length < 3) {
+ selectedFlows.push(null);
+ }
updateSelectedFlowsTable();
updateSelectedFlowsTopology();
@@ -783,7 +803,7 @@
setTimeout(function () {
deselectFlow(flow);
- }, 10000);
+ }, pendingTimeout);
}
} else {
var map = linkMap[srcData.dpid];
@@ -828,7 +848,7 @@
delete pendingLinks[makeLinkKey(link2)];
updateTopology();
- }, 10000);
+ }, pendingTimeout);
}
}
}
diff --git a/web/ons-demo/js/controller.js b/web/ons-demo/js/controller.js
index 35df661..fd3f6ae 100644
--- a/web/ons-demo/js/controller.js
+++ b/web/ons-demo/js/controller.js
@@ -35,13 +35,11 @@
callURL(url);
},
delFlowCmd: function (flow) {
- alert('delete flow')
+ var url = '/proxy/gui/delflow/' + flow.flowId.value;
+ callURL(url);
}
};
-// http://gui3.onlab.us:8081/gui/addflow/<src_dpid>/<src_port>/<dst_dpid>/<dst_port>/<srcMAC>/<dstMAC>
-// http://gui3.onlab.us:8081/gui/delflow/<flow_id>
-
function linkUp(link) {
controllerFunctions.linkCmd('up', link);
}
diff --git a/web/topology_rest.py b/web/topology_rest.py
index ccf9a53..ff1b32f 100755
--- a/web/topology_rest.py
+++ b/web/topology_rest.py
@@ -140,6 +140,18 @@
resp = Response(result, status=200, mimetype='application/json')
return resp
+@app.route("/proxy/gui/delflow/<flow_id>")
+def proxy_del_flow(flow_id):
+ try:
+ command = "curl -s %s/gui/delflow/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id)
+ print command
+ result = os.popen(command).read()
+ except:
+ print "REST IF has issue"
+ exit
+
+ resp = Response(result, status=200, mimetype='application/json')
+ return resp
@app.route("/wm/core/topology/switches/all/json")
def switches():
if request.args.get('proxy') == None: