summaryrefslogtreecommitdiffstats
path: root/vbd
diff options
context:
space:
mode:
authorDaniel Malachovsky <daniel.malachovsky@pantheon.sk>2016-02-06 00:55:22 +0100
committerDaniel Malachovsky <daniel.malachovsky@pantheon.sk>2016-02-07 18:46:47 +0000
commitdf53da6e0a476db6c0e46b9d5e6c2b5d620c600a (patch)
treedd2798287ab227df2708fecfb1bfcd5736dce496 /vbd
parent0280a5f3852e30b7d28747fcf43adaa6a11b5a13 (diff)
vBDManager services initial commit
- added add/get/object definitions for vBD, VPP and Interfaces Change-Id: Ic639f06fad5700a1722fdb0b1034b8134bdb1c41 Signed-off-by: Daniel Malachovsky <daniel.malachovsky@pantheon.sk>
Diffstat (limited to 'vbd')
-rw-r--r--vbd/gui/module/src/main/resources/vpp/controllers/bdm.controller.js187
-rw-r--r--vbd/gui/module/src/main/resources/vpp/controllers/bdm.vpp.controller.js133
-rw-r--r--vbd/gui/module/src/main/resources/vpp/controllers/inventory.controller.js4
-rw-r--r--vbd/gui/module/src/main/resources/vpp/services/bdm.bridgedomain.service.js51
-rw-r--r--vbd/gui/module/src/main/resources/vpp/services/bdm.interface.service.js37
-rw-r--r--vbd/gui/module/src/main/resources/vpp/services/bdm.vpp.service.js41
-rw-r--r--vbd/gui/module/src/main/resources/vpp/views/bridge-domains.tpl.html2
7 files changed, 356 insertions, 99 deletions
diff --git a/vbd/gui/module/src/main/resources/vpp/controllers/bdm.controller.js b/vbd/gui/module/src/main/resources/vpp/controllers/bdm.controller.js
index 02c9879a8..b49fe8af8 100644
--- a/vbd/gui/module/src/main/resources/vpp/controllers/bdm.controller.js
+++ b/vbd/gui/module/src/main/resources/vpp/controllers/bdm.controller.js
@@ -11,7 +11,6 @@ define(['app/vpp/vpp.module'], function(vpp) {
}]);
-
vpp.register.controller('TableController', ['$scope', '$rootScope','$filter', 'dataService', 'toastService', function ($scope, $rootScope, filter, dataService, toastService) {
var vm = this;
vm.rowCollection = dataService.tableContent;
@@ -34,94 +33,110 @@ define(['app/vpp/vpp.module'], function(vpp) {
};
}]);
- vpp.register.controller('BridgeDomainsController', function(dataService, $location, $mdDialog, toastService) {
- var vm = this;
- vm.dataService = dataService;
-
- dataService.nextApp.container(document.getElementById('bridge-domains-next-app'));
- dataService.bridgeDomainsTopo.attach(dataService.nextApp);
-
- window.addEventListener('resize', function () {
- if ($location.path() === '/bridgedomains') {
- dataService.topo.adaptToContainer();
- }
- });
-
- vm.bridgedomains = dataService.bridgedomains;
- vm.selectedBd = dataService.selectedBd;
-
- dataService.bridgeDomainsTopo.on('clickNode',function(topo,node) {
- console.log(node);
- });
-
- vm.bdChanged = function() {
- dataService.injectBridgeDomainsTopoElements();
- dataService.buildTableContent();
- };
-
- vm.addBd = function() {
- //show dialog
- $mdDialog.show({
- controller: function() {
- var vm = this;
- vm.bd = {};
- vm.waiting = false;
-
- //function called when the cancel button ( 'x' in the top right) is clicked
- vm.close = function() {
- $mdDialog.cancel();
- };
-
- vm.isDone = function(status) {
+ vpp.register.controller('BridgeDomainsController', ['$scope', '$rootScope','$filter', 'dataService', 'bdmBridgeDomainService', 'toastService',
+ function($scope, $rootScope, $filter, dataService, bdmBridgeDomainService, toastService) {
+ $scope.addBd = function() {
+ var obj = bdmBridgeDomainService.createObj('vBD' + ((Math.random() * 100) + 1) );
+
+ bdmBridgeDomainService.add(obj,
+ function(data) {
+ console.log('successadding vbd');
+ },
+ function() {
+ console.warn('add bd failed');
+ });
+ };
+
+ /*var vm = this;
+ vm.dataService = dataService;
+
+ dataService.nextApp.container(document.getElementById('bridge-domains-next-app'));
+ dataService.bridgeDomainsTopo.attach(dataService.nextApp);
+
+ window.addEventListener('resize', function () {
+ if ($location.path() === '/bridgedomains') {
+ dataService.topo.adaptToContainer();
+ }
+ });
+
+ vm.bridgedomains = dataService.bridgedomains;
+ vm.selectedBd = dataService.selectedBd;
+
+ dataService.bridgeDomainsTopo.on('clickNode',function(topo,node) {
+ console.log(node);
+ });
+
+ vm.bdChanged = function() {
+ dataService.injectBridgeDomainsTopoElements();
+ dataService.buildTableContent();
+ };
+
+ vm.addBd = function() {
+ //show dialog
+ $mdDialog.show({
+ controller: function() {
+ var vm = this;
+ vm.bd = {};
vm.waiting = false;
- if (status === 'success') {
- dataService.bridgedomains.push(vm.bd);
- dataService.selectedBd.name = vm.bd.name;
- dataService.injectBridgeDomainsTopoElements();
- dataService.buildTableContent();
- vm.close();
- }
- };
- //function called when the update button is clicked
- vm.updateConfig = function() {
- vm.waiting = true;
- //send a POST with the entered content in the form field
+ //function called when the cancel button ( 'x' in the top right) is clicked
+ vm.close = function() {
+ $mdDialog.cancel();
+ };
+
+ vm.isDone = function(status) {
+ vm.waiting = false;
+ if (status === 'success') {
+ dataService.bridgedomains.push(vm.bd);
+ dataService.selectedBd.name = vm.bd.name;
+ dataService.injectBridgeDomainsTopoElements();
+ dataService.buildTableContent();
+ vm.close();
+ }
+ };
+
+ //function called when the update button is clicked
+ vm.updateConfig = function() {
+ vm.waiting = true;
+ //send a POST with the entered content in the form field
+
+ };
+ },
+ controllerAs: 'NewBdDialogCtrl',
+ templateUrl: 'templates/new-bd-dialog.html',
+ parent: angular.element(document.body),
+ clickOutsideToClose:false
+ })
+ };
+
+
+
+ vm.deploy = function() {
+
+ };
+
+ vm.removeBd = function() {
+ if(vm.selectedBd.name) {
+ var successCallback = function(success) {
+ if (success) {
+ console.log(vm.bridgedomains);
+ _.remove(vm.bridgedomains, {
+ name: vm.selectedBd.name
+ });
+ toastService.showToast('Bridge Domain Removed!');
+ vm.selectedBd.name = '';
+ dataService.clearInjectedInterfacesInBridgeDomainTopo();
+ dataService.injectBdIntoBridgeDomainsTopo();
+ dataService.tableContent.length = 0;
+ } else {
+ toastService.showToast('Error removing Bridge Domain!');
+ }
};
- },
- controllerAs: 'NewBdDialogCtrl',
- templateUrl: 'templates/new-bd-dialog.html',
- parent: angular.element(document.body),
- clickOutsideToClose:false
- })
- };
- vm.deploy = function() {
-
- };
-
- vm.removeBd = function() {
- if(vm.selectedBd.name) {
- var successCallback = function(success) {
- if (success) {
- console.log(vm.bridgedomains);
- _.remove(vm.bridgedomains, {
- name: vm.selectedBd.name
- });
- toastService.showToast('Bridge Domain Removed!');
- vm.selectedBd.name = '';
- dataService.clearInjectedInterfacesInBridgeDomainTopo();
- dataService.injectBdIntoBridgeDomainsTopo();
- dataService.tableContent.length = 0;
- } else {
- toastService.showToast('Error removing Bridge Domain!');
-
- }
- };
-
- //... removeBdFromOdl(vm.selectedBd.name, successCallback);
- }
- };
- });
+ //... removeBdFromOdl(vm.selectedBd.name, successCallback);
+ }
+ };
+ */
+ }]);
}); \ No newline at end of file
diff --git a/vbd/gui/module/src/main/resources/vpp/controllers/bdm.vpp.controller.js b/vbd/gui/module/src/main/resources/vpp/controllers/bdm.vpp.controller.js
index 5ef5c3c6a..69dfd2fcb 100644
--- a/vbd/gui/module/src/main/resources/vpp/controllers/bdm.vpp.controller.js
+++ b/vbd/gui/module/src/main/resources/vpp/controllers/bdm.vpp.controller.js
@@ -7,11 +7,136 @@
*/
define(['app/vpp/vpp.module'], function(vpp) {
+ vpp.register.controller('bdmCtrl', ['$scope', '$rootScope','$filter', 'dataService', 'toastService', function ($scope, $rootScope, filter, dataService, toastService) {
- vpp.register.controller('bdmVppCtrl', ['$scope', '$rootScope', '$timeout' ,'dataService', 'toastService', '$mdSidenav', '$mdDialog',
- function ($scope, $rootScope, $timeout ,dataService, toastService, $mdSidenav, $mdDialog) {
+ }]);
- }]);
+ vpp.register.controller('TableController', ['$scope', '$rootScope','$filter', 'dataService', 'toastService', function ($scope, $rootScope, filter, dataService, toastService) {
+ var vm = this;
+ vm.rowCollection = dataService.tableContent;
+ vm.displayedCollection = [].concat(vm.rowCollection);
+ vm.updateAssignment = function(receivedInterface) {
+ var interf = _.find(dataService.interfaces, {name: receivedInterface.name, 'phys-address': receivedInterface['phys-address']});
+ angular.copy(receivedInterface, interf);
+ if (interf.assigned){
+ interf['v3po:l2']['bridge-domain'] = dataService.selectedBd.name;
+ } else {
+ interf['v3po:l2']['bridge-domain'] = '';
+ }
+ dataService.injectBridgeDomainsTopoElements();
+ dataService.buildTableContent();
+ var previouslyChangedInterface = _.find(dataService.changedInterfaces, {name: interf.name, 'phys-address': interf['phys-address']});
+ if (!previouslyChangedInterface) {
+ dataService.changedInterfaces.push(interf);
+ }
+ console.log(dataService.changedInterfaces);
+ };
+ }]);
+
+ vpp.register.controller('BridgeDomainsController', ['$scope', '$rootScope','$filter', 'dataService', 'bdmBridgeDomainService', 'toastService',
+ function($scope, $rootScope, $filter, dataService, bdmBridgeDomainService, toastService) {
+ $scope.addBd = function() {
+ var obj = bdmBridgeDomainService.createObj('vBD' + ((Math.random() * 100) + 1) );
+
+ bdmBridgeDomainService.add(obj,
+ function(data) {
+ console.log('successadding vbd');
+ },
+ function() {
+ console.warn('add bd failed');
+ });
+ };
+
+ /*var vm = this;
+ vm.dataService = dataService;
+
+ dataService.nextApp.container(document.getElementById('bridge-domains-next-app'));
+ dataService.bridgeDomainsTopo.attach(dataService.nextApp);
+
+ window.addEventListener('resize', function () {
+ if ($location.path() === '/bridgedomains') {
+ dataService.topo.adaptToContainer();
+ }
+ });
+
+ vm.bridgedomains = dataService.bridgedomains;
+ vm.selectedBd = dataService.selectedBd;
+
+ dataService.bridgeDomainsTopo.on('clickNode',function(topo,node) {
+ console.log(node);
+ });
+
+ vm.bdChanged = function() {
+ dataService.injectBridgeDomainsTopoElements();
+ dataService.buildTableContent();
+ };
+
+ vm.addBd = function() {
+ //show dialog
+ $mdDialog.show({
+ controller: function() {
+ var vm = this;
+ vm.bd = {};
+ vm.waiting = false;
+ //function called when the cancel button ( 'x' in the top right) is clicked
+ vm.close = function() {
+ $mdDialog.cancel();
+ };
-});
+ vm.isDone = function(status) {
+ vm.waiting = false;
+ if (status === 'success') {
+ dataService.bridgedomains.push(vm.bd);
+ dataService.selectedBd.name = vm.bd.name;
+ dataService.injectBridgeDomainsTopoElements();
+ dataService.buildTableContent();
+ vm.close();
+ }
+ };
+
+ //function called when the update button is clicked
+ vm.updateConfig = function() {
+ vm.waiting = true;
+ //send a POST with the entered content in the form field
+
+ };
+ },
+ controllerAs: 'NewBdDialogCtrl',
+ templateUrl: 'templates/new-bd-dialog.html',
+ parent: angular.element(document.body),
+ clickOutsideToClose:false
+ })
+ };
+
+
+
+ vm.deploy = function() {
+
+ };
+
+ vm.removeBd = function() {
+ if(vm.selectedBd.name) {
+ var successCallback = function(success) {
+ if (success) {
+ console.log(vm.bridgedomains);
+ _.remove(vm.bridgedomains, {
+ name: vm.selectedBd.name
+ });
+ toastService.showToast('Bridge Domain Removed!');
+ vm.selectedBd.name = '';
+ dataService.clearInjectedInterfacesInBridgeDomainTopo();
+ dataService.injectBdIntoBridgeDomainsTopo();
+ dataService.tableContent.length = 0;
+ } else {
+ toastService.showToast('Error removing Bridge Domain!');
+
+ }
+ };
+
+ //... removeBdFromOdl(vm.selectedBd.name, successCallback);
+ }
+ };
+ */
+ }]);
+}); \ No newline at end of file
diff --git a/vbd/gui/module/src/main/resources/vpp/controllers/inventory.controller.js b/vbd/gui/module/src/main/resources/vpp/controllers/inventory.controller.js
index f447bd0fb..8d85cc704 100644
--- a/vbd/gui/module/src/main/resources/vpp/controllers/inventory.controller.js
+++ b/vbd/gui/module/src/main/resources/vpp/controllers/inventory.controller.js
@@ -8,8 +8,8 @@
define(['app/vpp/vpp.module'], function(vpp) {
- vpp.register.controller('InventoryTableController', ['$scope', '$rootScope','$filter', 'toastService', 'VppService', '$mdDialog', 'dataService', 'VppInterfaceService',
- function($scope, $rootScope, filter, toastService, VppService, $mdDialog, dataService, VppInterfaceService) {
+ vpp.register.controller('InventoryTableController', ['$scope', '$rootScope','$filter', 'toastService', 'VppService', '$mdDialog', 'dataService',
+ function($scope, $rootScope, filter, toastService, VppService, $mdDialog, dataService) {
$scope.getVppList = function() {
$scope.initVppList();
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 9316cbff7..5d3b69632 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
@@ -5,10 +5,57 @@
* 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', 'next'], function(vpp) {
- vpp.register.factory('bdmBridgeDomainService', function(VPPRestangular, VPPRestangularXml) {
+define(['app/vpp/vpp.module'], function(vpp) {
+ vpp.register.factory('bdmBridgeDomainService', function(VPPRestangular) {
var s = {};
+ var BridgeDomain = function(topologyId) {
+ this['topology-id'] = topologyId || null;
+ this['topology-types'] = {
+ 'vbridge-topology:vbridge-topology': {}
+ };
+ this['underlay-topology'] = [
+ {
+ 'topology-ref': 'topology-netconf'
+ }
+ ];
+ this['vbridge-topology:tunnel-type'] = 'tunnel-type-vxlan';
+ this['vbridge-topology:vxlan'] = {
+ 'vni': '1'
+ };
+ this['vbridge-topology:flood'] = "true",
+ this['vbridge-topology:forward'] = "true",
+ this['vbridge-topology:learn'] = "true",
+ this['vbridge-topology:unknown-unicast-flood'] = "true",
+ this['vbridge-topology:arp-termination'] = "false"
+ };
+
+ s.createObj = function(topologyId) {
+ return new BridgeDomain(topologyId);
+ };
+
+ s.add = function(bridgeDomain, successCallback, errorCallback) {
+ var restObj = VPPRestangular.one('restconf').one('config').one('network-topology:network-topology').one('topology').one(bridgeDomain['topology-id']);
+ var dataObj = {'topology': [bridgeDomain]};
+
+ restObj.customPUT(dataObj).then(function(data) {
+ successCallback(data);
+ }, function(res) {
+ errorCallback(res.data, res.status);
+ });
+ };
+
+ s.get = function(successCallback, errorCallback) {
+ var restObj = VPPRestangular.one('restconf').one('config').one('network-topology:network-topology');
+
+ restObj.get().then(function(data) {
+ successCallback(data);
+ }, 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.interface.service.js b/vbd/gui/module/src/main/resources/vpp/services/bdm.interface.service.js
index 9dca2d29d..341fb5d48 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
@@ -5,10 +5,43 @@
* 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', 'next'], function(vpp) {
- vpp.register.factory('bdmInterfaceService', function(VPPRestangular, VPPRestangularXml) {
+define(['app/vpp/vpp.module'], function(vpp) {
+ vpp.register.factory('bdmInterfaceService', function(VPPRestangular) {
var s = {};
+ var Interface = function(tpId, interfaceName) {
+ this['tp-id'] = tpId || null;
+ this['vbridge-topology:user-interface'] = interfaceName;
+ };
+
+ s.createObj = function(tpId, interfaceName) {
+ return new Interface(tpId, interfaceName);
+ };
+
+ s.add = function(interface, 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]};
+
+ restObj.customPUT(dataObj).then(function(data) {
+ successCallback(data);
+ }, function(res) {
+ errorCallback(res.data, res.status);
+ });
+ };
+
+ s.get = 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);
+
+ restObj.get().then(function(data) {
+ successCallback(data);
+ }, 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 5a23d831c..b817a75a3 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
@@ -5,10 +5,47 @@
* 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', 'next'], function(vpp) {
- vpp.register.factory('bdmVppService', function(VPPRestangular, VPPRestangularXml) {
+define(['app/vpp/vpp.module'], function(vpp) {
+ vpp.register.factory('bdmVppService', function(VPPRestangular) {
var s = {};
+ var Vpp = function(nodeId, vppId) {
+ this['node-id'] = nodeId || null;
+ this['supporting-node'] = [
+ {
+ 'topology-ref': 'topology-netconf',
+ 'node-ref': vppId
+ }
+ ];
+ this['netconf-node-topology:pass-through'] = {};
+ };
+
+ s.createObj = function(nodeId, vppId) {
+ return new Vpp(nodeId, vppId);
+ };
+
+ s.add = function(vpp, bridgeDomainId, successCallback, errorCallback) {
+ var restObj = VPPRestangular.one('restconf').one('config').one('network-topology:network-topology').one('topology').one(bridgeDomainId).one('node').one(vpp['node-id']);
+ var dataObj = {'node': [vpp]};
+
+ restObj.customPUT(dataObj).then(function(data) {
+ successCallback(data);
+ }, function(res) {
+ errorCallback(res.data, res.status);
+ });
+ };
+
+ 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) {
+ successCallback(data);
+ }, 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/views/bridge-domains.tpl.html b/vbd/gui/module/src/main/resources/vpp/views/bridge-domains.tpl.html
index a8b4689d1..d92873afe 100644
--- a/vbd/gui/module/src/main/resources/vpp/views/bridge-domains.tpl.html
+++ b/vbd/gui/module/src/main/resources/vpp/views/bridge-domains.tpl.html
@@ -9,7 +9,7 @@
<md-select ng-model='BridgeDomainsController.selectedBd.name' placeholder="Select BD" ng-change="BridgeDomainsController.bdChanged()" style="width: 100%;">
<md-option ng-repeat="bd in BridgeDomainsController.bridgedomains" value="{{bd.name}}">{{bd.name}}</md-option>
</md-select>
- <md-button class="md-raised" md-no-ink ng-click="BridgeDomainsController.addBd()" style="width: 25%;">Add BD</md-button>
+ <md-button class="md-raised" md-no-ink ng-click="addBd()" style="width: 25%;">Add BD</md-button>
<md-button class="md-raised" md-no-ink ng-click="BridgeDomainsController.removeBd()" style="width: 35%;" ng-if="BridgeDomainsController.dataService.injectedInterfaces.length===0 && BridgeDomainsController.dataService.selectedBd.name">Remove BD</md-button>
</md-input-container>