3 * Copyright 2016 RIFT.IO Inc
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 import RecordViewActions
from './recordViewActions.js';
19 let Utils
= require('utils/utils.js');
20 import $ from 'jquery';
21 let API_SERVER
= require('utils/rw.js').getSearchParams(window
.location
).api_server
;
22 let HOST
= API_SERVER
;
23 let NODE_PORT
= require('utils/rw.js').getSearchParams(window
.location
).api_port
|| ((window
.location
.protocol
== 'https:') ? 8443 : 8000);
24 let DEV_MODE
= require('utils/rw.js').getSearchParams(window
.location
).dev_mode
|| false;
27 HOST
= window
.location
.protocol
+ '//' + window
.location
.hostname
;
33 remote: function(state
, recordID
) {
34 return new Promise(function(resolve
, reject
) {
36 url
: 'api/nsr/' + recordID
+ '?api_server=' + API_SERVER
,
38 beforeSend
: Utils
.addAuthorizationStub
,
39 success: function(data
) {
42 }).fail(function(xhr
) {
43 //Authentication and the handling of fail states should be wrapped up into a connection class.
44 Utils
.checkAuthentication(xhr
.status
);
48 loading
: RecordViewActions
.getNSRLoading
,
49 success
: RecordViewActions
.getNSRSuccess
,
50 error
: RecordViewActions
.getNSRError
55 remote: function(state
, vnfrID
) {
56 return new Promise(function(resolve
, reject
) {
58 url
: 'passthrough/data/api/operational/vnfr-catalog/vnfr/' + vnfrID
+ '?api_server=' + API_SERVER
,
60 beforeSend
: Utils
.addAuthorizationStub
,
61 success: function(data
) {
67 loading
: RecordViewActions
.getRawLoading
,
68 success
: RecordViewActions
.getRawSuccess
,
69 error
: RecordViewActions
.getRawError
74 remote: function(state
, nsrID
) {
75 return new Promise(function(resolve
, reject
) {
77 url
: 'passthrough/data/api/operational/ns-instance-opdata/nsr/' + nsrID
+ '?api_server=' + API_SERVER
,
79 beforeSend
: Utils
.addAuthorizationStub
,
80 success: function(data
) {
86 loading
: RecordViewActions
.getRawLoading
,
87 success
: RecordViewActions
.getRawSuccess
,
88 error
: RecordViewActions
.getRawError
93 remote(state
, recordID
) {
94 return new Promise(function(resolve
, reject
) {
95 console
.log('Getting NSR Socket');
97 url
: '/socket-polling?api_server=' + API_SERVER
,
99 beforeSend
: Utils
.addAuthorizationStub
,
101 url
: '/launchpad/api/nsr/' + recordID
+ '?api_server=' + API_SERVER
,
103 success: function(data
) {
104 Utils
.checkAndResolveSocketRequest(data
, resolve
, reject
);
109 loading
: RecordViewActions
.getNSRSocketLoading
,
110 success
: RecordViewActions
.getNSRSocketSuccess
,
111 error
: RecordViewActions
.getNSRSocketError
114 getConfigJobSocket() {
116 remote(state
, recordID
) {
117 return new Promise(function(resolve
, reject
) {
118 console
.log('Getting Job Socket');
120 url
: '/socket-polling?api_server=' + API_SERVER
,
122 beforeSend
: Utils
.addAuthorizationStub
,
124 url
: '/launchpad/api/nsr/' + recordID
+ '?api_server=' + API_SERVER
,
126 success: function(data
) {
127 Utils
.checkAndResolveSocketRequest(data
, resolve
, reject
);
132 success
: RecordViewActions
.getConfigSocketJobSuccess
,
133 error
: RecordViewActions
.getConfigSocketJobError
139 return new Promise(function(resolve
, reject
) {
140 console
.log('Getting VNFR Socket for: ' + state
.recordID
);
142 url
: '/socket-polling?api_server=' + API_SERVER
,
144 beforeSend
: Utils
.addAuthorizationStub
,
146 url
: '/launchpad/api/vnfr/' + state
.recordID
+ '?api_server=' + API_SERVER
,
148 success: function(data
) {
149 Utils
.checkAndResolveSocketRequest(data
, resolve
, reject
);
154 loading
: RecordViewActions
.getVNFRSocketLoading
,
155 success
: RecordViewActions
.getVNFRSocketSuccess
,
156 error
: RecordViewActions
.getVNFRSocketError
159 execNsConfigPrimitive() {
161 remote(state
, payload
) {
162 return new Promise(function(resolve
, reject
) {
164 url
: 'api/exec-ns-service-primitive?api_server=' + API_SERVER
,
168 beforeSend
: Utils
.addAuthorizationStub
,
169 success: function(data
) {
175 loading
: RecordViewActions
.execNsConfigPrimitiveLoading
,
176 success
: RecordViewActions
.execNsConfigPrimitiveSuccess
,
177 error
: RecordViewActions
.execNsConfigPrimitiveError
180 createScalingGroupInstance() {
182 remote(state
, params
) {
183 return new Promise(function(resolve
, reject
) {
185 url
: 'api/nsr/' + params
.nsr_id
+ '/' + params
.scaling_group_id
+ '/instance' + '?api_server=' + API_SERVER
,
187 beforeSend
: Utils
.addAuthorizationStub
,
188 success: function(data
) {
194 loading
: RecordViewActions
.createScalingGroupInstanceLoading
,
195 success
: RecordViewActions
.createScalingGroupInstanceSuccess
,
196 error
: RecordViewActions
.createScalingGroupInstanceError
199 deleteScalingGroupInstance() {
201 remote(state
, params
) {
202 return new Promise(function(resolve
, reject
) {
204 url
: 'api/nsr/' + params
.nsr_id
+ '/' + params
.scaling_group_id
+ '/instance/' + params
.scaling_instance_index
+ '?api_server=' + API_SERVER
,
206 beforeSend
: Utils
.addAuthorizationStub
,
207 success: function(data
) {
213 loading
: RecordViewActions
.deleteScalingGroupInstanceLoading
,
214 success
: RecordViewActions
.deleteScalingGroupInstanceSuccess
,
215 error
: RecordViewActions
.deleteScalingGroupInstanceError
218 createVirtualLink() {
220 remote(state
, params
) {
221 return new Promise(function(resolve
, reject
) {
223 url
: 'api/nsr/' + params
.nsr_id
+ '/vld' + '?api_server=' + API_SERVER
,
225 beforeSend
: Utils
.addAuthorizationStub
,
226 success: function(data
) {
232 loading
: RecordViewActions
.createVirtualLinkLoading
,
233 success
: RecordViewActions
.createVirtualLinkSuccess
,
234 error
: RecordViewActions
.createVirtualLinkError
237 deleteVirtualLink() {
239 remote(state
, params
) {
240 return new Promise(function(resolve
, reject
) {
242 url
: 'api/nsr/' + params
.nsr_id
+ '/vld/' + params
.vldId
+ '?api_server=' + API_SERVER
,
244 beforeSend
: Utils
.addAuthorizationStub
,
245 success: function(data
) {
251 loading
: RecordViewActions
.deleteVirtualLinkLoading
,
252 success
: RecordViewActions
.deleteVirtualLinkSuccess
,
253 error
: RecordViewActions
.deleteVirtualLinkError
258 remote(state
, params
) {
259 return new Promise(function(resolve
, reject
) {
261 url
: 'api/nsr/' + params
.nsr_id
+ '/vld/' + params
.vldId
+ '?api_server=' + API_SERVER
,
263 beforeSend
: Utils
.addAuthorizationStub
,
264 success: function(data
) {
270 loading
: RecordViewActions
.editVirtualLinkLoading
,
271 success
: RecordViewActions
.editVirtualLinkSuccess
,
272 error
: RecordViewActions
.editVirtualLinkError