summaryrefslogtreecommitdiffstats
path: root/vbd/gui/module/src/main/resources/vpp/services
diff options
context:
space:
mode:
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.js10
-rw-r--r--vbd/gui/module/src/main/resources/vpp/services/bdm.interface.service.js31
-rw-r--r--vbd/gui/module/src/main/resources/vpp/services/bdm.vpp.service.js28
-rw-r--r--vbd/gui/module/src/main/resources/vpp/services/vpp.services.js220
4 files changed, 231 insertions, 58 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 5d3b69632..1438208d2 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
@@ -55,6 +55,16 @@ define(['app/vpp/vpp.module'], function(vpp) {
});
};
+ s.remove = function(bdName,successCallback,errorCallback) {
+ //http://localhost:8181/restconf/config/network-topology:network-topology/topology/testBD
+ var restObj = VPPRestangular.one('restconf').one('config').one('network-topology:network-topology').one('topology').one(bdName);
+
+ restObj.remove().then(function(data) {
+ successCallback(data);
+ }, function(res) {
+ errorCallback(res.data, res.status);
+ });
+ };
return s;
});
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 341fb5d48..d2abc77b1 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
@@ -6,7 +6,7 @@
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
define(['app/vpp/vpp.module'], function(vpp) {
- vpp.register.factory('bdmInterfaceService', function(VPPRestangular) {
+ vpp.register.factory('bdmInterfaceService', function(VPPRestangular, bdmVppService) {
var s = {};
var Interface = function(tpId, interfaceName) {
@@ -18,12 +18,32 @@ define(['app/vpp/vpp.module'], function(vpp) {
return new Interface(tpId, interfaceName);
};
- s.add = function(interface, bridgeDomainId, vppId, successCallback, errorCallback) {
+ s.add = function(interf, bridgeDomainId, vppId, successCallback, errorCallback) {
var restObj = VPPRestangular.one('restconf').one('config').one('network-topology:network-topology')
- .one('topology').one(bridgeDomainId).one('node').one(vppId).one('termination-point').one(interface['tp-id']);
- var dataObj = {'termination-point': [interface]};
+ .one('topology').one(bridgeDomainId).one('node').one(vppId).one('termination-point').one(encodeURIComponent(interf['tp-id']));
- restObj.customPUT(dataObj).then(function(data) {
+ var dataObj = {'termination-point': [interf]};
+
+ var write = function() {
+ restObj.customPUT(dataObj).then(function(data) {
+ successCallback(data);
+ }, function(res) {
+ errorCallback(res.data, res.status);
+ });
+ };
+
+ var errorCallback = function() {};
+
+ bdmVppService.checkAndWriteVpp(bridgeDomainId, vppId, write, errorCallback);
+
+
+ };
+
+ s.delete = function(interf, bridgeDomainId, vppId, successCallback, errorCallback) {
+ var restObj = VPPRestangular.one('restconf').one('config').one('network-topology:network-topology')
+ .one('topology').one(bridgeDomainId).one('node').one(vppId).one('termination-point').one(encodeURIComponent(interf['tp-id']));
+
+ restObj.remove().then(function(data) {
successCallback(data);
}, function(res) {
errorCallback(res.data, res.status);
@@ -41,7 +61,6 @@ define(['app/vpp/vpp.module'], function(vpp) {
});
};
-
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 b817a75a3..0a24c2329 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
@@ -38,14 +38,40 @@ define(['app/vpp/vpp.module'], function(vpp) {
s.get = function(bridgeDomainId, successCallback, errorCallback) {
var restObj = VPPRestangular.one('restconf').one('config').one('network-topology:network-topology').one('topology').one(bridgeDomainId);
- restObj.get().then(function(data) {
+ return restObj.get().then(function(data) {
successCallback(data);
}, function(res) {
errorCallback(res.data, res.status);
});
};
+ s.getOne = 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.get().then(function(data) {
+ successCallback(data);
+ }, function(res) {
+ errorCallback(res.data, res.status);
+ });
+ };
+
+ s.checkAndWriteVpp = function(bridgeDomainId, vppId, successCallback, errorCallback) {
+ s.getOne(bridgeDomainId, vppId,
+ function() {
+ successCallback();
+ }, function() {
+ var vppObject = s.createObj(vppId, vppId);
+
+ s.add(vppObject, bridgeDomainId, function() {
+ successCallback();
+ }, function() {
+ errorCallback();
+ });
+ }
+ );
+
+ //getPromise.then
+ };
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 70b1631f7..4c20f844e 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,14 +30,15 @@ define(['app/vpp/vpp.module', 'next'], function(vpp) {
}
});
- vpp.register.service('dataService', function() {
+ vpp.register.service('dataService', ['$timeout', function($timeout) {
+
+ 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({
- height: 350,
- width: 500,
+ adaptive: true,
scalable: true,
theme:'blue',
enableGradualScaling:true,
@@ -49,8 +50,6 @@ define(['app/vpp/vpp.module', 'next'], function(vpp) {
var type = vertex.get().type;
if (type === 'bd') {
return 'bd'
- } else if (type === 'vpp') {
- return 'switch'
} else {
return 'interf';
}
@@ -82,11 +81,11 @@ define(['app/vpp/vpp.module', 'next'], function(vpp) {
}
});
this.nextApp = new nx.ui.Application;
+ this.bridgedomainsLoaded = false;
this.vpps = [];
-
this.tableContent = [];
- this.unassignedInterfaces = [];
+ this.originalAssignments = [];
this.interfaces = [];
this.injectedInterfaces = [];
this.bridgedomains = [];
@@ -95,69 +94,188 @@ define(['app/vpp/vpp.module', 'next'], function(vpp) {
name: ''
};
- this.setBridgeDomains = function(data) {
- angular.copy(data['bridge-domains']['bridge-domain'], this.bridgedomains);
+ 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.clearInjectedInterfacesInBridgeDomainTopo = function() {
- this.bridgeDomainsTopo.clear();
- this.injectedInterfaces.length = 0;
+ 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.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.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.injectBridgeDomainsTopoElements = function() {
- this.clearInjectedInterfacesInBridgeDomainTopo();
- this.injectBdIntoBridgeDomainsTopo();
- this.injectInterfacesIntoBridgeDomainsTopo();
- this.injectInterfacesLinksIntoBridgeDomainsTopo();
- this.bridgeDomainsTopo.adaptToContainer();
};
- this.buildTableContent = function() {
- this.tableContent.length = 0;
- this.generateUnassignedInterfaces();
- angular.copy(this.unassignedInterfaces.concat(this.injectedInterfaces),this.tableContent);
+
+ this.clearTopology = function() {
+ this.bridgeDomainsTopo.clear();
+ this.injectedInterfaces.length = 0;
+
};
- this.injectBdIntoBridgeDomainsTopo = function() {
- this.bridgeDomainsTopo.addNode({
+ //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,
- x: 60,
- y: -50,
- scale: 5
- });
- };
+ type:'bd',
+ x: 0,
+ y: 0,
+ scale: 1
+ }].concat(this.injectedInterfaces);
- this.injectInterfacesLinksIntoBridgeDomainsTopo = function() {
- var nodes = this.bridgeDomainsTopo.getNodes();
+ var links = [];
for (var x=1; x<nodes.length; x++){
- var target = nodes[x].get('data-id');
- this.bridgeDomainsTopo.addLink({'source':0, 'target': target});
+ links.push({'source':0, 'target': x});
}
- };
- this.injectInterfacesIntoBridgeDomainsTopo = function() {
- for (var x=0; x<this.interfaces.length; x++) {
- if ((this.interfaces[x]['v3po:l2']['bridge-domain'] === this.selectedBd.name) && (this.interfaces[x].type==='iana-if-type:ethernetCsmacd')) {
- this.interfaces[x].label = 'vpp1/'+this.interfaces[x].name;
- this.bridgeDomainsTopo.addNode(this.interfaces[x]);
- this.injectedInterfaces.push(this.interfaces[x]);
- this.interfaces[x].assigned = true;
- }
- }
+ var topoData = {
+ nodes: nodes,
+ links: links
+ };
+
+ this.bridgeDomainsTopo.data(topoData);
};
- });
+ this.injectBridgeDomainsTopoElements = function() {
+ this.clearTopology();
+ this.setData();
+ self.bridgeDomainsTopo.adaptToContainer();
+ };
+ }]);