diff options
author | 2016-02-05 13:26:48 +0100 | |
---|---|---|
committer | 2016-02-06 03:57:32 +0000 | |
commit | 03b448f806cc561f62941e231f3de9e38e8b9a4e (patch) | |
tree | 309b97eab6581eb4dda4a3ef3746fb4539456b71 /vbd/gui/module/src/main/resources/vpp/services | |
parent | 843fe81ebf7f11920a52f625bf863a1fad4d29de (diff) |
Splitting sources
- splitted vpp.controller.js and vpp.services.js into smaller files to
avoid blocking and problems during merging
Change-Id: I379dc1e5154c6f685fb6a976db239b620e58fc6e
Signed-off-by: Daniel Malachovsky <daniel.malachovsky@pantheon.sk>
Diffstat (limited to 'vbd/gui/module/src/main/resources/vpp/services')
6 files changed, 362 insertions, 0 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 new file mode 100644 index 000000000..9316cbff7 --- /dev/null +++ b/vbd/gui/module/src/main/resources/vpp/services/bdm.bridgedomain.service.js @@ -0,0 +1,14 @@ +/* + * 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', 'next'], function(vpp) { + vpp.register.factory('bdmBridgeDomainService', function(VPPRestangular, VPPRestangularXml) { + var s = {}; + + 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 new file mode 100644 index 000000000..9dca2d29d --- /dev/null +++ b/vbd/gui/module/src/main/resources/vpp/services/bdm.interface.service.js @@ -0,0 +1,14 @@ +/* + * 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', 'next'], function(vpp) { + vpp.register.factory('bdmInterfaceService', function(VPPRestangular, VPPRestangularXml) { + var s = {}; + + return s; + }); +});
\ No newline at end of file diff --git a/vbd/gui/module/src/main/resources/vpp/services/bdm.service.js b/vbd/gui/module/src/main/resources/vpp/services/bdm.service.js new file mode 100644 index 000000000..5d6592787 --- /dev/null +++ b/vbd/gui/module/src/main/resources/vpp/services/bdm.service.js @@ -0,0 +1,14 @@ +/* + * 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', 'next'], function(vpp) { + vpp.register.factory('bdmService', function(VPPRestangular, VPPRestangularXml) { + var s = {}; + + 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 new file mode 100644 index 000000000..5a23d831c --- /dev/null +++ b/vbd/gui/module/src/main/resources/vpp/services/bdm.vpp.service.js @@ -0,0 +1,14 @@ +/* + * 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', 'next'], function(vpp) { + vpp.register.factory('bdmVppService', function(VPPRestangular, VPPRestangularXml) { + var s = {}; + + return s; + }); +});
\ No newline at end of file diff --git a/vbd/gui/module/src/main/resources/vpp/services/inventory.service.js b/vbd/gui/module/src/main/resources/vpp/services/inventory.service.js new file mode 100644 index 000000000..a90354fb4 --- /dev/null +++ b/vbd/gui/module/src/main/resources/vpp/services/inventory.service.js @@ -0,0 +1,142 @@ +/* + * 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', 'next'], function(vpp) { + vpp.register.factory('VppService', function(VPPRestangular, VPPRestangularXml, VppInterfaceService, $q) { + var s = {}; + + var Vpp = function(name, ipAddress, port, username, password, status) { + this.name = name || null; + this.ipAddress = ipAddress || null; + this.port = port || null; + this.username = username || null; + this.password = password || null; + this.status = status || null; + this.interfaces = []; + }; + + s.createObj = function(name, ipAddress, port, username, password, status) { + return new Vpp(name, ipAddress, port, username, password, status); + }; + + s.getVppList = function(successCallback, errorCallback) { + var vppList = []; + var promiseList = []; + var restObj = VPPRestangular.one('restconf').one('operational').one('network-topology:network-topology').one('topology').one('topology-netconf'); + + restObj.get().then(function(data) { + //if(data.topology.length || data.topology[0].node.length) { + data.topology[0].node.forEach(function(n) { + if(n['node-id'] !== 'controller-config') { + //create new object + var vppObj = s.createObj(n['node-id'], n['netconf-node-topology:host'], n['netconf-node-topology:port'], null, null, n['netconf-node-topology:connection-status']); + // register a promise + if (vppObj.status === 'connected') { + var promise = VppInterfaceService.getInterfaceListByVppName(n['node-id'], function (interfaceList) { + vppObj.interfaces = interfaceList; + }); + // add promise to array + promiseList.push(promise); + // when promise is resolved, push vpp into vppList + promise.then(function () { + vppList.push(vppObj); + }) + } + else { + vppList.push(vppObj); + } + + } + }); + //} + // when all promises are resolved, call success callback + $q.all(promiseList).then(function () { + successCallback(vppList); + }); + }, function(res) { + errorCallback(res); + }); + }; + + s.deleteVpp = function(vpp, finishedSuccessfullyCallback) { + console.log(vpp); + var restObj = VPPRestangular.one('restconf').one('config').one('network-topology:network-topology').one('topology').one('topology-netconf').one('node').one('controller-config').one('yang-ext:mount').one('config:modules').one('module').one('odl-sal-netconf-connector-cfg:sal-netconf-connector').one(vpp.name); + + restObj.remove().then(function() { + finishedSuccessfullyCallback(true); + }, function(res) { + finishedSuccessfullyCallback(false); + }); + }; + + s.mountVpp = function(name,ip,port,un,pw,finishedSuccessfullyCallback) { + + var postData = '\ + <module xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">\ + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">prefix:sal-netconf-connector</type>\ + <name>'+name+'</name>\ + <address xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">'+ip+'</address>\ + <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">'+port+'</port>\ + <username xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">'+un+'</username>\ + <password xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">'+pw+'</password>\ + <tcp-only xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">false</tcp-only>\ + <event-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">\ + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-event-executor</type>\ + <name>global-event-executor</name>\ + </event-executor>\ + <binding-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">\ + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>\ + <name>binding-osgi-broker</name>\ + </binding-registry>\ + <dom-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">\ + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>\ + <name>dom-broker</name>\ + </dom-registry>\ + <client-dispatcher xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">\ + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf">prefix:netconf-client-dispatcher</type>\ + <name>global-netconf-dispatcher</name>\ + </client-dispatcher>\ + <processing-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">\ + <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>\ + <name>global-netconf-processing-executor</name>\ + </processing-executor>\ + </module>'; + + var restObj = VPPRestangularXml.one('restconf').one('config').one('opendaylight-inventory:nodes').one('node').one('controller-config').one('yang-ext:mount'); + + restObj.post('config:modules', postData).then(function() { + finishedSuccessfullyCallback(true); + }, function(res) { + finishedSuccessfullyCallback(false); + }); + }; + + return s; + }); + + vpp.register.factory('VppInterfaceService', function(VPPRestangular, $q) { + var s = {}; + + s.getInterfaceListByVppName = function(vppName, successCallback) { + var interfaceList = []; + var restObj = VPPRestangular.one('restconf').one('operational').one('network-topology:network-topology').one('topology').one('topology-netconf').one('node').one(vppName).one('yang-ext:mount').one('ietf-interfaces:interfaces-state'); + + return restObj.get().then(function(data) { + if (data['interfaces-state'].interface) { + interfaceList = data['interfaces-state'].interface.filter(function(i) { + if (i.name != 'local0') { + return i; + } + }); + } + successCallback(interfaceList); + }); + }; + + 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 new file mode 100644 index 000000000..70b1631f7 --- /dev/null +++ b/vbd/gui/module/src/main/resources/vpp/services/vpp.services.js @@ -0,0 +1,164 @@ +/* + * 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', 'next'], function(vpp) { + + vpp.register.factory('VPPRestangular', function(Restangular, ENV) { + return Restangular.withConfig(function(RestangularConfig) { + RestangularConfig.setBaseUrl(ENV.getBaseURL("MD_SAL")); + }); + }); + + vpp.register.factory('VPPRestangularXml', function(Restangular, ENV) { + return Restangular.withConfig(function(RestangularConfig) { + RestangularConfig.setBaseUrl(ENV.getBaseURL("MD_SAL")); + RestangularConfig.setDefaultHeaders({ "Content-Type": "application/xml" }, { "Accept": "application/xml" }); + }); + }); + + vpp.register.service('toastService', function($mdToast) { + this.showToast = function(content) { + var toast = $mdToast.simple() + .content(content) + .action('OK') + .position('bottom right'); + $mdToast.show(toast); + } + }); + + vpp.register.service('dataService', function() { + + 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, + 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 if (type === 'vpp') { + return 'switch' + } else { + return 'interf'; + } + } + }, + linkConfig: { + label: 'model.label', + linkType: 'parallel', + color: function(link) { + if (link.getData().type === 'tunnel') { + return '#00FF00'; + } else { + return '#414040'; + } + }, + 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.vpps = []; + + this.tableContent = []; + this.unassignedInterfaces = []; + this.interfaces = []; + this.injectedInterfaces = []; + this.bridgedomains = []; + this.changedInterfaces = []; + this.selectedBd = { + name: '' + }; + + this.setBridgeDomains = function(data) { + angular.copy(data['bridge-domains']['bridge-domain'], this.bridgedomains); + }; + + this.clearInjectedInterfacesInBridgeDomainTopo = 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.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.injectBdIntoBridgeDomainsTopo = function() { + this.bridgeDomainsTopo.addNode({ + name : this.selectedBd.name, + label: this.selectedBd.name, + x: 60, + y: -50, + scale: 5 + }); + }; + + this.injectInterfacesLinksIntoBridgeDomainsTopo = function() { + var nodes = this.bridgeDomainsTopo.getNodes(); + for (var x=1; x<nodes.length; x++){ + var target = nodes[x].get('data-id'); + this.bridgeDomainsTopo.addLink({'source':0, 'target': target}); + } + }; + + 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; + } + } + }; + + }); + + + +});
\ No newline at end of file |