1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
|
/*-
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.openecomp.mso.adapters.vfc;
import java.util.HashMap;
import java.util.Map;
import org.openecomp.mso.adapters.vfc.constant.CommonConstant;
import org.openecomp.mso.adapters.vfc.constant.CommonConstant.Step;
import org.openecomp.mso.adapters.vfc.constant.DriverExceptionID;
import org.openecomp.mso.adapters.vfc.constant.HttpCode;
import org.openecomp.mso.adapters.vfc.exceptions.ApplicationException;
import org.openecomp.mso.adapters.vfc.model.CustomerModel;
import org.openecomp.mso.adapters.vfc.model.NSResourceInputParameter;
import org.openecomp.mso.adapters.vfc.model.NsCreateReq;
import org.openecomp.mso.adapters.vfc.model.NsInstantiateReq;
import org.openecomp.mso.adapters.vfc.model.NsOperationKey;
import org.openecomp.mso.adapters.vfc.model.NsParameters;
import org.openecomp.mso.adapters.vfc.model.NsProgressStatus;
import org.openecomp.mso.adapters.vfc.model.ResponseDescriptor;
import org.openecomp.mso.adapters.vfc.model.RestfulResponse;
import org.openecomp.mso.adapters.vfc.model.*;
import org.openecomp.mso.adapters.vfc.util.JsonUtil;
import org.openecomp.mso.adapters.vfc.util.RestfulUtil;
import org.openecomp.mso.adapters.vfc.util.ValidateUtil;
import org.openecomp.mso.requestsdb.RequestsDatabase;
import org.openecomp.mso.requestsdb.RequestsDbConstant;
import org.openecomp.mso.requestsdb.ResourceOperationStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* VF-C Manager <br>
* <p>
* </p>
*
* @author
* @version ONAP Amsterdam Release 2017-08-28
*/
public class VfcManager {
private static final Logger LOGGER = LoggerFactory.getLogger(VfcManager.class);
/**
* nfvo url map
*/
private static Map<String, String> nfvoUrlMap;
static {
nfvoUrlMap = new HashMap<>();
nfvoUrlMap.put(Step.CREATE, CommonConstant.NFVO_CREATE_URL);
nfvoUrlMap.put(Step.INSTANTIATE, CommonConstant.NFVO_INSTANTIATE_URL);
nfvoUrlMap.put(Step.TERMINATE, CommonConstant.NFVO_TERMINATE_URL);
nfvoUrlMap.put(Step.DELETE, CommonConstant.NFVO_DELETE_URL);
nfvoUrlMap.put(Step.QUERY, CommonConstant.NFVO_QUERY_URL);
nfvoUrlMap.put(Step.SCALE, CommonConstant.NFVO_SCALE_URL);
}
public VfcManager() {
}
/**
* create network service <br>
*
* @param segInput input parameters for current node from http request
* @return
* @since ONAP Amsterdam Release
*/
public RestfulResponse createNs(NSResourceInputParameter segInput) throws ApplicationException {
// Step1: get service template by node type
String csarId = segInput.getNsOperationKey().getNodeTemplateUUID();
// nsdId for NFVO is "id" in the response, while for SDNO is "servcice template id"
LOGGER.info("serviceTemplateId is {}, id is {}", csarId);
LOGGER.info("create ns -> begin");
// Step2: Prepare url and method type
String url = getUrl(null, CommonConstant.Step.CREATE);
String methodType = CommonConstant.MethodType.POST;
// Step3: Prepare restful parameters and options
NsCreateReq oRequest = new NsCreateReq();
oRequest.setCsarId(csarId);
oRequest.setNsName(segInput.getNsServiceName());
oRequest.setDescription(segInput.getNsServiceDescription());
CustomerModel context = new CustomerModel();
context.setGlobalCustomerId(segInput.getNsOperationKey().getGlobalSubscriberId());
context.setServiceType(segInput.getNsOperationKey().getServiceType());
oRequest.setContext(context);
String createReq = JsonUtil.marshal(oRequest);
// Step4: Call NFVO or SDNO lcm to create ns
RestfulResponse createRsp = RestfulUtil.send(url, methodType, createReq);
ValidateUtil.assertObjectNotNull(createRsp);
LOGGER.info("create ns response status is : {}", createRsp.getStatus());
LOGGER.info("create ns response content is : {}", createRsp.getResponseContent());
// Step 5: save resource operation information
ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance())
.getResourceOperationStatus(segInput.getNsOperationKey().getServiceId(),
segInput.getNsOperationKey().getOperationId(),
segInput.getNsOperationKey().getNodeTemplateUUID());
nsOperInfo.setStatus(RequestsDbConstant.Status.PROCESSING);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
if (!HttpCode.isSucess(createRsp.getStatus())) {
LOGGER.error("update segment operation status : fail to create ns");
nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
nsOperInfo.setErrorCode(String.valueOf(createRsp.getStatus()));
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
DriverExceptionID.FAIL_TO_CREATE_NS);
}
@SuppressWarnings("unchecked")
Map<String, String> rsp = JsonUtil.unMarshal(createRsp.getResponseContent(), Map.class);
String nsInstanceId = rsp.get(CommonConstant.NS_INSTANCE_ID);
if (ValidateUtil.isStrEmpty(nsInstanceId)) {
LOGGER.error("Invalid instanceId from create operation");
throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
DriverExceptionID.INVALID_RESPONSEE_FROM_CREATE_OPERATION);
}
LOGGER.info("create ns -> end");
LOGGER.info("save segment and operaton info -> begin");
// Step 6: add relation between service and NS
AaiUtil.addRelation(segInput.getNsOperationKey().getGlobalSubscriberId(),
segInput.getNsOperationKey().getServiceType(), segInput.getNsOperationKey().getServiceId(),
nsInstanceId);
LOGGER.info("save segment and operation info -> end");
return createRsp;
}
/**
* delete network service <br>
*
* @param nsOperationKey The operation key of the NS resource
* @param nsInstanceId The NS instance id
* @return
* @since ONAP Amsterdam Release
*/
public RestfulResponse deleteNs(NsOperationKey nsOperationKey, String nsInstanceId)
throws ApplicationException {
LOGGER.info("delete ns -> begin");
// Step1: prepare url and methodType
String url = getUrl(nsInstanceId, CommonConstant.Step.DELETE);
String methodType = CommonConstant.MethodType.DELETE;
// Step2: prepare restful parameters and options
RestfulResponse deleteRsp = RestfulUtil.send(url, methodType, "");
ValidateUtil.assertObjectNotNull(deleteRsp);
LOGGER.info("delete ns response status is : {}", deleteRsp.getStatus());
LOGGER.info("delete ns response content is : {}", deleteRsp.getResponseContent());
LOGGER.info("delete ns -> end");
ResourceOperationStatus nsOperInfo =
(RequestsDatabase.getInstance()).getResourceOperationStatus(nsOperationKey.getServiceId(),
nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID());
if (!HttpCode.isSucess(deleteRsp.getStatus())) {
LOGGER.error("fail to delete ns");
nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
nsOperInfo.setErrorCode(String.valueOf(deleteRsp.getStatus()));
nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
DriverExceptionID.FAIL_TO_DELETE_NS);
}
// Step3: remove relation info between service and ns
AaiUtil.removeRelation(nsOperationKey.getGlobalSubscriberId(), nsOperationKey.getServiceType(),
nsOperationKey.getServiceId(), nsInstanceId);
LOGGER.info("delete segment information -> end");
// Step4: update service segment operation status
nsOperInfo.setStatus(RequestsDbConstant.Status.FINISHED);
nsOperInfo.setErrorCode(String.valueOf(deleteRsp.getStatus()));
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
LOGGER.info("update segment operaton status for delete -> end");
return deleteRsp;
}
/**
* instantiate network service <br>
*
* @param nsInstanceId The NS instance id
* @param segInput input parameters for current node from http request
* @return
* @since ONAP Amsterdam Release
*/
public RestfulResponse instantiateNs(String nsInstanceId, NSResourceInputParameter segInput)
throws ApplicationException {
// Call the NFVO or SDNO service to instantiate service
LOGGER.info("instantiate ns -> begin");
// Step1: Prepare restful parameters and options
NsInstantiateReq oRequest = new NsInstantiateReq();
oRequest.setNsInstanceId(nsInstanceId);
NsParameters nsParameters = segInput.getNsParameters();
oRequest.setLocationConstraints(nsParameters.getLocationConstraints());
oRequest.setAdditionalParamForNs(nsParameters.getAdditionalParamForNs());
String instReq = JsonUtil.marshal(oRequest);
// Step2: prepare url and
String url = getUrl(nsInstanceId, CommonConstant.Step.INSTANTIATE);
String methodType = CommonConstant.MethodType.POST;
RestfulResponse instRsp = RestfulUtil.send(url, methodType, instReq);
ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance())
.getResourceOperationStatus(segInput.getNsOperationKey().getServiceId(),
segInput.getNsOperationKey().getOperationId(),
segInput.getNsOperationKey().getNodeTemplateUUID());
ValidateUtil.assertObjectNotNull(instRsp);
if (!HttpCode.isSucess(instRsp.getStatus())) {
LOGGER.error("update segment operation status : fail to instantiate ns");
nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
nsOperInfo.setErrorCode(String.valueOf(instRsp.getStatus()));
nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
DriverExceptionID.FAIL_TO_INSTANTIATE_NS);
}
LOGGER.info("instantiate ns response status is : {}", instRsp.getStatus());
LOGGER.info("instantiate ns response content is : {}", instRsp.getResponseContent());
ValidateUtil.assertObjectNotNull(instRsp.getResponseContent());
@SuppressWarnings("unchecked")
Map<String, String> rsp = JsonUtil.unMarshal(instRsp.getResponseContent(), Map.class);
String jobId = rsp.get(CommonConstant.JOB_ID);
if (ValidateUtil.isStrEmpty(jobId)) {
LOGGER.error("Invalid jobId from instantiate operation");
nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
nsOperInfo.setErrorCode(String.valueOf(instRsp.getStatus()));
nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
DriverExceptionID.INVALID_RESPONSE_FROM_INSTANTIATE_OPERATION);
}
LOGGER.info("instantiate ns -> end");
// Step 3: update segment operation job id
LOGGER.info("update resource operation status job id -> begin");
nsOperInfo.setJobId(jobId);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
LOGGER.info("update segment operation job id -> end");
return instRsp;
}
/**
* terminate network service <br>
*
* @param nsOperationKey The operation key for NS resource
* @param nsInstanceId The NS instance id
* @return
* @since ONAP Amsterdam Release
*/
public RestfulResponse terminateNs(NsOperationKey nsOperationKey, String nsInstanceId)
throws ApplicationException {
// Step1: save segment operation info for delete process
LOGGER.info("save segment operation for delete process");
ResourceOperationStatus nsOperInfo =
(RequestsDatabase.getInstance()).getResourceOperationStatus(nsOperationKey.getServiceId(),
nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID());
nsOperInfo.setStatus(RequestsDbConstant.Status.PROCESSING);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
LOGGER.info("terminate ns -> begin");
// Step2: prepare url and method type
String url = getUrl(nsInstanceId, CommonConstant.Step.TERMINATE);
String methodType = CommonConstant.MethodType.POST;
// Step3: prepare restful parameters and options
Map<String, String> reqBody = new HashMap<>();
reqBody.put("nsInstanceId", nsInstanceId);
reqBody.put("terminationType", "graceful");
reqBody.put("gracefulTerminationTimeout", "60");
// Step4: Call the NFVO or SDNO service to terminate service
RestfulResponse terminateRsp = RestfulUtil.send(url, methodType, JsonUtil.marshal(reqBody));
ValidateUtil.assertObjectNotNull(terminateRsp);
LOGGER.info("terminate ns response status is : {}", terminateRsp.getStatus());
LOGGER.info("terminate ns response content is : {}", terminateRsp.getResponseContent());
// Step 3: update segment operation
if (!HttpCode.isSucess(terminateRsp.getStatus())) {
LOGGER.error("fail to instantiate ns");
nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
nsOperInfo.setErrorCode(String.valueOf(terminateRsp.getStatus()));
nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
DriverExceptionID.FAIL_TO_TERMINATE_NS);
}
@SuppressWarnings("unchecked")
Map<String, String> rsp = JsonUtil.unMarshal(terminateRsp.getResponseContent(), Map.class);
String jobId = rsp.get(CommonConstant.JOB_ID);
if (ValidateUtil.isStrEmpty(jobId)) {
LOGGER.error("Invalid jobId from terminate operation");
nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
nsOperInfo.setErrorCode(String.valueOf(terminateRsp.getStatus()));
nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
DriverExceptionID.INVALID_RESPONSE_FROM_TERMINATE_OPERATION);
}
LOGGER.info("terminate ns -> end");
LOGGER.info("update segment job id -> begin");
nsOperInfo.setJobId(jobId);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
LOGGER.info("update segment job id -> end");
return terminateRsp;
}
/**
* get ns progress by job Id <br>
*
* @param nsOperationKey The OperationKey for NS resource
* @param jobId the job id
* @return
* @since ONAP Amsterdam Release
*/
public RestfulResponse getNsProgress(NsOperationKey nsOperationKey, String jobId)
throws ApplicationException {
ValidateUtil.assertObjectNotNull(jobId);
// Step 1: query the current resource operation status
ResourceOperationStatus nsOperInfo =
(RequestsDatabase.getInstance()).getResourceOperationStatus(nsOperationKey.getServiceId(),
nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID());
// Step 2: start query
LOGGER.info("query ns status -> begin");
String url = getUrl(jobId, CommonConstant.Step.QUERY);
String methodType = CommonConstant.MethodType.GET;
// prepare restful parameters and options
RestfulResponse rsp = RestfulUtil.send(url, methodType, "");
ValidateUtil.assertObjectNotNull(rsp);
LOGGER.info("query ns progress response status is : {}", rsp.getStatus());
LOGGER.info("query ns progress response content is : {}", rsp.getResponseContent());
// Step 3:check the response staus
if (!HttpCode.isSucess(rsp.getStatus())) {
LOGGER.info("fail to query job status");
nsOperInfo.setErrorCode(String.valueOf(rsp.getStatus()));
nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.QUERY_JOB_STATUS_FAILED);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
DriverExceptionID.FAIL_TO_QUERY_JOB_STATUS);
}
// Step 4: Process Network Service Instantiate Response
NsProgressStatus nsProgress =
JsonUtil.unMarshal(rsp.getResponseContent(), NsProgressStatus.class);
ResponseDescriptor rspDesc = nsProgress.getResponseDescriptor();
// Step 5: update segment operation progress
nsOperInfo.setProgress(rspDesc.getProgress());
nsOperInfo.setStatusDescription(rspDesc.getStatusDescription());
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
// Step 6: update segment operation status
if (RequestsDbConstant.Progress.ONE_HUNDRED.equals(rspDesc.getProgress())
&& RequestsDbConstant.Status.FINISHED.equals(rspDesc.getStatus())) {
LOGGER.info("job result is succeeded, operType is {}", nsOperInfo.getOperType());
nsOperInfo.setErrorCode(String.valueOf(rsp.getStatus()));
nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.QUERY_JOB_STATUS_FAILED);
if(RequestsDbConstant.OperationType.CREATE.equalsIgnoreCase(nsOperInfo.getOperType())) {
nsOperInfo.setStatus(RequestsDbConstant.Status.FINISHED);
}
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
} else if (RequestsDbConstant.Status.ERROR.equals(rspDesc.getStatus())) {
LOGGER.error("job result is failed, operType is {}", nsOperInfo.getOperType());
nsOperInfo.setErrorCode(String.valueOf(rsp.getStatus()));
nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.QUERY_JOB_STATUS_FAILED);
nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
DriverExceptionID.JOB_STATUS_ERROR);
} else {
LOGGER.error("unexcepted response status");
}
LOGGER.info("query ns status -> end");
return rsp;
}
/**
* Scale NS instance
* <br>
*
* @param nsInstanceId The NS instance id
* @param segInput input parameters for current node from http request
* @return
* @since ONAP Amsterdam Release
*/
public RestfulResponse scaleNs(String nsInstanceId, NSResourceInputParameter segInput)
throws ApplicationException {
// Call the NFVO to scale service
LOGGER.info("scale ns -> begin");
// Step1: Prepare restful parameters and options
VFCScaleData oRequest = new VFCScaleData();
oRequest.setNsInstanceId(nsInstanceId);
NsScaleParameters nsScaleParameters = segInput.getNsScaleParameters();
oRequest.setScaleType(nsScaleParameters.getScaleType());
oRequest.setScaleNsData(nsScaleParameters.getScaleNsByStepsData());
String scaleReq = JsonUtil.marshal(oRequest);
// Step2: prepare url and method type
String url = getUrl(nsInstanceId, CommonConstant.Step.SCALE);
String methodType = CommonConstant.MethodType.POST;
LOGGER.info("scale ns request is {}", scaleReq);
// Step3: Call NFVO lcm to scale ns
RestfulResponse scaleRsp = RestfulUtil.send(url, methodType, scaleReq);
ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance()).getResourceOperationStatus(
segInput.getNsOperationKey().getServiceId(), segInput.getNsOperationKey().getOperationId(),
segInput.getNsOperationKey().getNodeTemplateUUID());
ValidateUtil.assertObjectNotNull(scaleRsp);
if(!HttpCode.isSucess(scaleRsp.getStatus())) {
LOGGER.error("update segment operation status : fail to scale ns");
nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
nsOperInfo.setErrorCode(String.valueOf(scaleRsp.getStatus()));
nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.SCALE_NS_FAILED);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_SCALE_NS);
}
LOGGER.info("scale ns response status is {}", scaleRsp.getStatus());
LOGGER.info("scale ns response content is {}", scaleRsp.getResponseContent());
ValidateUtil.assertObjectNotNull(scaleRsp.getResponseContent());
@SuppressWarnings("unchecked")
Map<String, String> rsp = JsonUtil.unMarshal(scaleRsp.getResponseContent(), Map.class);
String jobId = rsp.get(CommonConstant.JOB_ID);
if(ValidateUtil.isStrEmpty(jobId)) {
LOGGER.error("Invalid jobId from scale operation");
nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
nsOperInfo.setErrorCode(String.valueOf(scaleRsp.getStatus()));
nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.SCALE_NS_FAILED);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
DriverExceptionID.INVALID_RESPONSE_FROM_SCALE_OPERATION);
}
LOGGER.info("update resource operation status job id -> begin");
// Step 4: update segment operation job id
nsOperInfo.setJobId(jobId);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
LOGGER.info("update segment operation job id -> end");
LOGGER.info("scale ns -> end");
return scaleRsp;
}
/**
* get url for the operation <br>
*
* @param variable variable should be put in the url
* @param step step of the operation (terminate,query,delete)
* @return
* @since ONAP Amsterdam Release
*/
private String getUrl(String variable, String step) {
String url;
String originalUrl;
originalUrl = (String) nfvoUrlMap.get(step);
url = String.format(originalUrl, variable);
return url;
}
}
|