Assign image keyname and pubkey at vnf level
[ccsdk/apps.git] / sdnr / wireless-transport / code-Carbon-SR1 / ux / mwtnSpectrum / mwtnSpectrum-module / src / main / resources / mwtnSpectrum / mwtnSpectrum.services.js
1 /*
2  * Copyright (c) 2016 highstreet technologies GmbH and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 define(['app/mwtnSpectrum/mwtnSpectrum.module'],function(mwtnSpectrumApp) {
10
11
12   mwtnSpectrumApp.register.factory('$mwtnSpectrum', function($q, $mwtnCommons, $mwtnLog) {
13     var service = {};
14
15     service.gridOptions = $mwtnCommons.gridOptions;
16     service.highlightFilteredHeader = $mwtnCommons.highlightFilteredHeader;
17     service.getActualNetworkElement = $mwtnCommons.getActualNetworkElement;
18     service.getPacParts = $mwtnCommons.getPacParts;
19     
20     
21     service.execute = function() {
22       var request = {
23           method: 'POST',
24           url: 'operations/scheduler:next'
25       };
26       var deferred = $q.defer();
27       $mwtnCommons.genericRequest(request).then(function(success) {
28         deferred.resolve(success);
29       }, function(error) {
30         deferred.reject(error);
31       });
32       return deferred.promise;
33     };
34     
35     service.refresh = function() {
36       var deferred = $q.defer();
37       $mwtnCommons.getRequiredNetworkElements(true).then(function(pNes){
38         var neIds = pNes.map(function(pNe){
39           pNe._source.connectionStatus = 'disconnected';
40           return pNe._id;
41         });
42         $mwtnCommons.getMountPoints(). then(function(mountpoints){
43           var actualNodes = mountpoints.map(function(mountpoint){
44             var pIndex = neIds.indexOf(mountpoint['node-id']);
45             if (pIndex > -1) {
46               pNes[pIndex]._source.connectionStatus = mountpoint['netconf-node-topology:connection-status']; 
47             }
48             return {
49               id: mountpoint['node-id'],
50               connectionStatus: mountpoint['netconf-node-topology:connection-status']
51             };
52           });
53           var airInterfaces = [];
54           pNes.map(function(hit){
55             hit._source.MW_AirInterface_Pac.filter(function(airinterface){
56               return airinterface.airInterfaceConfiguration;
57             }).map(function(airinterface){
58               airInterfaces.push({
59                 id: $mwtnCommons.getNodeIntIdFromNodeId(hit._source.nodeId),
60                 name: hit._source.nodeId,
61                 connectionStatus: hit._source.connectionStatus,
62                 airInterfaceName: airinterface.airInterfaceConfiguration.airInterfaceName,
63                 radioSignalID: airinterface.airInterfaceConfiguration.radioSignalID,
64                 plannedTxFrequency: airinterface.airInterfaceConfiguration.txFrequency,
65                 actualTxFrequency: '?',
66                 plannedRxFrequency: airinterface.airInterfaceConfiguration.rxFrequency,
67                 actualRxFrequency: '?'
68               });
69             });
70           });
71           
72           airInterfaces.sort(function(a, b){
73             if(a.radioSignalID < b.radioSignalID) return -1;
74             if(a.radioSignalID > b.radioSignalID) return 1;
75             return 0;
76           });
77           deferred.resolve({airInterfaces: airInterfaces, actualNodes: actualNodes});
78         }, function(error){
79           deferred.reject([]);
80         });
81         
82       }, function(error){
83         deferred.reject([]);
84       });
85       return deferred.promise;
86     };
87
88     return service;
89   });
90 });