aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-vfc-adapter/src/main/java
diff options
context:
space:
mode:
authorguanwenyao <guanwenyao@chinamobile.com>2018-03-28 17:42:46 +0800
committerguanwenyao <guanwenyao@chinamobile.com>2018-03-28 17:43:29 +0800
commit8b216bf982491685c08fdbfb404d4acf01c049f1 (patch)
tree56915ce12f14061807733150ed7b814062bf61f6 /adapters/mso-vfc-adapter/src/main/java
parent9903fb12ab6b3081e8c1b680ae4088d638503776 (diff)
support manual scale for NS
Issue-ID: SO-423 Change-Id: I752e096806ec513250a8fb1bf51a2ed57fb05f6e Signed-off-by: guanwenyao <guanwenyao@chinamobile.com>
Diffstat (limited to 'adapters/mso-vfc-adapter/src/main/java')
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java69
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/CommonConstant.java6
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java5
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java11
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleParameters.java66
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleReq.java49
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsByStepsData.java88
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsData.java49
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VFCScaleData.java82
9 files changed, 424 insertions, 1 deletions
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java
index 06a937ad6d..8e16d1c22f 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java
@@ -37,6 +37,7 @@ 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;
@@ -70,6 +71,7 @@ public class VfcManager {
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() {
@@ -400,6 +402,73 @@ public class VfcManager {
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>
*
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/CommonConstant.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/CommonConstant.java
index 471ba43b2b..57c68def5a 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/CommonConstant.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/CommonConstant.java
@@ -42,6 +42,8 @@ public class CommonConstant {
public static final String NFVO_QUERY_URL = "/api/nslcm/v1/jobs/%s";
+ public static final String NFVO_SCALE_URL = "/api/nslcm/v1/ns/%s/scale";
+
/**
*
* <br>
@@ -89,6 +91,8 @@ public class CommonConstant {
public static final String DELETE = "delete";
+ public static final String SCALE = "scale";
+
private Step() {
}
@@ -122,6 +126,8 @@ public class CommonConstant {
public static final String CREATE_NS_FAILED = "create ns failed";
+ public static final String SCALE_NS_FAILED = "scale ns failed";
+
private StatusDesc() {
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java
index afaa9019ad..48273f0c9f 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java
@@ -52,6 +52,11 @@ public class DriverExceptionID {
public static final String FAIL_TO_QUERY_JOB_STATUS = "Fail to query job status";
+ public static final String FAIL_TO_SCALE_NS = "Fail to scale network service";
+
+ public static final String INVALID_RESPONSE_FROM_SCALE_OPERATION = "Invalid response from scale operation";
+
+
private DriverExceptionID() {
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java
index 35dec4b937..765ee52069 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (C) 2018 CMCC 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.
@@ -47,9 +48,9 @@ public class NSResourceInputParameter {
private NsParameters nsParameters;
+ private NsScaleParameters nsScaleParameters;
-
/**
* @return Returns the nsServiceName.
*/
@@ -127,4 +128,12 @@ public class NSResourceInputParameter {
return "";
}
}
+
+ public NsScaleParameters getNsScaleParameters() {
+ return nsScaleParameters;
+ }
+
+ public void setNsScaleParameters(NsScaleParameters nsScaleParameters) {
+ this.nsScaleParameters = nsScaleParameters;
+ }
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleParameters.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleParameters.java
new file mode 100644
index 0000000000..eb40cddc7b
--- /dev/null
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleParameters.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 CMCC 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.model;
+
+import java.util.List;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version ONAP Amsterdam Release 2017-9-26
+ */
+public class NsScaleParameters {
+
+ private List<ScaleNsByStepsData> scaleNsByStepsData;
+
+ private String scaleType;
+
+ /**
+ * @return Returns the scaleNsByStepsData.
+ */
+ public List<ScaleNsByStepsData> getScaleNsByStepsData() {
+ return scaleNsByStepsData;
+ }
+
+ /**
+ * @param scaleNsByStepsData The scaleNsByStepsData to set.
+ */
+ public void setScaleNsByStepsData(List<ScaleNsByStepsData> scaleNsByStepsData) {
+ this.scaleNsByStepsData = scaleNsByStepsData;
+ }
+
+ /**
+ * @return Returns the scale Type.
+ */
+ public String getScaleType() {
+ return scaleType;
+ }
+
+ /**
+ * @param scaleType The scaleType to set.
+ */
+ public void setScaleType(String scaleType) {
+ this.scaleType = scaleType;
+ }
+
+}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleReq.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleReq.java
new file mode 100644
index 0000000000..1d9e7aabac
--- /dev/null
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleReq.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 CMCC 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.model;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ * request model for scale
+ *
+ * @author
+ * @version ONAP Amsterdam Release 2017-9-26
+ */
+public class NsScaleReq extends NsScaleParameters {
+
+ String nsInstanceId;
+
+ /**
+ * @return Returns the nsInstanceId.
+ */
+ public String getNsInstanceId() {
+ return nsInstanceId;
+ }
+
+ /**
+ * @param nsInstanceId The nsInstanceId to set.
+ */
+ public void setNsInstanceId(String nsInstanceId) {
+ this.nsInstanceId = nsInstanceId;
+ }
+
+}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsByStepsData.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsByStepsData.java
new file mode 100644
index 0000000000..668b66013d
--- /dev/null
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsByStepsData.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 CMCC 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.model;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version ONAP Amsterdam Release 2017-9-26
+ */
+public class ScaleNsByStepsData {
+
+ /**
+ * scaling Direction
+ */
+ private String scalingDirection;
+
+ /**
+ * aspect ID
+ */
+ private String aspectId;
+
+ /**
+ * number of Steps
+ */
+ private Integer numberOfSteps;
+
+ /**
+ * @return Returns the scalingDirection.
+ */
+ public String getScalingDirection() {
+ return scalingDirection;
+ }
+
+ /**
+ * @param scalingDirection The scalingDirection to set.
+ */
+ public void setScalingDirection(String scalingDirection) {
+ this.scalingDirection = scalingDirection;
+ }
+
+ /**
+ * @return Returns the aspectId.
+ */
+ public String getAspectId() {
+ return aspectId;
+ }
+
+ /**
+ * @param aspectId The aspectId to set.
+ */
+ public void setAspectId(String aspectId) {
+ this.aspectId = aspectId;
+ }
+
+ /**
+ * @return Returns the numberOfSteps.
+ */
+ public Integer getNumberOfSteps() {
+ return numberOfSteps;
+ }
+
+ /**
+ * @param numberOfSteps The numberOfSteps to set.
+ */
+ public void setNumberOfSteps(int numberOfSteps) {
+ this.numberOfSteps = numberOfSteps;
+ }
+}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsData.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsData.java
new file mode 100644
index 0000000000..437af5be11
--- /dev/null
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsData.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 CMCC 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.model;
+
+import java.util.List;
+
+/**
+ * aim to wrap List<ScaleNsByStepsData> as a new list
+ * then be provided for the usage of vfc json
+ *
+ * added on 2018/01/30 by Qihui Zhao from CMCC
+ * */
+
+public class ScaleNsData {
+
+ private List<ScaleNsByStepsData> scaleNsByStepsData;
+
+ /**
+ * @return Returns the scaleNsByStepsData.
+ */
+ public List<ScaleNsByStepsData> getScaleNsByStepsData() {
+ return scaleNsByStepsData;
+ }
+
+ /**
+ * @param scaleNsByStepsData The scaleNsByStepsData to set.
+ */
+ public void setScaleNsByStepsData(List<ScaleNsByStepsData> scaleNsByStepsData) {
+ this.scaleNsByStepsData = scaleNsByStepsData;
+ }
+}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VFCScaleData.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VFCScaleData.java
new file mode 100644
index 0000000000..33460b4757
--- /dev/null
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VFCScaleData.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 CMCC 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.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Object totally matches required VFC input json format
+ * JsonUtil.marshal will convert this Object to string
+ *
+ * added on 2018/01/30 by Qihui Zhao from CMCC*/
+
+public class VFCScaleData {
+
+ private String nsInstanceId;
+
+ private String scaleType;
+
+ private List<ScaleNsData> scaleNsData = new ArrayList<>();
+
+ /**
+ * @return Returns the nsInstanceId.
+ */
+ public String getNsInstanceId() {
+ return nsInstanceId;
+ }
+
+ /**
+ * @param nsInstanceId The nsInstanceId to set.
+ */
+ public void setNsInstanceId(String nsInstanceId) {
+ this.nsInstanceId = nsInstanceId;
+ }
+
+ /**
+ * @return Returns the scale Type.
+ */
+ public String getScaleType() {
+ return scaleType;
+ }
+
+ /**
+ * @param scaleType The scaleType to set.
+ */
+ public void setScaleType(String scaleType) {
+ this.scaleType = scaleType;
+ }
+
+ /**
+ *@return Returns the scaleNsDate.
+ */
+ public List<ScaleNsData> getScaleNsData(){return scaleNsData;}
+
+ /**
+ * The scaleNsData to set.
+ */
+ public void setScaleNsData(List<ScaleNsByStepsData> scaleNsByStepsData){
+ ScaleNsData scaleNsDataObj = new ScaleNsData();
+ scaleNsDataObj.setScaleNsByStepsData(scaleNsByStepsData);
+
+ this.scaleNsData.add(scaleNsDataObj);
+ }
+}