summaryrefslogtreecommitdiffstats
path: root/vbd/gui/module/src/main/resources/vpp/services
diff options
context:
space:
mode:
authorDaniel Malachovsky <daniel.malachovsky@pantheon.sk>2016-02-11 14:13:09 +0100
committerDave Wallace <dwallacelf@gmail.com>2016-02-12 02:12:20 +0000
commit73353537994c067cd6eea24545efc53df08b4a1a (patch)
treece9007eca2a2a437e9c3e1086086085c419d0676 /vbd/gui/module/src/main/resources/vpp/services
parentea8d1af7f75565cee845ce0b4672d64bc7cb676f (diff)
Underlay added
- bd manager rewritten - underlay topo functional - lot of cleaning Change-Id: I48e259aaf341eb0a1c09e6b25dd411d525d854c1 Signed-off-by: Varun Seereeram <vseereer@cisco.com> Signed-off-by: Daniel Malachovsky <daniel.malachovsky@pantheon.sk>
Diffstat (limited to 'vbd/gui/module/src/main/resources/vpp/services')
-rw-r--r--vbd/gui/module/src/main/resources/vpp/services/bdm.bridgedomain.service.js20
-rw-r--r--vbd/gui/module/src/main/resources/vpp/services/bdm.interface.service.js10
-rw-r--r--vbd/gui/module/src/main/resources/vpp/services/bdm.tunnel.service.js25
-rw-r--r--vbd/gui/module/src/main/resources/vpp/services/bdm.vpp.service.js31
-rw-r--r--vbd/gui/module/src/main/resources/vpp/services/vpp.services.js236
5 files changed, 84 insertions, 238 deletions
diff --git a/vbd/gui/module/src/main/resources/vpp/services/bdm.bridgedomain.service.js b/vbd/gui/module/src/main/resources/vpp/services/bdm.bridgedomain.service.js
index 1438208d2..e0fcee68f 100644
--- a/vbd/gui/module/src/main/resources/vpp/services/bdm.bridgedomain.service.js
+++ b/vbd/gui/module/src/main/resources/vpp/services/bdm.bridgedomain.service.js
@@ -47,9 +47,27 @@ define(['app/vpp/vpp.module'], function(vpp) {
s.get = function(successCallback, errorCallback) {
var restObj = VPPRestangular.one('restconf').one('config').one('network-topology:network-topology');
+ var bridgeDomainList = [];
restObj.get().then(function(data) {
- successCallback(data);
+ if(data['network-topology'].topology) {
+ bridgeDomainList = data['network-topology'].topology.filter(function (topology) {
+ if (topology['topology-types'] && topology['topology-types']['vbridge-topology:vbridge-topology']) {
+ return topology['topology-types']['vbridge-topology:vbridge-topology'] !== undefined;
+ }
+ });
+ }
+ successCallback(bridgeDomainList);
+ }, function(res) {
+ errorCallback(res.data, res.status);
+ });
+ };
+
+ s.getOne = function(bdId, successCallback, errorCallback) {
+ var restObj = VPPRestangular.one('restconf').one('config').one('network-topology:network-topology').one('topology').one(bdId);
+
+ restObj.get().then(function(data) {
+ successCallback(data.topology[0]);
}, function(res) {
errorCallback(res.data, res.status);
});
diff --git a/vbd/gui/module/src/main/resources/vpp/services/bdm.interface.service.js b/vbd/gui/module/src/main/resources/vpp/services/bdm.interface.service.js
index d2abc77b1..5fc907b7f 100644
--- a/vbd/gui/module/src/main/resources/vpp/services/bdm.interface.service.js
+++ b/vbd/gui/module/src/main/resources/vpp/services/bdm.interface.service.js
@@ -44,7 +44,15 @@ define(['app/vpp/vpp.module'], function(vpp) {
.one('topology').one(bridgeDomainId).one('node').one(vppId).one('termination-point').one(encodeURIComponent(interf['tp-id']));
restObj.remove().then(function(data) {
- successCallback(data);
+ bdmVppService.checkAndDeleteVpp(bridgeDomainId, vppId,
+ function() {
+ successCallback(data);
+ },
+ function() {
+
+ }
+ );
+
}, function(res) {
errorCallback(res.data, res.status);
});
diff --git a/vbd/gui/module/src/main/resources/vpp/services/bdm.tunnel.service.js b/vbd/gui/module/src/main/resources/vpp/services/bdm.tunnel.service.js
new file mode 100644
index 000000000..7c8f1492f
--- /dev/null
+++ b/vbd/gui/module/src/main/resources/vpp/services/bdm.tunnel.service.js
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+define(['app/vpp/vpp.module'], function(vpp) {
+ vpp.register.factory('bdmTunnelService', function(VPPRestangular) {
+ var s = {};
+
+ s.get = function(bridgeDomainId, successCallback, errorCallback) {
+ var restObj = VPPRestangular.one('restconf').one('operational').one('network-topology:network-topology')
+ .one('topology').one(bridgeDomainId);
+
+ restObj.get().then(function(data) {
+ successCallback(data.topology[0].link);
+ }, function(res) {
+ errorCallback(res.data, res.status);
+ });
+ };
+
+ return s;
+ });
+}); \ No newline at end of file
diff --git a/vbd/gui/module/src/main/resources/vpp/services/bdm.vpp.service.js b/vbd/gui/module/src/main/resources/vpp/services/bdm.vpp.service.js
index 0a24c2329..a86fa06fc 100644
--- a/vbd/gui/module/src/main/resources/vpp/services/bdm.vpp.service.js
+++ b/vbd/gui/module/src/main/resources/vpp/services/bdm.vpp.service.js
@@ -55,6 +55,16 @@ define(['app/vpp/vpp.module'], function(vpp) {
});
};
+ s.delete = function(bridgeDomainId, vppId, successCallback, errorCallback) {
+ var restObj = VPPRestangular.one('restconf').one('config').one('network-topology:network-topology').one('topology').one(bridgeDomainId).one('node').one(vppId);
+
+ return restObj.remove().then(function(data) {
+ successCallback(data);
+ }, function(res) {
+ errorCallback(res.data, res.status);
+ });
+ };
+
s.checkAndWriteVpp = function(bridgeDomainId, vppId, successCallback, errorCallback) {
s.getOne(bridgeDomainId, vppId,
function() {
@@ -69,9 +79,28 @@ define(['app/vpp/vpp.module'], function(vpp) {
});
}
);
+ };
- //getPromise.then
+ s.checkAndDeleteVpp = function(bridgeDomainId, vppId, successCallback, errorCallback) {
+ s.getOne(bridgeDomainId, vppId,
+ function(data) {
+ if(!data['termination-point']) {
+ s.delete(bridgeDomainId, vppId,
+ function(){
+ successCallback();
+ },
+ function() {
+ errorCallback();
+ }
+ );
+ }
+ },
+ function() {
+ errorCallback();
+ }
+ );
};
+
return s;
});
}); \ No newline at end of file
diff --git a/vbd/gui/module/src/main/resources/vpp/services/vpp.services.js b/vbd/gui/module/src/main/resources/vpp/services/vpp.services.js
index 1e9d20b23..19cee135b 100644
--- a/vbd/gui/module/src/main/resources/vpp/services/vpp.services.js
+++ b/vbd/gui/module/src/main/resources/vpp/services/vpp.services.js
@@ -30,251 +30,17 @@ define(['app/vpp/vpp.module', 'next'], function(vpp) {
}
});
- vpp.register.service('dataService', ['$timeout', function($timeout) {
+ vpp.register.service('dataService', ['$timeout', 'bdmTunnelService',function($timeout, bdmTunnelService) {
var self = this;
- nx.graphic.Icons.registerIcon("bd", "src/app/vpp/assets/images/bd1.svg", 45, 45);
- nx.graphic.Icons.registerIcon("interf", "src/app/vpp/assets/images/interf.svg", 45, 45);
-
- this.bridgeDomainsTopo = new nx.graphic.Topology({
- adaptive: true,
- scalable: true,
- theme:'blue',
- enableGradualScaling:true,
- nodeConfig: {
- color: '#414040',
- label: 'model.label',
- scale: 'model.scale',
- iconType: function(vertex) {
- var type = vertex.get().type;
- if (type === 'bd') {
- return 'bd'
- } else {
- return 'interf';
- }
- }
- },
- linkConfig: {
- label: 'model.label',
- linkType: 'parallel',
- color: function(link) {
- if (link.getData().type === 'tunnel') {
- return '#00FF00';
- } else {
- return '#ffffff';
- }
- },
- width: function(link) {
- if (link.getData().type === 'tunnel') {
- return 5;
- }
- }
- },
- showIcon: true,
- dataProcessor: 'force',
- autoLayout: true,
- enableSmartNode: false,
- tooltipManagerConfig: {
- nodeTooltipContentClass: 'TooltipNode',
- linkTooltipContentClass: 'TooltipLink'
- }
- });
- this.nextApp = new nx.ui.Application;
- this.bridgedomainsLoaded = false;
-
this.vpps = [];
- this.tableContent = [];
- this.originalAssignments = [];
this.interfaces = [];
- this.injectedInterfaces = [];
- this.bridgedomains = [];
- this.changedInterfaces = [];
this.selectedBd = {
name: ''
};
- this.generateInterfaces = function() {
- self.interfaces.length = 0;
- _.forEach(this.vpps, function(vpp) {
- _.forEach(vpp.interfaces, function(interf) {
- interf.vppName = vpp.name;
- interf.label = vpp.name+'/'+interf.name;
- interf.scale = 0.5;
- self.interfaces.push(interf);
- });
- });
- console.log(this.interfaces);
- };
-
- this.buildAssignedInterfaces = function() {
- this.originalAssignments.length = 0;
- _.forEach(this.bridgedomains, function(bd){
- var bdName = bd['topology-id'];
- var nodes = bd.node;
- if (nodes) {
- _.forEach(nodes, function(vpp) {
- var vppName = vpp['node-id'];
- var tps = vpp['termination-point'];
- if (tps) {
- _.forEach(tps, function(tp) {
- tp.vppName = vppName;
- tp.vbd = bdName;
- self.originalAssignments.push(tp);
- })
- }
- })
- }
- });
-
- console.log('Assigned Interfaces: ');
- console.log(this.originalAssignments);
- };
-
- this.buildTableContent = function() {
- this.tableContent.length = 0;
- angular.copy(this.interfaces,this.tableContent);
-
-
- //Makes assignements based on previously changed interfaces, or assignments retrieved from ODL
- _.forEach(this.tableContent, function(interf) {
- var matchedChangedInterface = _.find(self.changedInterfaces, {
- name: interf.name,
- vppName: interf.vppName
- });
-
- var matchedOriginalAssignment = _.find(self.originalAssignments, {
- 'vbridge-topology:user-interface': interf.name,
- vppName: interf.vppName
- });
-
- if (matchedChangedInterface) {
- interf.assigned = matchedChangedInterface.assigned;
- interf.vbd = matchedChangedInterface.vbd;
- } else if (matchedOriginalAssignment) {
- interf.assigned = true;
- interf.vbd = matchedOriginalAssignment.vbd;
- } else {
- interf.assigned = false;
- interf.vbd = '';
- }
- });
-
- _.remove(self.tableContent, function(interf){
- var isAssigned = interf.assigned === true;
- var isNotCorrectBd = !(interf.vbd === self.selectedBd.name);
- return(isAssigned && isNotCorrectBd);
- });
-
- //_.forEach(this.originalAssignments, function(origAssignment) {
- // if (origAssignment.vbd === self.selectedBd.name) {
- // var matchedInterface = _.find(self.tableContent, {
- // name: origAssignment['vbridge-topology:user-interface'],
- // vppName: origAssignment.vppName
- // });
- // if (matchedInterface) {
- // matchedInterface.assigned = true;
- // matchedInterface.vbd = origAssignment.vbd;
- // } else {
- // console.error('Interface "'+origAssignment['vbridge-topology:user-interface']+'" on VPP "'+origAssignment.vppName+'" in vBD "'+origAssignment.vbd+'" was not found at mount point!');
- // }
- // } else {
- // _.remove(self.tableContent, {
- // name: origAssignment['vbridge-topology:user-interface'],
- // vppName: origAssignment.vppName
- // });
- // }
- //});
- //
- //_.forEach(this.changedInterfaces, function(changedInterface) {
- //
- // var matchedInterface = _.find(self.tableContent, {
- // name: changedInterface.name,
- // vppName: changedInterface.vppName
- // });
- //
- // if (matchedInterface) {
- // if (changedInterface.assigned) {
- // if (changedInterface.vbd === self.selectedBd.name) {
- // matchedInterface.assigned = true;
- // matchedInterface.vbd = changedInterface.vbd;
- // }
- // else {
- // _.remove(self.tableContent, {
- // name: changedInterface.name,
- // vppName: changedInterface.vppName
- // });
- // }
- // } else {
- // matchedInterface.assigned = false;
- // matchedInterface.vbd = '';
- // }
- // }
- //});
-
- //..
-
- //_.remove(self.tableContent, {
- // name: origAssignment['vbridge-topology:user-interface'],
- // vppName: origAssignment.vppName
- //});
-
- this.injectBridgeDomainsTopoElements();
-
- };
-
-
- this.clearTopology = function() {
- this.bridgeDomainsTopo.clear();
- this.injectedInterfaces.length = 0;
-
- };
-
- //this.generateUnassignedInterfaces = function() {
- // this.unassignedInterfaces.length = 0;
- // for (var x=0; x<this.interfaces.length; x++) {
- // if (!this.interfaces[x]['v3po:l2']['bridge-domain']) {
- // this.unassignedInterfaces.push(this.interfaces[x]);
- // }
- // }
- //};
- this.setData = function() {
-
- for (var x=0; x<this.tableContent.length; x++) {
- if (this.tableContent[x].assigned) {
- this.bridgeDomainsTopo.addNode(this.tableContent[x]);
- this.injectedInterfaces.push(this.tableContent[x]);
- }
- }
-
- var nodes = [{
- name : this.selectedBd.name,
- label: this.selectedBd.name,
- type:'bd',
- x: 0,
- y: 0,
- scale: 1
- }].concat(this.injectedInterfaces);
-
- var links = [];
- for (var x=1; x<nodes.length; x++){
- links.push({'source':0, 'target': x});
- }
-
- var topoData = {
- nodes: nodes,
- links: links
- };
-
- this.bridgeDomainsTopo.data(topoData);
- };
-
- this.injectBridgeDomainsTopoElements = function() {
- this.clearTopology();
- this.setData();
- self.bridgeDomainsTopo.adaptToContainer();
- };
}]);