diff options
189 files changed, 15488 insertions, 81 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceArtifact.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceArtifact.java new file mode 100644 index 0000000000..ce39b9713a --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceArtifact.java @@ -0,0 +1,118 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2019, CMCC Technologies Co., Ltd. + * ================================================================================ + * 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.onap.so.adapters.catalogdb.catalogrest; + +import org.onap.so.db.catalog.beans.ServiceArtifact; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@XmlRootElement(name = "serviceArtifacts") +public class QueryServiceArtifact extends CatalogQuery { + + protected static Logger logger = LoggerFactory.getLogger(QueryServiceArtifact.class); + + private List<ServiceArtifact> serviceArtifactList; + + private static final String TEMPLATE = "\t{\n" + "\t\t\"artifactUUID\" : <ARTIFACT_UUID>,\n" + + "\t\t\"name\" : <NAME>,\n" + "\t\t\"version\" : <VERSION>,\n" + + "\t\t\"checksum\" : <CHECKSUM>,\n" + "\t\t\"type\" : <TYPE>,\n" + + "\t\t\"content\" : <CONTENT>,\n" + "\t\t\"description\" : <DESCRIPTION>\n" + "\t}"; + + public QueryServiceArtifact() { + super(); + serviceArtifactList = new ArrayList<>(); + } + + public QueryServiceArtifact(List<ServiceArtifact> alist) { + serviceArtifactList = new ArrayList<>(); + for (ServiceArtifact o : alist) { + if (logger.isDebugEnabled()) + logger.debug(o.toString()); + serviceArtifactList.add(o); + } + } + + public List<ServiceArtifact> getServiceArtifact() { + return this.serviceArtifactList; + } + + public void setServiceArtifact(List<ServiceArtifact> a) { + this.serviceArtifactList = a; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + + boolean first = true; + int i = 1; + for (ServiceArtifact o : serviceArtifactList) { + sb.append(i).append("\t"); + if (!first) + sb.append("\n"); + first = false; + sb.append(o); + } + return sb.toString(); + } + + @Override + public String JSON2(boolean isArray, boolean isEmbed) { + StringBuilder sb = new StringBuilder(); + if (!isEmbed && isArray) + sb.append("{ "); + if (isArray) + sb.append("\"serviceArtifact\": ["); + Map<String, String> valueMap = new HashMap<>(); + String sep = ""; + boolean first = true; + + for (ServiceArtifact o : serviceArtifactList) { + if (first) + sb.append("\n"); + first = false; + + boolean vrNull = o == null; + + put(valueMap, "ARTIFACT_UUID", vrNull ? null : o.getArtifactUUID()); + put(valueMap, "TYPE", vrNull ? null : o.getType()); + put(valueMap, "NAME", vrNull ? null : o.getName()); + put(valueMap, "VERSION", vrNull ? null : o.getVersion()); + put(valueMap, "DESCRIPTION", vrNull ? null : o.getDescription()); + put(valueMap, "CONTENT", vrNull ? null : o.getContent()); + put(valueMap, "CHECKSUM", vrNull ? null : o.getChecksum()); + sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap)); + sep = ",\n"; + } + if (!first) + sb.append("\n"); + if (isArray) + sb.append("]"); + if (!isEmbed && isArray) + sb.append("}"); + return sb.toString(); + } +} diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java new file mode 100644 index 0000000000..b1911654c4 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2019, CMCC Technologies Co., Ltd. + * ================================================================================ + * 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.onap.so.adapters.catalogdb.catalogrest; + +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ServiceInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.HashMap; +import java.util.Map; + +@XmlRootElement(name = "serviceInfo") +public class QueryServiceInfo extends CatalogQuery { + + protected static Logger logger = LoggerFactory.getLogger(QueryServiceInfo.class); + + private ServiceInfo serviceInfo; + + private static final String TEMPLATE = + "\n" + "\t{" + "\t\t\"id\" : <ID>,\n" + "\t\t\"serviceInput\" : <SERVICE_INPUT>,\n" + + "\t\"serviceProperties\" : <SERVICE_PROPERTIES>,\n" + "<_SERVICEARTIFACT_>\n"; + + + public QueryServiceInfo() { + super(); + this.serviceInfo = new ServiceInfo(); + } + + public QueryServiceInfo(ServiceInfo serviceInfo) { + this.serviceInfo = serviceInfo; + } + + public ServiceInfo getServiceInfo() { + return this.serviceInfo; + } + + public void setServiceInfo(ServiceInfo serviceInfo) { + this.serviceInfo = serviceInfo; + } + + @Override + public String toString() { + + return serviceInfo.toString(); + } + + @Override + public String JSON2(boolean isArray, boolean isEmbed) { + StringBuilder sb = new StringBuilder(); + sb.append("\"serviceInfo\": "); + sb.append("\n"); + Map<String, String> valueMap = new HashMap<>(); + Service service = serviceInfo.getService(); + put(valueMap, "ID", null == serviceInfo ? null : serviceInfo.getId()); + put(valueMap, "SERVICE_INPUT", null == serviceInfo ? null : serviceInfo.getServiceInput()); + put(valueMap, "SERVICE_PROPERTIES", null == serviceInfo ? null : serviceInfo.getServiceProperties()); + // String subitem = new QueryServiceArtifact(service.getServiceArtifactList()).JSON2(true, true); + // valueMap.put("_SERVICEARTIFACT_", subitem.replaceAll("(?m)^", "\t\t"));m + sb.append(this.setTemplate(TEMPLATE, valueMap)); + sb.append("}"); + return sb.toString(); + } +} diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.5__AddServiceArtifact.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.5__AddServiceArtifact.sql new file mode 100644 index 0000000000..d32c4666c5 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.5__AddServiceArtifact.sql @@ -0,0 +1,30 @@ +use catalogdb; + +CREATE TABLE IF NOT EXISTS `service_info` ( + `ID` int (11) AUTO_INCREMENT, + `SERVICE_INPUT` varchar (5000), + `SERVICE_PROPERTIES` varchar (5000), + PRIMARY KEY (`ID`) +)ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE IF NOT EXISTS `service_artifact`( + `ARTIFACT_UUID` varchar (200) NOT NULL, + `TYPE` varchar (200) NOT NULL, + `NAME` varchar (200) NOT NULL, + `VERSION` varchar (200) NOT NULL, + `DESCRIPTION` varchar (200) DEFAULT NULL, + `CONTENT` LONGTEXT DEFAULT NULL, + `CHECKSUM` varchar (200) DEFAULT NULL, + `CREATION_TIMESTAMP` DATETIME DEFAULT CURRENT_TIMESTAMP, + `SERVICE_MODEL_UUID` varchar (200) NOT NULL, + PRIMARY KEY (`ARTIFACT_UUID`), + CONSTRAINT `fk_service_artifact_service_info1` FOREIGN KEY (`SERVICE_MODEL_UUID`) REFERENCES `service` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE IF NOT EXISTS `service_to_service_info` ( + `SERVICE_MODEL_UUID` varchar (200) NOT NULL, + `SERVICE_INFO_ID` INT (11) NOT NULL, + PRIMARY KEY (`SERVICE_MODEL_UUID`,`SERVICE_INFO_ID`), + CONSTRAINT `fk_service_to_service_info__service1` FOREIGN KEY (`SERVICE_MODEL_UUID`) REFERENCES `service` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_service_to_service_info__service_info1` FOREIGN KEY (`SERVICE_INFO_ID`) REFERENCES `service_info` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE +)
\ No newline at end of file diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java new file mode 100644 index 0000000000..f63ba356a1 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.adapters.nssmf.exceptions; + +import org.onap.so.adapters.nssmf.model.ErrorResponse; +import org.springframework.http.ResponseEntity; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; + +public class ApplicationException extends Exception { + + private static final long serialVersionUID = 1L; + + private int errorCode; + + private String errorMsg; + + public ApplicationException(int errorCode, String errorMsg) { + this.errorCode = errorCode; + this.errorMsg = errorMsg; + } + + public int getErrorCode() { + return errorCode; + } + + public void setErrorCode(int errorCode) { + this.errorCode = errorCode; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + public ResponseEntity buildErrorResponse() { + String message; + try { + ErrorResponse err = new ErrorResponse(errorCode, errorMsg); + message = marshal(err); + } catch (ApplicationException e) { + return ResponseEntity.status(500).body("Internal Server Error"); + } + return ResponseEntity.status(errorCode).body(message); + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/HttpMethod.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/HttpMethod.java new file mode 100644 index 0000000000..f6abd98794 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/HttpMethod.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.adapters.nssmf.rest; + +public enum HttpMethod { + GET, POST, PUT, DELETE, PATCH; + + public static HttpMethod fromString(String s) { + if (s == null) + return null; + if (("get").equalsIgnoreCase(s)) + return GET; + if (("post").equalsIgnoreCase(s)) + return POST; + if (("put").equalsIgnoreCase(s)) + return PUT; + if (("delete").equalsIgnoreCase(s)) + return DELETE; + if (("patch").equalsIgnoreCase(s)) + return PATCH; + throw new IllegalArgumentException("Invalid value for HTTP Method: " + s); + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/JobStatus.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/JobStatus.java new file mode 100644 index 0000000000..f2e651fd6e --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/JobStatus.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.adapters.nssmf.rest; + +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; + + +public enum JobStatus { + STARTED, PROCESSING, FINISHED, ERROR; + + public static JobStatus fromString(String s) throws ApplicationException { + if (s == null) + return null; + if (("started").equalsIgnoreCase(s)) + return STARTED; + if (("processing").equalsIgnoreCase(s)) + return PROCESSING; + if (("finished").equalsIgnoreCase(s)) + return FINISHED; + if (("error").equalsIgnoreCase(s)) + return ERROR; + throw new ApplicationException(500, "Invalid value for Job " + "Status: " + s); + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfAdapterRest.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfAdapterRest.java new file mode 100644 index 0000000000..d8e1e36058 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfAdapterRest.java @@ -0,0 +1,205 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.adapters.nssmf.rest; + +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.onap.so.beans.nsmf.JobStatusRequest; +import org.onap.so.beans.nsmf.NssiActDeActRequest; +import org.onap.so.beans.nsmf.NssiAllocateRequest; +import org.onap.so.beans.nsmf.NssiCreateRequest; +import org.onap.so.beans.nsmf.NssiDeAllocateRequest; +import org.onap.so.beans.nsmf.NssiTerminateRequest; +import org.onap.so.beans.nsmf.NssiUpdateRequest; +import org.onap.so.beans.nsmf.NssiUpdateRequestById; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.assertObjectNotNull; + +@Controller +@RequestMapping(value = "/api/rest/provMns/v1", produces = {APPLICATION_JSON}, consumes = {APPLICATION_JSON}) +public class NssmfAdapterRest { + + private static final Logger logger = LoggerFactory.getLogger(NssmfAdapterRest.class); + + @Autowired + private NssmfManager nssmfMgr; + + @PostMapping(value = "/NSS/SliceProfiles") + public ResponseEntity allocateNssi(@RequestBody NssiAllocateRequest allocate) { + try { + logger.info("Nssmi allocate request is invoked"); + assertObjectNotNull(allocate); + RestResponse rsp = getNssmfMgr().allocateNssi(allocate); + return buildResponse(rsp); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + @PostMapping(value = "/NSS/nssi") + public ResponseEntity createNssi(@RequestBody NssiCreateRequest create) { + try { + logger.info("Nssmf create request is invoked"); + assertObjectNotNull(create); + RestResponse rsp = getNssmfMgr().createNssi(create); + return buildResponse(rsp); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + @PostMapping(value = "/NSS/SliceProfiles/{sliceProfileId}") + public ResponseEntity deAllocateNssi(@RequestBody NssiDeAllocateRequest deAllocate, + @PathVariable("sliceProfileId") final String sliceId) { + try { + logger.info("Nssmf deallocate request is invoked"); + assertObjectNotNull(deAllocate); + RestResponse rsp = getNssmfMgr().deAllocateNssi(deAllocate, sliceId); + return buildResponse(rsp); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + @PostMapping(value = "/NSS/nssi/{nssiId}") + public ResponseEntity terminateNssi(@RequestBody NssiTerminateRequest terminate, + @PathVariable("nssiId") String nssiId) { + try { + logger.info("Nssmf terminate request is invoked"); + assertObjectNotNull(terminate); + RestResponse rsp = getNssmfMgr().terminateNssi(terminate, nssiId); + return buildResponse(rsp); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + @PutMapping(value = "/NSS/SliceProfiles/{sliceProfileId}") + public ResponseEntity modifyNssi(@RequestBody NssiUpdateRequest update, + @PathVariable("sliceProfileId") String sliceId) { + try { + logger.info("Nssmf modify request is invoked"); + assertObjectNotNull(update); + RestResponse rsp = getNssmfMgr().updateNssi(update, sliceId); + return buildResponse(rsp); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + @PutMapping(value = "/NSS/nssi/{nssiId}") + public ResponseEntity modifyNssiById(@RequestBody NssiUpdateRequestById updateById, + @PathVariable("nssiId") String nssiId) { + try { + logger.info("Nssmf modify by ID request is invoked"); + assertObjectNotNull(updateById); + RestResponse rsp = getNssmfMgr().updateNssiById(updateById, nssiId); + return buildResponse(rsp); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + @PostMapping(value = "/NSS/{snssai}/activation") + public ResponseEntity activateNssi(@RequestBody NssiActDeActRequest activate, + @PathVariable("snssai") String snssai) { + try { + logger.info("Nssmf activate request is invoked"); + assertObjectNotNull(activate); + RestResponse rsp = getNssmfMgr().activateNssi(activate, snssai); + return buildResponse(rsp); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + @PostMapping(value = "/NSS/{snssai}/deactivation") + public ResponseEntity deactivateNssi(@RequestBody NssiActDeActRequest deActivate, + @PathVariable("snssai") String snssai) { + try { + logger.info("Nssmf activate request is invoked"); + assertObjectNotNull(deActivate); + RestResponse rsp = getNssmfMgr().deActivateNssi(deActivate, snssai); + return buildResponse(rsp); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + @PostMapping(value = "/NSS/jobs/{jobId}") + public ResponseEntity queryJobStatus(@RequestBody JobStatusRequest jobStatusReq, + @PathVariable("jobId") String jobId) { + try { + logger.info("Nssmf query job status request is invoked"); + assertObjectNotNull(jobStatusReq); + RestResponse rsp = getNssmfMgr().queryJobStatus(jobStatusReq, jobId); + return buildResponse(rsp); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + @GetMapping(value = "/vendor/{vendorName}/type/{networkType}/NSS" + "/SliceProfiles/{sliceProfileId}") + public ResponseEntity queryNssi(@PathVariable("vendorName") String vendorName, + @PathVariable("networktype") String networkType, @PathVariable("sliceProfileId") String sliceId) { + try { + logger.info("Nssmf query nssi request is invoked"); + RestResponse rsp = getNssmfMgr().queryNssi(vendorName, networkType, sliceId); + return buildResponse(rsp); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + @GetMapping(value = "/vendor/{vendorName}/type/{networkType}/NSS/nssi" + "/{nssiId}") + public ResponseEntity queryNssiById(@PathVariable("vendorName") String vendorName, + @PathVariable("networkTtype") String networkType, @PathVariable("nssiId") String nssiId) { + try { + logger.info("Nssmf query nssi by ID request is invoked"); + RestResponse rsp = getNssmfMgr().queryNssiById(vendorName, networkType, nssiId); + return buildResponse(rsp); + } catch (ApplicationException e) { + return e.buildErrorResponse(); + } + } + + public void setNssmfMgr(NssmfManager nssmfMgr) { + this.nssmfMgr = nssmfMgr; + } + + public NssmfManager getNssmfMgr() { + return nssmfMgr; + } + + private ResponseEntity buildResponse(RestResponse rsp) { + return ResponseEntity.status(rsp.getStatus()).body(rsp.getResponseContent()); + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfInfo.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfInfo.java new file mode 100644 index 0000000000..6306643a97 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfInfo.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.adapters.nssmf.rest; + +public class NssmfInfo { + + private String url; + + private String ipAddress; + + private String port; + + private String insecure; + + private String cacert; + + private String userName; + + private String password; + + public String getInsecure() { + return insecure; + } + + public void setInsecure(String insecure) { + this.insecure = insecure; + } + + public String getCacert() { + return cacert; + } + + public void setCacert(String cacert) { + this.cacert = cacert; + } + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + + public String getPort() { + return port; + } + + public void setPort(String port) { + this.port = port; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java new file mode 100644 index 0000000000..0e25729610 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java @@ -0,0 +1,541 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.adapters.nssmf.rest; + +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.onap.so.beans.nsmf.ActDeActNssi; +import org.onap.so.beans.nsmf.AllocateAnNssi; +import org.onap.so.beans.nsmf.AllocateCnNssi; +import org.onap.so.beans.nsmf.AllocateTnNssi; +import org.onap.so.beans.nsmf.CreateCnNssi; +import org.onap.so.beans.nsmf.DeAllocateNssi; +import org.onap.so.beans.nsmf.EsrInfo; +import org.onap.so.beans.nsmf.JobStatusRequest; +import org.onap.so.beans.nsmf.JobStatusResponse; +import org.onap.so.beans.nsmf.NetworkType; +import org.onap.so.beans.nsmf.NssiActDeActRequest; +import org.onap.so.beans.nsmf.NssiAllocateRequest; +import org.onap.so.beans.nsmf.NssiCreateRequest; +import org.onap.so.beans.nsmf.NssiDeAllocateRequest; +import org.onap.so.beans.nsmf.NssiResponse; +import org.onap.so.beans.nsmf.NssiTerminateRequest; +import org.onap.so.beans.nsmf.NssiUpdateRequest; +import org.onap.so.beans.nsmf.NssiUpdateRequestById; +import org.onap.so.beans.nsmf.ResponseDescriptor; +import org.onap.so.beans.nsmf.TerminateNssi; +import org.onap.so.beans.nsmf.UpdateCnNssi; +import org.onap.so.beans.nsmf.UpdateCnNssiById; +import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Primary; +import org.springframework.data.domain.Example; +import org.springframework.stereotype.Component; +import static java.lang.String.valueOf; +import static org.onap.so.adapters.nssmf.rest.HttpMethod.DELETE; +import static org.onap.so.adapters.nssmf.rest.HttpMethod.GET; +import static org.onap.so.adapters.nssmf.rest.HttpMethod.POST; +import static org.onap.so.adapters.nssmf.rest.HttpMethod.PUT; +import static org.onap.so.adapters.nssmf.rest.JobStatus.ERROR; +import static org.onap.so.adapters.nssmf.rest.JobStatus.FINISHED; +import static org.onap.so.adapters.nssmf.rest.JobStatus.PROCESSING; +import static org.onap.so.adapters.nssmf.rest.JobStatus.STARTED; +import static org.onap.so.adapters.nssmf.rest.JobStatus.fromString; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.ACTIVATE_NSS_SUCCESS; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.ALLOCATE_NSS_SUCCESS; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.CREATE_NSS_SUCCESS; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.DEACTIVATE_NSS_SUCCESS; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.DEALLOCATE_NSS_SUCCESS; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.QUERY_JOB_STATUS_FAILED; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.QUERY_JOB_STATUS_SUCCESS; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.assertObjectNotNull; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; +import static org.onap.so.beans.nsmf.ActDeActNssi.ACT_URL; +import static org.onap.so.beans.nsmf.ActDeActNssi.DE_ACT_URL; + +@Component +@Primary +public class NssmfManager { + + private static final Logger logger = LoggerFactory.getLogger(NssmfManager.class); + + public final static String QUERY = "/api/rest/provMns/v1/NSS" + "/SliceProfiles/{sliceProfileId}"; + + public final static String QUERY_BY_ID = "/api/rest/provMns/v1/NSS/nssi" + "/{nssiId}"; + + @Autowired + private ResourceOperationStatusRepository rscOperStatusRepo; + + @Autowired + private RestUtil restUtil; + + + public RestResponse allocateNssi(NssiAllocateRequest nssmiAllocate) throws ApplicationException { + + assertObjectNotNull(nssmiAllocate.getEsrInfo()); + assertObjectNotNull(nssmiAllocate.getEsrInfo().getNetworkType()); + assertObjectNotNull(nssmiAllocate.getEsrInfo().getVendor()); + + String nsiId = null; + String allocateReq = null; + String allocateUrl = null; + logger.info("Allocate Nssi for " + nssmiAllocate.getEsrInfo().getNetworkType() + " Network has begun"); + + switch (nssmiAllocate.getEsrInfo().getNetworkType()) { + + case CORE: + AllocateCnNssi cn = nssmiAllocate.getAllocateCnNssi(); + assertObjectNotNull(cn); + assertObjectNotNull(cn.getNsiInfo()); + assertObjectNotNull(cn.getNsiInfo().getNsiId()); + nsiId = cn.getNsiInfo().getNsiId(); + assertObjectNotNull(nsiId); + allocateReq = marshal(cn); + allocateUrl = AllocateCnNssi.URL; + break; + + case ACCESS: + AllocateAnNssi an = nssmiAllocate.getAllocateAnNssi(); + assertObjectNotNull(an); + assertObjectNotNull(an.getNsiInfo()); + assertObjectNotNull(an.getNsiInfo().getNsiId()); + nsiId = an.getNsiInfo().getNsiId(); + assertObjectNotNull(nsiId); + allocateReq = marshal(an); + allocateUrl = AllocateAnNssi.URL; + break; + + case TRANSPORT: + AllocateTnNssi tn = nssmiAllocate.getAllocateTnNssi(); + assertObjectNotNull(tn); + assertObjectNotNull(tn.getNsiInfo()); + assertObjectNotNull(tn.getNsiInfo().getNsiId()); + nsiId = tn.getNsiInfo().getNsiId(); + allocateReq = marshal(tn); + allocateUrl = AllocateTnNssi.URL; + break; + + } + RestResponse rsp = restUtil.sendRequest(allocateUrl, POST, allocateReq, nssmiAllocate.getEsrInfo()); + assertObjectNotNull(rsp); + + if (valueOf(rsp.getStatus()).startsWith("2")) { + NssiResponse allocateRes = unMarshal(rsp.getResponseContent(), NssiResponse.class); + + ResourceOperationStatus status = + new ResourceOperationStatus(allocateRes.getNssiId(), allocateRes.getJobId(), nsiId); + logger.info("save segment and operaton info -> begin"); + updateDbStatus(status, rsp.getStatus(), STARTED, ALLOCATE_NSS_SUCCESS); + logger.info("save segment and operation info -> end"); + } + return rsp; + } + + public RestResponse createNssi(NssiCreateRequest nssiCreate) throws ApplicationException { + + assertObjectNotNull(nssiCreate.getEsrInfo()); + assertObjectNotNull(nssiCreate.getEsrInfo().getNetworkType()); + assertObjectNotNull(nssiCreate.getEsrInfo().getVendor()); + + String nsiId = null; + String createReq = null; + String createUrl = null; + logger.info("Create Nssi for " + nssiCreate.getEsrInfo().getNetworkType() + " Network has begun"); + + switch (nssiCreate.getEsrInfo().getNetworkType()) { + case CORE: + CreateCnNssi cn = nssiCreate.getCreateCnNssi(); + nsiId = cn.getNsiInfo().getNsiId(); + assertObjectNotNull(nsiId); + createReq = marshal(cn); + createUrl = AllocateCnNssi.URL; + break; + + case ACCESS: + case TRANSPORT: + throw new ApplicationException(1, "Create Nssi doesn't " + "support the Network type:" + + nssiCreate.getEsrInfo().getNetworkType()); + } + RestResponse rsp = restUtil.sendRequest(createUrl, POST, createReq, nssiCreate.getEsrInfo()); + assertObjectNotNull(rsp); + + if (valueOf(rsp.getStatus()).startsWith("2")) { + NssiResponse allocateRes = unMarshal(rsp.getResponseContent(), NssiResponse.class); + + ResourceOperationStatus status = + new ResourceOperationStatus(allocateRes.getNssiId(), allocateRes.getJobId(), nsiId); + logger.info("save segment and operaton info -> begin"); + updateDbStatus(status, rsp.getStatus(), STARTED, CREATE_NSS_SUCCESS); + logger.info("save segment and operaton info -> end"); + } + return rsp; + } + + public RestResponse deAllocateNssi(NssiDeAllocateRequest nssiDeallocate, String sliceId) + throws ApplicationException { + + assertObjectNotNull(nssiDeallocate.getEsrInfo()); + assertObjectNotNull(nssiDeallocate.getEsrInfo().getNetworkType()); + assertObjectNotNull(nssiDeallocate.getEsrInfo().getVendor()); + + DeAllocateNssi deAllocate = nssiDeallocate.getDeAllocateNssi(); + + assertObjectNotNull(sliceId); + assertObjectNotNull(deAllocate.getNssiId()); + assertObjectNotNull(deAllocate.getNsiId()); + + String deallocateUrl = formTnAndAnUrl(nssiDeallocate.getEsrInfo(), DeAllocateNssi.URL, sliceId); + String deAllocateReq = marshal(deAllocate); + + logger.info("Deallocate Nssi has begun"); + + RestResponse rsp = restUtil.sendRequest(deallocateUrl, DELETE, deAllocateReq, nssiDeallocate.getEsrInfo()); + assertObjectNotNull(rsp); + + if (valueOf(rsp.getStatus()).startsWith("2")) { + NssiResponse res = unMarshal(rsp.getResponseContent(), NssiResponse.class); + + ResourceOperationStatus status = + new ResourceOperationStatus(deAllocate.getNssiId(), res.getJobId(), deAllocate.getNsiId()); + logger.info("save segment and operaton info -> begin"); + updateDbStatus(status, rsp.getStatus(), STARTED, DEALLOCATE_NSS_SUCCESS); + logger.info("save segment and operaton info -> end"); + } + return rsp; + } + + private String formTnAndAnUrl(EsrInfo esrInfo, String origUrl, String variable) { + + origUrl = formatUrl(origUrl, variable); + String[] val; + + switch (esrInfo.getNetworkType()) { + + case TRANSPORT: + val = origUrl.split("v1"); + return val[0] + "v1/tn" + val[1]; + + case ACCESS: + val = origUrl.split("v1"); + return val[0] + "v1/an" + val[1]; + + case CORE: + return origUrl; + } + return origUrl; + } + + private String formatUrl(String origUrl, String variable) { + + if (variable != null) { + origUrl = String.format(origUrl, variable); + } + return origUrl; + } + + + public RestResponse terminateNssi(NssiTerminateRequest nssiTerminate, String nssiId) throws ApplicationException { + + assertObjectNotNull(nssiTerminate.getEsrInfo()); + assertObjectNotNull(nssiTerminate.getEsrInfo().getNetworkType()); + assertObjectNotNull(nssiTerminate.getEsrInfo().getVendor()); + + TerminateNssi terminate = nssiTerminate.getTerminateNssi(); + + assertObjectNotNull(nssiId); + assertObjectNotNull(terminate.getNsiId()); + + logger.info("Terminate Nssi has begun"); + + String terminateUrl = formTnAndAnUrl(nssiTerminate.getEsrInfo(), TerminateNssi.URL, nssiId); + String terminateReq = marshal(terminate); + + RestResponse rsp = restUtil.sendRequest(terminateUrl, DELETE, terminateReq, nssiTerminate.getEsrInfo()); + assertObjectNotNull(rsp); + + if (valueOf(rsp.getStatus()).startsWith("2")) { + NssiResponse res = unMarshal(rsp.getResponseContent(), NssiResponse.class); + + ResourceOperationStatus status = new ResourceOperationStatus(nssiId, res.getJobId(), terminate.getNsiId()); + logger.info("save segment and operaton info -> begin"); + updateDbStatus(status, rsp.getStatus(), STARTED, DEALLOCATE_NSS_SUCCESS); + logger.info("save segment and operaton info -> end"); + } + return rsp; + } + + public RestResponse activateNssi(NssiActDeActRequest nssiActivate, String snssai) throws ApplicationException { + + assertObjectNotNull(nssiActivate.getEsrInfo()); + assertObjectNotNull(nssiActivate.getEsrInfo().getNetworkType()); + assertObjectNotNull(nssiActivate.getEsrInfo().getVendor()); + + ActDeActNssi activate = nssiActivate.getActDeActNssi(); + + assertObjectNotNull(snssai); + assertObjectNotNull(activate.getNssiId()); + assertObjectNotNull(activate.getNsiId()); + + logger.info("Activate Nssi has begun"); + + String activateUrl = formTnAndAnUrl(nssiActivate.getEsrInfo(), ACT_URL, snssai); + String activateReq = marshal(activate); + + RestResponse rsp = restUtil.sendRequest(activateUrl, PUT, activateReq, nssiActivate.getEsrInfo()); + assertObjectNotNull(rsp); + + if (valueOf(rsp.getStatus()).startsWith("2")) { + NssiResponse activateRes = unMarshal(rsp.getResponseContent(), NssiResponse.class); + + ResourceOperationStatus status = + new ResourceOperationStatus(activate.getNssiId(), activateRes.getJobId(), activate.getNsiId()); + logger.info("save segment and operaton info -> begin"); + updateDbStatus(status, rsp.getStatus(), STARTED, ACTIVATE_NSS_SUCCESS); + logger.info("save segment and operaton info -> end"); + } + return rsp; + } + + public RestResponse deActivateNssi(NssiActDeActRequest nssiDeActivate, String snssai) throws ApplicationException { + + assertObjectNotNull(nssiDeActivate.getEsrInfo()); + assertObjectNotNull(nssiDeActivate.getEsrInfo().getNetworkType()); + assertObjectNotNull(nssiDeActivate.getEsrInfo().getVendor()); + + logger.info("Deactivate Nssi has begun"); + + ActDeActNssi deActivate = nssiDeActivate.getActDeActNssi(); + + assertObjectNotNull(snssai); + assertObjectNotNull(deActivate.getNssiId()); + assertObjectNotNull(deActivate.getNsiId()); + + String deActivateUrl = formTnAndAnUrl(nssiDeActivate.getEsrInfo(), DE_ACT_URL, snssai); + String deActivateReq = marshal(deActivate); + + RestResponse rsp = restUtil.sendRequest(deActivateUrl, PUT, deActivateReq, nssiDeActivate.getEsrInfo()); + assertObjectNotNull(rsp); + + if (valueOf(rsp.getStatus()).startsWith("2")) { + NssiResponse deActivateRes = unMarshal(rsp.getResponseContent(), NssiResponse.class); + + ResourceOperationStatus status = new ResourceOperationStatus(deActivate.getNssiId(), + deActivateRes.getJobId(), deActivate.getNsiId()); + logger.info("save segment and operaton info -> begin"); + updateDbStatus(status, rsp.getStatus(), STARTED, DEACTIVATE_NSS_SUCCESS); + logger.info("save segment and operaton info -> end"); + } + return rsp; + } + + public RestResponse queryJobStatus(JobStatusRequest jobReq, String jobId) throws ApplicationException { + + assertObjectNotNull(jobReq.getEsrInfo()); + assertObjectNotNull(jobReq.getEsrInfo().getNetworkType()); + assertObjectNotNull(jobReq.getEsrInfo().getVendor()); + assertObjectNotNull(jobId); + assertObjectNotNull(jobReq.getNssiId()); + assertObjectNotNull(jobReq.getNsiId()); + + logger.info("Query job status has begun"); + + ResourceOperationStatus status = new ResourceOperationStatus(jobReq.getNssiId(), jobId, jobReq.getNsiId()); + status = rscOperStatusRepo.findOne(Example.of(status)) + .orElseThrow(() -> new ApplicationException(404, "Cannot Find Operation Status")); + + String statusUrl = formatUrl(JobStatusRequest.URL, jobId); + if (jobReq.getResponseId() != null) { + statusUrl = statusUrl + "?responseId=" + jobReq.getResponseId(); + } + + RestResponse rsp = restUtil.sendRequest(statusUrl, GET, "", jobReq.getEsrInfo()); + assertObjectNotNull(rsp); + + if (!valueOf(rsp.getStatus()).startsWith("2")) { + updateDbStatus(status, rsp.getStatus(), ERROR, QUERY_JOB_STATUS_FAILED); + throw new ApplicationException(500, QUERY_JOB_STATUS_FAILED); + } + + ResponseDescriptor rspDesc = + unMarshal(rsp.getResponseContent(), JobStatusResponse.class).getResponseDescriptor(); + logger.info("save segment and operaton info -> begin"); + updateRequestDbJobStatus(rspDesc, status, rsp); + logger.info("save segment and operaton info -> end"); + return rsp; + } + + + public RestResponse updateNssi(NssiUpdateRequest nssiUpdate, String sliceId) throws ApplicationException { + + assertObjectNotNull(nssiUpdate.getEsrInfo()); + assertObjectNotNull(nssiUpdate.getEsrInfo().getNetworkType()); + assertObjectNotNull(nssiUpdate.getEsrInfo().getVendor()); + assertObjectNotNull(sliceId); + + String nsiId = null; + String nssiId = null; + String updateReq = null; + String updateUrl = null; + logger.info("Update Nssi for " + nssiUpdate.getEsrInfo().getNetworkType() + " Network has begun"); + + switch (nssiUpdate.getEsrInfo().getNetworkType()) { + case CORE: + UpdateCnNssi cn = nssiUpdate.getUpdateCnNssi(); + nsiId = cn.getNsiInfo().getNsiId(); + nssiId = cn.getNssiId(); + assertObjectNotNull(nsiId); + assertObjectNotNull(nssiId); + updateReq = marshal(cn); + updateUrl = formatUrl(UpdateCnNssi.URL, sliceId); + break; + + case ACCESS: + case TRANSPORT: + throw new ApplicationException(1, "Update Nssi doesn't " + "support the Network type:" + + nssiUpdate.getEsrInfo().getNetworkType()); + } + + RestResponse rsp = restUtil.sendRequest(updateUrl, PUT, updateReq, nssiUpdate.getEsrInfo()); + assertObjectNotNull(rsp); + + if (valueOf(rsp.getStatus()).startsWith("2")) { + NssiResponse allocateRes = unMarshal(rsp.getResponseContent(), NssiResponse.class); + + ResourceOperationStatus status = new ResourceOperationStatus(nssiId, allocateRes.getJobId(), nsiId); + logger.info("save segment and operaton info -> begin"); + updateDbStatus(status, rsp.getStatus(), STARTED, ALLOCATE_NSS_SUCCESS); + logger.info("save segment and operaton info -> end"); + } + return rsp; + } + + public RestResponse updateNssiById(NssiUpdateRequestById nssiUpdateById, String nssiId) + throws ApplicationException { + + assertObjectNotNull(nssiUpdateById.getEsrInfo()); + assertObjectNotNull(nssiUpdateById.getEsrInfo().getNetworkType()); + assertObjectNotNull(nssiUpdateById.getEsrInfo().getVendor()); + assertObjectNotNull(nssiId); + + String nsiId = null; + String updateReq = null; + String updateUrl = null; + logger.info("Update Nssi by ID for " + nssiUpdateById.getEsrInfo().getNetworkType() + " Network has begun"); + + switch (nssiUpdateById.getEsrInfo().getNetworkType()) { + case CORE: + UpdateCnNssiById cn = nssiUpdateById.getUpdateCnNssiById(); + nsiId = cn.getNsiInfo().getNsiId(); + assertObjectNotNull(nsiId); + updateReq = marshal(cn); + updateUrl = formatUrl(UpdateCnNssiById.URL, nssiId); + break; + + case ACCESS: + case TRANSPORT: + throw new ApplicationException(1, "Update Nssi doesn't " + "support the Network type:" + + nssiUpdateById.getEsrInfo().getNetworkType()); + } + + RestResponse rsp = restUtil.sendRequest(updateUrl, PUT, updateReq, nssiUpdateById.getEsrInfo()); + assertObjectNotNull(rsp); + + if (valueOf(rsp.getStatus()).startsWith("2")) { + NssiResponse allocateRes = unMarshal(rsp.getResponseContent(), NssiResponse.class); + + ResourceOperationStatus status = new ResourceOperationStatus(nssiId, allocateRes.getJobId(), nsiId); + logger.info("save segment and operaton info -> begin"); + updateDbStatus(status, rsp.getStatus(), STARTED, ALLOCATE_NSS_SUCCESS); + logger.info("save segment and operaton info -> end"); + } + return rsp; + } + + public RestResponse queryNssi(String vendor, String type, String sliceId) throws ApplicationException { + + logger.info("Query Nssi has begun"); + String getUrl = formatUrl(QUERY, sliceId); + EsrInfo esr = new EsrInfo(); + esr.setVendor(vendor); + esr.setNetworkType(NetworkType.valueOf(type)); + RestResponse rsp = restUtil.sendRequest(getUrl, GET, "", esr); + assertObjectNotNull(rsp); + return rsp; + } + + public RestResponse queryNssiById(String vendor, String type, String nssiId) throws ApplicationException { + + logger.info("Query Nssi by ID has begun"); + String getUrl = formatUrl(QUERY_BY_ID, nssiId); + EsrInfo esr = new EsrInfo(); + esr.setVendor(vendor); + esr.setNetworkType(NetworkType.valueOf(type)); + RestResponse rsp = restUtil.sendRequest(getUrl, GET, "", esr); + assertObjectNotNull(rsp); + return rsp; + } + + private void updateRequestDbJobStatus(ResponseDescriptor rspDesc, ResourceOperationStatus status, RestResponse rsp) + throws ApplicationException { + + switch (fromString(rspDesc.getStatus())) { + + case STARTED: + updateDbStatus(status, rsp.getStatus(), STARTED, QUERY_JOB_STATUS_SUCCESS); + break; + + case ERROR: + updateDbStatus(status, rsp.getStatus(), ERROR, QUERY_JOB_STATUS_FAILED); + throw new ApplicationException(500, QUERY_JOB_STATUS_FAILED); + + case FINISHED: + if (rspDesc.getProgress() == 100) { + updateDbStatus(status, rsp.getStatus(), FINISHED, QUERY_JOB_STATUS_SUCCESS); + } + break; + + case PROCESSING: + updateDbStatus(status, rsp.getStatus(), PROCESSING, QUERY_JOB_STATUS_SUCCESS); + break; + } + } + + private void updateDbStatus(ResourceOperationStatus status, int rspStatus, JobStatus jobStatus, + String description) { + status.setErrorCode(valueOf(rspStatus)); + status.setStatus(jobStatus.toString()); + status.setStatusDescription(description); + logger.info("Updating DB status"); + rscOperStatusRepo.save(status); + logger.info("Updating successful"); + } + + public void setRscOperStatusRepo(ResourceOperationStatusRepository rscOperStatusRepo) { + this.rscOperStatusRepo = rscOperStatusRepo; + } + + public void setRestUtil(RestUtil restUtil) { + this.restUtil = restUtil; + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestResponse.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestResponse.java new file mode 100644 index 0000000000..cc047e45c7 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestResponse.java @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.adapters.nssmf.rest; + +import java.util.Map; + +public class RestResponse { + + // the response content + private String responseContent; + + // the response status + private int status; + + // the response header + private Map<String, String> respHeaderMap; + + public RestResponse() { + this.status = -1; + + this.respHeaderMap = null; + } + + public int getStatus() { + return this.status; + } + + public void setStatus(int status) { + this.status = status; + } + + public Map<String, String> getRespHeaderMap() { + return this.respHeaderMap; + } + + public void setRespHeaderMap(Map<String, String> header) { + this.respHeaderMap = header; + } + + public int getRespHeaderInt(String key) { + if (this.respHeaderMap != null) { + String result = this.respHeaderMap.get(key); + if (result != null) { + return Integer.parseInt(result); + } + } + return -1; + } + + public long getRespHeaderLong(String key) { + if (this.respHeaderMap != null) { + String result = this.respHeaderMap.get(key); + if (result != null) { + return Long.parseLong(result); + } + } + return -1L; + } + + public String getRespHeaderStr(String key) { + if (this.respHeaderMap != null) { + return this.respHeaderMap.get(key); + } + return null; + } + + public String getResponseContent() { + return this.responseContent; + } + + public void setResponseContent(String responseString) { + this.responseContent = responseString; + } +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java new file mode 100644 index 0000000000..3592d4f6a3 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java @@ -0,0 +1,307 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.adapters.nssmf.rest; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import javax.ws.rs.core.UriBuilder; +import java.net.SocketTimeoutException; +import java.net.URI; +import org.apache.http.Header; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.client.methods.HttpRequestBase; +import org.apache.http.conn.ConnectTimeoutException; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicHeader; +import org.apache.http.util.EntityUtils; +import org.onap.aai.domain.yang.EsrSystemInfo; +import org.onap.aai.domain.yang.EsrSystemInfoList; +import org.onap.aai.domain.yang.EsrThirdpartySdnc; +import org.onap.aai.domain.yang.EsrThirdpartySdncList; +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.onap.so.adapters.nssmf.extclients.aai.AaiServiceProvider; +import org.onap.so.adapters.nssmf.model.TokenRequest; +import org.onap.so.adapters.nssmf.model.TokenResponse; +import org.onap.so.beans.nsmf.EsrInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import static org.apache.http.entity.ContentType.APPLICATION_JSON; +import static org.onap.so.adapters.nssmf.rest.HttpMethod.POST; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.BAD_REQUEST; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; +import static org.onap.so.logger.ErrorCode.AvailabilityError; +import static org.onap.so.logger.LoggingAnchor.FOUR; +import static org.onap.so.logger.MessageEnum.RA_NS_EXC; + +@Component +public class RestUtil { + + private static final Logger logger = LoggerFactory.getLogger(RestUtil.class); + + private static final int DEFAULT_TIME_OUT = 60000; + + private static final String NSSMI_ADAPTER = "NSSMI Adapter"; + + private static final String TOKEN_URL = "/api/rest/securityManagement/v1" + "/oauth/token"; + + @Autowired + private AaiServiceProvider aaiSvcProv; + + + public NssmfInfo getNssmfHost(EsrInfo esrInfo) throws ApplicationException { + EsrThirdpartySdncList sdncList = aaiSvcProv.invokeGetThirdPartySdncList(); + if (sdncList != null && sdncList.getEsrThirdpartySdnc() != null) { + for (EsrThirdpartySdnc sdncEsr : sdncList.getEsrThirdpartySdnc()) { + + EsrSystemInfoList sysInfoList = + aaiSvcProv.invokeGetThirdPartySdncEsrSystemInfo(sdncEsr.getThirdpartySdncId()); + + if (sysInfoList != null && sysInfoList.getEsrSystemInfo() != null) { + for (EsrSystemInfo esr : sysInfoList.getEsrSystemInfo()) { + if (esr != null && esr.getType().equals(esrInfo.getNetworkType().getNetworkType()) + && esr.getVendor().equals(esrInfo.getVendor())) { + logger.info("Found an entry with vendor name " + esrInfo.getVendor() + " and network type " + + esrInfo.getNetworkType() + " in ESR."); + NssmfInfo nssmfInfo = new NssmfInfo(); + nssmfInfo.setIpAddress(esr.getIpAddress()); + nssmfInfo.setPort(esr.getPort()); + nssmfInfo.setCacert(esr.getSslCacert()); + nssmfInfo.setUserName(esr.getUserName()); + nssmfInfo.setPassword(esr.getPassword()); + String endPoint = UriBuilder.fromPath("").host(esr.getIpAddress()) + .port(Integer.valueOf(esr.getPort())).scheme("https").build().toString(); + nssmfInfo.setUrl(endPoint); + return nssmfInfo; + } + } + } + + } + } + + throw new ApplicationException(BAD_REQUEST, "ESR information is improper"); + } + + public RestResponse sendRequest(String url, HttpMethod methodType, String content, EsrInfo esrInfo) + throws ApplicationException { + + NssmfInfo nssmfInfo = getNssmfHost(esrInfo); + + TokenRequest req = new TokenRequest(); + req.setGrantType("password"); + req.setUserName(nssmfInfo.getUserName()); + req.setValue(nssmfInfo.getPassword()); + + String tokenReq = marshal(req); + + logger.info("Sending token request to NSSMF: " + tokenReq); + RestResponse tokenRes = send(nssmfInfo.getUrl() + TOKEN_URL, POST, tokenReq, null); + + TokenResponse res = unMarshal(tokenRes.getResponseContent(), TokenResponse.class); + String token = res.getAccessToken(); + Header header = new BasicHeader("X-Auth-Token", token); + String nssmfUrl = nssmfInfo.getUrl() + url; + return send(nssmfUrl, methodType, content, header); + } + + private RestResponse send(String url, HttpMethod methodType, String content, Header header) { + + HttpRequestBase req = null; + HttpResponse res = null; + + logger.debug("Beginning to send message {}: {}", methodType, url); + + try { + int timeout = DEFAULT_TIME_OUT; + + RequestConfig config = RequestConfig.custom().setSocketTimeout(timeout).setConnectTimeout(timeout) + .setConnectionRequestTimeout(timeout).build(); + logger.debug("Sending request to NSSMF: " + content); + req = getHttpReq(url, methodType, header, config, content); + res = getHttpsClient().execute(req); + + String resContent = null; + if (res.getEntity() != null) { + resContent = EntityUtils.toString(res.getEntity(), "UTF-8"); + } + + int statusCode = res.getStatusLine().getStatusCode(); + String statusMessage = res.getStatusLine().getReasonPhrase(); + logger.info("NSSMF Response: {} {}", statusCode, + statusMessage + (resContent == null ? "" : System.lineSeparator() + resContent)); + + if (res.getStatusLine().getStatusCode() >= 300) { + String errMsg = "{\n \"errorCode\": " + res.getStatusLine().getStatusCode() + + "\n \"errorDescription\": " + statusMessage + "\n}"; + logError(errMsg); + return createResponse(statusCode, errMsg); + } + if (null != req) { + req.reset(); + } else { + logger.debug("method is NULL:"); + } + req = null; + + return createResponse(statusCode, resContent); + + } catch (SocketTimeoutException | ConnectTimeoutException e) { + String errMsg = "Request to NSSMF timed out"; + logError(errMsg, e); + return createResponse(408, errMsg); + } catch (Exception e) { + String errMsg = "Error processing request to NSSMF"; + logError(errMsg, e); + return createResponse(500, errMsg); + } finally { + if (res != null) { + try { + EntityUtils.consume(res.getEntity()); + } catch (Exception e) { + logger.debug("Exception :", e); + } + } + if (req != null) { + try { + req.reset(); + } catch (Exception e) { + logger.debug("Exception :", e); + } + } + } + } + + private RestResponse createResponse(int statusCode, String errMsg) { + RestResponse restResponse = new RestResponse(); + restResponse.setStatus(statusCode); + restResponse.setResponseContent(errMsg); + return restResponse; + } + + private HttpRequestBase getHttpReq(String url, HttpMethod method, Header header, RequestConfig config, + String content) throws ApplicationException { + HttpRequestBase base = null; + switch (method) { + case POST: + HttpPost post = new HttpPost(url); + post.setEntity(new StringEntity(content, APPLICATION_JSON)); + base = post; + break; + + case GET: + base = new HttpGet(url); + break; + + case PUT: + HttpPut put = new HttpPut(url); + put.setEntity(new StringEntity(content, APPLICATION_JSON)); + base = put; + break; + + case PATCH: + break; + + case DELETE: + HttpDeleteWithBody delete = new HttpDeleteWithBody(url); + if (content != null) { + delete.setEntity(new StringEntity(content, APPLICATION_JSON)); + } + base = delete; + break; + + } + base.setConfig(config); + if (header != null) { + base.setHeader(header); + } + return base; + } + + class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase { + public static final String METHOD_NAME = "DELETE"; + + public String getMethod() { + return METHOD_NAME; + } + + public HttpDeleteWithBody(final String uri) { + super(); + setURI(URI.create(uri)); + } + + public HttpDeleteWithBody(final URI uri) { + super(); + setURI(uri); + } + + public HttpDeleteWithBody() { + super(); + } + } + + + public HttpClient getHttpsClient() { + + TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() { + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + + public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {} + + public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {} + }}; + + // Install the all-trusting trust manager + try { + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, trustAllCerts, new java.security.SecureRandom()); + // HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); + + SSLConnectionSocketFactory sslsf = + new SSLConnectionSocketFactory(sc, new String[] {"TLSv1"}, null, new TrustAllHostNameVerifier()); + return HttpClients.custom().setSSLSocketFactory(sslsf).build(); + } catch (Exception e) { + throw new IllegalArgumentException(e); + } + } + + private static void logError(String errMsg, Throwable t) { + logger.error(FOUR, RA_NS_EXC.toString(), NSSMI_ADAPTER, AvailabilityError.getValue(), errMsg, t); + } + + private static void logError(String errMsg) { + logger.error(FOUR, RA_NS_EXC.toString(), NSSMI_ADAPTER, AvailabilityError.toString(), errMsg); + } +} + diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/TrustAllHostNameVerifier.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/TrustAllHostNameVerifier.java new file mode 100644 index 0000000000..254186bda8 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/TrustAllHostNameVerifier.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.adapters.nssmf.rest; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLSession; + +public class TrustAllHostNameVerifier implements HostnameVerifier { + + public boolean verify(String hostname, SSLSession session) { + return true; + } + +} diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java new file mode 100644 index 0000000000..b0b84d822b --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.adapters.nssmf.util; + +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import org.onap.so.adapters.nssmf.exceptions.ApplicationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.onap.so.logger.ErrorCode; +import static org.onap.so.logger.LoggingAnchor.THREE; +import static org.onap.so.logger.MessageEnum.RA_NS_EXC; + +public class NssmfAdapterUtil { + + private static final Logger LOGGER = LoggerFactory.getLogger(NssmfAdapterUtil.class); + + public static final int BAD_REQUEST = 400; + + private static final String UNMARSHAL_FAIL_MSG = "Failed to unmarshal json"; + + private static final String MARSHAL_FAIL_MSG = "Failed to marshal object"; + + private static final ObjectMapper MAPPER = new ObjectMapper(); + + public static class StatusDesc { + + public static final String ALLOCATE_NSS_SUCCESS = "Allocating nss is " + "successful"; + + public static final String CREATE_NSS_SUCCESS = "Creating nss is " + "successful"; + + public static final String DEALLOCATE_NSS_SUCCESS = "Deallocate nss " + "is successful"; + + public static final String ACTIVATE_NSS_SUCCESS = "Activate nss " + "is successful"; + + public static final String DEACTIVATE_NSS_SUCCESS = "Deactivate nss " + "is successful"; + + public static final String QUERY_JOB_STATUS_FAILED = "Query job " + "status failed"; + + public static final String QUERY_JOB_STATUS_SUCCESS = "Query job " + "status is successful"; + + private StatusDesc() { + + } + } + + private NssmfAdapterUtil() { + + } + + public static void assertObjectNotNull(Object object) throws ApplicationException { + if (null == object) { + LOGGER.error("Object is null."); + throw new ApplicationException(BAD_REQUEST, "An object is null."); + } + } + + public static <T> T unMarshal(String jsonstr, Class<T> type) throws ApplicationException { + try { + return MAPPER.readValue(jsonstr, type); + } catch (IOException e) { + LOGGER.error(THREE, RA_NS_EXC.toString(), ErrorCode.BusinessProcessError.getValue(), UNMARSHAL_FAIL_MSG, e); + throw new ApplicationException(BAD_REQUEST, UNMARSHAL_FAIL_MSG); + } + } + + public static String marshal(Object srcObj) throws ApplicationException { + try { + return MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(srcObj); + } catch (IOException e) { + LOGGER.error(THREE, RA_NS_EXC.toString(), ErrorCode.BusinessProcessError.getValue(), MARSHAL_FAIL_MSG, e); + throw new ApplicationException(BAD_REQUEST, MARSHAL_FAIL_MSG); + } + } + +} diff --git a/adapters/mso-nssmf-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties b/adapters/mso-nssmf-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties new file mode 100644 index 0000000000..f93ec63f37 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties @@ -0,0 +1 @@ +org.onap.so.adapters.nssmf.extclients.aai.AaiClientPropertiesImpl
\ No newline at end of file diff --git a/adapters/mso-nssmf-adapter/src/main/resources/application.yaml b/adapters/mso-nssmf-adapter/src/main/resources/application.yaml new file mode 100644 index 0000000000..cb2f04d7ec --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/resources/application.yaml @@ -0,0 +1,61 @@ +# +# ============LICENSE_START======================================================= +# ONAP - SO +# ================================================================================ +# Copyright (C) 2020 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========================================================= +#/ +aai: + auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586 + endpoint: https://aai.onap:30233 +logging: + path: logs + +spring: + datasource: + driver-class-name: org.mariadb.jdbc.Driver + jdbcUrl: jdbc:mariadb://192.168.235.44:30444/requestdb + username: root + password: secretpassword + + jpa: + show-sql: false + hibernate: + dialect: org.hibernate.dialect.MySQL5Dialect + ddl-auto: validate + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true +server: + port: 8080 + tomcat: + max-threads: 50 + +mso: + key: 07a7159d3bf51a0e53be7a8f89699be7 + site-name: localSite + logPath: ./logs/nssmf + msb-ip: msb-iag.{{ include "common.namespace" . }} + msb-port: 80 + adapters: + requestDb: + endpoint: https://so-request-db-adapter.{{ include "common.namespace" . }}:8083 + auth: Basic YnBlbDpwYXNzd29yZDEk + +#Actuator +management: + security: + enabled: false + basic: + enabled: false
\ No newline at end of file diff --git a/adapters/mso-nssmf-adapter/src/main/resources/nssmf.jks b/adapters/mso-nssmf-adapter/src/main/resources/nssmf.jks Binary files differnew file mode 100644 index 0000000000..2ecce5bd3d --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/resources/nssmf.jks diff --git a/adapters/mso-nssmf-adapter/src/main/resources/nssmf.p12 b/adapters/mso-nssmf-adapter/src/main/resources/nssmf.p12 Binary files differnew file mode 100644 index 0000000000..25e7fbfca9 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/resources/nssmf.p12 diff --git a/adapters/mso-nssmf-adapter/src/main/resources/org.onap.so.jks b/adapters/mso-nssmf-adapter/src/main/resources/org.onap.so.jks Binary files differnew file mode 100644 index 0000000000..f7cd9e8f86 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/resources/org.onap.so.jks diff --git a/adapters/mso-nssmf-adapter/src/main/resources/org.onap.so.p12 b/adapters/mso-nssmf-adapter/src/main/resources/org.onap.so.p12 Binary files differnew file mode 100644 index 0000000000..1927b1f13f --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/resources/org.onap.so.p12 diff --git a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java new file mode 100644 index 0000000000..5bfd39096c --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java @@ -0,0 +1,392 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.adapters.nssmf; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.LinkedList; +import java.util.List; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.StatusLine; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpRequestBase; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.onap.so.adapters.nssmf.model.TokenResponse; +import org.onap.so.adapters.nssmf.rest.HttpMethod; +import org.onap.so.adapters.nssmf.rest.NssmfAdapterRest; +import org.onap.so.adapters.nssmf.rest.NssmfInfo; +import org.onap.so.adapters.nssmf.rest.NssmfManager; +import org.onap.so.adapters.nssmf.rest.RestUtil; +import org.onap.so.beans.nsmf.ActDeActNssi; +import org.onap.so.beans.nsmf.AllocateCnNssi; +import org.onap.so.beans.nsmf.CnSliceProfile; +import org.onap.so.beans.nsmf.DeAllocateNssi; +import org.onap.so.beans.nsmf.EsrInfo; +import org.onap.so.beans.nsmf.JobStatusRequest; +import org.onap.so.beans.nsmf.NsiInfo; +import org.onap.so.beans.nsmf.NssiActDeActRequest; +import org.onap.so.beans.nsmf.NssiAllocateRequest; +import org.onap.so.beans.nsmf.NssiDeAllocateRequest; +import org.onap.so.beans.nsmf.NssiResponse; +import org.onap.so.beans.nsmf.PerfReq; +import org.onap.so.beans.nsmf.PerfReqEmbbList; +import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.junit4.SpringRunner; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; +import static org.onap.so.beans.nsmf.NetworkType.CORE; +import static org.onap.so.beans.nsmf.ResourceSharingLevel.NON_SHARED; + +@RunWith(SpringRunner.class) +public class NssmfAdapterRestTest { + + private final static String ALLOCATE = "{\n" + " \"esrInfo\" : {\n" + " \"vendor\" : \"huawei\",\n" + + " \"networkType\" : \"cn\"\n" + " },\n" + " \"allocateCnNssi\" : {\n" + + " \"nssiId\" : \"NSST-C-001-HDBNJ-NSSMF-01-A-ZX\",\n" + " \"nssiName\" : \"eMBB-001\",\n" + + " \"sliceProfile\" : {\n" + " \"snssaiList\" : [ \"001-100001\" ],\n" + + " \"sliceProfileId\" : \"ab9af40f13f721b5f13539d87484098\",\n" + + " \"plmnIdList\" : [ \"460-00\", \"460-01\" ],\n" + " \"perfReq\" : {\n" + + " \"perfReqEmbbList\" : [ {\n" + " \"activityFactor\" : 50\n" + " } ]\n" + + " },\n" + " \"maxNumberofUEs\" : 200,\n" + + " \"coverageAreaTAList\" : [ \"1\", \"2\", \"3\" ],\n" + " \"latency\" : 6,\n" + + " \"resourceSharingLevel\" : \"non-shared\"\n" + " },\n" + " \"scriptName\" : \"CN1\",\n" + + " \"nsiInfo\" : {\n" + " \"nsiName\" : \"eMBB-001\",\n" + + " \"nsiId\" : \"NSI-M-001-HDBNJ-NSMF-01-A-ZX\"\n" + " }\n" + " }\n" + "}"; + + private NssmfManager nssmfMgr; + + @Mock + private ResourceOperationStatusRepository rscOperStatusRepo; + + @Mock + private RestUtil restUtil; + + @Mock + private NssmfAdapterRest nssmfRest; + + @Mock + private HttpResponse tokenResponse; + + @Mock + private HttpEntity tokenEntity; + + @Mock + private HttpResponse commonResponse; + + @Mock + private HttpEntity commonEntity; + + @Mock + private StatusLine statusLine; + + @Mock + private HttpClient httpClient; + + private InputStream postStream; + + private InputStream tokenStream; + + @Before + public void setUp() { + initMocks(this); + nssmfMgr = new NssmfManager(); + nssmfMgr.setRestUtil(restUtil); + nssmfMgr.setRscOperStatusRepo(rscOperStatusRepo); + } + + private void createCommonMock(int statusCode, NssmfInfo nssmf) throws Exception { + when(nssmfRest.getNssmfMgr()).thenReturn(nssmfMgr); + when(nssmfRest.allocateNssi(any(NssiAllocateRequest.class))).thenCallRealMethod(); + when(nssmfRest.deAllocateNssi(any(NssiDeAllocateRequest.class), any(String.class))).thenCallRealMethod(); + when(nssmfRest.activateNssi(any(NssiActDeActRequest.class), any(String.class))).thenCallRealMethod(); + when(nssmfRest.deactivateNssi(any(NssiActDeActRequest.class), any(String.class))).thenCallRealMethod(); + + when(nssmfRest.queryJobStatus(any(JobStatusRequest.class), any(String.class))).thenCallRealMethod(); + when(restUtil.sendRequest(any(String.class), any(HttpMethod.class), any(String.class), any(EsrInfo.class))) + .thenCallRealMethod(); + when(restUtil.getHttpsClient()).thenReturn(httpClient); + + when(statusLine.getStatusCode()).thenReturn(200); + when(restUtil.getNssmfHost(any(EsrInfo.class))).thenReturn(nssmf); + + when(tokenResponse.getEntity()).thenReturn(tokenEntity); + when(tokenResponse.getStatusLine()).thenReturn(statusLine); + when(tokenEntity.getContent()).thenReturn(tokenStream); + + when(commonResponse.getEntity()).thenReturn(commonEntity); + when(commonResponse.getStatusLine()).thenReturn(statusLine); + when(commonEntity.getContent()).thenReturn(postStream); + + Answer<HttpResponse> answer = new Answer<HttpResponse>() { + + public HttpResponse answer(InvocationOnMock invocation) throws Throwable { + Object[] arguments = invocation.getArguments(); + if (arguments != null && arguments.length == 1 && arguments[0] != null) { + + HttpRequestBase base = (HttpRequestBase) arguments[0]; + if (base.getURI().toString().endsWith("/oauth/token")) { + return tokenResponse; + } else { + return commonResponse; + } + } + return commonResponse; + } + }; + doAnswer(answer).when(httpClient).execute(any(HttpRequestBase.class)); + } + + @Test + public void testNssiAllocate() throws Exception { + NssmfInfo nssmf = new NssmfInfo(); + nssmf.setUserName("nssmf-user"); + nssmf.setPassword("nssmf-pass"); + nssmf.setPort("8080"); + nssmf.setIpAddress("127.0.0.1"); + + NssiResponse nssiRes = new NssiResponse(); + nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); + nssiRes.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); + + TokenResponse token = new TokenResponse(); + token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); + token.setExpires(1800); + + postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); + tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); + + createCommonMock(200, nssmf); + // assertEquals(prettyPrint(allocateNssi()), ALLOCATE); + ResponseEntity res = nssmfRest.allocateNssi(allocateNssi()); + assertNotNull(res); + assertNotNull(res.getBody()); + NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); + assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); + assertEquals(allRes.getNssiId(), "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); + } + + @Test + public void testNssiDeAllocate() throws Exception { + NssmfInfo nssmf = new NssmfInfo(); + nssmf.setUserName("nssmf-user"); + nssmf.setPassword("nssmf-pass"); + nssmf.setPort("8080"); + nssmf.setIpAddress("127.0.0.1"); + + NssiResponse nssiRes = new NssiResponse(); + nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); + + TokenResponse token = new TokenResponse(); + token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); + token.setExpires(1800); + + postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); + tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); + + createCommonMock(200, nssmf); + ResponseEntity res = nssmfRest.deAllocateNssi(deAllocateNssi(), "ab9af40f13f721b5f13539d87484098"); + assertNotNull(res); + assertNotNull(res.getBody()); + NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); + assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); + } + + @Test + public void testNssiActivate() throws Exception { + NssmfInfo nssmf = new NssmfInfo(); + nssmf.setUserName("nssmf-user"); + nssmf.setPassword("nssmf-pass"); + nssmf.setPort("8080"); + nssmf.setIpAddress("127.0.0.1"); + + NssiResponse nssiRes = new NssiResponse(); + nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); + + TokenResponse token = new TokenResponse(); + token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); + token.setExpires(1800); + + postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); + tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); + + createCommonMock(200, nssmf); + ResponseEntity res = nssmfRest.activateNssi(activateNssi(), "001-100001"); + assertNotNull(res); + assertNotNull(res.getBody()); + NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); + assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); + } + + @Test + public void testNssiDeActivate() throws Exception { + NssmfInfo nssmf = new NssmfInfo(); + nssmf.setUserName("nssmf-user"); + nssmf.setPassword("nssmf-pass"); + nssmf.setPort("8080"); + nssmf.setIpAddress("127.0.0.1"); + + NssiResponse nssiRes = new NssiResponse(); + nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); + + TokenResponse token = new TokenResponse(); + token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); + token.setExpires(1800); + + postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); + tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); + + createCommonMock(200, nssmf); + ResponseEntity res = nssmfRest.deactivateNssi(deActivateNssi(), "001-100001"); + assertNotNull(res); + assertNotNull(res.getBody()); + NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); + assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); + } + + @Test + public void testAllocateJsonSerDeSer() throws Exception { + assertEquals(marshal(allocateNssi()), ALLOCATE); + NssiAllocateRequest all = unMarshal(ALLOCATE, NssiAllocateRequest.class); + assertNotNull(all); + assertNotNull(all.getAllocateCnNssi()); + assertNotNull(all.getAllocateCnNssi().getSliceProfile()); + assertEquals(all.getAllocateCnNssi().getSliceProfile().getResourceSharingLevel(), NON_SHARED); + assertNotNull(all.getAllocateCnNssi().getSliceProfile().getPerfReq()); + assertNotNull(all.getAllocateCnNssi().getSliceProfile().getPerfReq().getPerfReqEmbbList()); + PerfReqEmbbList embb = + all.getAllocateCnNssi().getSliceProfile().getPerfReq().getPerfReqEmbbList().iterator().next(); + assertNotNull(embb); + assertEquals(embb.getActivityFactor(), 50); + } + + public NssiAllocateRequest allocateNssi() throws Exception { + CnSliceProfile sP = new CnSliceProfile(); + List<String> sns = new LinkedList<>(); + sns.add("001-100001"); + List<String> plmn = new LinkedList<>(); + plmn.add("460-00"); + plmn.add("460-01"); + PerfReqEmbbList embb = new PerfReqEmbbList(); + embb.setActivityFactor(50); + List<PerfReqEmbbList> embbList = new LinkedList<>(); + embbList.add(embb); + PerfReq perfReq = new PerfReq(); + perfReq.setPerfReqEmbbList(embbList); + List<String> taList = new LinkedList<>(); + taList.add("1"); + taList.add("2"); + taList.add("3"); + sP.setSnssaiList(sns); + sP.setSliceProfileId("ab9af40f13f721b5f13539d87484098"); + sP.setPlmnIdList(plmn); + sP.setPerfReq(perfReq); + sP.setMaxNumberofUEs(200); + sP.setCoverageAreaTAList(taList); + sP.setLatency(6); + sP.setResourceSharingLevel(NON_SHARED); + NsiInfo nsiInfo = new NsiInfo(); + nsiInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); + nsiInfo.setNsiName("eMBB-001"); + AllocateCnNssi cnNssi = new AllocateCnNssi(); + cnNssi.setNssiId("NSST-C-001-HDBNJ-NSSMF-01-A-ZX"); + cnNssi.setNssiName("eMBB-001"); + cnNssi.setScriptName("CN1"); + cnNssi.setSliceProfile(sP); + cnNssi.setNsiInfo(nsiInfo); + EsrInfo esrInfo = new EsrInfo(); + esrInfo.setVendor("huawei"); + esrInfo.setNetworkType(CORE); + NssiAllocateRequest allocate = new NssiAllocateRequest(); + allocate.setAllocateCnNssi(cnNssi); + allocate.setEsrInfo(esrInfo); + return allocate; + } + + public NssiDeAllocateRequest deAllocateNssi() throws Exception { + DeAllocateNssi deAllocateNssi = new DeAllocateNssi(); + deAllocateNssi.setTerminateNssiOption(0); + List<String> snssai = new LinkedList<>(); + snssai.add("001-100001"); + deAllocateNssi.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); + deAllocateNssi.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); + deAllocateNssi.setScriptName("CN1"); + deAllocateNssi.setSnssaiList(snssai); + EsrInfo esrInfo = new EsrInfo(); + esrInfo.setVendor("huawei"); + esrInfo.setNetworkType(CORE); + NssiDeAllocateRequest deAllocate = new NssiDeAllocateRequest(); + deAllocate.setDeAllocateNssi(deAllocateNssi); + deAllocate.setEsrInfo(esrInfo); + return deAllocate; + } + + public NssiActDeActRequest activateNssi() throws Exception { + EsrInfo esrInfo = new EsrInfo(); + esrInfo.setVendor("huawei"); + esrInfo.setNetworkType(CORE); + ActDeActNssi act = new ActDeActNssi(); + act.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); + act.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); + NssiActDeActRequest actReq = new NssiActDeActRequest(); + actReq.setActDeActNssi(act); + actReq.setEsrInfo(esrInfo); + return actReq; + } + + public NssiActDeActRequest deActivateNssi() throws Exception { + EsrInfo esrInfo = new EsrInfo(); + esrInfo.setVendor("huawei"); + esrInfo.setNetworkType(CORE); + ActDeActNssi deAct = new ActDeActNssi(); + deAct.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); + deAct.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); + NssiActDeActRequest deActReq = new NssiActDeActRequest(); + deActReq.setActDeActNssi(deAct); + deActReq.setEsrInfo(esrInfo); + return deActReq; + } + + public String queryJobStatusNssi() throws Exception { + EsrInfo esrInfo = new EsrInfo(); + esrInfo.setVendor("huawei"); + esrInfo.setNetworkType(CORE); + + JobStatusRequest jobStatus = new JobStatusRequest(); + jobStatus.setEsrInfo(esrInfo); + jobStatus.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); + jobStatus.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); + return marshal(jobStatus); + } +} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java index 110fc6c03e..84ff054a7c 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java @@ -26,6 +26,7 @@ import javax.jws.WebService; import javax.xml.bind.annotation.XmlElement; import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.beans.InstanceNfvoMapping; import org.onap.so.db.request.beans.ResourceOperationStatus; /** @@ -55,6 +56,20 @@ public interface MsoRequestsDbAdapter { throws MsoRequestsDbException; @WebMethod + public void setInstanceNfvoMappingRepository( + @WebParam(name = "instanceId") @XmlElement(required = true) String instanceId, + @WebParam(name = "nfvoName") @XmlElement(required = true) String nfvoName, + @WebParam(name = "endpoint") @XmlElement(required = true) String endpoint, + @WebParam(name = "username") @XmlElement(required = true) String username, + @WebParam(name = "password") @XmlElement(required = true) String password, + @WebParam(name = "apiRoot") @XmlElement(required = false) String apiRoot) throws MsoRequestsDbException; + + @WebMethod + public InstanceNfvoMapping getInstanceNfvoMapping( + @WebParam(name = "instanceId") @XmlElement(required = true) String instanceId) + throws MsoRequestsDbException; + + @WebMethod public InfraActiveRequests getInfraRequest( @WebParam(name = "requestId") @XmlElement(required = true) String requestId) throws MsoRequestsDbException; diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java index 085a255948..052a53bb1f 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java @@ -31,12 +31,14 @@ import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.OperationStatus; import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.onap.so.db.request.beans.InstanceNfvoMapping; import org.onap.so.db.request.beans.ResourceOperationStatusId; import org.onap.so.db.request.beans.SiteStatus; import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; import org.onap.so.db.request.data.repository.OperationStatusRepository; import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; import org.onap.so.db.request.data.repository.SiteStatusRepository; +import org.onap.so.db.request.data.repository.InstanceNfvoMappingRepository; import org.onap.so.logger.ErrorCode; import org.onap.so.requestsdb.RequestsDbConstant; import org.slf4j.Logger; @@ -59,6 +61,9 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { private InfraActiveRequestsRepository infraActive; @Autowired + private InstanceNfvoMappingRepository instanceNfvoMappingRepository; + + @Autowired private SiteStatusRepository siteRepo; @Autowired @@ -69,6 +74,40 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { @Transactional @Override + public void setInstanceNfvoMappingRepository(String instanceId, String nfvoName, String endpoint, String username, + String password, String apiRoot) { + InstanceNfvoMapping instanceNfvoMapping = new InstanceNfvoMapping(); + if (apiRoot != null) { + instanceNfvoMapping.setApiRoot(apiRoot); + } + if (endpoint != null) { + instanceNfvoMapping.setEndpoint(endpoint); + } + if (instanceId != null) { + instanceNfvoMapping.setInstanceId(instanceId); + } + if (nfvoName != null) { + instanceNfvoMapping.setNfvoName(nfvoName); + } + if (username != null) { + instanceNfvoMapping.setUsername(username); + } + if (password != null) { + instanceNfvoMapping.setPassword(password); + } + + instanceNfvoMappingRepository.save(instanceNfvoMapping); + } + + @Transactional + @Override + public InstanceNfvoMapping getInstanceNfvoMapping(String instanceId) { + InstanceNfvoMapping instanceNfvoMapping = instanceNfvoMappingRepository.findOneByInstanceId(instanceId); + return instanceNfvoMapping; + } + + @Transactional + @Override public void updateInfraRequest(String requestId, String lastModifiedBy, String statusMessage, String responseBody, RequestStatusType requestStatus, String progress, String vnfOutputs, String serviceInstanceId, String networkId, String vnfId, String vfModuleId, String volumeGroupId, String serviceInstanceName, diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.1.1__Add_Instance_NFVO_Mapping_Table.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.1.1__Add_Instance_NFVO_Mapping_Table.sql new file mode 100644 index 0000000000..165a9b33f8 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.1.1__Add_Instance_NFVO_Mapping_Table.sql @@ -0,0 +1,12 @@ +use requestdb; + +CREATE TABLE `instance_nfvo_mapping` ( + `INSTANCE_ID` varchar(256) NOT NULL, + `NFVO_NAME` varchar(256) DEFAULT NULL, + `ENDPOINT` varchar(256) DEFAULT NULL, + `USERNAME` varchar(256) DEFAULT NULL, + `PASSWORD` varchar(256) DEFAULT NULL, + `API_ROOT` varchar(256) DEFAULT NULL, + `JOB_ID` varchar(256) DEFAULT NULL, + PRIMARY KEY (`INSTANCE_ID`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1;
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java index fef9dbc22c..9ded5b4b79 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java @@ -39,8 +39,10 @@ import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.OperationStatus; import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.onap.so.db.request.beans.InstanceNfvoMapping; import org.onap.so.db.request.data.repository.OperationStatusRepository; import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.onap.so.db.request.data.repository.InstanceNfvoMappingRepository; import org.onap.so.requestsdb.RequestsDbConstant; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.server.LocalServerPort; @@ -58,6 +60,9 @@ public class MSORequestDBImplTest extends RequestsAdapterBase { @Autowired private ResourceOperationStatusRepository resourceOperationStatusRepo; + @Autowired + private InstanceNfvoMappingRepository instanceNfvoMappingRepository; + @Rule public ExpectedException thrown = ExpectedException.none(); @@ -257,6 +262,29 @@ public class MSORequestDBImplTest extends RequestsAdapterBase { } @Test + public void setInstanceNfvoMappingRepository() throws MsoRequestsDbException { + InstanceNfvoMapping instanceNfvoMapping = new InstanceNfvoMapping(); + String instanceId = "9b9f02c0-298b-458a-bc9c-be3692e4f354"; + String nfvoName = "testNFVO"; + String endpoint = "http://127.0.0.1:80/"; + String username = "admin"; + String password = "admin"; + String apiRoot = "v1"; + + instanceNfvoMapping.setApiRoot(apiRoot); + instanceNfvoMapping.setEndpoint(endpoint); + instanceNfvoMapping.setInstanceId(instanceId); + instanceNfvoMapping.setNfvoName(nfvoName); + instanceNfvoMapping.setUsername(username); + instanceNfvoMapping.setPassword(password); + + dbAdapter.setInstanceNfvoMappingRepository(instanceId, nfvoName, endpoint, username, password, apiRoot); + InstanceNfvoMapping dbInstNfvoMap = dbAdapter.getInstanceNfvoMapping(instanceId); + assertThat(dbInstNfvoMap, sameBeanAs(instanceNfvoMapping)); + } + + + @Test public void updateServiceOperation() throws MsoRequestsDbException { String serviceId = "serviceid"; String operationId = "operationid"; diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/CommonConstant.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/CommonConstant.java index 04c6749b61..51a0fc0c97 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/CommonConstant.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/CommonConstant.java @@ -33,17 +33,32 @@ public class CommonConstant { public static final String STR_EMPTY = ""; public static final String NFVO_CREATE_URL = "/api/nslcm/v1/ns"; + public static final String SOL005_NFVO_CREATE_URL = "/api/nslcm/v1/ns_instances"; public static final String NFVO_INSTANTIATE_URL = "/api/nslcm/v1/ns/%s/instantiate"; + public static final String SOL005_NFVO_INSTANTIATE_URL = "/api/nslcm/v1/ns_instances/%s/instantiate"; public static final String NFVO_TERMINATE_URL = "/api/nslcm/v1/ns/%s/terminate"; + public static final String SOL005_NFVO_TERMINATE_URL = "/api/nslcm/v1/ns_instances/%s/terminate"; public static final String NFVO_DELETE_URL = "/api/nslcm/v1/ns/%s"; + public static final String SOL005_NFVO_DELETE_URL = "/api/nslcm/v1/ns_instances/%s"; public static final String NFVO_QUERY_URL = "/api/nslcm/v1/jobs/%s"; + public static final String SOL005_NFVO_QUERY_URL = "/api/nslcm/v1/ns_lcm_op_occs/%s"; public static final String NFVO_SCALE_URL = "/api/nslcm/v1/ns/%s/scale"; + public enum operationState { + PROCESSING, COMPLETED, PARTIALLY_COMPLETED, FAILED_TEMP, FAILED, ROLLING_BACK, ROLLED_BACK + } + public enum lcmOperationType { + INSTANTIATE, SCALE, UPDATE, TERMINATE, HEAL + }; + public enum cancelMode { + GRACEFUL, FORCEFUL + }; + /** * * <br> @@ -107,8 +122,11 @@ public class CommonConstant { public static final String DESC = "description"; public static final String NS_INSTANCE_ID = "nsInstanceId"; + public static final String SOL005_NS_INSTANCE_ID = "id"; + public static final String JOB_ID = "jobId"; + public static final String JOB_URI = "Location"; public static final String ADDITIONAL_PARAM_FOR_NS = "additionalParamForNs"; diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AddPnfData.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AddPnfData.java new file mode 100644 index 0000000000..d312501fd7 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AddPnfData.java @@ -0,0 +1,68 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + + +package org.onap.so.adapters.vfc.model; + +import java.util.List; + +public class AddPnfData { + private String pnfId; + private String pnfName; + private String pnfdId; + private String pnfProfileId; + private List<PnfExtCpData> cpData; + + /*** + * + * @return id of pnf + */ + public String getPnfId() { + return pnfId; + } + + public void setPnfId(String pnfId) { + this.pnfId = pnfId; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String pnfName) { + this.pnfName = pnfName; + } + + public String getPnfdId() { + return pnfdId; + } + + public void setPnfdId(String pnfdId) { + this.pnfdId = pnfdId; + } + + public String getPnfProfileId() { + return pnfProfileId; + } + + public void setPnfProfileId(String pnfProfileId) { + this.pnfProfileId = pnfProfileId; + } + + public List<PnfExtCpData> getCpData() { + return cpData; + } + + public void setCpData(List<PnfExtCpData> cpData) { + this.cpData = cpData; + } +} + diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AddressRange.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AddressRange.java new file mode 100644 index 0000000000..9f357a549d --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AddressRange.java @@ -0,0 +1,33 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class AddressRange { + private String minAddress; + private String maxAddress; + + public String getMinAddress() { + return minAddress; + } + + public void setMinAddress(String minAddress) { + this.minAddress = minAddress; + } + + public String getMaxAddress() { + return maxAddress; + } + + public void setMaxAddress(String maxAddress) { + this.maxAddress = maxAddress; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedNs.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedNs.java new file mode 100644 index 0000000000..fa502f3962 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedNs.java @@ -0,0 +1,40 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class AffectedNs { + private String nsInstanceId; + private String nsdId; + + private enum changeType { + ADD, REMOVE, INSTANTIATE, TERMINATE, SCALE, UPDATE, HEAL + } + private enum changeResult { + COMPLETED, ROLLED_BACK, FAILED, PARTIALLY_COMPLETED + } + + public String getNsInstanceId() { + return nsInstanceId; + } + + public void setNsInstanceId(String nsInstanceId) { + this.nsInstanceId = nsInstanceId; + } + + public String getNsdId() { + return nsdId; + } + + public void setNsdId(String nsdId) { + this.nsdId = nsdId; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedPnf.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedPnf.java new file mode 100644 index 0000000000..9d98e1c256 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedPnf.java @@ -0,0 +1,67 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class AffectedPnf { + private String pnfid; + private String pnfdid; + private String pnfProfileId; + private String pnfName; + private String cpInstanceId; + + private enum changeType { + ADD, REMOVE, MODIFY + } + private enum changeResult { + COMPLETED, ROLLED_BACK, FAILED + } + + public String getPnfid() { + return pnfid; + } + + public void setPnfid(String pnfid) { + this.pnfid = pnfid; + } + + public String getPnfdid() { + return pnfdid; + } + + public void setPnfdid(String pnfdid) { + this.pnfdid = pnfdid; + } + + public String getPnfProfileId() { + return pnfProfileId; + } + + public void setPnfProfileId(String pnfProfileId) { + this.pnfProfileId = pnfProfileId; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String pnfName) { + this.pnfName = pnfName; + } + + public String getCpInstanceId() { + return cpInstanceId; + } + + public void setCpInstanceId(String cpInstanceId) { + this.cpInstanceId = cpInstanceId; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedSap.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedSap.java new file mode 100644 index 0000000000..62f4f92fa9 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedSap.java @@ -0,0 +1,49 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class AffectedSap { + private String sapInstanceId; + private String sapdId; + private String sapName; + + private enum changeType { + ADD, REMOVE, MODIFY + } + private enum changeResult { + COMPLETED, ROLLED_BACK, FAILED + } + + public String getSapInstanceId() { + return sapInstanceId; + } + + public void setSapInstanceId(String sapInstanceId) { + this.sapInstanceId = sapInstanceId; + } + + public String getSapdId() { + return sapdId; + } + + public void setSapdId(String sapdId) { + this.sapdId = sapdId; + } + + public String getSapName() { + return sapName; + } + + public void setSapName(String sapName) { + this.sapName = sapName; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedVirtualLink.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedVirtualLink.java new file mode 100644 index 0000000000..ecaa1c5d3b --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedVirtualLink.java @@ -0,0 +1,49 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class AffectedVirtualLink { + private String nsVirtualLinkInstanceId; + private String nsVirtualLinkDescId; + private String vlProfileId; + + private enum changeType { + ADD, DELETE, MODIFY, ADD_LINK_PORT, REMOVE_LINK_PORT + }; + private enum changeResult { + COMPLETED, ROLLED_BACK, FAILED + } + + public String getNsVirtualLinkInstanceId() { + return nsVirtualLinkInstanceId; + } + + public void setNsVirtualLinkInstanceId(String nsVirtualLinkInstanceId) { + this.nsVirtualLinkInstanceId = nsVirtualLinkInstanceId; + } + + public String getNsVirtualLinkDescId() { + return nsVirtualLinkDescId; + } + + public void setNsVirtualLinkDescId(String nsVirtualLinkDescId) { + this.nsVirtualLinkDescId = nsVirtualLinkDescId; + } + + public String getVlProfileId() { + return vlProfileId; + } + + public void setVlProfileId(String vlProfileId) { + this.vlProfileId = vlProfileId; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedVnf.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedVnf.java new file mode 100644 index 0000000000..6463c7a129 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedVnf.java @@ -0,0 +1,78 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class AffectedVnf { + private String vnfInstanceId; + private String vnfdId; + private String vnfProfileId; + private String vnfName; + + private enum changeType { + ADD, + REMOVE, + INSTANTIATE, + TERMINATE, + SCALE, + CHANGE_FLAVOUR, + HEAL, + OPERATE, + MODIFY_INFORMATION, + CHANGE_EXTERNAL_VNF_CONNECTIVITY + }; + private enum changeResult { + COMPLETED, ROLLED_BACK, FAILED + } + + private ChangedInfo changedInfo; + + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public String getVnfdId() { + return vnfdId; + } + + public void setVnfdId(String vnfdId) { + this.vnfdId = vnfdId; + } + + public String getVnfProfileId() { + return vnfProfileId; + } + + public void setVnfProfileId(String vnfProfileId) { + this.vnfProfileId = vnfProfileId; + } + + public String getVnfName() { + return vnfName; + } + + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + public ChangedInfo getChangedInfo() { + return changedInfo; + } + + public void setChangedInfo(ChangedInfo changedInfo) { + this.changedInfo = changedInfo; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedVnffg.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedVnffg.java new file mode 100644 index 0000000000..04e9481190 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffectedVnffg.java @@ -0,0 +1,40 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class AffectedVnffg { + private String vnffgInstanceId; + private String vnffgdId; + + private enum changeType { + ADD, REMOVE, MODIFY + } + private enum changeResult { + COMPLETED, ROLLED_BACK, FAILED + } + + public String getVnffgInstanceId() { + return vnffgInstanceId; + } + + public void setVnffgInstanceId(String vnffgInstanceId) { + this.vnffgInstanceId = vnffgInstanceId; + } + + public String getVnffgdId() { + return vnffgdId; + } + + public void setVnffgdId(String vnffgdId) { + this.vnffgdId = vnffgdId; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffinityOrAntiAffinityRule.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffinityOrAntiAffinityRule.java new file mode 100644 index 0000000000..7f019bcf40 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/AffinityOrAntiAffinityRule.java @@ -0,0 +1,51 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import java.util.List; + +public class AffinityOrAntiAffinityRule { + private String vnfdId; + private List<String> vnfProfileId; + private List<String> vnfInstanceId; + + private enum affinityOrAntiAffiinty { + AFFINITY, ANTI_AFFIINTY + }; + private enum scope { + NFVI_POP, ZONE, ZONE_GROUP, NFVI_NODE + }; + + public String getVnfdId() { + return vnfdId; + } + + public void setVnfdId(String vnfdId) { + this.vnfdId = vnfdId; + } + + public List<String> getVnfProfileId() { + return vnfProfileId; + } + + public void setVnfProfileId(List<String> vnfProfileId) { + this.vnfProfileId = vnfProfileId; + } + + public List<String> getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(List<String> vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ChangedInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ChangedInfo.java new file mode 100644 index 0000000000..5de6cbf139 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ChangedInfo.java @@ -0,0 +1,33 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class ChangedInfo { + private ModifyVnfInfoData changedVnfInfo; + private ExtVirtualLinkInfo changedExtConnectivity; + + public ModifyVnfInfoData getChangedVnfInfo() { + return changedVnfInfo; + } + + public void setChangedVnfInfo(ModifyVnfInfoData changedVnfInfo) { + this.changedVnfInfo = changedVnfInfo; + } + + public ExtVirtualLinkInfo getChangedExtConnectivity() { + return changedExtConnectivity; + } + + public void setChangedExtConnectivity(ExtVirtualLinkInfo changedExtConnectivity) { + this.changedExtConnectivity = changedExtConnectivity; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CivicAddressElement.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CivicAddressElement.java new file mode 100644 index 0000000000..2a63d39be0 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CivicAddressElement.java @@ -0,0 +1,33 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class CivicAddressElement { + private int caType; + private String caValue; + + public int getCaType() { + return caType; + } + + public void setCaType(int caType) { + this.caType = caType; + } + + public String getCaValue() { + return caValue; + } + + public void setCaValue(String caValue) { + this.caValue = caValue; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CpProtocolData.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CpProtocolData.java new file mode 100644 index 0000000000..27272ea22a --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CpProtocolData.java @@ -0,0 +1,33 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class CpProtocolData { + private String layerProtocol; + private IpOverEthernetAddressData ipOverEthernet; + + public String getLayerProtocol() { + return layerProtocol; + } + + public void setLayerProtocol(String layerProtocol) { + this.layerProtocol = layerProtocol; + } + + public IpOverEthernetAddressData getIpOverEthernet() { + return ipOverEthernet; + } + + public void setIpOverEthernet(IpOverEthernetAddressData ipOverEthernet) { + this.ipOverEthernet = ipOverEthernet; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CpProtocolInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CpProtocolInfo.java new file mode 100644 index 0000000000..5f1191efe9 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CpProtocolInfo.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; + +public class CpProtocolInfo { + @NotNull + private enum layerProtocol { + IP_OVER_ETHERNET + }; + + private IpOverEthernetAddressData ipOverEthernet; + + public IpOverEthernetAddressData getIpOverEthernet() { + return ipOverEthernet; + } + + public void setIpOverEthernet(IpOverEthernetAddressData ipOverEthernet) { + this.ipOverEthernet = ipOverEthernet; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CreateNsRequest.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CreateNsRequest.java new file mode 100644 index 0000000000..878ce60ba1 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CreateNsRequest.java @@ -0,0 +1,53 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class CreateNsRequest { + + String nsdId; + + String nsName; + + String nsDescription; + + + public String getNsdId() { + return nsdId; + } + + public void setNsdId(String nsdId) { + this.nsdId = nsdId; + } + + public String getNsDescription() { + return nsDescription; + } + + public void setNsDescription(String nsDescription) { + this.nsDescription = nsDescription; + } + + /** + * @return Returns the nsName. + */ + public String getNsName() { + return nsName; + } + + /** + * @param nsName The nsName to set. + */ + public void setNsName(String nsName) { + this.nsName = nsName; + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ExtCpInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ExtCpInfo.java new file mode 100644 index 0000000000..63ca66bd43 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ExtCpInfo.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; +import java.util.List; + +public class ExtCpInfo { + @NotNull + private String id; + @NotNull + private String cpdId; + private List<CpProtocolData> cpProtocolInfo; + private List<String> extLinkPortId; + + + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ExtLinkPortInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ExtLinkPortInfo.java new file mode 100644 index 0000000000..a1ab3fdb97 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ExtLinkPortInfo.java @@ -0,0 +1,33 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class ExtLinkPortInfo { + private String id; + private ResourceHandle resourceHandle; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ResourceHandle getResourceHandle() { + return resourceHandle; + } + + public void setResourceHandle(ResourceHandle resourceHandle) { + this.resourceHandle = resourceHandle; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ExtManagedVirtualLinkInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ExtManagedVirtualLinkInfo.java new file mode 100644 index 0000000000..3f643a8330 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ExtManagedVirtualLinkInfo.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; +import java.util.List; + +public class ExtManagedVirtualLinkInfo { + @NotNull + private String id; + @NotNull + private String vnfVirtualLinkDescId; + @NotNull + private ResourceHandle networkResource; + private List<VnfLinkPortInfo> vnfLinkPorts; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getVnfVirtualLinkDescId() { + return vnfVirtualLinkDescId; + } + + public void setVnfVirtualLinkDescId(String vnfVirtualLinkDescId) { + this.vnfVirtualLinkDescId = vnfVirtualLinkDescId; + } + + public ResourceHandle getNetworkResource() { + return networkResource; + } + + public void setNetworkResource(ResourceHandle networkResource) { + this.networkResource = networkResource; + } + + public List<VnfLinkPortInfo> getVnfLinkPorts() { + return vnfLinkPorts; + } + + public void setVnfLinkPorts(List<VnfLinkPortInfo> vnfLinkPorts) { + this.vnfLinkPorts = vnfLinkPorts; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ExtVirtualLinkInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ExtVirtualLinkInfo.java new file mode 100644 index 0000000000..ce7d1cfe6d --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ExtVirtualLinkInfo.java @@ -0,0 +1,42 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class ExtVirtualLinkInfo { + private String id; + private ResourceHandle resourceHandle; + private ExtLinkPortInfo extLinkPorts; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ResourceHandle getResourceHandle() { + return resourceHandle; + } + + public void setResourceHandle(ResourceHandle resourceHandle) { + this.resourceHandle = resourceHandle; + } + + public ExtLinkPortInfo getExtLinkPorts() { + return extLinkPorts; + } + + public void setExtLinkPorts(ExtLinkPortInfo extLinkPorts) { + this.extLinkPorts = extLinkPorts; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/InstantiateNsRequest.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/InstantiateNsRequest.java new file mode 100644 index 0000000000..ff0730a527 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/InstantiateNsRequest.java @@ -0,0 +1,207 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import java.util.List; +import java.util.Map; + +public class InstantiateNsRequest { + + private String nsFlavourId; + private List<SapData> sapData; + private List<AddPnfData> addpnfData; + private List<VnfInstanceData> vnfInstanceData; + private List<String> nestedNsInstanceId; + private List<VnfLocationConstraint> localizationLanguage; + private Map<String, Object> aditionalParamsForNs; + private List<ParamsForVnf> additionalParamsForVnf; + private String startTime; + private String nsInstantiationLevelId; + private List<AffinityOrAntiAffinityRule> additionalAffinityOrAntiAffiniityRule; + + /*** + * + * @return nsFlavourId + */ + public String getNsFlavourId() { + return nsFlavourId; + } + + /*** + * + * @param nsFlavourId + */ + public void setNsFlavourId(String nsFlavourId) { + this.nsFlavourId = nsFlavourId; + } + + /*** + * + * @return + */ + public List<SapData> getSapData() { + return sapData; + } + + /*** + * + * @param sapData + */ + public void setSapData(List<SapData> sapData) { + this.sapData = sapData; + } + + /*** + * + * @return + */ + public List<AddPnfData> getAddpnfData() { + return addpnfData; + } + + /*** + * + * @param addpnfData + */ + public void setAddpnfData(List<AddPnfData> addpnfData) { + this.addpnfData = addpnfData; + } + + /*** + * + * @return + */ + public List<VnfInstanceData> getVnfInstanceData() { + return vnfInstanceData; + } + + /*** + * + * @param vnfInstanceData + */ + public void setVnfInstanceData(List<VnfInstanceData> vnfInstanceData) { + this.vnfInstanceData = vnfInstanceData; + } + + /*** + * + * @return + */ + public List<String> getNestedNsInstanceId() { + return nestedNsInstanceId; + } + + /*** + * + * @param nestedNsInstanceId + */ + public void setNestedNsInstanceId(List<String> nestedNsInstanceId) { + this.nestedNsInstanceId = nestedNsInstanceId; + } + + /*** + * + * @return + */ + public List<VnfLocationConstraint> getLocalizationLanguage() { + return localizationLanguage; + } + + /*** + * + * @param localizationLanguage + */ + public void setLocalizationLanguage(List<VnfLocationConstraint> localizationLanguage) { + this.localizationLanguage = localizationLanguage; + } + + /*** + * + * @return + */ + public Map<String, Object> getAditionalParamsForNs() { + return aditionalParamsForNs; + } + + /*** + * + * @param aditionalParamsForNs + */ + public void setAditionalParamsForNs(Map<String, Object> aditionalParamsForNs) { + this.aditionalParamsForNs = aditionalParamsForNs; + } + + /*** + * + * @return + */ + public List<ParamsForVnf> getAdditionalParamsForVnf() { + return additionalParamsForVnf; + } + + /*** + * + * @param additionalParamsForVnf + */ + public void setAdditionalParamsForVnf(List<ParamsForVnf> additionalParamsForVnf) { + this.additionalParamsForVnf = additionalParamsForVnf; + } + + /*** + * + * @return + */ + public String getStartTime() { + return startTime; + } + + /*** + * + * @param startTime + */ + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + /*** + * + * @return + */ + public String getNsInstantiationLevelId() { + return nsInstantiationLevelId; + } + + /*** + * + * @param nsInstantiationLevelId + */ + public void setNsInstantiationLevelId(String nsInstantiationLevelId) { + this.nsInstantiationLevelId = nsInstantiationLevelId; + } + + /*** + * + * @return + */ + public List<AffinityOrAntiAffinityRule> getAdditionalAffinityOrAntiAffiniityRule() { + return additionalAffinityOrAntiAffiniityRule; + } + + /*** + * + * @param additionalAffinityOrAntiAffiniityRule + */ + public void setAdditionalAffinityOrAntiAffiniityRule( + List<AffinityOrAntiAffinityRule> additionalAffinityOrAntiAffiniityRule) { + this.additionalAffinityOrAntiAffiniityRule = additionalAffinityOrAntiAffiniityRule; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/InstantiatedVnfInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/InstantiatedVnfInfo.java new file mode 100644 index 0000000000..83a8a56756 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/InstantiatedVnfInfo.java @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; +import java.util.List; +import java.util.Map; + +public class InstantiatedVnfInfo { + @NotNull + private String flavourId; + @NotNull + private String vnfState; + private List<VnfScaleInfo> vnfScaleInfos; + @NotNull + private List<ExtCpInfo> extCpInfo; + private List<ExtVirtualLinkInfo> extVirtualLinkInfo; + private List<ExtManagedVirtualLinkInfo> extManagedVirtualLinkInfo; + // Defination of MonitoringParameter is not there in ETSI document + // considering as String + private List<String> monitoringParameters; + private String localizationLanguage; + + private List<VnfcResourceInfo> vnfcResourceInfo; + // Defination of VirtualStorageResourceInfo is not there in ETSI document + // considering as String + private List<String> virtualStorageResourceInfo; + + public String getFlavourId() { + return flavourId; + } + + public void setFlavourId(String flavourId) { + this.flavourId = flavourId; + } + + public String getVnfState() { + return vnfState; + } + + public void setVnfState(String vnfState) { + this.vnfState = vnfState; + } + + public List<VnfScaleInfo> getVnfScaleInfos() { + return vnfScaleInfos; + } + + public void setVnfScaleInfos(List<VnfScaleInfo> vnfScaleInfos) { + this.vnfScaleInfos = vnfScaleInfos; + } + + public List<ExtCpInfo> getExtCpInfo() { + return extCpInfo; + } + + public void setExtCpInfo(List<ExtCpInfo> extCpInfo) { + this.extCpInfo = extCpInfo; + } + + public List<ExtVirtualLinkInfo> getExtVirtualLinkInfo() { + return extVirtualLinkInfo; + } + + public void setExtVirtualLinkInfo(List<ExtVirtualLinkInfo> extVirtualLinkInfo) { + this.extVirtualLinkInfo = extVirtualLinkInfo; + } + + public List<ExtManagedVirtualLinkInfo> getExtManagedVirtualLinkInfo() { + return extManagedVirtualLinkInfo; + } + + public void setExtManagedVirtualLinkInfo(List<ExtManagedVirtualLinkInfo> extManagedVirtualLinkInfo) { + this.extManagedVirtualLinkInfo = extManagedVirtualLinkInfo; + } + + public List<String> getMonitoringParameters() { + return monitoringParameters; + } + + public void setMonitoringParameters(List<String> monitoringParameters) { + this.monitoringParameters = monitoringParameters; + } + + public String getLocalizationLanguage() { + return localizationLanguage; + } + + public void setLocalizationLanguage(String localizationLanguage) { + this.localizationLanguage = localizationLanguage; + } + + public List<VnfcResourceInfo> getVnfcResourceInfo() { + return vnfcResourceInfo; + } + + public void setVnfcResourceInfo(List<VnfcResourceInfo> vnfcResourceInfo) { + this.vnfcResourceInfo = vnfcResourceInfo; + } + + public List<String> getVirtualStorageResourceInfo() { + return virtualStorageResourceInfo; + } + + public void setVirtualStorageResourceInfo(List<String> virtualStorageResourceInfo) { + this.virtualStorageResourceInfo = virtualStorageResourceInfo; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/IpAddresses.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/IpAddresses.java new file mode 100644 index 0000000000..32c5571d96 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/IpAddresses.java @@ -0,0 +1,63 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import java.util.List; + +public class IpAddresses { + private String type; + private List<String> fixedAddresses; + private int numDynamicAddresses; + private AddressRange addressRange; + private String subnetId; + + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public List<String> getFixedAddresses() { + return fixedAddresses; + } + + public void setFixedAddresses(List<String> fixedAddresses) { + this.fixedAddresses = fixedAddresses; + } + + public int getNumDynamicAddresses() { + return numDynamicAddresses; + } + + public void setNumDynamicAddresses(int numDynamicAddresses) { + this.numDynamicAddresses = numDynamicAddresses; + } + + public AddressRange getAddressRange() { + return addressRange; + } + + public void setAddressRange(AddressRange addressRange) { + this.addressRange = addressRange; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/IpOverEthernetAddressData.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/IpOverEthernetAddressData.java new file mode 100644 index 0000000000..48529e5f76 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/IpOverEthernetAddressData.java @@ -0,0 +1,35 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import java.util.List; + +public class IpOverEthernetAddressData { + private String macAddress; + private List<IpAddresses> ipAddresses; + + public String getMacAddress() { + return macAddress; + } + + public void setMacAddress(String macAddress) { + this.macAddress = macAddress; + } + + public List<IpAddresses> getIpAddresses() { + return ipAddresses; + } + + public void setIpAddresses(List<IpAddresses> ipAddresses) { + this.ipAddresses = ipAddresses; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/Link.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/Link.java new file mode 100644 index 0000000000..2459346826 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/Link.java @@ -0,0 +1,24 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class Link { + private String href; + + public String getHref() { + return href; + } + + public void setHref(String href) { + this.href = href; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/Links.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/Links.java new file mode 100644 index 0000000000..8ad8f000c1 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/Links.java @@ -0,0 +1,78 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class Links { + private Link self; + private Link nsInstance; + private Link cancel; + private Link retry; + private Link rollback; + private Link continues; + private Link fail; + + public Link getSelf() { + return self; + } + + public void setSelf(Link self) { + this.self = self; + } + + public Link getNsInstance() { + return nsInstance; + } + + public void setNsInstance(Link nsInstance) { + this.nsInstance = nsInstance; + } + + public Link getCancel() { + return cancel; + } + + public void setCancel(Link cancel) { + this.cancel = cancel; + } + + public Link getRetry() { + return retry; + } + + public void setRetry(Link retry) { + this.retry = retry; + } + + public Link getRollback() { + return rollback; + } + + public void setRollback(Link rollback) { + this.rollback = rollback; + } + + public Link getContinues() { + return continues; + } + + public void setContinues(Link continues) { + this.continues = continues; + } + + public Link getFail() { + return fail; + } + + public void setFail(Link fail) { + this.fail = fail; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/LocationConstraints.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/LocationConstraints.java new file mode 100644 index 0000000000..b636d49edf --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/LocationConstraints.java @@ -0,0 +1,33 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class LocationConstraints { + private String countryCode; + private CivicAddressElement civicAddressElement; + + public String getCountryCode() { + return countryCode; + } + + public void setCountryCode(String countryCode) { + this.countryCode = countryCode; + } + + public CivicAddressElement getCivicAddressElement() { + return civicAddressElement; + } + + public void setCivicAddressElement(CivicAddressElement civicAddressElement) { + this.civicAddressElement = civicAddressElement; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/Mask.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/Mask.java new file mode 100644 index 0000000000..352f47e19f --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/Mask.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; + +public class Mask { + @NotNull + private int startingPoint; + @NotNull + private int length; + @NotNull + private String value; + + public int getStartingPoint() { + return startingPoint; + } + + public void setStartingPoint(int startingPoint) { + this.startingPoint = startingPoint; + } + + public int getLength() { + return length; + } + + public void setLength(int length) { + this.length = length; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ModifyVnfInfoData.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ModifyVnfInfoData.java new file mode 100644 index 0000000000..55ab21e8e2 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ModifyVnfInfoData.java @@ -0,0 +1,80 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import java.util.Map; + +public class ModifyVnfInfoData { + private String vnfInstanceId; + private String vnfInstanceName; + private String vnfInstanceDescription; + private String vnfPkgId; + private Map<String, Object> vnfConfigurableProperties; + private Map<String, Object> Metadata; + private Map<String, Object> Extensions; + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public String getVnfInstanceName() { + return vnfInstanceName; + } + + public void setVnfInstanceName(String vnfInstanceName) { + this.vnfInstanceName = vnfInstanceName; + } + + public String getVnfInstanceDescription() { + return vnfInstanceDescription; + } + + public void setVnfInstanceDescription(String vnfInstanceDescription) { + this.vnfInstanceDescription = vnfInstanceDescription; + } + + public String getVnfPkgId() { + return vnfPkgId; + } + + public void setVnfPkgId(String vnfPkgId) { + this.vnfPkgId = vnfPkgId; + } + + public Map<String, Object> getVnfConfigurableProperties() { + return vnfConfigurableProperties; + } + + public void setVnfConfigurableProperties(Map<String, Object> vnfConfigurableProperties) { + this.vnfConfigurableProperties = vnfConfigurableProperties; + } + + public Map<String, Object> getMetadata() { + return Metadata; + } + + public void setMetadata(Map<String, Object> metadata) { + Metadata = metadata; + } + + public Map<String, Object> getExtensions() { + return Extensions; + } + + public void setExtensions(Map<String, Object> extensions) { + Extensions = extensions; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NfpInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NfpInfo.java new file mode 100644 index 0000000000..a6e3963725 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NfpInfo.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; +import java.util.List; + +public class NfpInfo { + @NotNull + private String id; + private String nfpdId; + private String nfpName; + private String description; + @NotNull + private List<NsCpHandle> nscpHandle; + private int totalCp; + @NotNull + private NfpRule nfpRule; + + @NotNull + private enum nfpState { + ENABLED, DISABLED + }; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getNfpdId() { + return nfpdId; + } + + public void setNfpdId(String nfpdId) { + this.nfpdId = nfpdId; + } + + public String getNfpName() { + return nfpName; + } + + public void setNfpName(String nfpName) { + this.nfpName = nfpName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List<NsCpHandle> getNscpHandle() { + return nscpHandle; + } + + public void setNscpHandle(List<NsCpHandle> nscpHandle) { + this.nscpHandle = nscpHandle; + } + + public int getTotalCp() { + return totalCp; + } + + public void setTotalCp(int totalCp) { + this.totalCp = totalCp; + } + + public NfpRule getNfpRule() { + return nfpRule; + } + + public void setNfpRule(NfpRule nfpRule) { + this.nfpRule = nfpRule; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NfpRule.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NfpRule.java new file mode 100644 index 0000000000..b4f684a3e2 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NfpRule.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import java.util.List; + +public class NfpRule { + private String etherDestinationAddress; + private String etherSourceAddress; + + private enum etherType { + IPV4, IPV6 + }; + + private List<String> vlanTag; + + private enum protocol { + TCP, UDP, ICMP + } + + private String dscp; + private PortRange sourcePortRange; + private PortRange destinationPortRange; + private String sourceIpAddressPrefix; + private String destinationIpAddressPrefix; + private List<Mask> extendedCriteria; + + public String getEtherDestinationAddress() { + return etherDestinationAddress; + } + + public void setEtherDestinationAddress(String etherDestinationAddress) { + this.etherDestinationAddress = etherDestinationAddress; + } + + public String getEtherSourceAddress() { + return etherSourceAddress; + } + + public void setEtherSourceAddress(String etherSourceAddress) { + this.etherSourceAddress = etherSourceAddress; + } + + public List<String> getVlanTag() { + return vlanTag; + } + + public void setVlanTag(List<String> vlanTag) { + this.vlanTag = vlanTag; + } + + public String getDscp() { + return dscp; + } + + public void setDscp(String dscp) { + this.dscp = dscp; + } + + public PortRange getSourcePortRange() { + return sourcePortRange; + } + + public void setSourcePortRange(PortRange sourcePortRange) { + this.sourcePortRange = sourcePortRange; + } + + public PortRange getDestinationPortRange() { + return destinationPortRange; + } + + public void setDestinationPortRange(PortRange destinationPortRange) { + this.destinationPortRange = destinationPortRange; + } + + public String getSourceIpAddressPrefix() { + return sourceIpAddressPrefix; + } + + public void setSourceIpAddressPrefix(String sourceIpAddressPrefix) { + this.sourceIpAddressPrefix = sourceIpAddressPrefix; + } + + public String getDestinationIpAddressPrefix() { + return destinationIpAddressPrefix; + } + + public void setDestinationIpAddressPrefix(String destinationIpAddressPrefix) { + this.destinationIpAddressPrefix = destinationIpAddressPrefix; + } + + public List<Mask> getExtendedCriteria() { + return extendedCriteria; + } + + public void setExtendedCriteria(List<Mask> extendedCriteria) { + this.extendedCriteria = extendedCriteria; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsCpHandle.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsCpHandle.java new file mode 100644 index 0000000000..326488fb76 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsCpHandle.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class NsCpHandle { + private String vnfInstanceId; + private String vnfExtCpInstanceId; + private String pnfInfoId; + private String pnfExtCpInstanceId; + private String nsInstanceId; + private String nsSapInstanceId; + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public String getVnfExtCpInstanceId() { + return vnfExtCpInstanceId; + } + + public void setVnfExtCpInstanceId(String vnfExtCpInstanceId) { + this.vnfExtCpInstanceId = vnfExtCpInstanceId; + } + + public String getPnfInfoId() { + return pnfInfoId; + } + + public void setPnfInfoId(String pnfInfoId) { + this.pnfInfoId = pnfInfoId; + } + + public String getPnfExtCpInstanceId() { + return pnfExtCpInstanceId; + } + + public void setPnfExtCpInstanceId(String pnfExtCpInstanceId) { + this.pnfExtCpInstanceId = pnfExtCpInstanceId; + } + + public String getNsInstanceId() { + return nsInstanceId; + } + + public void setNsInstanceId(String nsInstanceId) { + this.nsInstanceId = nsInstanceId; + } + + public String getNsSapInstanceId() { + return nsSapInstanceId; + } + + public void setNsSapInstanceId(String nsSapInstanceId) { + this.nsSapInstanceId = nsSapInstanceId; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsInstance.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsInstance.java new file mode 100644 index 0000000000..d2d4b4e772 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsInstance.java @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; +import java.util.List; + +public class NsInstance { + @NotNull + private String id; + @NotNull + private String nsInstanceName; + @NotNull + private String nsInstanceDescription; + @NotNull + private String nsdId; + @NotNull + private String nsdInfoId; + private String flavourId; + private List<VnfInstance> vnfInstance; + private List<PnfInfo> pnfInfo; + private List<NsVirtualLinkInfo> virtualLinkInfo; + private List<VnffgInfo> vnffgInfo; + private List<SapInfo> sapInfo; + private List<String> nestedNsInstanceId; + + @NotNull + private enum nsState { + NOT_INSTANTIATED, INSTANTIATED + }; + + private List<NsScaleInfo> nsScaleStatus; + private List<AffinityOrAntiAffinityRule> additionalAffinityOrAntiAffinityRule; + @NotNull + private NsInstanceLinks _links; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getNsInstanceName() { + return nsInstanceName; + } + + public void setNsInstanceName(String nsInstanceName) { + this.nsInstanceName = nsInstanceName; + } + + public String getNsInstanceDescription() { + return nsInstanceDescription; + } + + public void setNsInstanceDescription(String nsInstanceDescription) { + this.nsInstanceDescription = nsInstanceDescription; + } + + public String getNsdId() { + return nsdId; + } + + public void setNsdId(String nsdId) { + this.nsdId = nsdId; + } + + public String getNsdInfoId() { + return nsdInfoId; + } + + public void setNsdInfoId(String nsdInfoId) { + this.nsdInfoId = nsdInfoId; + } + + public String getFlavourId() { + return flavourId; + } + + public void setFlavourId(String flavourId) { + this.flavourId = flavourId; + } + + public List<VnfInstance> getVnfInstance() { + return vnfInstance; + } + + public void setVnfInstance(List<VnfInstance> vnfInstance) { + this.vnfInstance = vnfInstance; + } + + public List<PnfInfo> getPnfInfo() { + return pnfInfo; + } + + public void setPnfInfo(List<PnfInfo> pnfInfo) { + this.pnfInfo = pnfInfo; + } + + public List<NsVirtualLinkInfo> getVirtualLinkInfo() { + return virtualLinkInfo; + } + + public void setVirtualLinkInfo(List<NsVirtualLinkInfo> virtualLinkInfo) { + this.virtualLinkInfo = virtualLinkInfo; + } + + public List<VnffgInfo> getVnffgInfo() { + return vnffgInfo; + } + + public void setVnffgInfo(List<VnffgInfo> vnffgInfo) { + this.vnffgInfo = vnffgInfo; + } + + public List<SapInfo> getSapInfo() { + return sapInfo; + } + + public void setSapInfo(List<SapInfo> sapInfo) { + this.sapInfo = sapInfo; + } + + public List<String> getNestedNsInstanceId() { + return nestedNsInstanceId; + } + + public void setNestedNsInstanceId(List<String> nestedNsInstanceId) { + this.nestedNsInstanceId = nestedNsInstanceId; + } + + public List<NsScaleInfo> getNsScaleStatus() { + return nsScaleStatus; + } + + public void setNsScaleStatus(List<NsScaleInfo> nsScaleStatus) { + this.nsScaleStatus = nsScaleStatus; + } + + public List<AffinityOrAntiAffinityRule> getAdditionalAffinityOrAntiAffinityRule() { + return additionalAffinityOrAntiAffinityRule; + } + + public void setAdditionalAffinityOrAntiAffinityRule( + List<AffinityOrAntiAffinityRule> additionalAffinityOrAntiAffinityRule) { + this.additionalAffinityOrAntiAffinityRule = additionalAffinityOrAntiAffinityRule; + } + + public NsInstanceLinks get_links() { + return _links; + } + + public void set_links(NsInstanceLinks _links) { + this._links = _links; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsInstanceLinks.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsInstanceLinks.java new file mode 100644 index 0000000000..08b3c63c08 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsInstanceLinks.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; +import java.util.List; + +public class NsInstanceLinks { + @NotNull + private Link self; + private List<Link> nestedNsInstances; + private Link instantiate; + private Link terminate; + private Link update; + private Link scale; + private Link heal; + + public Link getSelf() { + return self; + } + + public void setSelf(Link self) { + this.self = self; + } + + public List<Link> getNestedNsInstances() { + return nestedNsInstances; + } + + public void setNestedNsInstances(List<Link> nestedNsInstances) { + this.nestedNsInstances = nestedNsInstances; + } + + public Link getInstantiate() { + return instantiate; + } + + public void setInstantiate(Link instantiate) { + this.instantiate = instantiate; + } + + public Link getTerminate() { + return terminate; + } + + public void setTerminate(Link terminate) { + this.terminate = terminate; + } + + public Link getUpdate() { + return update; + } + + public void setUpdate(Link update) { + this.update = update; + } + + public Link getScale() { + return scale; + } + + public void setScale(Link scale) { + this.scale = scale; + } + + public Link getHeal() { + return heal; + } + + public void setHeal(Link heal) { + this.heal = heal; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsLcmOpOcc.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsLcmOpOcc.java new file mode 100644 index 0000000000..559b1f7ba7 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsLcmOpOcc.java @@ -0,0 +1,125 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.onap.so.adapters.vfc.constant.CommonConstant; + +public class NsLcmOpOcc { + private String id; + private CommonConstant.operationState operationState; + private String statusEnteredTime; + private String nsInstanceId; + private CommonConstant.lcmOperationType lcmOperationType; + private String startTime; + private Boolean isAutomaticInvocation; + private String operationParams; + private Boolean isCancelPending; + private CommonConstant.cancelMode cancelMode; + private ProblemDetails error; + private Links links; + + public CommonConstant.lcmOperationType getLcmOperationType() { + return lcmOperationType; + } + + public void setLcmOperationType(CommonConstant.lcmOperationType lcmOperationType) { + this.lcmOperationType = lcmOperationType; + } + + public CommonConstant.cancelMode getCancelMode() { + return cancelMode; + } + + public void setCancelMode(CommonConstant.cancelMode cancelMode) { + this.cancelMode = cancelMode; + } + + public CommonConstant.operationState getOperationState() { + return operationState; + } + + public void setOperationState(CommonConstant.operationState operationState) { + this.operationState = operationState; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getStatusEnteredTime() { + return statusEnteredTime; + } + + public void setStatusEnteredTime(String statusEnteredTime) { + this.statusEnteredTime = statusEnteredTime; + } + + public String getNsInstanceId() { + return nsInstanceId; + } + + public void setNsInstanceId(String nsInstanceId) { + this.nsInstanceId = nsInstanceId; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public Boolean getAutomaticInvocation() { + return isAutomaticInvocation; + } + + public void setAutomaticInvocation(Boolean automaticInvocation) { + isAutomaticInvocation = automaticInvocation; + } + + public String getOperationParams() { + return operationParams; + } + + public void setOperationParams(String operationParams) { + this.operationParams = operationParams; + } + + public Boolean getCancelPending() { + return isCancelPending; + } + + public void setCancelPending(Boolean cancelPending) { + isCancelPending = cancelPending; + } + + public ProblemDetails getError() { + return error; + } + + public void setError(ProblemDetails error) { + this.error = error; + } + + public Links getLinks() { + return links; + } + + public void setLinks(Links links) { + this.links = links; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsLinkPortInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsLinkPortInfo.java new file mode 100644 index 0000000000..20c8972c98 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsLinkPortInfo.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; +import java.util.List; + +public class NsLinkPortInfo { + @NotNull + private String id; + @NotNull + private ResourceHandle resourceHandle; + private NsCpHandle nsCpHandle; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ResourceHandle getResourceHandle() { + return resourceHandle; + } + + public void setResourceHandle(ResourceHandle resourceHandle) { + this.resourceHandle = resourceHandle; + } + + public NsCpHandle getNsCpHandle() { + return nsCpHandle; + } + + public void setNsCpHandle(NsCpHandle nsCpHandle) { + this.nsCpHandle = nsCpHandle; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsScaleInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsScaleInfo.java new file mode 100644 index 0000000000..59acf564c2 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsScaleInfo.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; + +public class NsScaleInfo { + @NotNull + private String nsScalingAspectId; + @NotNull + private String nsScaleLevelId; + + public String getNsScalingAspectId() { + return nsScalingAspectId; + } + + public void setNsScalingAspectId(String nsScalingAspectId) { + this.nsScalingAspectId = nsScalingAspectId; + } + + public String getNsScaleLevelId() { + return nsScaleLevelId; + } + + public void setNsScaleLevelId(String nsScaleLevelId) { + this.nsScaleLevelId = nsScaleLevelId; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsVirtualLinkInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsVirtualLinkInfo.java new file mode 100644 index 0000000000..ed2debd2e6 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsVirtualLinkInfo.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; +import java.util.List; + +public class NsVirtualLinkInfo { + @NotNull + private String id; + @NotNull + private String nsVirtualLinkDescId; + @NotNull + private List<ResourceHandle> resourceHandle; + private List<NsLinkPortInfo> linkPort; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getNsVirtualLinkDescId() { + return nsVirtualLinkDescId; + } + + public void setNsVirtualLinkDescId(String nsVirtualLinkDescId) { + this.nsVirtualLinkDescId = nsVirtualLinkDescId; + } + + public List<ResourceHandle> getResourceHandle() { + return resourceHandle; + } + + public void setResourceHandle(List<ResourceHandle> resourceHandle) { + this.resourceHandle = resourceHandle; + } + + public List<NsLinkPortInfo> getLinkPort() { + return linkPort; + } + + public void setLinkPort(List<NsLinkPortInfo> linkPort) { + this.linkPort = linkPort; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ParamsForVnf.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ParamsForVnf.java new file mode 100644 index 0000000000..b7324e50fe --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ParamsForVnf.java @@ -0,0 +1,35 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import java.util.Map; + +public class ParamsForVnf { + private String vnfProfileId; + private Map<String, Object> additionalParams; + + public String getVnfProfileId() { + return vnfProfileId; + } + + public void setVnfProfileId(String vnfProfileId) { + this.vnfProfileId = vnfProfileId; + } + + public Map<String, Object> getAdditionalParams() { + return additionalParams; + } + + public void setAdditionalParams(Map<String, Object> additionalParams) { + this.additionalParams = additionalParams; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/PnfExtCpData.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/PnfExtCpData.java new file mode 100644 index 0000000000..d5d091fcb1 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/PnfExtCpData.java @@ -0,0 +1,44 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import java.util.List; + +public class PnfExtCpData { + private String cpInstanceI16; + private String cpdId; + private List<CpProtocolData> cpProtocolData; + + public String getCpInstanceI16() { + return cpInstanceI16; + } + + public void setCpInstanceI16(String cpInstanceI16) { + this.cpInstanceI16 = cpInstanceI16; + } + + public String getCpdId() { + return cpdId; + } + + public void setCpdId(String cpdId) { + this.cpdId = cpdId; + } + + public List<CpProtocolData> getCpProtocolData() { + return cpProtocolData; + } + + public void setCpProtocolData(List<CpProtocolData> cpProtocolData) { + this.cpProtocolData = cpProtocolData; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/PnfExtCpInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/PnfExtCpInfo.java new file mode 100644 index 0000000000..402cb83147 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/PnfExtCpInfo.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; +import java.util.List; + +public class PnfExtCpInfo { + @NotNull + private String cpInstanceId; + @NotNull + private String cpdId; + @NotNull + private List<CpProtocolData> cpProtocolData; + + public String getCpInstanceI16() { + return cpInstanceId; + } + + public void setCpInstanceI16(String cpInstanceI16) { + this.cpInstanceId = cpInstanceI16; + } + + public String getCpdId() { + return cpdId; + } + + public void setCpdId(String cpdId) { + this.cpdId = cpdId; + } + + public List<CpProtocolData> getCpProtocolData() { + return cpProtocolData; + } + + public void setCpProtocolData(List<CpProtocolData> cpProtocolData) { + this.cpProtocolData = cpProtocolData; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/PnfInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/PnfInfo.java new file mode 100644 index 0000000000..a1cc11bd0c --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/PnfInfo.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; +import java.util.List; + +public class PnfInfo { + + @NotNull + private String pnfId; + @NotNull + private String pnfName; + @NotNull + private String pnfdId; + @NotNull + private String pnfdInfoId; + @NotNull + private String pnfProfileId; + private List<PnfExtCpData> cpData; + + /*** + * + * @return id of pnf + */ + public String getPnfId() { + return pnfId; + } + + public void setPnfId(String pnfId) { + this.pnfId = pnfId; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String pnfName) { + this.pnfName = pnfName; + } + + public String getPnfdId() { + return pnfdId; + } + + public void setPnfdId(String pnfdId) { + this.pnfdId = pnfdId; + } + + public String getPnfProfileId() { + return pnfProfileId; + } + + public void setPnfProfileId(String pnfProfileId) { + this.pnfProfileId = pnfProfileId; + } + + public List<PnfExtCpData> getCpData() { + return cpData; + } + + public void setCpData(List<PnfExtCpData> cpData) { + this.cpData = cpData; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/PortRange.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/PortRange.java new file mode 100644 index 0000000000..8318a8ccff --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/PortRange.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; + +public class PortRange { + @NotNull + private int lowerPort; + @NotNull + private int upperPort; + + public int getLowerPort() { + return lowerPort; + } + + public void setLowerPort(int lowerPort) { + this.lowerPort = lowerPort; + } + + public int getUpperPort() { + return upperPort; + } + + public void setUpperPort(int upperPort) { + this.upperPort = upperPort; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ProblemDetails.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ProblemDetails.java new file mode 100644 index 0000000000..efaa5de7a8 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ProblemDetails.java @@ -0,0 +1,62 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class ProblemDetails { + private String type; + private String title; + private int status; + private String detail; + private String instance; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getDetail() { + return detail; + } + + public void setDetail(String detail) { + this.detail = detail; + } + + public String getInstance() { + return instance; + } + + public void setInstance(String instance) { + this.instance = instance; + } + + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ResourceChanges.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ResourceChanges.java new file mode 100644 index 0000000000..062a6aa32a --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ResourceChanges.java @@ -0,0 +1,71 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import java.util.List; + +public class ResourceChanges { + private List<AffectedVnf> affectedVnfs; + private List<AffectedPnf> affectedPnfs; + private List<AffectedVirtualLink> affectedVls; + private List<AffectedVnffg> affectedVnffgs; + private List<AffectedNs> affectedNss; + private List<AffectedSap> affectedSaps; + + public List<AffectedVnf> getAffectedVnfs() { + return affectedVnfs; + } + + public void setAffectedVnfs(List<AffectedVnf> affectedVnfs) { + this.affectedVnfs = affectedVnfs; + } + + public List<AffectedPnf> getAffectedPnfs() { + return affectedPnfs; + } + + public void setAffectedPnfs(List<AffectedPnf> affectedPnfs) { + this.affectedPnfs = affectedPnfs; + } + + public List<AffectedVirtualLink> getAffectedVls() { + return affectedVls; + } + + public void setAffectedVls(List<AffectedVirtualLink> affectedVls) { + this.affectedVls = affectedVls; + } + + public List<AffectedVnffg> getAffectedVnffgs() { + return affectedVnffgs; + } + + public void setAffectedVnffgs(List<AffectedVnffg> affectedVnffgs) { + this.affectedVnffgs = affectedVnffgs; + } + + public List<AffectedNs> getAffectedNss() { + return affectedNss; + } + + public void setAffectedNss(List<AffectedNs> affectedNss) { + this.affectedNss = affectedNss; + } + + public List<AffectedSap> getAffectedSaps() { + return affectedSaps; + } + + public void setAffectedSaps(List<AffectedSap> affectedSaps) { + this.affectedSaps = affectedSaps; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ResourceHandle.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ResourceHandle.java new file mode 100644 index 0000000000..fbfecaa007 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ResourceHandle.java @@ -0,0 +1,51 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class ResourceHandle { + private String vimId; + private String resourceProviderId; + private String resourceId; + private String vimLevelResourceType; + + public String getVimId() { + return vimId; + } + + public void setVimId(String vimId) { + this.vimId = vimId; + } + + public String getResourceProviderId() { + return resourceProviderId; + } + + public void setResourceProviderId(String resourceProviderId) { + this.resourceProviderId = resourceProviderId; + } + + public String getResourceId() { + return resourceId; + } + + public void setResourceId(String resourceId) { + this.resourceId = resourceId; + } + + public String getVimLevelResourceType() { + return vimLevelResourceType; + } + + public void setVimLevelResourceType(String vimLevelResourceType) { + this.vimLevelResourceType = vimLevelResourceType; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/SapData.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/SapData.java new file mode 100644 index 0000000000..d8e96e22f5 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/SapData.java @@ -0,0 +1,56 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import java.util.List; + +public class SapData { + private String sapdId; + private String sapName; + private String description; + private List<CpProtocolData> sapProtocolData; + + public String getSapdId() { + return sapdId; + } + + public void setSapdId(String sapdId) { + this.sapdId = sapdId; + } + + public String getSapName() { + return sapName; + } + + public void setSapName(String sapName) { + this.sapName = sapName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List<CpProtocolData> getSapProtocolData() { + return sapProtocolData; + } + + public void setSapProtocolData(List<CpProtocolData> sapProtocolData) { + this.sapProtocolData = sapProtocolData; + } + + + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/SapInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/SapInfo.java new file mode 100644 index 0000000000..182aceb127 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/SapInfo.java @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; +import java.util.List; + +public class SapInfo { + @NotNull + private String id; + @NotNull + private String sapdId; + @NotNull + private String sapName; + @NotNull + private String description; + @NotNull + private List<CpProtocolInfo> sapProtocolInfo; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getSapdId() { + return sapdId; + } + + public void setSapdId(String sapdId) { + this.sapdId = sapdId; + } + + public String getSapName() { + return sapName; + } + + public void setSapName(String sapName) { + this.sapName = sapName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List<CpProtocolInfo> getSapProtocolInfo() { + return sapProtocolInfo; + } + + public void setSapProtocolInfo(List<CpProtocolInfo> sapProtocolInfo) { + this.sapProtocolInfo = sapProtocolInfo; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfInstance.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfInstance.java new file mode 100644 index 0000000000..ccd6532ee0 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfInstance.java @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; +import java.util.Map; + +public class VnfInstance { + @NotNull + private String id; + private String vnfInstanceName; + private String vnfInstanceDescription; + @NotNull + private String vnfdId; + @NotNull + private String vnfProvider; + @NotNull + private String vnfProductName; + @NotNull + private String vnfSoftwareVersion; + @NotNull + private String vnfdVersion; + @NotNull + private String vnfPkgId; + private Map<String, Object> vnfConfigurableProperties; + private String vimId; + + private enum instantiationState { + NOT_INSTANTIATED, INSTANTIATED + }; + + private InstantiatedVnfInfo instantiatedVnfInfo; + private Map<String, Object> metadata; + private Map<String, Object> extensions; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getVnfInstanceName() { + return vnfInstanceName; + } + + public void setVnfInstanceName(String vnfInstanceName) { + this.vnfInstanceName = vnfInstanceName; + } + + public String getVnfInstanceDescription() { + return vnfInstanceDescription; + } + + public void setVnfInstanceDescription(String vnfInstanceDescription) { + this.vnfInstanceDescription = vnfInstanceDescription; + } + + public String getVnfdId() { + return vnfdId; + } + + public void setVnfdId(String vnfdId) { + this.vnfdId = vnfdId; + } + + public String getVnfProvider() { + return vnfProvider; + } + + public void setVnfProvider(String vnfProvider) { + this.vnfProvider = vnfProvider; + } + + public String getVnfProductName() { + return vnfProductName; + } + + public void setVnfProductName(String vnfProductName) { + this.vnfProductName = vnfProductName; + } + + public String getVnfSoftwareVersion() { + return vnfSoftwareVersion; + } + + public void setVnfSoftwareVersion(String vnfSoftwareVersion) { + this.vnfSoftwareVersion = vnfSoftwareVersion; + } + + public String getVnfdVersion() { + return vnfdVersion; + } + + public void setVnfdVersion(String vnfdVersion) { + this.vnfdVersion = vnfdVersion; + } + + public String getVnfPkgId() { + return vnfPkgId; + } + + public void setVnfPkgId(String vnfPkgId) { + this.vnfPkgId = vnfPkgId; + } + + public Map<String, Object> getVnfConfigurableProperties() { + return vnfConfigurableProperties; + } + + public void setVnfConfigurableProperties(Map<String, Object> vnfConfigurableProperties) { + this.vnfConfigurableProperties = vnfConfigurableProperties; + } + + public String getVimId() { + return vimId; + } + + public void setVimId(String vimId) { + this.vimId = vimId; + } + + public InstantiatedVnfInfo getInstantiatedVnfInfo() { + return instantiatedVnfInfo; + } + + public void setInstantiatedVnfInfo(InstantiatedVnfInfo instantiatedVnfInfo) { + this.instantiatedVnfInfo = instantiatedVnfInfo; + } + + public Map<String, Object> getMetadata() { + return metadata; + } + + public void setMetadata(Map<String, Object> metadata) { + this.metadata = metadata; + } + + public Map<String, Object> getExtensions() { + return extensions; + } + + public void setExtensions(Map<String, Object> extensions) { + this.extensions = extensions; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfInstanceData.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfInstanceData.java new file mode 100644 index 0000000000..83345fcb4c --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfInstanceData.java @@ -0,0 +1,33 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class VnfInstanceData { + private String vnfInstanceId; + private String vnfProfileId; + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public String getVnfProfileId() { + return vnfProfileId; + } + + public void setVnfProfileId(String vnfProfileId) { + this.vnfProfileId = vnfProfileId; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfLinkPortInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfLinkPortInfo.java new file mode 100644 index 0000000000..0b09d066fa --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfLinkPortInfo.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; + +public class VnfLinkPortInfo { + @NotNull + private String id; + @NotNull + private ResourceHandle resourceHandle; + private String cpInstanceId; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ResourceHandle getResourceHandle() { + return resourceHandle; + } + + public void setResourceHandle(ResourceHandle resourceHandle) { + this.resourceHandle = resourceHandle; + } + + public String getCpInstanceId() { + return cpInstanceId; + } + + public void setCpInstanceId(String cpInstanceId) { + this.cpInstanceId = cpInstanceId; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfLocationConstraint.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfLocationConstraint.java new file mode 100644 index 0000000000..5db3060b88 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfLocationConstraint.java @@ -0,0 +1,33 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +public class VnfLocationConstraint { + private String vnfProfileId; + private LocationConstraint locationConstraints; + + public String getVnfProfileId() { + return vnfProfileId; + } + + public void setVnfProfileId(String vnfProfileId) { + this.vnfProfileId = vnfProfileId; + } + + public LocationConstraint getLocationConstraints() { + return locationConstraints; + } + + public void setLocationConstraints(LocationConstraint locationConstraints) { + this.locationConstraints = locationConstraints; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfScaleInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfScaleInfo.java new file mode 100644 index 0000000000..e702edc821 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfScaleInfo.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; + +public class VnfScaleInfo { + @NotNull + private String aspectlId; + @NotNull + private int scaleLevel; + + public String getAspectlId() { + return aspectlId; + } + + public void setAspectlId(String aspectlId) { + this.aspectlId = aspectlId; + } + + public int getScaleLevel() { + return scaleLevel; + } + + public void setScaleLevel(int scaleLevel) { + this.scaleLevel = scaleLevel; + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfVirtualLinkResourceInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfVirtualLinkResourceInfo.java new file mode 100644 index 0000000000..9f41a383fc --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfVirtualLinkResourceInfo.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; +import java.util.List; +import java.util.Map; + +public class VnfVirtualLinkResourceInfo { + @NotNull + private String id; + @NotNull + private String virtualLinkDescId; + @NotNull + private ResourceHandle networkResource; + private String reservationId; + private List<VnfLinkPortInfo> vnfLinkPorts; + Map<String, Object> metadata; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getVirtualLinkDescId() { + return virtualLinkDescId; + } + + public void setVirtualLinkDescId(String virtualLinkDescId) { + this.virtualLinkDescId = virtualLinkDescId; + } + + public ResourceHandle getNetworkResource() { + return networkResource; + } + + public void setNetworkResource(ResourceHandle networkResource) { + this.networkResource = networkResource; + } + + public String getReservationId() { + return reservationId; + } + + public void setReservationId(String reservationId) { + this.reservationId = reservationId; + } + + public List<VnfLinkPortInfo> getVnfLinkPorts() { + return vnfLinkPorts; + } + + public void setVnfLinkPorts(List<VnfLinkPortInfo> vnfLinkPorts) { + this.vnfLinkPorts = vnfLinkPorts; + } + + public Map<String, Object> getMetadata() { + return metadata; + } + + public void setMetadata(Map<String, Object> metadata) { + this.metadata = metadata; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfcCpInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfcCpInfo.java new file mode 100644 index 0000000000..ec629effd2 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfcCpInfo.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; +import java.util.List; + +public class VnfcCpInfo { + @NotNull + private String id; + @NotNull + private String cpdId; + private String vnfExtCpId; + private List<CpProtocolInfo> cpProtocolInfo; + private String vnfLinkPortId; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getCpdId() { + return cpdId; + } + + public void setCpdId(String cpdId) { + this.cpdId = cpdId; + } + + public String getVnfExtCpId() { + return vnfExtCpId; + } + + public void setVnfExtCpId(String vnfExtCpId) { + this.vnfExtCpId = vnfExtCpId; + } + + public List<CpProtocolInfo> getCpProtocolInfo() { + return cpProtocolInfo; + } + + public void setCpProtocolInfo(List<CpProtocolInfo> cpProtocolInfo) { + this.cpProtocolInfo = cpProtocolInfo; + } + + public String getVnfLinkPortId() { + return vnfLinkPortId; + } + + public void setVnfLinkPortId(String vnfLinkPortId) { + this.vnfLinkPortId = vnfLinkPortId; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfcResourceInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfcResourceInfo.java new file mode 100644 index 0000000000..1f7aa67b8d --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnfcResourceInfo.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; +import java.util.List; +import java.util.Map; + +public class VnfcResourceInfo { + @NotNull + private String id; + @NotNull + private String vduId; + @NotNull + private ResourceHandle computeResource; + private List<String> storageResourceIds; + private String reservationId; + private List<VnfcCpInfo> vnfcCpInfo; + private Map<String, Object> metadata; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getVduId() { + return vduId; + } + + public void setVduId(String vduId) { + this.vduId = vduId; + } + + public ResourceHandle getComputeResource() { + return computeResource; + } + + public void setComputeResource(ResourceHandle computeResource) { + this.computeResource = computeResource; + } + + public List<String> getStorageResourceIds() { + return storageResourceIds; + } + + public void setStorageResourceIds(List<String> storageResourceIds) { + this.storageResourceIds = storageResourceIds; + } + + public String getReservationId() { + return reservationId; + } + + public void setReservationId(String reservationId) { + this.reservationId = reservationId; + } + + public List<VnfcCpInfo> getVnfcCpInfo() { + return vnfcCpInfo; + } + + public void setVnfcCpInfo(List<VnfcCpInfo> vnfcCpInfo) { + this.vnfcCpInfo = vnfcCpInfo; + } + + public Map<String, Object> getMetadata() { + return metadata; + } + + public void setMetadata(Map<String, Object> metadata) { + this.metadata = metadata; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnffgInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnffgInfo.java new file mode 100644 index 0000000000..c02d5177db --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VnffgInfo.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import javax.validation.constraints.NotNull; +import java.util.List; + +public class VnffgInfo { + @NotNull + private String id; + @NotNull + private String vnffgdId; + @NotNull + private List<String> vnfInstanceId; + private String pnfInfoId; + @NotNull + private List<String> nsVirtualLinkInfoId; + @NotNull + private List<NsCpHandle> nsCpHandle; + @NotNull + private List<NfpInfo> nfpInfo; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getVnffgdId() { + return vnffgdId; + } + + public void setVnffgdId(String vnffgdId) { + this.vnffgdId = vnffgdId; + } + + public List<String> getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(List<String> vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public String getPnfInfoId() { + return pnfInfoId; + } + + public void setPnfInfoId(String pnfInfoId) { + this.pnfInfoId = pnfInfoId; + } + + public List<String> getNsVirtualLinkInfoId() { + return nsVirtualLinkInfoId; + } + + public void setNsVirtualLinkInfoId(List<String> nsVirtualLinkInfoId) { + this.nsVirtualLinkInfoId = nsVirtualLinkInfoId; + } + + public List<NsCpHandle> getNsCpHandle() { + return nsCpHandle; + } + + public void setNsCpHandle(List<NsCpHandle> nsCpHandle) { + this.nsCpHandle = nsCpHandle; + } + + public List<NfpInfo> getNfpInfo() { + return nfpInfo; + } + + public void setNfpInfo(List<NfpInfo> nfpInfo) { + this.nfpInfo = nfpInfo; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcAdapterRest.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcAdapterRest.java index bb9ae69f51..5a89c04a5a 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcAdapterRest.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcAdapterRest.java @@ -37,6 +37,8 @@ import org.onap.so.adapters.vfc.model.NsOperationKey; import org.onap.so.adapters.vfc.model.RestfulResponse; import org.onap.so.adapters.vfc.util.JsonUtil; import org.onap.so.adapters.vfc.util.ValidateUtil; +import org.onap.so.db.request.beans.InstanceNfvoMapping; +import org.onap.so.db.request.data.repository.InstanceNfvoMappingRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -58,7 +60,12 @@ public class VfcAdapterRest { private static final String REQUEST_DEBUG_MSG = "body from request is {}"; private static final String APPLICATION_EXCEPTION = "ApplicationException: "; @Autowired + private VfcManagerSol005 vfcManagerSol005; + + @Autowired private VfcManager driverMgr; + @Autowired + private InstanceNfvoMappingRepository instanceNfvoMappingRepository; public VfcAdapterRest() { @@ -80,7 +87,13 @@ public class VfcAdapterRest { ValidateUtil.assertObjectNotNull(data); logger.debug(REQUEST_DEBUG_MSG + data); NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class); - RestfulResponse rsp = driverMgr.createNs(nsInput); + RestfulResponse rsp; + if (nsInput.getNsParameters().getAdditionalParamForNs().containsKey("isSol005Interface")) { + rsp = vfcManagerSol005.createNs(nsInput); + } else { + rsp = driverMgr.createNs(nsInput); + } + return buildResponse(rsp); } catch (ApplicationException e) { logger.debug(APPLICATION_EXCEPTION, e); @@ -106,7 +119,13 @@ public class VfcAdapterRest { ValidateUtil.assertObjectNotNull(data); logger.debug(REQUEST_DEBUG_MSG + data); NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class); - RestfulResponse rsp = driverMgr.deleteNs(nsOperationKey, nsInstanceId); + RestfulResponse rsp; + InstanceNfvoMapping instanceNfvoMapping = instanceNfvoMappingRepository.findOneByInstanceId(nsInstanceId); + if (instanceNfvoMapping != null) { + rsp = vfcManagerSol005.deleteNs(nsOperationKey, nsInstanceId); + } else { + rsp = driverMgr.deleteNs(nsOperationKey, nsInstanceId); + } return buildResponse(rsp); } catch (ApplicationException e) { logger.debug(APPLICATION_EXCEPTION, e); @@ -131,7 +150,13 @@ public class VfcAdapterRest { ValidateUtil.assertObjectNotNull(data); logger.debug(REQUEST_DEBUG_MSG + data); NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class); - RestfulResponse rsp = driverMgr.getNsProgress(nsOperationKey, jobId); + RestfulResponse rsp; + InstanceNfvoMapping instanceNfvoMapping = instanceNfvoMappingRepository.findOneByJobId(jobId); + if (instanceNfvoMapping != null) { + rsp = vfcManagerSol005.getNsProgress(nsOperationKey, jobId); + } else { + rsp = driverMgr.getNsProgress(nsOperationKey, jobId); + } return buildResponse(rsp); } catch (ApplicationException e) { logger.debug(APPLICATION_EXCEPTION, e); @@ -156,7 +181,12 @@ public class VfcAdapterRest { ValidateUtil.assertObjectNotNull(data); logger.debug(REQUEST_DEBUG_MSG + data); NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class); - RestfulResponse rsp = driverMgr.instantiateNs(nsInstanceId, nsInput); + RestfulResponse rsp; + if (nsInput.getNsParameters().getAdditionalParamForNs().containsKey("isSol005Interface")) { + rsp = vfcManagerSol005.instantiateNs(nsInstanceId, nsInput); + } else { + rsp = driverMgr.instantiateNs(nsInstanceId, nsInput); + } return buildResponse(rsp); } catch (ApplicationException e) { logger.debug(APPLICATION_EXCEPTION, e); @@ -181,7 +211,14 @@ public class VfcAdapterRest { ValidateUtil.assertObjectNotNull(data); logger.debug(REQUEST_DEBUG_MSG + data); NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class); - RestfulResponse rsp = driverMgr.terminateNs(nsOperationKey, nsInstanceId); + RestfulResponse rsp; + InstanceNfvoMapping instanceNfvoMapping = instanceNfvoMappingRepository.findOneByInstanceId(nsInstanceId); + if (instanceNfvoMapping != null) { + rsp = vfcManagerSol005.terminateNs(nsOperationKey, nsInstanceId); + } else { + rsp = driverMgr.terminateNs(nsOperationKey, nsInstanceId); + } + return buildResponse(rsp); } catch (ApplicationException e) { logger.debug(APPLICATION_EXCEPTION, e); diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcManagerSol005.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcManagerSol005.java new file mode 100644 index 0000000000..9033becf8a --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/rest/VfcManagerSol005.java @@ -0,0 +1,620 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.rest; + +import java.time.LocalDateTime; +import java.util.*; +import org.onap.so.adapters.vfc.constant.CommonConstant; +import org.onap.so.adapters.vfc.constant.CommonConstant.Step; +import org.onap.so.adapters.vfc.constant.DriverExceptionID; +import org.onap.so.adapters.vfc.constant.HttpCode; +import org.onap.so.adapters.vfc.exceptions.ApplicationException; +import org.onap.so.adapters.vfc.model.*; +import org.onap.so.adapters.vfc.util.JsonUtil; +import org.onap.so.adapters.vfc.util.RestfulUtil; +import org.onap.so.adapters.vfc.util.ValidateUtil; +import org.onap.so.db.request.beans.InstanceNfvoMapping; +import org.onap.so.db.request.beans.OperationStatus; +import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.onap.so.db.request.data.repository.InstanceNfvoMappingRepository; +import org.onap.so.db.request.data.repository.OperationStatusRepository; +import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.onap.so.requestsdb.RequestsDbConstant; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Primary; +import org.springframework.data.domain.Example; +import org.springframework.stereotype.Component; + +/** + * VF-C Manager <br> + * <p> + * </p> + * + * @author + * @version ONAP Amsterdam Release 2017-08-28 + */ +@Component +@Primary +public class VfcManagerSol005 { + + private static final Logger LOGGER = LoggerFactory.getLogger(VfcManagerSol005.class); + + /** + * nfvo url map + */ + private Map<String, String> nfvoUrlMap; + + @Autowired + private ResourceOperationStatusRepository resourceOperationStatusRepository; + + @Autowired + private RestfulUtil restfulUtil; + + @Autowired + private OperationStatusRepository operationStatusRepository; + + @Autowired + private InstanceNfvoMappingRepository instanceNfvoMappingRepository; + + private InstanceNfvoMapping instanceNfvoMapping = new InstanceNfvoMapping(); + + public VfcManagerSol005() { + nfvoUrlMap = new HashMap<>(); + nfvoUrlMap.put(Step.CREATE, CommonConstant.SOL005_NFVO_CREATE_URL); + nfvoUrlMap.put(Step.INSTANTIATE, CommonConstant.SOL005_NFVO_INSTANTIATE_URL); + nfvoUrlMap.put(Step.TERMINATE, CommonConstant.SOL005_NFVO_TERMINATE_URL); + nfvoUrlMap.put(Step.DELETE, CommonConstant.SOL005_NFVO_DELETE_URL); + nfvoUrlMap.put(Step.QUERY, CommonConstant.SOL005_NFVO_QUERY_URL); + nfvoUrlMap.put(Step.SCALE, CommonConstant.NFVO_SCALE_URL); + } + + /** + * create network service <br> + * + * @param segInput input parameters for current node from http request + * @return + * @since ONAP Dubilin Release + */ + public RestfulResponse createNs(NSResourceInputParameter segInput) throws ApplicationException { + + Map<String, String> nfvoDetails; + // Step1: get service template by node type + String nsdId = segInput.getNsServiceModelUUID(); + // nsdId for NFVO is "id" in the response, while for SDNO is "servcice template id" + LOGGER.info("serviceTemplateId is {}, id is {}", nsdId, nsdId); + + + LOGGER.info("SOL005 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 + CreateNsRequest createNsRequest = new CreateNsRequest(); + createNsRequest.setNsDescription(segInput.getNsServiceDescription()); + createNsRequest.setNsdId(segInput.getNsServiceModelUUID()); + createNsRequest.setNsName(segInput.getNsServiceName()); + + String createReq = JsonUtil.marshal(createNsRequest); + RestfulResponse aaiRestfulResponse = null; + NsParameters nsParameters = segInput.getNsParameters(); + if (nsParameters.getAdditionalParamForNs().containsKey("orchestrator")) { + if (nsParameters.getAdditionalParamForNs().get("orchestrator") != null) { + String nfvo = nsParameters.getAdditionalParamForNs().get("nfvo").toString(); + aaiRestfulResponse = restfulUtil.getNfvoFromAAI(nfvo); + nfvoDetails = JsonUtil.unMarshal(aaiRestfulResponse.getResponseContent(), Map.class); + url = nfvoDetails.get("url") + nfvoDetails.get("api-root") + url; + + } + } else { + LOGGER.error("Nfvo not present in AAI"); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_CREATE_NS); + } + + + // Prepare request header for createNs request. + Map<String, String> requestHeader = new HashMap<>(); + requestHeader.put("GLOBALCUSTOMERID", segInput.getNsOperationKey().getGlobalSubscriberId()); + requestHeader.put("SERVICETYPE", segInput.getNsOperationKey().getServiceType()); + + // Step4: Call NFVO or SDNO lcm to create ns + LOGGER.info("Request Payload for CreateNs: " + createReq); + + RestfulResponse createRsp = restfulUtil.send(url, methodType, createReq, requestHeader); + 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 status = new ResourceOperationStatus(segInput.getNsOperationKey().getServiceId(), + segInput.getNsOperationKey().getOperationId(), segInput.getNsOperationKey().getNodeTemplateUUID()); + status.setStatus(RequestsDbConstant.Status.PROCESSING); + status = resourceOperationStatusRepository.save(status); + if (!HttpCode.isSucess(createRsp.getStatus())) { + LOGGER.error("update segment operation status : fail to create ns"); + status.setProgress("40"); + status.setStatusDescription("NS not created"); + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setErrorCode(String.valueOf(createRsp.getStatus())); + resourceOperationStatusRepository.save(status); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_CREATE_NS); + } + // TODO: Capture all the content of the response. Currently fetching ID value alone. + // Should be converted into the NsInstance.class + @SuppressWarnings("unchecked") + Map<String, String> rsp = JsonUtil.unMarshal(createRsp.getResponseContent(), Map.class); + String nsInstanceId = rsp.get(CommonConstant.SOL005_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); + } + + nfvoDetails = JsonUtil.unMarshal(aaiRestfulResponse.getResponseContent(), Map.class); + instanceNfvoMapping.setInstanceId(nsInstanceId); + instanceNfvoMapping.setPassword(nfvoDetails.get("password")); + instanceNfvoMapping.setUsername(nfvoDetails.get("userName")); + instanceNfvoMapping.setNfvoName(nfvoDetails.get("nfvoId")); + instanceNfvoMapping.setEndpoint(nfvoDetails.get("url")); + instanceNfvoMapping.setApiRoot(nfvoDetails.get("api-root")); + instanceNfvoMappingRepository.save(instanceNfvoMapping); + 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 Dublin Release + */ + public RestfulResponse deleteNs(NsOperationKey nsOperationKey, String nsInstanceId) throws ApplicationException { + LOGGER.info("SOL005 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 status = new ResourceOperationStatus(nsOperationKey.getServiceId(), + nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID()); + if (!HttpCode.isSucess(deleteRsp.getStatus())) { + LOGGER.error("fail to delete ns"); + + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setErrorCode(String.valueOf(deleteRsp.getStatus())); + status.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED); + resourceOperationStatusRepository.save(status); + 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 + status.setStatus(RequestsDbConstant.Status.FINISHED); + status.setErrorCode(String.valueOf(deleteRsp.getStatus())); + status.setProgress("100"); + status.setStatusDescription("VFC resource deletion finished"); + resourceOperationStatusRepository.save(status); + 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 Dublin Release + */ + public RestfulResponse instantiateNs(String nsInstanceId, NSResourceInputParameter segInput) + throws ApplicationException { + // Call the NFVO or SDNO service to instantiate service + LOGGER.info("SOL005 instantiate ns -> begin"); + + // Step1: Prepare restful parameters and options + InstantiateNsRequest instantiateNsRequest = new InstantiateNsRequest(); + + NsInstantiateReq oRequest = new NsInstantiateReq(); + oRequest.setNsInstanceId(nsInstanceId); + NsParameters nsParameters = segInput.getNsParameters(); + + ArrayList<VnfLocationConstraint> vnfLocationConstraints = new ArrayList<VnfLocationConstraint>(); + for (LocationConstraint locationConstraint : nsParameters.getLocationConstraints()) { + VnfLocationConstraint vnfLocationConstraint = new VnfLocationConstraint(); + vnfLocationConstraint.setVnfProfileId(locationConstraint.getVnfProfileId()); + vnfLocationConstraint.setLocationConstraints(null); + vnfLocationConstraints.add(vnfLocationConstraint); + + } + instantiateNsRequest.setAditionalParamsForNs(nsParameters.getAdditionalParamForNs()); + // Setting FlavourID which is a mandatory paramater to default + // as UUI is not sending this parameter to so + instantiateNsRequest.setNsFlavourId("default"); + String instReq = JsonUtil.marshal(instantiateNsRequest); + LOGGER.info("Request Payload for InstantiateNs: " + instReq); + // Step2: prepare url and + String url = getUrl(nsInstanceId, CommonConstant.Step.INSTANTIATE); + String methodType = CommonConstant.MethodType.POST; + instanceNfvoMapping = instanceNfvoMappingRepository.findOneByInstanceId(nsInstanceId); + + if (instanceNfvoMapping != null) { + + url = instanceNfvoMapping.getEndpoint() + instanceNfvoMapping.getApiRoot() + url; + + } else { + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_INSTANTIATE_NS); + + } + // Step3: prepare restful parameters and options + Map<String, String> reqBody = new HashMap<>(); + reqBody.put("terminationTime", LocalDateTime.now().toString()); + RestfulResponse instRsp = restfulUtil.send(url, methodType, instReq); + ResourceOperationStatus status = new ResourceOperationStatus(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"); + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setErrorCode(String.valueOf(instRsp.getStatus())); + status.setStatusDescription(CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED); + resourceOperationStatusRepository.save(status); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_INSTANTIATE_NS); + } + LOGGER.info("instantiate ns response status is : {}", instRsp.getStatus()); + LOGGER.info("response payload is {}", instRsp.getResponseContent()); + String jobId = null; + if (instRsp.getStatus() == 202) { + String jobUri = instRsp.getRespHeaderStr(CommonConstant.JOB_URI); + LOGGER.info("JOB URI" + jobUri); + jobId = jobUri.split("/")[4]; + if (ValidateUtil.isStrEmpty(jobId)) { + LOGGER.error("Invalid jobId from instantiate operation"); + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setErrorCode(String.valueOf(instRsp.getStatus())); + status.setStatusDescription(CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED); + resourceOperationStatusRepository.save(status); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, + DriverExceptionID.INVALID_RESPONSE_FROM_INSTANTIATE_OPERATION); + } + + } else if (instRsp.getStatus() > 400 && instRsp.getStatus() < 600) { + LOGGER.error("ERROR while executing instantiateNs request"); + ProblemDetails problemDetails = JsonUtil.unMarshal(instRsp.getResponseContent(), ProblemDetails.class); + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setErrorCode(String.valueOf(instRsp.getStatus())); + status.setStatusDescription(CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED + problemDetails.getDetail()); + resourceOperationStatusRepository.save(status); + if (instRsp.getStatus() == 406) { + throw new ApplicationException(HttpCode.NOT_ACCEPTABLE, DriverExceptionID.FAIL_TO_INSTANTIATE_NS); + } else if (instRsp.getStatus() == 400) { + throw new ApplicationException(HttpCode.BAD_REQUEST, DriverExceptionID.FAIL_TO_INSTANTIATE_NS); + } else if (instRsp.getStatus() == 404) { + throw new ApplicationException(HttpCode.NOT_FOUND, DriverExceptionID.FAIL_TO_INSTANTIATE_NS); + } else if (instRsp.getStatus() == 409) { + LOGGER.error("The operation cannot be executed currently,\n" + + "due to a conflict with the state of the resource"); + throw new ApplicationException(HttpCode.RESPOND_CONFLICT, DriverExceptionID.FAIL_TO_INSTANTIATE_NS); + } else if (instRsp.getStatus() == 500) { + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, + DriverExceptionID.FAIL_TO_INSTANTIATE_NS); + } else { + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, + DriverExceptionID.FAIL_TO_INSTANTIATE_NS); + } + + } + LOGGER.info("Job id is " + jobId); + LOGGER.info("Nfvo Details" + instanceNfvoMapping.toString()); + LOGGER.info("instantiate ns -> end"); + // Step 3: update segment operation job id + LOGGER.info("update resource operation status job id -> begin"); + status.setJobId(jobId); + status.setProgress("100"); + status.setStatusDescription("NS initiation completed."); + resourceOperationStatusRepository.save(status); + instanceNfvoMapping.setJobId(jobId); + instanceNfvoMappingRepository.save(instanceNfvoMapping); + LOGGER.info("update segment operation job id -> end" + instanceNfvoMapping.toString()); + return instRsp; + } + + /** + * terminate network service <br> + * + * @param nsOperationKey The operation key for NS resource + * @param nsInstanceId The NS instance id + * @return + * @since ONAP Dublin 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 status = new ResourceOperationStatus(nsOperationKey.getServiceId(), + nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID()); + status.setStatus(RequestsDbConstant.Status.PROCESSING); + resourceOperationStatusRepository.save(status); + + LOGGER.info("SOL005 terminate ns -> begin"); + // Step2: prepare url and method type + String url = getUrl(nsInstanceId, CommonConstant.Step.TERMINATE); + String methodType = CommonConstant.MethodType.POST; + + instanceNfvoMapping = instanceNfvoMappingRepository.findOneByInstanceId(nsInstanceId); + + if (instanceNfvoMapping != null) { + + url = instanceNfvoMapping.getEndpoint() + instanceNfvoMapping.getApiRoot() + url; + + } else { + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_TERMINATE_NS); + } + // Step3: prepare restful parameters and options + Map<String, String> reqBody = new HashMap<>(); + reqBody.put("terminationTime", LocalDateTime.now().toString()); + + // Step4: Call the NFVO or SDNO service to terminate service + LOGGER.info("request body for terminate NS" + JsonUtil.marshal(reqBody)); + 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 terminate ns"); + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setErrorCode(String.valueOf(terminateRsp.getStatus())); + status.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED); + resourceOperationStatusRepository.save(status); + + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_TERMINATE_NS); + } + // @SuppressWarnings("unchecked") + String jobId = null; + Map<String, String> rsp = new HashMap<>(); + if (terminateRsp.getStatus() == 202) { + String jobUri = terminateRsp.getRespHeaderStr(CommonConstant.JOB_URI); + jobId = jobUri.split("/")[4]; + jobId.split("/"); + if (ValidateUtil.isStrEmpty(jobId)) { + LOGGER.error("Invalid jobId from instantiate operation"); + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setErrorCode(String.valueOf(terminateRsp.getStatus())); + status.setStatusDescription(CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED); + resourceOperationStatusRepository.save(status); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, + DriverExceptionID.INVALID_RESPONSE_FROM_INSTANTIATE_OPERATION); + } + rsp.put(CommonConstant.JOB_ID, jobId); + LOGGER.info("terminate ns -> end"); + LOGGER.info("update segment job id -> begin"); + status.setProgress("60"); + status.setStatusDescription("NS is termination completed"); + status.setJobId(jobId); + resourceOperationStatusRepository.save(status); + LOGGER.info("update segment job id -> end"); + } else if (terminateRsp.getStatus() > 400 && terminateRsp.getStatus() < 600) { + LOGGER.error("ERROR while executing instantiateNs request"); + ProblemDetails problemDetails = JsonUtil.unMarshal(terminateRsp.getResponseContent(), ProblemDetails.class); + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setErrorCode(String.valueOf(terminateRsp.getStatus())); + status.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED + problemDetails.getDetail()); + resourceOperationStatusRepository.save(status); + if (terminateRsp.getStatus() == 406) { + throw new ApplicationException(HttpCode.NOT_ACCEPTABLE, DriverExceptionID.FAIL_TO_TERMINATE_NS); + } else if (terminateRsp.getStatus() == 400) { + throw new ApplicationException(HttpCode.BAD_REQUEST, DriverExceptionID.FAIL_TO_TERMINATE_NS); + } else if (terminateRsp.getStatus() == 404) { + throw new ApplicationException(HttpCode.NOT_FOUND, DriverExceptionID.FAIL_TO_TERMINATE_NS); + } else if (terminateRsp.getStatus() == 409) { + LOGGER.error("The operation cannot be executed currently,\n" + + "due to a conflict with the state of the resource"); + throw new ApplicationException(HttpCode.RESPOND_CONFLICT, DriverExceptionID.FAIL_TO_TERMINATE_NS); + } else if (terminateRsp.getStatus() == 500) { + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_TERMINATE_NS); + } else { + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_TERMINATE_NS); + } + + } + instanceNfvoMapping.setJobId(jobId); + instanceNfvoMappingRepository.save(instanceNfvoMapping); + terminateRsp.setResponseContent(rsp.toString()); + return terminateRsp; + } + + /** + * get ns progress by job Id <br> + * + * @param nsOperationKey The OperationKey for NS resource + * @param jobId the job id + * @return + * @since ONAP Dublin Release + */ + public RestfulResponse getNsProgress(NsOperationKey nsOperationKey, String jobId) throws ApplicationException { + + ValidateUtil.assertObjectNotNull(jobId); + // Step 1: query the current resource operation status + ResourceOperationStatus status = new ResourceOperationStatus(nsOperationKey.getServiceId(), + nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID()); + // status = resourceOperationStatusRepository.findOne(Example.of(status)) + // .orElseThrow(() -> new ApplicationException(404, "Cannot Find Operation Status")); + + // Get NFVO details + instanceNfvoMapping = instanceNfvoMappingRepository.findOneByJobId(jobId); + + // Step 2: start query + LOGGER.info("SOL005 query ns status -> begin"); + String url = getUrl(jobId, CommonConstant.Step.QUERY); + String methodType = CommonConstant.MethodType.GET; + if (instanceNfvoMapping != null) { + + url = instanceNfvoMapping.getEndpoint() + instanceNfvoMapping.getApiRoot() + url; + + } else { + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_QUERY_JOB_STATUS); + } + + // 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"); + ProblemDetails problemDetails = JsonUtil.unMarshal(rsp.getResponseContent(), ProblemDetails.class); + status.setErrorCode(String.valueOf(rsp.getStatus())); + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setStatusDescription(CommonConstant.StatusDesc.QUERY_JOB_STATUS_FAILED + problemDetails.getDetail()); + resourceOperationStatusRepository.save(status); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_QUERY_JOB_STATUS); + } + // Step 4: Process Network Service Instantiate Response + NsLcmOpOcc nsProgress = JsonUtil.unMarshal(rsp.getResponseContent(), NsLcmOpOcc.class); + if (CommonConstant.operationState.FAILED.equals(nsProgress.getOperationState())) { + LOGGER.info("NS instantiate fails"); + status.setErrorCode(String.valueOf(rsp.getStatus())); + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setStatusDescription( + CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED + nsProgress.getError().getDetail()); + resourceOperationStatusRepository.save(status); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_QUERY_JOB_STATUS); + } + // Step 5: update segment operation progress + + if (nsProgress.getOperationState().equals(CommonConstant.operationState.PROCESSING)) { + status.setProgress("40"); + status.setStatus(RequestsDbConstant.Status.PROCESSING); + status.setStatusDescription("NS operation is in progress"); + resourceOperationStatusRepository.save(status); + updateOperationStatusBasedOnResourceStatus(status); + } else if (nsProgress.getOperationState().equals(CommonConstant.operationState.PARTIALLY_COMPLETED)) { + status.setProgress("60"); + status.setStatus(RequestsDbConstant.Status.PROCESSING); + status.setStatusDescription("NS operation is partially completed"); + resourceOperationStatusRepository.save(status); + } else if (nsProgress.getOperationState().equals(CommonConstant.operationState.COMPLETED)) { + status.setStatus(RequestsDbConstant.Status.FINISHED); + status.setProgress("100"); + status.setStatusDescription("NS operation is Completed"); + resourceOperationStatusRepository.save(status); + updateOperationStatusBasedOnResourceStatus(status); + + } else if (nsProgress.getOperationState().equals(CommonConstant.operationState.FAILED) + || nsProgress.getOperationState().equals(CommonConstant.operationState.FAILED_TEMP)) { + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setProgress("0"); + status.setStatusDescription("NS operation Failed"); + resourceOperationStatusRepository.save(status); + updateOperationStatusBasedOnResourceStatus(status); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.JOB_STATUS_ERROR); + } else { + LOGGER.error("unexcepted response status"); + + } + return rsp; + } + + /** + * 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 Dublin Release + */ + private String getUrl(String variable, String step) { + + String url; + String originalUrl; + originalUrl = nfvoUrlMap.get(step); + url = String.format(originalUrl, variable); + return url; + + } + + private void updateOperationStatusBasedOnResourceStatus(ResourceOperationStatus operStatus) { + String serviceId = operStatus.getServiceId(); + String operationId = operStatus.getOperationId(); + + LOGGER.debug("Request database - update Operation Status Based On Resource Operation Status with service Id: " + + "{}, operationId: {}", serviceId, operationId); + + List<ResourceOperationStatus> lstResourceStatus = + resourceOperationStatusRepository.findByServiceIdAndOperationId(serviceId, operationId); + if (lstResourceStatus == null) { + LOGGER.error("Unable to retrieve resourceOperStatus Object by ServiceId: {} operationId: {}", serviceId, + operationId); + return; + } + + // count the total progress + int resourceCount = lstResourceStatus.size(); + int progress = 0; + boolean isFinished = true; + for (ResourceOperationStatus lstResourceStatu : lstResourceStatus) { + progress = progress + Integer.valueOf(lstResourceStatu.getProgress()) / resourceCount; + if (RequestsDbConstant.Status.PROCESSING.equals(lstResourceStatu.getStatus())) { + isFinished = false; + } + } + + OperationStatus serviceOperStatus = + operationStatusRepository.findOneByServiceIdAndOperationId(serviceId, operationId); + if (serviceOperStatus == null) { + String error = "Entity not found. Unable to retrieve OperationStatus Object ServiceId: " + serviceId + + " operationId: " + operationId; + LOGGER.error(error); + + serviceOperStatus = new OperationStatus(); + serviceOperStatus.setOperationId(operationId); + serviceOperStatus.setServiceId(serviceId); + } + + progress = progress > 100 ? 100 : progress; + serviceOperStatus.setProgress(String.valueOf(progress)); + serviceOperStatus.setOperationContent(operStatus.getStatusDescription()); + // if current resource failed. service failed. + if (RequestsDbConstant.Status.ERROR.equals(operStatus.getStatus())) { + serviceOperStatus.setResult(RequestsDbConstant.Status.ERROR); + serviceOperStatus.setReason(operStatus.getStatusDescription()); + } else if (isFinished) { + // if finished + serviceOperStatus.setResult(RequestsDbConstant.Status.FINISHED); + serviceOperStatus.setProgress(RequestsDbConstant.Progress.ONE_HUNDRED); + } + + operationStatusRepository.save(serviceOperStatus); + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java index 647fcafa66..984cdb8016 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java @@ -26,8 +26,13 @@ package org.onap.so.adapters.vfc.util; import java.net.HttpURLConnection; import java.net.SocketTimeoutException; +import java.util.Base64; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import javax.ws.rs.core.UriBuilder; import org.onap.so.logger.LoggingAnchor; +import org.apache.http.Header; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.config.RequestConfig; @@ -102,9 +107,10 @@ public class RestfulUtil { } - public RestfulResponse send(String url, String methodType, String content) { - String msbUrl = getMsbHost() + url; - logger.debug("Begin to sent message {}: {}", methodType, msbUrl); + + public RestfulResponse send(String msbUrl, String methodType, String content, Map<String, String> requestHeader) { + // String msbUrl = getMsbHost() + url; + logger.debug("Begin to sent message " + methodType + ": " + msbUrl); HttpRequestBase method = null; HttpResponse httpResponse = null; @@ -115,9 +121,14 @@ public class RestfulUtil { RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(timeout).setConnectTimeout(timeout) .setConnectionRequestTimeout(timeout).build(); + HttpClient client = HttpClientBuilder.create().build(); + if ("POST".equalsIgnoreCase(methodType)) { HttpPost httpPost = new HttpPost(msbUrl); httpPost.setConfig(requestConfig); + for (String key : requestHeader.keySet()) { + httpPost.setHeader(key, requestHeader.get(key)); + } httpPost.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON)); method = httpPost; } else if ("PUT".equalsIgnoreCase(methodType)) { @@ -135,11 +146,24 @@ public class RestfulUtil { method = httpDelete; } - httpResponse = client.execute(method); + // now VFC have no auth + // String userCredentials = + // SDNCAdapterProperties.getEncryptedProperty(Constants.SDNC_AUTH_PROP, + // Constants.DEFAULT_SDNC_AUTH, Constants.ENCRYPTION_KEY); + // String authorization = "Basic " + + // DatatypeConverter.printBase64Binary(userCredentials.getBytes()); + // method.setHeader("Authorization", authorization); + httpResponse = client.execute(method); + Map<String, String> responseHeader = new HashMap<>(); String responseContent = null; if (httpResponse.getEntity() != null) { responseContent = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); + Header[] httpResponseAllHeaders = httpResponse.getAllHeaders(); + for (Header header : httpResponseAllHeaders) { + responseHeader.put(header.getName(), header.getValue()); + + } } int statusCode = httpResponse.getStatusLine().getStatusCode(); @@ -163,7 +187,115 @@ public class RestfulUtil { } method = null; - return createResponse(statusCode, responseContent); + return createResponse(statusCode, responseContent, responseHeader); + + } catch (SocketTimeoutException | ConnectTimeoutException e) { + String errMsg = "Request to VFC timed out"; + logError(errMsg, e); + return createResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg); + + } catch (Exception e) { + String errMsg = "Error processing request to VFC"; + logError(errMsg, e); + return createResponse(HttpURLConnection.HTTP_INTERNAL_ERROR, errMsg); + + } finally { + if (httpResponse != null) { + try { + EntityUtils.consume(httpResponse.getEntity()); + } catch (Exception e) { + logger.debug("Exception :", e); + } + } + + if (method != null) { + try { + method.reset(); + } catch (Exception e) { + logger.debug("Exception :", e); + } + } + } + } + + public RestfulResponse send(String msbUrl, String methodType, String content) { + if (!msbUrl.contains("http")) { + msbUrl = getMsbHost() + msbUrl; + } + // String msbUrl = getMsbHost() + url; + logger.debug("Begin to sent message " + methodType + ": " + msbUrl); + + HttpRequestBase method = null; + HttpResponse httpResponse = null; + + try { + int timeout = DEFAULT_TIME_OUT; + + RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(timeout).setConnectTimeout(timeout) + .setConnectionRequestTimeout(timeout).build(); + + if ("POST".equalsIgnoreCase(methodType)) { + HttpPost httpPost = new HttpPost(msbUrl); + httpPost.setConfig(requestConfig); + httpPost.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON)); + method = httpPost; + } else if ("PUT".equalsIgnoreCase(methodType)) { + HttpPut httpPut = new HttpPut(msbUrl); + httpPut.setConfig(requestConfig); + httpPut.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON)); + method = httpPut; + } else if ("GET".equalsIgnoreCase(methodType)) { + HttpGet httpGet = new HttpGet(msbUrl); + httpGet.setConfig(requestConfig); + method = httpGet; + } else if ("DELETE".equalsIgnoreCase(methodType)) { + HttpDelete httpDelete = new HttpDelete(msbUrl); + httpDelete.setConfig(requestConfig); + method = httpDelete; + } + + // now VFC have no auth + // String userCredentials = + // SDNCAdapterProperties.getEncryptedProperty(Constants.SDNC_AUTH_PROP, + // Constants.DEFAULT_SDNC_AUTH, Constants.ENCRYPTION_KEY); + // String authorization = "Basic " + + // DatatypeConverter.printBase64Binary(userCredentials.getBytes()); + // method.setHeader("Authorization", authorization); + + httpResponse = client.execute(method); + Map<String, String> responseHeader = new HashMap<>(); + String responseContent = null; + if (httpResponse.getEntity() != null) { + responseContent = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); + Header[] httpResponseAllHeaders = httpResponse.getAllHeaders(); + for (Header header : httpResponseAllHeaders) { + responseHeader.put(header.getName(), header.getValue()); + + } + } + + int statusCode = httpResponse.getStatusLine().getStatusCode(); + String statusMessage = httpResponse.getStatusLine().getReasonPhrase(); + + logger.debug("VFC Response: " + statusCode + " " + statusMessage + + (responseContent == null ? "" : System.lineSeparator() + responseContent)); + + if (httpResponse.getStatusLine().getStatusCode() >= 300) { + String errMsg = "VFC returned " + statusCode + " " + statusMessage; + logError(errMsg); + return createResponse(statusCode, errMsg); + } + + httpResponse = null; + + if (null != method) { + method.reset(); + } else { + logger.debug("method is NULL:"); + } + + method = null; + return createResponse(statusCode, responseContent, responseHeader); } catch (SocketTimeoutException | ConnectTimeoutException e) { String errMsg = "Request to VFC timed out"; @@ -194,6 +326,46 @@ public class RestfulUtil { } } + public RestfulResponse getNfvoFromAAI(String nfvo) { + HttpRequestBase method = null; + HttpResponse httpResponse = null; + String endPoint = getMsbHost() + "/api/aai-esr-server/v1/nfvos/" + nfvo; + logger.info("Endpoint URL" + endPoint); + RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(DEFAULT_TIME_OUT) + .setConnectTimeout(DEFAULT_TIME_OUT).setConnectionRequestTimeout(DEFAULT_TIME_OUT).build(); + HttpClient client = HttpClientBuilder.create().build(); + HttpGet httpGet = new HttpGet(endPoint); + httpGet.setConfig(requestConfig); + String encoding = Base64.getEncoder().encodeToString(("AAI:AAI").getBytes()); + httpGet.setHeader("Authorization", "Basic " + encoding); + method = httpGet; + String responseContent = null; + Map<String, String> responseHeader = null; + try { + httpResponse = client.execute(method); + if (httpResponse.getEntity() != null) { + responseContent = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); + } + + int statusCode = httpResponse.getStatusLine().getStatusCode(); + String statusMessage = httpResponse.getStatusLine().getReasonPhrase(); + + logger.debug("AAI Response: " + statusCode + " " + statusMessage + + (responseContent == null ? "" : System.lineSeparator() + responseContent)); + + if (httpResponse.getStatusLine().getStatusCode() >= 300) { + String errMsg = "AAI returned " + statusCode + " " + statusMessage; + logError(errMsg); + return createResponse(statusCode, errMsg); + } + } catch (Exception e) { + String errMsg = "Error processing request to AAI"; + logError(errMsg, e); + return createResponse(HttpURLConnection.HTTP_INTERNAL_ERROR, errMsg); + } + return createResponse(200, responseContent); + } + private static void logError(String errMsg, Throwable t) { logger.error(LoggingAnchor.FOUR, MessageEnum.RA_NS_EXC.toString(), VFC_ADAPTER, ErrorCode.AvailabilityError.getValue(), errMsg, t); @@ -211,4 +383,12 @@ public class RestfulUtil { return rsp; } + private static RestfulResponse createResponse(int statusCode, String content, Map<String, String> responseHeader) { + RestfulResponse rsp = new RestfulResponse(); + rsp.setStatus(statusCode); + rsp.setRespHeaderMap(responseHeader); + rsp.setResponseContent(content); + return rsp; + } + } diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AddPnfDataTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AddPnfDataTest.java new file mode 100644 index 0000000000..1fedac9cc9 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AddPnfDataTest.java @@ -0,0 +1,189 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import static org.junit.Assert.*; + +public class AddPnfDataTest { + AddPnfData pnfData = new AddPnfData(); + + @Test + public void getPnfId() { + pnfData.getPnfId(); + } + + + @Test + public void setPnfId() { + pnfData.setPnfId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getPnfName() { + pnfData.getPnfName(); + } + + @Test + public void setPnfName() { + pnfData.setPnfName("Router"); + } + + @Test + public void getPnfdId() { + pnfData.getPnfdId(); + } + + @Test + public void setPnfdId() { + pnfData.setPnfdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getPnfProfileId() { + pnfData.getPnfProfileId(); + } + + @Test + public void setPnfProfileId() { + pnfData.setPnfProfileId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getCpData() { + pnfData.getCpData(); + } + + @Test + public void setCpData() { + pnfData.setCpData(new List<PnfExtCpData>() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<PnfExtCpData> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T> T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(PnfExtCpData pnfExtCpData) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends PnfExtCpData> c) { + return false; + } + + @Override + public boolean addAll(int index, Collection<? extends PnfExtCpData> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public PnfExtCpData get(int index) { + return null; + } + + @Override + public PnfExtCpData set(int index, PnfExtCpData element) { + return null; + } + + @Override + public void add(int index, PnfExtCpData element) { + + } + + @Override + public PnfExtCpData remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator<PnfExtCpData> listIterator() { + return null; + } + + @Override + public ListIterator<PnfExtCpData> listIterator(int index) { + return null; + } + + @Override + public List<PnfExtCpData> subList(int fromIndex, int toIndex) { + return null; + } + }); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AddressRangeTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AddressRangeTest.java new file mode 100644 index 0000000000..9444efd4c5 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AddressRangeTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class AddressRangeTest { + AddressRange addressRange = new AddressRange(); + + @Test + public void getMinAddress() { + addressRange.getMinAddress(); + } + + @Test + public void setMinAddress() { + addressRange.setMinAddress("192.168.10.10"); + } + + @Test + public void getMaxAddress() { + addressRange.getMaxAddress(); + } + + @Test + public void setMaxAddress() { + addressRange.setMaxAddress("192.168.10.10"); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedNsTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedNsTest.java new file mode 100644 index 0000000000..06c52e2e52 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedNsTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class AffectedNsTest { + + AffectedNs affectedNs = new AffectedNs(); + + @Test + public void getNsInstanceId() { + affectedNs.getNsInstanceId(); + } + + @Test + public void setNsInstanceId() { + affectedNs.setNsInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getNsdId() { + affectedNs.getNsdId(); + } + + @Test + public void setNsdId() { + affectedNs.setNsdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedPnfTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedPnfTest.java new file mode 100644 index 0000000000..beecbe0675 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedPnfTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class AffectedPnfTest { + AffectedPnf affectedPnf = new AffectedPnf(); + + @Test + public void getPnfid() { + affectedPnf.getPnfid(); + } + + @Test + public void setPnfid() { + affectedPnf.setPnfid("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getPnfdid() { + affectedPnf.getPnfdid(); + } + + @Test + public void setPnfdid() { + affectedPnf.setPnfdid("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getPnfProfileId() { + affectedPnf.getPnfProfileId(); + } + + @Test + public void setPnfProfileId() { + affectedPnf.setPnfProfileId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getPnfName() { + affectedPnf.getPnfName(); + } + + @Test + public void setPnfName() { + affectedPnf.setPnfName("Router"); + } + + @Test + public void getCpInstanceId() { + affectedPnf.getCpInstanceId(); + } + + @Test + public void setCpInstanceId() { + affectedPnf.setCpInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedSapTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedSapTest.java new file mode 100644 index 0000000000..b96fe32836 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedSapTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class AffectedSapTest { + AffectedSap affectedSap = new AffectedSap(); + + @Test + public void getSapInstanceId() { + affectedSap.getSapInstanceId(); + } + + @Test + public void setSapInstanceId() { + affectedSap.setSapInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getSapdId() { + affectedSap.getSapdId(); + } + + @Test + public void setSapdId() { + affectedSap.setSapdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getSapName() { + affectedSap.getSapName(); + } + + @Test + public void setSapName() { + affectedSap.setSapName("Dummy SAP"); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedVirtualLinkTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedVirtualLinkTest.java new file mode 100644 index 0000000000..dbc6d0811f --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedVirtualLinkTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class AffectedVirtualLinkTest { + AffectedVirtualLink affectedVirtualLink = new AffectedVirtualLink(); + + @Test + public void getNsVirtualLinkInstanceId() { + affectedVirtualLink.getNsVirtualLinkInstanceId(); + } + + @Test + public void setNsVirtualLinkInstanceId() { + affectedVirtualLink.setNsVirtualLinkInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getNsVirtualLinkDescId() { + affectedVirtualLink.getNsVirtualLinkDescId(); + } + + @Test + public void setNsVirtualLinkDescId() { + affectedVirtualLink.setNsVirtualLinkDescId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVlProfileId() { + affectedVirtualLink.getVlProfileId(); + } + + @Test + public void setVlProfileId() { + affectedVirtualLink.setVlProfileId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedVnfTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedVnfTest.java new file mode 100644 index 0000000000..810f32d005 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedVnfTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class AffectedVnfTest { + AffectedVnf affectedVnf = new AffectedVnf(); + + @Test + public void getVnfInstanceId() { + affectedVnf.getVnfInstanceId(); + } + + @Test + public void setVnfInstanceId() { + affectedVnf.setVnfInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVnfdId() { + affectedVnf.getVnfdId(); + } + + @Test + public void setVnfdId() { + affectedVnf.setVnfdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVnfProfileId() { + affectedVnf.getVnfProfileId(); + } + + @Test + public void setVnfProfileId() { + affectedVnf.setVnfProfileId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVnfName() { + affectedVnf.getVnfName(); + } + + @Test + public void setVnfName() { + affectedVnf.setVnfName("Dummy Vnf Name"); + } + + @Test + public void getChangedInfo() { + affectedVnf.getChangedInfo(); + } + + @Test + public void setChangedInfo() { + affectedVnf.setChangedInfo(new ChangedInfo()); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedVnffgTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedVnffgTest.java new file mode 100644 index 0000000000..0d5670133d --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffectedVnffgTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class AffectedVnffgTest { + AffectedVnffg affectedVnffg = new AffectedVnffg(); + + @Test + public void getVnffgInstanceId() { + affectedVnffg.getVnffgInstanceId(); + } + + @Test + public void setVnffgInstanceId() { + affectedVnffg.setVnffgInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVnffgdId() { + affectedVnffg.getVnffgdId(); + } + + @Test + public void setVnffgdId() { + affectedVnffg.setVnffgdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffinityOrAntiAffinityRuleTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffinityOrAntiAffinityRuleTest.java new file mode 100644 index 0000000000..99a40e4ee1 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/AffinityOrAntiAffinityRuleTest.java @@ -0,0 +1,283 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import static org.junit.Assert.*; + +public class AffinityOrAntiAffinityRuleTest { + AffinityOrAntiAffinityRule affinityOrAntiAffinityRule = new AffinityOrAntiAffinityRule(); + + @Test + public void getVnfdId() { + affinityOrAntiAffinityRule.getVnfdId(); + } + + @Test + public void setVnfdId() { + affinityOrAntiAffinityRule.setVnfdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVnfProfileId() { + affinityOrAntiAffinityRule.getVnfProfileId(); + } + + @Test + public void setVnfProfileId() { + affinityOrAntiAffinityRule.setVnfProfileId(new List<String>() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<String> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T> T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(String s) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends String> c) { + return false; + } + + @Override + public boolean addAll(int index, Collection<? extends String> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public String get(int index) { + return null; + } + + @Override + public String set(int index, String element) { + return null; + } + + @Override + public void add(int index, String element) { + + } + + @Override + public String remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator<String> listIterator() { + return null; + } + + @Override + public ListIterator<String> listIterator(int index) { + return null; + } + + @Override + public List<String> subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getVnfInstanceId() { + affinityOrAntiAffinityRule.getVnfInstanceId(); + } + + @Test + public void setVnfInstanceId() { + affinityOrAntiAffinityRule.setVnfInstanceId(new List<String>() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<String> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T> T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(String s) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends String> c) { + return false; + } + + @Override + public boolean addAll(int index, Collection<? extends String> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public String get(int index) { + return null; + } + + @Override + public String set(int index, String element) { + return null; + } + + @Override + public void add(int index, String element) { + + } + + @Override + public String remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator<String> listIterator() { + return null; + } + + @Override + public ListIterator<String> listIterator(int index) { + return null; + } + + @Override + public List<String> subList(int fromIndex, int toIndex) { + return null; + } + }); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ChangedInfoTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ChangedInfoTest.java new file mode 100644 index 0000000000..41077fbe67 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ChangedInfoTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class ChangedInfoTest { + ChangedInfo changedInfo = new ChangedInfo(); + + @Test + public void getChangedVnfInfo() { + changedInfo.getChangedVnfInfo(); + } + + @Test + public void setChangedVnfInfo() { + changedInfo.setChangedVnfInfo(new ModifyVnfInfoData()); + } + + @Test + public void getChangedExtConnectivity() { + changedInfo.getChangedExtConnectivity(); + } + + @Test + public void setChangedExtConnectivity() { + changedInfo.setChangedExtConnectivity(new ExtVirtualLinkInfo()); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CivicAddressElementTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CivicAddressElementTest.java new file mode 100644 index 0000000000..e9c011b86a --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CivicAddressElementTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class CivicAddressElementTest { + CivicAddressElement civicAddressElement = new CivicAddressElement(); + + @Test + public void getCaType() { + civicAddressElement.getCaType(); + } + + @Test + public void setCaType() { + civicAddressElement.setCaType(12); + } + + @Test + public void getCaValue() { + civicAddressElement.getCaValue(); + } + + @Test + public void setCaValue() { + civicAddressElement.setCaValue("Dummy Ca value"); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CpProtocolDataTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CpProtocolDataTest.java new file mode 100644 index 0000000000..e47d02c926 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CpProtocolDataTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class CpProtocolDataTest { + CpProtocolData cpProtocolData = new CpProtocolData(); + + @Test + public void getLayerProtocol() { + cpProtocolData.getLayerProtocol(); + } + + @Test + public void setLayerProtocol() { + cpProtocolData.setLayerProtocol("BGP"); + } + + @Test + public void getIpOverEthernet() { + cpProtocolData.getIpOverEthernet(); + } + + @Test + public void setIpOverEthernet() { + cpProtocolData.setIpOverEthernet(new IpOverEthernetAddressData()); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CreateNsRequestTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CreateNsRequestTest.java new file mode 100644 index 0000000000..a2a6ae4fe1 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CreateNsRequestTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class CreateNsRequestTest { + CreateNsRequest createNsRequest = new CreateNsRequest(); + + @Test + public void getNsdId() { + createNsRequest.getNsdId(); + } + + @Test + public void setNsdId() { + createNsRequest.setNsdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getNsDescription() { + createNsRequest.getNsDescription(); + } + + @Test + public void setNsDescription() { + createNsRequest.setNsDescription("Dummy description"); + } + + @Test + public void getNsName() { + createNsRequest.getNsName(); + } + + @Test + public void setNsName() { + createNsRequest.setNsName("Dummy Name"); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ExtLinkPortInfoTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ExtLinkPortInfoTest.java new file mode 100644 index 0000000000..92cec88b34 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ExtLinkPortInfoTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class ExtLinkPortInfoTest { + + ExtLinkPortInfo extLinkPortInfo = new ExtLinkPortInfo(); + + @Test + public void getId() { + extLinkPortInfo.getId(); + } + + @Test + public void setId() { + extLinkPortInfo.setId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getResourceHandle() { + extLinkPortInfo.getResourceHandle(); + } + + @Test + public void setResourceHandle() { + extLinkPortInfo.setResourceHandle(new ResourceHandle()); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ExtVirtualLinkInfoTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ExtVirtualLinkInfoTest.java new file mode 100644 index 0000000000..c455b36a46 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ExtVirtualLinkInfoTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class ExtVirtualLinkInfoTest { + ExtVirtualLinkInfo extVirtualLinkInfo = new ExtVirtualLinkInfo(); + + @Test + public void getId() { + extVirtualLinkInfo.getId(); + } + + @Test + public void setId() { + extVirtualLinkInfo.setId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getResourceHandle() { + extVirtualLinkInfo.getResourceHandle(); + } + + @Test + public void setResourceHandle() { + extVirtualLinkInfo.setResourceHandle(new ResourceHandle()); + } + + @Test + public void getExtLinkPorts() { + extVirtualLinkInfo.getExtLinkPorts(); + } + + @Test + public void setExtLinkPorts() { + extVirtualLinkInfo.setExtLinkPorts(new ExtLinkPortInfo()); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/InstantiateNsRequestTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/InstantiateNsRequestTest.java new file mode 100644 index 0000000000..f27b041690 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/InstantiateNsRequestTest.java @@ -0,0 +1,413 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import static org.junit.Assert.*; + +public class InstantiateNsRequestTest { + InstantiateNsRequest instantiateNsRequest = new InstantiateNsRequest(); + + @Test + public void getNsFlavourId() { + instantiateNsRequest.getNsFlavourId(); + } + + @Test + public void setNsFlavourId() { + instantiateNsRequest.setNsFlavourId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getSapData() { + instantiateNsRequest.getSapData(); + } + + @Test + public void setSapData() { + instantiateNsRequest.setSapData(new List<SapData>() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<SapData> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T> T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(SapData sapData) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends SapData> c) { + return false; + } + + @Override + public boolean addAll(int index, Collection<? extends SapData> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public SapData get(int index) { + return null; + } + + @Override + public SapData set(int index, SapData element) { + return null; + } + + @Override + public void add(int index, SapData element) { + + } + + @Override + public SapData remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator<SapData> listIterator() { + return null; + } + + @Override + public ListIterator<SapData> listIterator(int index) { + return null; + } + + @Override + public List<SapData> subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getAddpnfData() { + instantiateNsRequest.getAddpnfData(); + } + + @Test + public void setAddpnfData() { + instantiateNsRequest.setAddpnfData(new List<AddPnfData>() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<AddPnfData> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T> T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(AddPnfData addPnfData) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends AddPnfData> c) { + return false; + } + + @Override + public boolean addAll(int index, Collection<? extends AddPnfData> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public AddPnfData get(int index) { + return null; + } + + @Override + public AddPnfData set(int index, AddPnfData element) { + return null; + } + + @Override + public void add(int index, AddPnfData element) { + + } + + @Override + public AddPnfData remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator<AddPnfData> listIterator() { + return null; + } + + @Override + public ListIterator<AddPnfData> listIterator(int index) { + return null; + } + + @Override + public List<AddPnfData> subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getVnfInstanceData() { + instantiateNsRequest.getVnfInstanceData(); + } + + @Test + public void setVnfInstanceData() { + instantiateNsRequest.setVnfInstanceData(new List<VnfInstanceData>() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<VnfInstanceData> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T> T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(VnfInstanceData vnfInstanceData) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends VnfInstanceData> c) { + return false; + } + + @Override + public boolean addAll(int index, Collection<? extends VnfInstanceData> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public VnfInstanceData get(int index) { + return null; + } + + @Override + public VnfInstanceData set(int index, VnfInstanceData element) { + return null; + } + + @Override + public void add(int index, VnfInstanceData element) { + + } + + @Override + public VnfInstanceData remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator<VnfInstanceData> listIterator() { + return null; + } + + @Override + public ListIterator<VnfInstanceData> listIterator(int index) { + return null; + } + + @Override + public List<VnfInstanceData> subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getNestedNsInstanceId() { + instantiateNsRequest.getNestedNsInstanceId(); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/IpAddressesTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/IpAddressesTest.java new file mode 100644 index 0000000000..edf6346bca --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/IpAddressesTest.java @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import static org.junit.Assert.*; + +public class IpAddressesTest { + IpAddresses ipAddresses = new IpAddresses(); + + @Test + public void getType() { + ipAddresses.getType(); + } + + @Test + public void setType() { + ipAddresses.setType("Dummy Type"); + } + + @Test + public void getFixedAddresses() { + ipAddresses.getFixedAddresses(); + } + + @Test + public void setFixedAddresses() { + ipAddresses.setFixedAddresses(new List<String>() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<String> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T> T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(String s) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends String> c) { + return false; + } + + @Override + public boolean addAll(int index, Collection<? extends String> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public String get(int index) { + return null; + } + + @Override + public String set(int index, String element) { + return null; + } + + @Override + public void add(int index, String element) { + + } + + @Override + public String remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator<String> listIterator() { + return null; + } + + @Override + public ListIterator<String> listIterator(int index) { + return null; + } + + @Override + public List<String> subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getNumDynamicAddresses() { + ipAddresses.getNumDynamicAddresses(); + } + + @Test + public void setNumDynamicAddresses() { + ipAddresses.setNumDynamicAddresses(5); + } + + @Test + public void getAddressRange() { + ipAddresses.getAddressRange(); + } + + @Test + public void setAddressRange() { + ipAddresses.setAddressRange(new AddressRange()); + } + + @Test + public void getSubnetId() { + ipAddresses.getSubnetId(); + } + + @Test + public void setSubnetId() { + ipAddresses.setSubnetId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/IpOverEthernetAddressDataTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/IpOverEthernetAddressDataTest.java new file mode 100644 index 0000000000..0088cdc50b --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/IpOverEthernetAddressDataTest.java @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import static org.junit.Assert.*; + +public class IpOverEthernetAddressDataTest { + IpOverEthernetAddressData ipOverEthernetAddressData = new IpOverEthernetAddressData(); + + @Test + public void getMacAddress() { + ipOverEthernetAddressData.getMacAddress(); + } + + @Test + public void setMacAddress() { + ipOverEthernetAddressData.setMacAddress("4e:86:9f:62:c1:bf"); + } + + @Test + public void getIpAddresses() { + ipOverEthernetAddressData.getIpAddresses(); + } + + @Test + public void setIpAddresses() { + ipOverEthernetAddressData.setIpAddresses(new List<IpAddresses>() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<IpAddresses> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T> T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(IpAddresses ipAddresses) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends IpAddresses> c) { + return false; + } + + @Override + public boolean addAll(int index, Collection<? extends IpAddresses> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public IpAddresses get(int index) { + return null; + } + + @Override + public IpAddresses set(int index, IpAddresses element) { + return null; + } + + @Override + public void add(int index, IpAddresses element) { + + } + + @Override + public IpAddresses remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator<IpAddresses> listIterator() { + return null; + } + + @Override + public ListIterator<IpAddresses> listIterator(int index) { + return null; + } + + @Override + public List<IpAddresses> subList(int fromIndex, int toIndex) { + return null; + } + }); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LinkTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LinkTest.java new file mode 100644 index 0000000000..e447c85ee7 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LinkTest.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class LinkTest { + Link link = new Link(); + + @Test + public void getHref() { + link.getHref(); + } + + @Test + public void setHref() { + link.setHref("dummy href"); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LinksTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LinksTest.java new file mode 100644 index 0000000000..aef87c47b1 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LinksTest.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class LinksTest { + Links links = new Links(); + + @Test + public void getSelf() { + links.getSelf(); + } + + @Test + public void setSelf() { + links.setSelf(new Link()); + } + + @Test + public void getNsInstance() { + links.getNsInstance(); + } + + @Test + public void setNsInstance() { + links.setNsInstance(new Link()); + } + + @Test + public void getCancel() { + links.getCancel(); + } + + @Test + public void setCancel() { + links.setCancel(new Link()); + } + + @Test + public void getRetry() { + links.getRetry(); + } + + @Test + public void setRetry() { + links.setRetry(new Link()); + } + + @Test + public void getRollback() { + links.getRollback(); + } + + @Test + public void setRollback() { + links.setRollback(new Link()); + } + + @Test + public void getContinues() { + links.getContinues(); + } + + @Test + public void setContinues() { + links.setContinues(new Link()); + } + + @Test + public void getFail() { + links.getFail(); + } + + @Test + public void setFail() { + links.setFail(new Link()); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintsTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintsTest.java new file mode 100644 index 0000000000..e68b12a626 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintsTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class LocationConstraintsTest { + LocationConstraints locationConstraints = new LocationConstraints(); + + @Test + public void getCountryCode() { + locationConstraints.getCountryCode(); + } + + @Test + public void setCountryCode() { + locationConstraints.setCountryCode("IND"); + + } + + @Test + public void getCivicAddressElement() { + locationConstraints.getCivicAddressElement(); + } + + @Test + public void setCivicAddressElement() { + locationConstraints.setCivicAddressElement(new CivicAddressElement()); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ModifyVnfInfoDataTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ModifyVnfInfoDataTest.java new file mode 100644 index 0000000000..c300923857 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ModifyVnfInfoDataTest.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.HashMap; +import static org.junit.Assert.*; + +public class ModifyVnfInfoDataTest { + ModifyVnfInfoData modifyVnfInfoData = new ModifyVnfInfoData(); + + @Test + public void getVnfInstanceId() { + modifyVnfInfoData.getVnfInstanceId(); + } + + @Test + public void setVnfInstanceId() { + modifyVnfInfoData.setVnfInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVnfInstanceName() { + modifyVnfInfoData.getVnfInstanceName(); + } + + @Test + public void setVnfInstanceName() { + modifyVnfInfoData.setVnfInstanceName("Dummy vnfInstanceName"); + } + + @Test + public void getVnfInstanceDescription() { + modifyVnfInfoData.getVnfInstanceDescription(); + } + + @Test + public void setVnfInstanceDescription() { + modifyVnfInfoData.setVnfInstanceDescription("Dummy vnfInstanceDescription"); + } + + @Test + public void getVnfPkgId() { + modifyVnfInfoData.getVnfPkgId(); + } + + @Test + public void setVnfPkgId() { + modifyVnfInfoData.setVnfPkgId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVnfConfigurableProperties() { + modifyVnfInfoData.getVnfConfigurableProperties(); + } + + @Test + public void setVnfConfigurableProperties() { + modifyVnfInfoData.setVnfConfigurableProperties(new HashMap<>()); + } + + @Test + public void getMetadata() { + modifyVnfInfoData.getMetadata(); + } + + @Test + public void setMetadata() { + modifyVnfInfoData.setMetadata(new HashMap<>()); + } + + @Test + public void getExtensions() { + modifyVnfInfoData.getExtensions(); + } + + @Test + public void setExtensions() { + modifyVnfInfoData.setExtensions(new HashMap<>()); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsLcmOpOccTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsLcmOpOccTest.java new file mode 100644 index 0000000000..f5d485a8c7 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsLcmOpOccTest.java @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import org.onap.so.adapters.vfc.constant.CommonConstant; +import java.time.LocalDateTime; +import java.util.Date; +import static org.junit.Assert.*; + +public class NsLcmOpOccTest { + NsLcmOpOcc nsLcmOpOcc = new NsLcmOpOcc(); + + @Test + public void getLcmOperationType() { + nsLcmOpOcc.getLcmOperationType(); + } + + @Test + public void setLcmOperationType() { + nsLcmOpOcc.setLcmOperationType(CommonConstant.lcmOperationType.INSTANTIATE); + } + + @Test + public void getCancelMode() { + nsLcmOpOcc.getCancelMode(); + } + + @Test + public void setCancelMode() { + nsLcmOpOcc.setCancelMode(CommonConstant.cancelMode.GRACEFUL); + } + + @Test + public void getOperationState() { + nsLcmOpOcc.getOperationState(); + } + + @Test + public void setOperationState() { + nsLcmOpOcc.setOperationState(CommonConstant.operationState.COMPLETED); + } + + @Test + public void getId() { + nsLcmOpOcc.getId(); + } + + @Test + public void setId() { + nsLcmOpOcc.setId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getStatusEnteredTime() { + nsLcmOpOcc.getStatusEnteredTime(); + } + + @Test + public void setStatusEnteredTime() { + nsLcmOpOcc.setStatusEnteredTime(LocalDateTime.now().toString()); + } + + @Test + public void getNsInstanceId() { + nsLcmOpOcc.getNsInstanceId(); + } + + @Test + public void setNsInstanceId() { + nsLcmOpOcc.setNsInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getStartTime() { + nsLcmOpOcc.getStartTime(); + } + + @Test + public void setStartTime() { + nsLcmOpOcc.setStartTime(LocalDateTime.now().toString()); + } + + @Test + public void getAutomaticInvocation() { + nsLcmOpOcc.getAutomaticInvocation(); + } + + @Test + public void setAutomaticInvocation() { + nsLcmOpOcc.setAutomaticInvocation(true); + } + + @Test + public void getOperationParams() { + nsLcmOpOcc.getOperationParams(); + } + + @Test + public void setOperationParams() { + nsLcmOpOcc.setOperationParams("Dummy operationParams"); + } + + @Test + public void getCancelPending() { + nsLcmOpOcc.getCancelPending(); + } + + @Test + public void setCancelPending() { + nsLcmOpOcc.setCancelPending(true); + } + + @Test + public void getError() { + nsLcmOpOcc.getError(); + } + + @Test + public void setError() { + nsLcmOpOcc.setError(new ProblemDetails()); + } + + @Test + public void getLinks() { + nsLcmOpOcc.getLinks(); + } + + @Test + public void setLinks() { + nsLcmOpOcc.setLinks(new Links()); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ParamsForVnfTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ParamsForVnfTest.java new file mode 100644 index 0000000000..e0455b0728 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ParamsForVnfTest.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.HashMap; +import static org.junit.Assert.*; + +public class ParamsForVnfTest { + + ParamsForVnf paramsForVnf = new ParamsForVnf(); + + @Test + public void getVnfProfileId() { + paramsForVnf.getVnfProfileId(); + } + + @Test + public void setVnfProfileId() { + paramsForVnf.setVnfProfileId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getAdditionalParams() { + paramsForVnf.getAdditionalParams(); + } + + @Test + public void setAdditionalParams() { + paramsForVnf.setAdditionalParams(new HashMap<>()); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/PnfExtCpDataTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/PnfExtCpDataTest.java new file mode 100644 index 0000000000..c586c7eb65 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/PnfExtCpDataTest.java @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import static org.junit.Assert.*; + +public class PnfExtCpDataTest { + PnfExtCpData pnfExtCpData = new PnfExtCpData(); + + @Test + public void getCpInstanceI16() { + pnfExtCpData.getCpInstanceI16(); + } + + @Test + public void setCpInstanceI16() { + pnfExtCpData.setCpInstanceI16("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getCpdId() { + pnfExtCpData.getCpdId(); + } + + @Test + public void setCpdId() { + pnfExtCpData.setCpdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getCpProtocolData() { + pnfExtCpData.getCpProtocolData(); + } + + @Test + public void setCpProtocolData() { + pnfExtCpData.setCpProtocolData(new List<CpProtocolData>() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<CpProtocolData> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T> T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(CpProtocolData cpProtocolData) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends CpProtocolData> c) { + return false; + } + + @Override + public boolean addAll(int index, Collection<? extends CpProtocolData> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public CpProtocolData get(int index) { + return null; + } + + @Override + public CpProtocolData set(int index, CpProtocolData element) { + return null; + } + + @Override + public void add(int index, CpProtocolData element) { + + } + + @Override + public CpProtocolData remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator<CpProtocolData> listIterator() { + return null; + } + + @Override + public ListIterator<CpProtocolData> listIterator(int index) { + return null; + } + + @Override + public List<CpProtocolData> subList(int fromIndex, int toIndex) { + return null; + } + }); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ProblemDetailsTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ProblemDetailsTest.java new file mode 100644 index 0000000000..ddea6cca40 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ProblemDetailsTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class ProblemDetailsTest { + ProblemDetails problemDetails = new ProblemDetails(); + + @Test + public void getType() { + problemDetails.getType(); + } + + @Test + public void setType() { + problemDetails.setType("Dummy Type"); + } + + @Test + public void getTitle() { + problemDetails.getTitle(); + } + + @Test + public void setTitle() { + problemDetails.setTitle("Dummy Title"); + } + + @Test + public void getStatus() { + problemDetails.getStatus(); + } + + @Test + public void setStatus() { + problemDetails.setStatus(200); + } + + @Test + public void getDetail() { + problemDetails.getDetail(); + } + + @Test + public void setDetail() { + problemDetails.setTitle("Dummy Title"); + } + + @Test + public void getInstance() { + problemDetails.getInstance(); + } + + @Test + public void setInstance() { + problemDetails.setInstance("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResourceChangesTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResourceChangesTest.java new file mode 100644 index 0000000000..9c4a0295e6 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResourceChangesTest.java @@ -0,0 +1,773 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import static org.junit.Assert.*; + +public class ResourceChangesTest { + ResourceChanges resourceChanges = new ResourceChanges(); + + @Test + public void getAffectedVnfs() { + resourceChanges.getAffectedVnfs(); + } + + @Test + public void setAffectedVnfs() { + resourceChanges.setAffectedVnfs(new List<AffectedVnf>() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<AffectedVnf> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T> T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(AffectedVnf affectedVnf) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends AffectedVnf> c) { + return false; + } + + @Override + public boolean addAll(int index, Collection<? extends AffectedVnf> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public AffectedVnf get(int index) { + return null; + } + + @Override + public AffectedVnf set(int index, AffectedVnf element) { + return null; + } + + @Override + public void add(int index, AffectedVnf element) { + + } + + @Override + public AffectedVnf remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator<AffectedVnf> listIterator() { + return null; + } + + @Override + public ListIterator<AffectedVnf> listIterator(int index) { + return null; + } + + @Override + public List<AffectedVnf> subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getAffectedPnfs() { + resourceChanges.getAffectedPnfs(); + } + + @Test + public void setAffectedPnfs() { + resourceChanges.setAffectedPnfs(new List<AffectedPnf>() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<AffectedPnf> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T> T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(AffectedPnf affectedPnf) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends AffectedPnf> c) { + return false; + } + + @Override + public boolean addAll(int index, Collection<? extends AffectedPnf> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public AffectedPnf get(int index) { + return null; + } + + @Override + public AffectedPnf set(int index, AffectedPnf element) { + return null; + } + + @Override + public void add(int index, AffectedPnf element) { + + } + + @Override + public AffectedPnf remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator<AffectedPnf> listIterator() { + return null; + } + + @Override + public ListIterator<AffectedPnf> listIterator(int index) { + return null; + } + + @Override + public List<AffectedPnf> subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getAffectedVls() { + resourceChanges.getAffectedVls(); + } + + @Test + public void setAffectedVls() { + resourceChanges.setAffectedVls(new List<AffectedVirtualLink>() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<AffectedVirtualLink> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T> T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(AffectedVirtualLink affectedVirtualLink) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends AffectedVirtualLink> c) { + return false; + } + + @Override + public boolean addAll(int index, Collection<? extends AffectedVirtualLink> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public AffectedVirtualLink get(int index) { + return null; + } + + @Override + public AffectedVirtualLink set(int index, AffectedVirtualLink element) { + return null; + } + + @Override + public void add(int index, AffectedVirtualLink element) { + + } + + @Override + public AffectedVirtualLink remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator<AffectedVirtualLink> listIterator() { + return null; + } + + @Override + public ListIterator<AffectedVirtualLink> listIterator(int index) { + return null; + } + + @Override + public List<AffectedVirtualLink> subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getAffectedVnffgs() { + resourceChanges.getAffectedVnffgs(); + } + + @Test + public void setAffectedVnffgs() { + resourceChanges.setAffectedVnffgs(new List<AffectedVnffg>() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<AffectedVnffg> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T> T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(AffectedVnffg affectedVnffg) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends AffectedVnffg> c) { + return false; + } + + @Override + public boolean addAll(int index, Collection<? extends AffectedVnffg> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public AffectedVnffg get(int index) { + return null; + } + + @Override + public AffectedVnffg set(int index, AffectedVnffg element) { + return null; + } + + @Override + public void add(int index, AffectedVnffg element) { + + } + + @Override + public AffectedVnffg remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator<AffectedVnffg> listIterator() { + return null; + } + + @Override + public ListIterator<AffectedVnffg> listIterator(int index) { + return null; + } + + @Override + public List<AffectedVnffg> subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getAffectedNss() { + resourceChanges.getAffectedNss(); + } + + @Test + public void setAffectedNss() { + resourceChanges.setAffectedNss(new List<AffectedNs>() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<AffectedNs> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T> T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(AffectedNs affectedNs) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends AffectedNs> c) { + return false; + } + + @Override + public boolean addAll(int index, Collection<? extends AffectedNs> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public AffectedNs get(int index) { + return null; + } + + @Override + public AffectedNs set(int index, AffectedNs element) { + return null; + } + + @Override + public void add(int index, AffectedNs element) { + + } + + @Override + public AffectedNs remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator<AffectedNs> listIterator() { + return null; + } + + @Override + public ListIterator<AffectedNs> listIterator(int index) { + return null; + } + + @Override + public List<AffectedNs> subList(int fromIndex, int toIndex) { + return null; + } + }); + } + + @Test + public void getAffectedSaps() { + resourceChanges.getAffectedSaps(); + } + + @Test + public void setAffectedSaps() { + resourceChanges.setAffectedSaps(new List<AffectedSap>() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<AffectedSap> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T> T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(AffectedSap affectedSap) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends AffectedSap> c) { + return false; + } + + @Override + public boolean addAll(int index, Collection<? extends AffectedSap> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public AffectedSap get(int index) { + return null; + } + + @Override + public AffectedSap set(int index, AffectedSap element) { + return null; + } + + @Override + public void add(int index, AffectedSap element) { + + } + + @Override + public AffectedSap remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator<AffectedSap> listIterator() { + return null; + } + + @Override + public ListIterator<AffectedSap> listIterator(int index) { + return null; + } + + @Override + public List<AffectedSap> subList(int fromIndex, int toIndex) { + return null; + } + }); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResourceHandleTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResourceHandleTest.java new file mode 100644 index 0000000000..6390c5afbd --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResourceHandleTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class ResourceHandleTest { + ResourceHandle resourceHandle = new ResourceHandle(); + + @Test + public void getVimId() { + resourceHandle.getVimId(); + } + + @Test + public void setVimId() { + resourceHandle.setVimId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getResourceProviderId() { + resourceHandle.getResourceProviderId(); + } + + @Test + public void setResourceProviderId() { + resourceHandle.setResourceProviderId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getResourceId() { + resourceHandle.getResourceId(); + } + + @Test + public void setResourceId() { + resourceHandle.setResourceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVimLevelResourceType() { + resourceHandle.getVimLevelResourceType(); + } + + @Test + public void setVimLevelResourceType() { + resourceHandle.setVimLevelResourceType("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/SapDataTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/SapDataTest.java new file mode 100644 index 0000000000..2a455994b8 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/SapDataTest.java @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import static org.junit.Assert.*; + +public class SapDataTest { + + SapData sapData = new SapData(); + + @Test + public void getSapdId() { + sapData.getSapdId(); + } + + @Test + public void setSapdId() { + sapData.setSapdId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getSapName() { + sapData.getSapName(); + } + + @Test + public void setSapName() { + sapData.setSapName("Dummy SapName"); + } + + @Test + public void getDescription() { + sapData.getDescription(); + } + + @Test + public void setDescription() { + sapData.setDescription("Dummy Description"); + } + + @Test + public void getSapProtocolData() { + sapData.getSapProtocolData(); + } + + @Test + public void setSapProtocolData() { + sapData.setSapProtocolData(new List<CpProtocolData>() { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<CpProtocolData> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T> T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(CpProtocolData cpProtocolData) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends CpProtocolData> c) { + return false; + } + + @Override + public boolean addAll(int index, Collection<? extends CpProtocolData> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public CpProtocolData get(int index) { + return null; + } + + @Override + public CpProtocolData set(int index, CpProtocolData element) { + return null; + } + + @Override + public void add(int index, CpProtocolData element) { + + } + + @Override + public CpProtocolData remove(int index) { + return null; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator<CpProtocolData> listIterator() { + return null; + } + + @Override + public ListIterator<CpProtocolData> listIterator(int index) { + return null; + } + + @Override + public List<CpProtocolData> subList(int fromIndex, int toIndex) { + return null; + } + }); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VnfInstanceDataTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VnfInstanceDataTest.java new file mode 100644 index 0000000000..b9bdfe3f6e --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VnfInstanceDataTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class VnfInstanceDataTest { + VnfInstanceData vnfInstanceData = new VnfInstanceData(); + + @Test + public void getVnfInstanceId() { + vnfInstanceData.getVnfInstanceId(); + } + + @Test + public void setVnfInstanceId() { + vnfInstanceData.setVnfInstanceId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getVnfProfileId() { + vnfInstanceData.getVnfProfileId(); + } + + @Test + public void setVnfProfileId() { + vnfInstanceData.setVnfProfileId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VnfLocationConstraintTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VnfLocationConstraintTest.java new file mode 100644 index 0000000000..b8f9b8e3e2 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VnfLocationConstraintTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.model; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class VnfLocationConstraintTest { + VnfLocationConstraint vnfLocationConstraint = new VnfLocationConstraint(); + + @Test + public void getVnfProfileId() { + vnfLocationConstraint.getVnfProfileId(); + } + + @Test + public void setVnfProfileId() { + vnfLocationConstraint.setVnfProfileId("c9f0a95e-dea0-4698-96e5-5a79bc5a233d"); + } + + @Test + public void getLocationConstraints() { + vnfLocationConstraint.getLocationConstraints(); + } + + @Test + public void setLocationConstraints() { + vnfLocationConstraint.setLocationConstraints(new LocationConstraint()); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerSol005Test.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerSol005Test.java new file mode 100644 index 0000000000..799283ddb4 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/rest/VfcManagerSol005Test.java @@ -0,0 +1,221 @@ +/* + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.adapters.vfc.rest; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.so.adapters.vfc.exceptions.ApplicationException; +import org.onap.so.adapters.vfc.model.NSResourceInputParameter; +import org.onap.so.adapters.vfc.model.RestfulResponse; +import org.onap.so.adapters.vfc.util.JsonUtil; +import org.onap.so.adapters.vfc.util.RestfulUtil; +import org.onap.so.db.request.beans.InstanceNfvoMapping; +import org.onap.so.db.request.beans.OperationStatus; +import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.onap.so.db.request.data.repository.InstanceNfvoMappingRepository; +import org.onap.so.db.request.data.repository.OperationStatusRepository; +import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.springframework.test.context.junit4.SpringRunner; +import java.io.File; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import static org.mockito.Mockito.when; + +@RunWith(SpringRunner.class) +public class VfcManagerSol005Test { + @InjectMocks + VfcManagerSol005 vfcManagerSol005; + + @Mock + InstanceNfvoMappingRepository instanceNfvoMappingRepository; + + @Mock + ResourceOperationStatusRepository resourceOperationStatusRepository; + + @Mock + OperationStatusRepository operationStatusRepository; + + @Mock + RestfulUtil restfulUtil; + + OperationStatus operationStatus = new OperationStatus(); + + InstanceNfvoMapping instanceNfvoMapping = new InstanceNfvoMapping(); + RestfulResponse restfulResponse = new RestfulResponse(); + RestfulResponse vfcrestfulResponse = new RestfulResponse(); + NSResourceInputParameter nsResourceInputParameter = new NSResourceInputParameter(); + ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus(); + + @Test + public void createNs() throws ApplicationException, Exception { + restfulResponse.setStatus(200); + ClassLoader classLoader = ClassLoader.getSystemClassLoader(); + + File file = new File(classLoader.getResource("json/createNsReq.json").getFile()); + String content = new String(Files.readAllBytes(file.toPath())).replace("\n", ""); + nsResourceInputParameter = JsonUtil.unMarshal(content, NSResourceInputParameter.class); + file = new File(classLoader.getResource("json/aainfvoResponse.json").getFile()); + content = new String(Files.readAllBytes(file.toPath())).replace("\n", ""); + restfulResponse.setResponseContent(content); + // restfulResponse.setResponseContent("{\"nfvoId\":\"6ee79fe2-9579-475a-9bb9-20cf4358a19e\",\"name\":\"external_nfvo\",\"api-root\":\"xyz\",\"vendor\":\"vz\",\"version\":\"v1.0\",\"url\":\"http://sample.com/\",\"userName\":\"admin\",\"password\":\"sacjnasnc\"}"); + file = new File(classLoader.getResource("json/createNsSol005Response.json").getFile()); + content = new String(Files.readAllBytes(file.toPath())).replace("\n", ""); + vfcrestfulResponse.setStatus(202); + vfcrestfulResponse.setResponseContent(content); + // vfcrestfulResponse.setResponseContent("{\"_links\": {\"heal\": {\"href\": \"\"}, \"instantiate\": {\"href\": + // \"\"}, \"nestedNsInstances\": {\"href\": \"\"}, \"scale\": {\"href\": \"\"}, \"self\": {\"href\": \"\"}, + // \"terminate\": {\"href\": \"\"}, \"update\": {\"href\": \"\"}}, \"additionalAffinityOrAntiAffiniityRule\": + // [{\"Scope\": \"\", \"affinityOrAntiAffiinty\": \"\", \"vnfInstanceId\": [], \"vnfProfileId\": [], \"vnfdId\": + // []}], \"flavourId\": \"\", \"id\": \"c9f0a95e-dea0-4698-96e5-5a79bc5a233d\", \"nestedNsInstanceId\": [], + // \"nsInstanceDescription\": \"\", \"nsInstanceName\": \"\", \"nsScaleStatus\": [{\"nsScaleLevelId\": \"\", + // \"nsScalingAspectId\": \"\"}], \"nsState\": \"\", \"nsdId\": \"\", \"nsdInfoId\": \"\", \"pnfInfo\": + // [{\"cpInfo\": [{\"cpInstanceId\": \"\", \"cpProtocolData\": {\"ipOverEthernet\": {\"ipAddresses\": + // {\"addressRange\": {\"maxAddress\": \"\", \"minAddress\": \"\"}, \"fixedAddresses\": \"\", + // \"numDynamicAddresses\": 1, \"subnetId\": \"\", \"type\": \"\"}, \"macAddress\": {}}, \"layerProtocol\": + // \"IP_OVER_ETHERNET\"}, \"cpdId\": \"\"}], \"pnfId\": \"\", \"pnfName\": \"\", \"pnfProfileId\": \"\", + // \"pnfdId\": \"\", \"pnfdInfoId\": \"\"}], \"sapInfo\": [{\"description\": \"\", \"id\": \"\", \"sapName\": + // \"\", \"sapProtocolInfo\": {\"ipOverEthernet\": {\"ipAddresses\": {\"addressRange\": {\"maxAddress\": \"\", + // \"minAddress\": \"\"}, \"fixedAddresses\": \"\", \"numDynamicAddresses\": 1, \"subnetId\": \"\", \"type\": + // \"\"}, \"macAddress\": \"\"}, \"layerProtocol\": \"IP_OVER_ETHERNET\"}, \"sapdId\": \"\"}], + // \"virtualLinkInfo\": [{\"id\": \"\", \"linkPort\": [{\"id\": \"\", \"resourceHandle\": {\"resourceId\": \"\", + // \"resourceProviderId\": \"\", \"vimId\": \"\", \"vimLevelResourceType\": \"\"}}], \"nsVirtualLinkDescId\": + // \"\", \"resourceHandle\": [{\"resourceId\": \"\", \"resourceProviderId\": \"\", \"vimId\": \"\", + // \"vimLevelResourceType\": \"\"}]}], \"vnfInstance\": [{\"vnfInstanceId\": \"\", \"vnfProfileId\": \"\"}], + // \"vnffgInfo\": [{\"id\": \"\", \"nfpInfo\": [{\"description\": \"\", \"id\": \"\", \"nfpName\": \"\", + // \"nfpRule\": {\"destinationIpAddressPrefix\": \"\", \"destinationPortRange\": \"\", \"dscp\": \"\", + // \"etherDestinationAddress\": \"\", \"etherSourceAddress\": \"\", \"etherType\": \"\", \"extendedCriteria\": + // [{\"length\": 1, \"startingPoint\": 1, \"value\": \"\"}], \"protocol\": \"\", \"sourceIpAddressPrefix\": + // \"\", \"sourcePortRange\": \"\", \"vlanTag\": []}, \"nfpState\": \"\", \"nfpdId\": \"\", \"nscpHandle\": + // [{\"nsInstanceId\": \"\", \"nsSapInstanceId\": \"\", \"pnfExtCpInstanceId\": \"\", \"pnfInfoId\": \"\", + // \"vnfExtCpInstanceId\": \"\", \"vnfInstanceId\": \"\"}], \"totalCp\": 1}], \"nsCpHandle\": + // [{\"nsInstanceId\": \"\", \"nsSapInstanceId\": \"\", \"pnfExtCpInstanceId\": \"\", \"pnfInfoId\": \"\", + // \"vnfExtCpInstanceId\": \"\", \"vnfInstanceId\": \"\"}], \"nsVirtualLinkInfoId\": [], \"pnfInfoId\": [], + // \"vnfInstanceId\": [], \"vnffgdId\": \"\"}]}"); + + resourceOperationStatus.setStatus("processing"); + resourceOperationStatus.setOperationId(nsResourceInputParameter.getNsOperationKey().getOperationId()); + resourceOperationStatus.setServiceId(nsResourceInputParameter.getNsOperationKey().getServiceId()); + resourceOperationStatus + .setResourceTemplateUUID(nsResourceInputParameter.getNsOperationKey().getNodeTemplateUUID()); + when(instanceNfvoMappingRepository.save(instanceNfvoMapping)).thenReturn(instanceNfvoMapping); + when(restfulUtil.getNfvoFromAAI("b1bb0ce7-2222-4fa7-95ed-4840d70a1101")).thenReturn(restfulResponse); + when(restfulUtil.send(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyMap())) + .thenReturn(vfcrestfulResponse); + when(resourceOperationStatusRepository.save(resourceOperationStatus)).thenReturn(resourceOperationStatus); + vfcManagerSol005.createNs(nsResourceInputParameter); + + } + + @Test + public void terminateNs() throws Exception { + instanceNfvoMapping.setInstanceId("b1bb0ce7-2222-4fa7-95ed-4840d70a1101"); + instanceNfvoMapping.setPassword("sacjnasnc"); + instanceNfvoMapping.setUsername("admin"); + instanceNfvoMapping.setNfvoName("external_nfvo"); + instanceNfvoMapping.setEndpoint("http://sample.com/"); + instanceNfvoMapping.setApiRoot("xyz"); + String nsInstanceId = "c9f0a95e-dea0-4698-96e5-5a79bc5a233d"; + ClassLoader classLoader = ClassLoader.getSystemClassLoader(); + File file = new File(classLoader.getResource("json/createNsReq.json").getFile()); + String content = new String(Files.readAllBytes(file.toPath())).replace("\n", ""); + nsResourceInputParameter = JsonUtil.unMarshal(content, NSResourceInputParameter.class); + Map<String, String> header = new HashMap<>(); + header.put("Location", "http://192.168.10.57:5000/ns_lcm_op_ops/12204a12-7da2-4ddf-8c2f-992a1a1acebf"); + vfcrestfulResponse.setStatus(202); + vfcrestfulResponse.setResponseContent(null); + vfcrestfulResponse.setRespHeaderMap(header); + when(instanceNfvoMappingRepository.findOneByInstanceId(nsInstanceId)).thenReturn(instanceNfvoMapping); + when(restfulUtil.send(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())) + .thenReturn(vfcrestfulResponse); + vfcManagerSol005.terminateNs(nsResourceInputParameter.getNsOperationKey(), nsInstanceId); + } + + @Test + public void getNsProgress() throws Exception { + String jobId = "12204a12-7da2-4ddf-8c2f-992a1a1acebf"; + instanceNfvoMapping.setInstanceId("b1bb0ce7-2222-4fa7-95ed-4840d70a1101"); + instanceNfvoMapping.setPassword("sacjnasnc"); + instanceNfvoMapping.setUsername("admin"); + instanceNfvoMapping.setNfvoName("external_nfvo"); + instanceNfvoMapping.setEndpoint("http://sample.com/"); + instanceNfvoMapping.setApiRoot("xyz"); + instanceNfvoMapping.setJobId(jobId); + ClassLoader classLoader = ClassLoader.getSystemClassLoader(); + File file = new File(classLoader.getResource("json/createNsReq.json").getFile()); + String content = new String(Files.readAllBytes(file.toPath())).replace("\n", ""); + nsResourceInputParameter = JsonUtil.unMarshal(content, NSResourceInputParameter.class); + operationStatus.setProgress("40"); + operationStatus.setServiceId(nsResourceInputParameter.getNsOperationKey().getServiceId()); + operationStatus.setOperationId(nsResourceInputParameter.getNsOperationKey().getOperationId()); + ResourceOperationStatus resourceOperationStatus = + new ResourceOperationStatus(nsResourceInputParameter.getNsOperationKey().getServiceId(), + nsResourceInputParameter.getNsOperationKey().getOperationId(), + nsResourceInputParameter.getNsOperationKey().getNodeTemplateUUID()); + file = new File(classLoader.getResource("json/lcmOperRsp.json").getFile()); + content = new String(Files.readAllBytes(file.toPath())).replace("\n", ""); + vfcrestfulResponse.setStatus(202); + vfcrestfulResponse.setResponseContent(content); + List<ResourceOperationStatus> resourceOperationStatuses = new ArrayList<>(); + resourceOperationStatuses.add(resourceOperationStatus); + when(instanceNfvoMappingRepository.findOneByJobId(jobId)).thenReturn(instanceNfvoMapping); + when(restfulUtil.send(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())) + .thenReturn(vfcrestfulResponse); + when(operationStatusRepository.findOneByServiceIdAndOperationId( + nsResourceInputParameter.getNsOperationKey().getServiceId(), + nsResourceInputParameter.getNsOperationKey().getOperationId())).thenReturn(operationStatus); + when(resourceOperationStatusRepository.findByServiceIdAndOperationId( + nsResourceInputParameter.getNsOperationKey().getServiceId(), + nsResourceInputParameter.getNsOperationKey().getOperationId())).thenReturn(resourceOperationStatuses); + when(operationStatusRepository.save(operationStatus)).thenReturn(operationStatus); + vfcManagerSol005.getNsProgress(nsResourceInputParameter.getNsOperationKey(), jobId); + + } + + @Test + public void instantiateNs() throws Exception { + String nsInstanceId = "c9f0a95e-dea0-4698-96e5-5a79bc5a233d"; + ClassLoader classLoader = ClassLoader.getSystemClassLoader(); + File file = new File(classLoader.getResource("json/createNsReq.json").getFile()); + String content = new String(Files.readAllBytes(file.toPath())).replace("\n", ""); + nsResourceInputParameter = JsonUtil.unMarshal(content, NSResourceInputParameter.class); + instanceNfvoMapping.setInstanceId("b1bb0ce7-2222-4fa7-95ed-4840d70a1101"); + instanceNfvoMapping.setPassword("sacjnasnc"); + instanceNfvoMapping.setUsername("admin"); + instanceNfvoMapping.setNfvoName("external_nfvo"); + instanceNfvoMapping.setEndpoint("http://sample.com/"); + instanceNfvoMapping.setApiRoot("xyz"); + resourceOperationStatus.setStatus("processing"); + resourceOperationStatus.setOperationId(nsResourceInputParameter.getNsOperationKey().getOperationId()); + resourceOperationStatus.setServiceId(nsResourceInputParameter.getNsOperationKey().getServiceId()); + resourceOperationStatus + .setResourceTemplateUUID(nsResourceInputParameter.getNsOperationKey().getNodeTemplateUUID()); + Map<String, String> header = new HashMap<>(); + header.put("Location", "http://192.168.10.57:5000/ns_lcm_op_ops/12204a12-7da2-4ddf-8c2f-992a1a1acebf"); + vfcrestfulResponse.setStatus(202); + vfcrestfulResponse.setResponseContent(null); + vfcrestfulResponse.setRespHeaderMap(header); + when(instanceNfvoMappingRepository.findOneByInstanceId(nsInstanceId)).thenReturn(instanceNfvoMapping); + when(restfulUtil.send(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())) + .thenReturn(vfcrestfulResponse); + when(resourceOperationStatusRepository.save(resourceOperationStatus)).thenReturn(resourceOperationStatus); + when(instanceNfvoMappingRepository.save(instanceNfvoMapping)).thenReturn(instanceNfvoMapping); + vfcManagerSol005.instantiateNs(nsInstanceId, nsResourceInputParameter); + + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/util/RestfulUtilTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/util/RestfulUtilTest.java index c388016ab4..4b6baa5cf4 100644 --- a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/util/RestfulUtilTest.java +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/util/RestfulUtilTest.java @@ -22,6 +22,8 @@ package org.onap.so.adapters.vfc.util; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; +import org.apache.http.Header; +import org.apache.http.message.BasicHeader; import org.apache.http.StatusLine; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpDelete; @@ -59,21 +61,27 @@ public class RestfulUtilTest { private HttpEntity httpEntity; private HttpResponse httpResponse; private StatusLine statusLine; + private Header httpResponseHeader; @Before public void setUp() { httpEntity = mock(HttpEntity.class); httpResponse = mock(HttpResponse.class); statusLine = mock(StatusLine.class); + httpResponseHeader = mock(Header.class); } private void sendInit() throws IOException { + Header[] headerList = new BasicHeader[2]; + headerList[0] = new BasicHeader("Content-Type", "application/json"); + headerList[1] = new BasicHeader("cache-control", "no-cache"); doReturn("https://testHost/").when(restfulUtil).getMsbHost(); when(statusLine.getStatusCode()).thenReturn(HttpStatus.OK.value()); when(httpResponse.getStatusLine()).thenReturn(statusLine); when(httpResponse.getEntity()).thenReturn(httpEntity); + when(httpResponse.getAllHeaders()).thenReturn(headerList); } @Test diff --git a/adapters/mso-vfc-adapter/src/test/resources/json/aainfvoResponse.json b/adapters/mso-vfc-adapter/src/test/resources/json/aainfvoResponse.json new file mode 100644 index 0000000000..35047a9c21 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/resources/json/aainfvoResponse.json @@ -0,0 +1,10 @@ +{ + "nfvoId":"6ee79fe2-9579-475a-9bb9-20cf4358a19e", + "name":"external_nfvo", + "api-root":"xyz", + "vendor":"vz", + "version":"v1.0", + "url":"http://sample.com/", + "userName":"admin", + "password":"sacjnasnc" +}
\ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/resources/json/createNsReq.json b/adapters/mso-vfc-adapter/src/test/resources/json/createNsReq.json index 047c81081e..aec8ae809d 100644 --- a/adapters/mso-vfc-adapter/src/test/resources/json/createNsReq.json +++ b/adapters/mso-vfc-adapter/src/test/resources/json/createNsReq.json @@ -1,32 +1,56 @@ { - "nsServiceName":"vIMS", - "nsServiceDescription":"vIMS NS", + "nsServiceName":"vcpe_e2e_vnf_test2", + "nsServiceDescription":"null", + "nsServiceModelUUID":"c9f0a95e-dea0-4698-96e5-5a79bc5a233d", "nsOperationKey":{ - "globalSubscriberId":"9b9f02c0-298b-458a-bc9c-be3692e4f350", - "serviceType":"service", - "serviceId":"9b9f02c0-298b-458a-bc9c-be3692e4f351", - "operationId":"9b9f02c0-298b-458a-bc9c-be3692e4f352", - "nodeTemplateUUID":"9b9f02c0-298b-458a-bc9c-be3692e4f353" + "globalSubscriberId":"Demonstration", + "serviceType":"vCPE", + "serviceId":"996fadbb-e806-4a19-b0e5-3454ad6ac29e", + "operationId":"1f1dd6b2-b027-4008-a9df-3b6c8274fb24", + "nodeTemplateUUID":"4d3a835c-29c8-4a63-83a4-50de5f7ffe16" }, "nsParameters":{ "locationConstraints":[ { - "vnfProfileId":"zte-CSCF-1.0", "locationConstraints":{ - "vimId":"1" - } + "vimId":"CloudOwner_regionOne" + }, + "vnfProfileId":"b1bb0ce7-2222-4fa7-95ed-4840d70a1101" + }, + { + "locationConstraints":{ + "vimId":"CloudOwner_regionOne" + }, + "vnfProfileId":"0408f076-e6c0-4c82-9940-272fddbb82de" + }, + { + "locationConstraints":{ + "vimId":"CloudOwner_regionOne" + }, + "vnfProfileId":"b1bb0ce7-2222-4fa7-95ed-4840d70a1100" + }, + { + "locationConstraints":{ + "vimId":"CloudOwner_regionOne" + }, + "vnfProfileId":"b1bb0ce7-2222-4fa7-95ed-4840d70a1102" + }, + { + "locationConstraints":{ + "vimId":"CloudOwner_regionOne" + }, + "vnfProfileId":"3fca3543-07f5-492f-812c-ed462e4f94f4" } ], "additionalParamForNs":{ - "externalDataNetworkName":"Flow_out_net", - "m6000_mng_ip":"192.168.20.2", - "externalCompanyFtpDataNetworkName":"Flow_out_net", - "externalPluginManageNetworkName":"plugin_net_2014", - "externalManageNetworkName":"mng_net_2017", - "sfc_data_network":"sfc_data_net_2016", - "NatIpRange":"210.1.1.10-210.1.1.20", - "location":"4050083f-465f-4838-af1e-47a545222ad0", - "sdncontroller":"9b9f02c0-298b-458a-bc9c-be3692e4f35e" + "orchestrator":"", + "nfvo":"b1bb0ce7-2222-4fa7-95ed-4840d70a1101", + "nf_naming":"true", + "multi_stage_design":"false", + "availability_zone_max_count":"1", + "xyz":"123", + "nsd0_providing_service_invariant_uuid":"12204a12-7da2-4ddf-8c2f-992a1a1acebf", + "nsd0_providing_service_uuid":"5791dbeb-19d4-43e8-bf44-5b327ccf6bca" } } -}
\ No newline at end of file +} diff --git a/adapters/mso-vfc-adapter/src/test/resources/json/createNsSol005Response.json b/adapters/mso-vfc-adapter/src/test/resources/json/createNsSol005Response.json new file mode 100644 index 0000000000..938969a87f --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/resources/json/createNsSol005Response.json @@ -0,0 +1,210 @@ +{ + "_links":{ + "heal":{ + "href":"" + }, + "instantiate":{ + "href":"" + }, + "nestedNsInstances":{ + "href":"" + }, + "scale":{ + "href":"" + }, + "self":{ + "href":"" + }, + "terminate":{ + "href":"" + }, + "update":{ + "href":"" + } + }, + "additionalAffinityOrAntiAffiniityRule":[ + { + "Scope":"", + "affinityOrAntiAffiinty":"", + "vnfInstanceId":[ + + ], + "vnfProfileId":[ + + ], + "vnfdId":[ + + ] + } + ], + "flavourId":"", + "id":"c9f0a95e-dea0-4698-96e5-5a79bc5a233d", + "nestedNsInstanceId":[ + + ], + "nsInstanceDescription":"", + "nsInstanceName":"", + "nsScaleStatus":[ + { + "nsScaleLevelId":"", + "nsScalingAspectId":"" + } + ], + "nsState":"", + "nsdId":"", + "nsdInfoId":"", + "pnfInfo":[ + { + "cpInfo":[ + { + "cpInstanceId":"", + "cpProtocolData":{ + "ipOverEthernet":{ + "ipAddresses":{ + "addressRange":{ + "maxAddress":"", + "minAddress":"" + }, + "fixedAddresses":"", + "numDynamicAddresses":1, + "subnetId":"", + "type":"" + }, + "macAddress":{ + + } + }, + "layerProtocol":"IP_OVER_ETHERNET" + }, + "cpdId":"" + } + ], + "pnfId":"", + "pnfName":"", + "pnfProfileId":"", + "pnfdId":"", + "pnfdInfoId":"" + } + ], + "sapInfo":[ + { + "description":"", + "id":"", + "sapName":"", + "sapProtocolInfo":{ + "ipOverEthernet":{ + "ipAddresses":{ + "addressRange":{ + "maxAddress":"", + "minAddress":"" + }, + "fixedAddresses":"", + "numDynamicAddresses":1, + "subnetId":"", + "type":"" + }, + "macAddress":"" + }, + "layerProtocol":"IP_OVER_ETHERNET" + }, + "sapdId":"" + } + ], + "virtualLinkInfo":[ + { + "id":"", + "linkPort":[ + { + "id":"", + "resourceHandle":{ + "resourceId":"", + "resourceProviderId":"", + "vimId":"", + "vimLevelResourceType":"" + } + } + ], + "nsVirtualLinkDescId":"", + "resourceHandle":[ + { + "resourceId":"", + "resourceProviderId":"", + "vimId":"", + "vimLevelResourceType":"" + } + ] + } + ], + "vnfInstance":[ + { + "vnfInstanceId":"", + "vnfProfileId":"" + } + ], + "vnffgInfo":[ + { + "id":"", + "nfpInfo":[ + { + "description":"", + "id":"", + "nfpName":"", + "nfpRule":{ + "destinationIpAddressPrefix":"", + "destinationPortRange":"", + "dscp":"", + "etherDestinationAddress":"", + "etherSourceAddress":"", + "etherType":"", + "extendedCriteria":[ + { + "length":1, + "startingPoint":1, + "value":"" + } + ], + "protocol":"", + "sourceIpAddressPrefix":"", + "sourcePortRange":"", + "vlanTag":[ + + ] + }, + "nfpState":"", + "nfpdId":"", + "nscpHandle":[ + { + "nsInstanceId":"", + "nsSapInstanceId":"", + "pnfExtCpInstanceId":"", + "pnfInfoId":"", + "vnfExtCpInstanceId":"", + "vnfInstanceId":"" + } + ], + "totalCp":1 + } + ], + "nsCpHandle":[ + { + "nsInstanceId":"", + "nsSapInstanceId":"", + "pnfExtCpInstanceId":"", + "pnfInfoId":"", + "vnfExtCpInstanceId":"", + "vnfInstanceId":"" + } + ], + "nsVirtualLinkInfoId":[ + + ], + "pnfInfoId":[ + + ], + "vnfInstanceId":[ + + ], + "vnffgdId":"" + } + ] +}
\ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/resources/json/lcmOperRsp.json b/adapters/mso-vfc-adapter/src/test/resources/json/lcmOperRsp.json new file mode 100644 index 0000000000..111afc1a7c --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/resources/json/lcmOperRsp.json @@ -0,0 +1,7 @@ +{ + "id":"12204a12-7da2-4ddf-8c2f-992a1a1acebf", + "lcmOperationType":"INSTANTIATE", + "nsInstanceId":"c9f0a95e-dea0-4698-96e5-5a79bc5a233d", + "operationState":"PROCESSING", + "statusEnteredTime":"Time" +}
\ No newline at end of file diff --git a/adapters/pom.xml b/adapters/pom.xml index 8acc7012ba..5d382fd4dd 100644 --- a/adapters/pom.xml +++ b/adapters/pom.xml @@ -23,6 +23,7 @@ <module>mso-openstack-adapters</module> <module>mso-vnfm-adapter</module> <module>mso-ve-vnfm-adapter</module> + <module>mso-nssmf-adapter</module> <module>so-appc-orchestrator</module> </modules> diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/ZipParser.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/ZipParser.java new file mode 100644 index 0000000000..c2f04dca7b --- /dev/null +++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/ZipParser.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2019, CMCC Technologies Co., Ltd. + * ================================================================================ + * 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.onap.so.asdc.util; + +import java.io.*; +import java.nio.charset.Charset; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import java.util.zip.ZipInputStream; + +public class ZipParser { + + private static volatile ZipParser instance; + + public static ZipParser getInstance() { + if (instance == null) { + synchronized (ZipParser.class) { + if (instance == null) { + instance = new ZipParser(); + } + } + } + return instance; + } + + public String parseJsonForZip(String path) throws IOException { + ZipFile zf = new ZipFile(path); + InputStream in = new BufferedInputStream(new FileInputStream(path)); + Charset cs = Charset.forName("utf-8"); + ZipInputStream zin = new ZipInputStream(in, cs); + ZipEntry ze; + String artifactContent = null; + while ((ze = zin.getNextEntry()) != null) { + if (ze.toString().endsWith("json")) { + StringBuilder jsonStr = new StringBuilder(); + BufferedReader br = new BufferedReader(new InputStreamReader(zf.getInputStream(ze))); + String line; + while ((line = br.readLine()) != null) { + jsonStr.append(line); + } + br.close(); + artifactContent = jsonStr.toString().replace("\"", "\\\"").replaceAll("\\s", ""); + } + } + zin.closeEntry(); + return artifactContent; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java index ebced8e933..51b1a218c8 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java @@ -58,7 +58,7 @@ public class AbstractCDSProcessingBBUtils { private static final String FAILED = "Failed"; private static final String PROCESSING = "Processing"; private static final String RESPONSE_PAYLOAD = "CDSResponsePayload"; - private static final String CDS_STATUS = "CDSStatus"; + private static final String CDS_STATUS = "ControllerStatus"; private static final String EXEC_INPUT = "executionServiceInput"; private static final String EXECUTION_OBJECT = "executionObject"; private static final String EXCEPTION = "Exception"; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java new file mode 100644 index 0000000000..eb2567d47c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.restproperties; + +import java.net.MalformedURLException; +import java.net.URL; +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.client.sdnc.common.SDNCConstants; +import org.onap.so.client.sdnc.lcm.SDNCLcmProperties; + +public class SDNCLcmPropertiesImpl implements SDNCLcmProperties { + + public static final String SDNC_HOST = "sdnc.host"; + public static final String SDNC_AUTH = "sdnc.auth"; + public static final String LCM_PATH = "sdnc.lcm.path"; + + public static final String DMAAP_HOST = "sdnc.dmaap.host"; + public static final String DMAAP_AUTH = "sdnc.dmaap.auth"; + public static final String DMAAP_PARTITION = "sdnc.dmaap.partition"; + public static final String DMAAP_TIMEOUT = "sdnc.dmaap.timeout"; + public static final String DMAAP_ENVIRONMENT = "sdnc.dmaap.environment"; + public static final String LCM_DMAAP_READ_TOPIC = "sdnc.lcm.dmapp.readTopic"; + public static final String LCM_DMAAP_WRITE_TOPIC = "sdnc.lcm.dmaap.writeTopic"; + + public static final String MSO_KEY = "mso.msoKey"; + + public SDNCLcmPropertiesImpl() {} + + @Override + public String getHost() { + return UrnPropertiesReader.getVariable(SDNC_HOST); + } + + @Override + public String getPath() { + String path = UrnPropertiesReader.getVariable(LCM_PATH); + return (path != null) ? path : SDNCConstants.LCM_API_BASE_PATH; + } + + @Override + public String getBasicAuth() { + return UrnPropertiesReader.getVariable(SDNC_AUTH); + } + + @Override + public String getDmaapHost() { + return UrnPropertiesReader.getVariable(DMAAP_HOST); + } + + @Override + public String getDmaapAuth() { + return UrnPropertiesReader.getVariable(DMAAP_AUTH); + } + + @Override + public String getDmaapPartition() { + String partition = UrnPropertiesReader.getVariable(DMAAP_PARTITION); + return (partition != null) ? partition : SDNCConstants.LCM_DMAAP_PARTITION; + } + + @Override + public String getDmaapTimeout() { + String timeout = UrnPropertiesReader.getVariable(DMAAP_TIMEOUT); + return (timeout != null) ? timeout : SDNCConstants.LCM_DMAAP_TIMEOUT; + } + + @Override + public String getDmaapEnvironment() { + String environment = UrnPropertiesReader.getVariable(DMAAP_ENVIRONMENT); + return (environment != null) ? environment : SDNCConstants.LCM_DMAAP_ENVIRONMENT; + } + + @Override + public String getDmaaPLcmReadTopic() { + String readTopic = UrnPropertiesReader.getVariable(LCM_DMAAP_READ_TOPIC); + return (readTopic != null) ? readTopic : SDNCConstants.LCM_DMAAP_READ_TOPIC; + } + + @Override + public String getDmaaPLcmWriteTopic() { + String writeTopic = UrnPropertiesReader.getVariable(LCM_DMAAP_WRITE_TOPIC); + return (writeTopic != null) ? writeTopic : SDNCConstants.LCM_DMAAP_WRITE_TOPIC; + } + + @Override + public String getKey() { + return UrnPropertiesReader.getVariable(MSO_KEY); + } + + @Override + public URL getEndpoint() throws MalformedURLException { + return new URL(getHost()); + } + + @Override + public String getSystemName() { + return SDNCConstants.SYSTEM_NAME; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java new file mode 100644 index 0000000000..fd9412e70e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.common; + +public interface SDNCConstants { + String SYSTEM_NAME = "MSO"; + + String LCM_API_VER = "2.00"; + + String LCM_FLAGS_MODE_NORMAL = "NORMAL"; + String LCM_FLAGS_MODE_EXCLUSIVE = "EXCLUSIVE"; + + String LCM_FLAGS_FORCE_TRUE = "TRUE"; + String LCM_FLAGS_FORCE_FALSE = "FALSE"; + + int LCM_FLAGS_TTL = 65000; + + String LCM_API_BASE_PATH = "/restconf/operations/LCM:"; + + String LCM_DMAAP_MSG_VER = "1.0"; + String LCM_DMAAP_MSG_TYPE_REQUEST = "request"; + String LCM_DMAAP_MSG_TYPE_RESPONSE = "response"; + + String LCM_DMAAP_PARTITION = "MSOLCM"; + String LCM_DMAAP_TIMEOUT = "20000"; + String LCM_DMAAP_ENVIRONMENT = "TEST"; + String LCM_DMAAP_READ_TOPIC = "SDNC-LCM-WRITE"; + String LCM_DMAAP_WRITE_TOPIC = "SDNC-LCM-READ"; + + int LCM_TIMEOUT = 300; +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java new file mode 100644 index 0000000000..5616db3577 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm; + +import java.net.URI; +import org.onap.so.client.RestPropertiesLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SDNCLcmClientBuilder { + + private static Logger logger = LoggerFactory.getLogger(SDNCLcmClientBuilder.class); + + private final SDNCLcmProperties sdncLcmProperties; + + public SDNCLcmClientBuilder() { + sdncLcmProperties = RestPropertiesLoader.getInstance().getNewImpl(SDNCLcmProperties.class); + } + + public SDNCLcmClientBuilder(SDNCLcmProperties pros) { + sdncLcmProperties = pros; + } + + public SDNCLcmRestClient newSDNCLcmRestClient(String operation) throws SDNCLcmClientBuilderException { + URI pathUri; + try { + String path = sdncLcmProperties.getPath() + operation; + pathUri = new URI(path); + logger.debug("SDNC host: " + sdncLcmProperties.getHost()); + logger.debug("SDNC API path: " + pathUri.getPath()); + } catch (Exception e) { + String msg = "Error API path syntax: "; + logger.error(msg, e); + throw new SDNCLcmClientBuilderException(msg + e.toString()); + } + + try { + SDNCLcmRestClient sdncLcmRestClient = new SDNCLcmRestClient(sdncLcmProperties, pathUri); + logger.debug("Create SDNCLcmRestClient success"); + return sdncLcmRestClient; + } catch (Exception e) { + String msg = "Create SDNCLcmRestClient failure: "; + logger.error(msg, e); + throw new SDNCLcmClientBuilderException(msg + e.toString()); + } + } + + public SDNCLcmDmaapClient newSDNCLcmDmaapClient() throws SDNCLcmClientBuilderException { + try { + SDNCLcmDmaapClient sdncLcmDmaapClient = new SDNCLcmDmaapClient(sdncLcmProperties); + logger.debug("Create SDNCLcmDmaapClient success"); + return sdncLcmDmaapClient; + } catch (Exception e) { + String msg = "Create SDNCLcmDmaapClient failure: "; + logger.error(msg, e); + throw new SDNCLcmClientBuilderException(msg + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilderException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilderException.java new file mode 100644 index 0000000000..9160d4e352 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilderException.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm; + +public class SDNCLcmClientBuilderException extends Exception { + + private static final long serialVersionUID = -1525705272349747712L; + + public SDNCLcmClientBuilderException(String message) { + super(message); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClient.java new file mode 100644 index 0000000000..f6e4ffce59 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClient.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.onap.so.client.sdnc.lcm.beans.LcmDmaapRequest; +import org.onap.so.client.sdnc.lcm.beans.LcmDmaapResponse; +import org.onap.so.client.dmaap.rest.RestPublisher; +import org.onap.so.client.dmaap.rest.RestConsumer; + +public class SDNCLcmDmaapClient { + + private static Logger logger = LoggerFactory.getLogger(SDNCLcmDmaapClient.class); + + private RestPublisher dmaapPublisher; + private RestConsumer dmaapConsumer; + + public SDNCLcmDmaapClient(SDNCLcmProperties sdncLcmProperties) { + Properties properties = new Properties(); + + properties.put("host", sdncLcmProperties.getDmaapHost()); + if (sdncLcmProperties.getDmaapAuth() != null && sdncLcmProperties.getKey() != null) { + properties.put("auth", sdncLcmProperties.getDmaapAuth()); + properties.put("key", sdncLcmProperties.getKey()); + } + properties.put("partition", sdncLcmProperties.getDmaapPartition()); + properties.put("timeout", sdncLcmProperties.getDmaapTimeout()); + properties.put("environment", sdncLcmProperties.getDmaapEnvironment()); + + properties.put("topic", sdncLcmProperties.getDmaaPLcmWriteTopic()); + dmaapPublisher = new RestPublisher(properties); + + properties.put("topic", sdncLcmProperties.getDmaaPLcmReadTopic()); + dmaapConsumer = new RestConsumer(properties); + } + + public void sendRequest(LcmDmaapRequest lcmDmaapRequest) throws Exception { + ObjectMapper mapper = new ObjectMapper(); + String lcmRestRequestString = mapper.writeValueAsString(lcmDmaapRequest); + + dmaapPublisher.send(lcmRestRequestString); + } + + public Iterable<String> fetch() { + return dmaapConsumer.fetch(); + } + + public List<LcmDmaapResponse> getResponse() { + List<LcmDmaapResponse> responseList = new ArrayList<>(); + + ObjectMapper mapper = new ObjectMapper(); + Iterable<String> itrString = dmaapConsumer.fetch(); + for (String message : itrString) { + LcmDmaapResponse lcmDmaapResponse; + try { + lcmDmaapResponse = mapper.readValue(message, LcmDmaapResponse.class); + } catch (Exception e) { + logger.warn("Invalid SDNC LCM DMaaP response: " + message); + continue; + } + + responseList.add(lcmDmaapResponse); + } + + return responseList; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilder.java new file mode 100644 index 0000000000..bf1229a310 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilder.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm; + +import java.time.Instant; +import org.onap.so.client.sdnc.common.SDNCConstants; +import org.onap.so.client.sdnc.lcm.beans.*; + +public class SDNCLcmMessageBuilder { + + public static LcmFlags getSDNCFlags() { + LcmFlags lcmFlags = new LcmFlags(); + + lcmFlags.setMode(SDNCConstants.LCM_FLAGS_MODE_NORMAL); + lcmFlags.setForce(SDNCConstants.LCM_FLAGS_FORCE_FALSE); + lcmFlags.setTtl(SDNCConstants.LCM_FLAGS_TTL); + + return lcmFlags; + } + + public static LcmCommonHeader buildLcmCommonHeader(String requestId, String subRequestId) { + LcmCommonHeader lcmCommonHeader = new LcmCommonHeader(); + + lcmCommonHeader.setApiVer(SDNCConstants.LCM_API_VER); + lcmCommonHeader.setOriginatorId(SDNCConstants.SYSTEM_NAME); + lcmCommonHeader.setRequestId(requestId); + lcmCommonHeader.setSubRequestId(subRequestId); + lcmCommonHeader.setFlags(getSDNCFlags()); + lcmCommonHeader.setTimestamp(Instant.now().toString()); + + return lcmCommonHeader; + } + + public static LcmInput buildLcmInputForPnf(String requestId, String subRequestId, String pnfName, String action, + String payload) { + LcmInput lcmInput = new LcmInput(); + + LcmCommonHeader lcmCommonHeader = buildLcmCommonHeader(requestId, subRequestId); + + LcmActionIdentifiers sdncActionIdentifiers = new LcmActionIdentifiers(); + sdncActionIdentifiers.setPnfName(pnfName); + + lcmInput.setCommonHeader(lcmCommonHeader); + lcmInput.setAction(action); + lcmInput.setActionIdentifiers(sdncActionIdentifiers); + lcmInput.setPayload(payload); + + return lcmInput; + } + + public static LcmDmaapRequest buildLcmDmaapRequest(String operation, LcmInput lcmInput) { + LcmDmaapRequest lcmDmaapRequest = new LcmDmaapRequest(); + + LcmRestRequest lcmRestRequest = new LcmRestRequest(); + lcmRestRequest.setInput(lcmInput); + + String correlationId = + lcmInput.getCommonHeader().getRequestId() + "-" + lcmInput.getCommonHeader().getSubRequestId(); + + lcmDmaapRequest.setVersion(SDNCConstants.LCM_DMAAP_MSG_VER); + lcmDmaapRequest.setType(SDNCConstants.LCM_DMAAP_MSG_TYPE_REQUEST); + lcmDmaapRequest.setCambriaPartition(SDNCConstants.SYSTEM_NAME); + lcmDmaapRequest.setCorrelationId(correlationId); + lcmDmaapRequest.setRpcName(operation); + lcmDmaapRequest.setBody(lcmRestRequest); + + return lcmDmaapRequest; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java new file mode 100644 index 0000000000..df5fb3be0b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm; + +import org.onap.so.client.RestProperties; + +public interface SDNCLcmProperties extends RestProperties { + String getHost(); + + String getPath(); + + String getBasicAuth(); + + String getDmaapHost(); + + String getDmaapAuth(); + + String getDmaapPartition(); + + String getDmaapTimeout(); + + String getDmaapEnvironment(); + + String getDmaaPLcmReadTopic(); + + String getDmaaPLcmWriteTopic(); + + String getKey(); +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmRestClient.java new file mode 100644 index 0000000000..3faf58ec28 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmRestClient.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm; + +import java.net.URI; +import java.util.Map; +import java.util.Optional; +import org.onap.so.client.RestClient; +import org.onap.logging.filter.base.ONAPComponents; +import org.onap.so.client.sdnc.lcm.beans.LcmInput; +import org.onap.so.client.sdnc.lcm.beans.LcmOutput; +import org.onap.so.client.sdnc.lcm.beans.LcmRestRequest; +import org.onap.so.client.sdnc.lcm.beans.LcmRestResponse; + +public class SDNCLcmRestClient extends RestClient { + + private final SDNCLcmProperties sdncLcmProperties; + + public SDNCLcmRestClient(SDNCLcmProperties props, URI path) { + this(props, path, "application/json", "application/json"); + } + + public SDNCLcmRestClient(SDNCLcmProperties props, URI path, String accept, String contentType) { + super(props, Optional.of(path), accept, contentType); + this.sdncLcmProperties = props; + } + + @Override + protected void initializeHeaderMap(Map<String, String> headerMap) { + headerMap.put("Authorization", sdncLcmProperties.getBasicAuth()); + } + + @Override + public ONAPComponents getTargetEntity() { + return ONAPComponents.SDNC; + } + + public LcmRestResponse sendRequest(LcmRestRequest lcmRestRequest) { + return post(lcmRestRequest, LcmRestResponse.class); + } + + public LcmOutput sendRequest(LcmInput lcmInput) { + LcmRestRequest lcmRestRequest = new LcmRestRequest(); + lcmRestRequest.setInput(lcmInput); + + LcmRestResponse lcmRestResponse = sendRequest(lcmRestRequest); + return lcmRestResponse.getOutput(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmActionIdentifiers.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmActionIdentifiers.java new file mode 100644 index 0000000000..883fd02c78 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmActionIdentifiers.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"serviceInstanceId", "vnfId", "vfModuleId", "vnfcName", "vserverId", "pnfName"}) +public class LcmActionIdentifiers { + + @JsonProperty("service-instance-id") + private String serviceInstanceId; + + @JsonProperty("vnf-id") + private String vnfId; + + @JsonProperty("vf-module-id") + private String vfModuleId; + + @JsonProperty("vnfc-name") + private String vnfcName; + + @JsonProperty("vserver-id") + private String vserverId; + + @JsonProperty("pnf-name") + private String pnfName; + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String value) { + this.serviceInstanceId = value; + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String value) { + this.vnfId = value; + } + + public String getVfModuleId() { + return vfModuleId; + } + + public void setVfModuleId(String value) { + this.vfModuleId = value; + } + + public String getVnfcName() { + return vnfcName; + } + + public void setVnfcName(String value) { + this.vnfcName = value; + } + + public String getVserverId() { + return vserverId; + } + + public void setVserverId(String value) { + this.vserverId = value; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String value) { + this.pnfName = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmCommonHeader.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmCommonHeader.java new file mode 100644 index 0000000000..f3fd2ca11d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmCommonHeader.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"apiVer", "flags", "originatorId", "requestId", "subRequestId", "timestamp"}) +public class LcmCommonHeader { + + @JsonProperty(value = "api-ver", required = true) + private String apiVer; + + @JsonProperty(value = "flags") + private LcmFlags flags; + + @JsonProperty(value = "originator-id", required = true) + private String originatorId; + + @JsonProperty(value = "request-id", required = true) + private String requestId; + + @JsonProperty(value = "sub-request-id") + private String subRequestId; + + @JsonProperty(value = "timestamp", required = true) + private String timestamp; + + public String getApiVer() { + return apiVer; + } + + public void setApiVer(String value) { + this.apiVer = value; + } + + public String getOriginatorId() { + return originatorId; + } + + public void setOriginatorId(String value) { + this.originatorId = value; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String value) { + this.requestId = value; + } + + public String getSubRequestId() { + return subRequestId; + } + + public void setSubRequestId(String value) { + this.subRequestId = value; + } + + public LcmFlags getFlags() { + return flags; + } + + public void setFlags(LcmFlags value) { + this.flags = value; + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String value) { + this.timestamp = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapRequest.java new file mode 100644 index 0000000000..db62e8b20b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapRequest.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"version", "type", "cambriaPartition", "correlationId", "rpcName", "body"}) +public class LcmDmaapRequest { + + @JsonProperty(value = "version", required = true) + private String version; + + @JsonProperty(value = "type", required = true) + private String type; + + @JsonProperty(value = "cambria.partition", required = true) + private String cambriaPartition; + + @JsonProperty(value = "correlation-id", required = true) + private String correlationId; + + @JsonProperty(value = "rpc-name", required = true) + private String rpcName; + + @JsonProperty(value = "body") + private LcmRestRequest body; + + public String getVersion() { + return version; + } + + public void setVersion(String value) { + this.version = value; + } + + public String getType() { + return type; + } + + public void setType(String value) { + this.type = value; + } + + public String getCambriaPartition() { + return cambriaPartition; + } + + public void setCambriaPartition(String value) { + this.cambriaPartition = value; + } + + public String getCorrelationId() { + return correlationId; + } + + public void setCorrelationId(String value) { + this.correlationId = value; + } + + public String getRpcName() { + return rpcName; + } + + public void setRpcName(String value) { + this.rpcName = value; + } + + public LcmRestRequest getBody() { + return body; + } + + public void setBody(LcmRestRequest value) { + this.body = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapResponse.java new file mode 100644 index 0000000000..35f4a26b17 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapResponse.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"version", "type", "cambriaPartition", "correlationId", "rpcName", "body"}) +public class LcmDmaapResponse { + + @JsonProperty(value = "version", required = true) + private String version; + + @JsonProperty(value = "type", required = true) + private String type; + + @JsonProperty(value = "cambria.partition", required = true) + private String cambriaPartition; + + @JsonProperty(value = "correlation-id", required = true) + private String correlationId; + + @JsonProperty(value = "rpc-name", required = true) + private String rpcName; + + @JsonProperty(value = "body") + private LcmRestResponse body; + + public String getVersion() { + return version; + } + + public void setVersion(String value) { + this.version = value; + } + + public String getType() { + return type; + } + + public void setType(String value) { + this.type = value; + } + + public String getCambriaPartition() { + return cambriaPartition; + } + + public void setCambriaPartition(String value) { + this.cambriaPartition = value; + } + + public String getCorrelationId() { + return correlationId; + } + + public void setCorrelationId(String value) { + this.correlationId = value; + } + + public String getRpcName() { + return rpcName; + } + + public void setRpcName(String value) { + this.rpcName = value; + } + + public LcmRestResponse getBody() { + return body; + } + + public void setBody(LcmRestResponse value) { + this.body = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmFlags.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmFlags.java new file mode 100644 index 0000000000..36527ec887 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmFlags.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"mode", "force", "ttl"}) +public class LcmFlags { + + @JsonProperty("mode") + private String mode; + + @JsonProperty("force") + private String force; + + @JsonProperty("ttl") + private int ttl; + + public String getMode() { + return mode; + } + + public void setMode(String value) { + this.mode = value; + } + + public String getForce() { + return force; + } + + public void setForce(String value) { + this.force = value; + } + + public Integer getTtl() { + return ttl; + } + + public void setTtl(Integer value) { + this.ttl = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmInput.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmInput.java new file mode 100644 index 0000000000..6634430bed --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmInput.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"commonHeader", "action", "actionIdentifiers", "payload"}) +public class LcmInput { + + @JsonProperty(value = "common-header", required = true) + private LcmCommonHeader commonHeader; + + @JsonProperty(value = "action", required = true) + private String action; + + @JsonProperty(value = "action-identifiers", required = true) + private LcmActionIdentifiers actionIdentifiers; + + @JsonProperty(value = "payload") + private String payload; + + public LcmCommonHeader getCommonHeader() { + return commonHeader; + } + + public void setCommonHeader(LcmCommonHeader value) { + this.commonHeader = value; + } + + public String getAction() { + return action; + } + + public void setAction(String value) { + this.action = value; + } + + public LcmActionIdentifiers getActionIdentifiers() { + return actionIdentifiers; + } + + public void setActionIdentifiers(LcmActionIdentifiers value) { + this.actionIdentifiers = value; + } + + public String getPayload() { + return payload; + } + + public void setPayload(String value) { + this.payload = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmOutput.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmOutput.java new file mode 100644 index 0000000000..3741786671 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmOutput.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"commonHeader", "status", "payload"}) +public class LcmOutput { + + @JsonProperty(value = "common-header", required = true) + private LcmCommonHeader commonHeader; + + @JsonProperty(value = "status", required = true) + private LcmStatus status; + + @JsonProperty(value = "payload") + private String payload; + + public LcmCommonHeader getCommonHeader() { + return commonHeader; + } + + public void setCommonHeader(LcmCommonHeader value) { + this.commonHeader = value; + } + + public LcmStatus getStatus() { + return status; + } + + public void setStatus(LcmStatus value) { + this.status = value; + } + + public String getPayload() { + return payload; + } + + public void setPayload(String value) { + this.payload = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmRestRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmRestRequest.java new file mode 100644 index 0000000000..146eb8a4f6 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmRestRequest.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"input"}) +public class LcmRestRequest { + + @JsonProperty(value = "input", required = true) + private LcmInput input; + + public LcmInput getInput() { + return input; + } + + public void setInput(LcmInput value) { + this.input = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmRestResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmRestResponse.java new file mode 100644 index 0000000000..6920f95ce2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmRestResponse.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"output"}) +public class LcmRestResponse { + + @JsonProperty(value = "output", required = true) + private LcmOutput output; + + public LcmOutput getOutput() { + return output; + } + + public void setOutput(LcmOutput value) { + this.output = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmStatus.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmStatus.java new file mode 100644 index 0000000000..8a2a142792 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmStatus.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"code", "message"}) +public class LcmStatus { + + @JsonProperty(value = "code", required = true) + private int code; + + @JsonProperty(value = "message", required = true) + private String message; + + public int getCode() { + return code; + } + + public void setCode(int value) { + this.code = value; + } + + public String getMessage() { + return message; + } + + public void setMessage(String value) { + this.message = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/services/org.onap.so.client.RestProperties b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/services/org.onap.so.client.RestProperties index 27da189456..147bc2ee95 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/services/org.onap.so.client.RestProperties +++ b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/services/org.onap.so.client.RestProperties @@ -1,3 +1,4 @@ org.onap.so.client.restproperties.AAIPropertiesImpl org.onap.so.client.restproperties.CDSPropertiesImpl -org.onap.so.client.restproperties.PolicyRestPropertiesImpl
\ No newline at end of file +org.onap.so.client.restproperties.PolicyRestPropertiesImpl +org.onap.so.client.restproperties.SDNCLcmPropertiesImpl diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java index 24962a0c14..998976589c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java @@ -55,7 +55,7 @@ public class GeneratePayloadForCdsTest { private static final String VF_SCOPE = "vfModule"; private static final String ASSIGN_ACTION = "configAssign"; private static final String DEPLOY_ACTION = "configDeploy"; - private static final String DOWNLOAD_ACTION = "downloadNeSw"; + private static final String DOWNLOAD_ACTION = "downloadNESw"; private static final String MSO_REQUEST_ID = "1234"; private static final String BUILDING_BLOCK = "buildingBlock"; private static final String PUBLIC_NET_ID = "public-net-id"; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java index e5cbc9a369..88559280b6 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java @@ -40,8 +40,8 @@ public class PnfCDSRequestProviderTest { @InjectMocks private PnfCDSRequestProvider pnfCDSRequestProvider; - private static final String DOWNLOAD_ACTION = "downloadNeSw"; - private static final String ACTIVATE_ACTION = "activateNeSw"; + private static final String DOWNLOAD_ACTION = "downloadNESw"; + private static final String ACTIVATE_ACTION = "activateNESw"; private static final String TEST_MODEL_UUID = "6bc0b04d-1873-4721-b53d-6615225b2a28"; private static final String TEST_SERVICE_INSTANCE_ID = "test_service_id"; private static final String TEST_PROCESS_KEY = "processKey1"; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java new file mode 100644 index 0000000000..5483792a84 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java @@ -0,0 +1,139 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm; + +import java.util.List; +import org.apache.http.HttpStatus; +import com.fasterxml.jackson.core.JsonProcessingException; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.fail; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import org.onap.so.BaseTest; +import org.onap.so.client.restproperties.SDNCLcmPropertiesImpl; +import org.onap.so.client.sdnc.lcm.beans.*; + +public class SDNCLcmDmaapClientTest extends BaseTest { + + protected SDNCLcmMessageBuilderTest sdncLcmMessageBuilderTest = new SDNCLcmMessageBuilderTest(); + + protected static final String DMAAP_HOST_PROP = SDNCLcmPropertiesImpl.DMAAP_HOST; + protected static final String DMAAP_WRITE_TOPIC_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_WRITE_TOPIC; + protected static final String DMAAP_READ_TOPIC_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_READ_TOPIC; + protected static final String DMAAP_PARTITION_PROP = SDNCLcmPropertiesImpl.DMAAP_PARTITION; + + protected String testWriteTopic = "TEST-WRITE-TOPIC"; + protected String testReadTopic = "TEST-READ-TOPIC"; + protected String testPartition = "TESTMSO"; + protected final String defaultConsumerName = "consumer1"; + + private void clearSystemProperty() { + System.clearProperty(DMAAP_HOST_PROP); + System.clearProperty(DMAAP_WRITE_TOPIC_PROP); + System.clearProperty(DMAAP_READ_TOPIC_PROP); + System.clearProperty(DMAAP_PARTITION_PROP); + } + + public SDNCLcmDmaapClient buildSDNCLcmDmaapClient() { + String testHost = "http://localhost:" + wireMockPort; + + System.setProperty(DMAAP_HOST_PROP, testHost); + System.setProperty(DMAAP_WRITE_TOPIC_PROP, testWriteTopic); + System.setProperty(DMAAP_READ_TOPIC_PROP, testReadTopic); + System.setProperty(DMAAP_PARTITION_PROP, testPartition); + + SDNCLcmProperties sdncLcmProperties = new SDNCLcmPropertiesImpl(); + SDNCLcmClientBuilder sdncLcmClientBuilder = new SDNCLcmClientBuilder(sdncLcmProperties); + + try { + return sdncLcmClientBuilder.newSDNCLcmDmaapClient(); + } catch (Exception e) { + clearSystemProperty(); + fail("Create SDNCLcmDmaapClient error: " + e.toString()); + return null; + } + } + + @Test + public final void testSDNCLcmDmaapClientSendRequest() { + SDNCLcmDmaapClient sdncLcmDmaapClient = buildSDNCLcmDmaapClient(); + + assertNotEquals(null, sdncLcmDmaapClient); + + String testDmaapWritePath = "/events/" + testWriteTopic; + String expectedWriteResponse = "{\"serverTimeMs\":2,\"count\":1}"; + wireMockServer.stubFor(post(urlPathEqualTo(testDmaapWritePath)) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(expectedWriteResponse) + .withStatus(HttpStatus.SC_OK))); + + LcmInput lcmInput = sdncLcmMessageBuilderTest.buildLcmInputForPnf(); + LcmDmaapRequest lcmDmaapRequest = + SDNCLcmMessageBuilder.buildLcmDmaapRequest(sdncLcmMessageBuilderTest.getOperation(), lcmInput); + + try { + sdncLcmDmaapClient.sendRequest(lcmDmaapRequest); + } catch (Exception e) { + clearSystemProperty(); + fail("SDNCLcmDmaapClient sends request error: " + e.toString()); + return; + } + + String testDmaapReadPath = "/events/" + testReadTopic + "/" + testPartition + "/" + defaultConsumerName; + + String expectedLcmDmaapResponse = LcmDmaapResponseTest.getExpectedLcmDmaapResponse(); + String expectedResponseListItem; + try { + expectedResponseListItem = sdncLcmMessageBuilderTest.convertToSting(expectedLcmDmaapResponse); + } catch (JsonProcessingException e) { + clearSystemProperty(); + fail("Convert LcmDmaapResponse String to List item error: " + e.toString()); + return; + } + String expectedReadResponse = "[" + expectedResponseListItem + "]"; + wireMockServer.stubFor(get(urlPathEqualTo(testDmaapReadPath)) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(expectedReadResponse) + .withStatus(HttpStatus.SC_OK))); + + List<LcmDmaapResponse> LcmDmaapResponseList = sdncLcmDmaapClient.getResponse(); + + clearSystemProperty(); + + if (LcmDmaapResponseList.size() < 1) { + clearSystemProperty(); + fail("Can not get LcmDmaapResponse list"); + return; + } + + LcmOutput lcmOutput = LcmDmaapResponseList.get(0).getBody().getOutput(); + + String expectedLcmOutput = LcmOutputTest.getExpectedLcmOutput(); + try { + String lcmOutputString = sdncLcmMessageBuilderTest.convertToSting(lcmOutput); + assertEquals(expectedLcmOutput, lcmOutputString); + } catch (Exception e) { + fail("Convert LcmOutput to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilderTest.java new file mode 100644 index 0000000000..d930c6728c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilderTest.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import org.onap.so.client.sdnc.lcm.beans.LcmBeanTest; +import org.onap.so.client.sdnc.lcm.beans.LcmInput; +import org.onap.so.client.sdnc.lcm.beans.LcmInputTest; + +public class SDNCLcmMessageBuilderTest extends LcmBeanTest { + + public LcmInput buildLcmInputForPnf() { + LcmInput lcmInput = + SDNCLcmMessageBuilder.buildLcmInputForPnf(requestId, subRequestId, pnfName, action, inputPayload); + + lcmInput.getCommonHeader().setTimestamp(timestamp); + + return lcmInput; + } + + @Test + public final void testBuildLcmRestRequestForPnf() { + LcmInput lcmInput = buildLcmInputForPnf(); + + String expectedLcmInput = LcmInputTest.getExpectedLcmInput(); + try { + String lcmInputString = convertToSting(lcmInput); + assertEquals(expectedLcmInput, lcmInputString); + } catch (Exception e) { + fail("Convert LcmInput to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmRestClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmRestClientTest.java new file mode 100644 index 0000000000..04cfc6e3c8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmRestClientTest.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm; + +import org.apache.http.HttpStatus; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.fail; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import org.onap.logging.filter.base.ONAPComponents; +import org.onap.so.BaseTest; +import org.onap.so.client.restproperties.SDNCLcmPropertiesImpl; +import org.onap.so.client.sdnc.common.SDNCConstants; +import org.onap.so.client.sdnc.lcm.beans.*; + +public class SDNCLcmRestClientTest extends BaseTest { + + protected SDNCLcmMessageBuilderTest sdncLcmMessageBuilderTest = new SDNCLcmMessageBuilderTest(); + + protected static final String SDNC_HOST_PROP = SDNCLcmPropertiesImpl.SDNC_HOST; + protected static final String SDNC_PATH_PROP = SDNCLcmPropertiesImpl.LCM_PATH; + + private void clearSystemProperty() { + System.clearProperty(SDNC_HOST_PROP); + System.clearProperty(SDNC_PATH_PROP); + } + + public SDNCLcmRestClient buildSDNCLcmRestClient() { + String testHost = "http://localhost:" + wireMockPort; + + System.setProperty(SDNC_HOST_PROP, testHost); + System.setProperty(SDNC_PATH_PROP, SDNCConstants.LCM_API_BASE_PATH); + + SDNCLcmProperties sdncLcmProperties = new SDNCLcmPropertiesImpl(); + SDNCLcmClientBuilder sdncLcmClientBuilder = new SDNCLcmClientBuilder(sdncLcmProperties); + + try { + return sdncLcmClientBuilder.newSDNCLcmRestClient(sdncLcmMessageBuilderTest.getOperation()); + } catch (Exception e) { + clearSystemProperty(); + fail("Create SDNCLcmRestClient error: " + e.toString()); + return null; + } + } + + @Test + public final void testSDNCLcmRestClientSendRequest() { + SDNCLcmRestClient sdncLcmRestClient = buildSDNCLcmRestClient(); + + assertNotEquals(null, sdncLcmRestClient); + assertEquals(ONAPComponents.SDNC, sdncLcmRestClient.getTargetEntity()); + + String testLcmApiPath = SDNCConstants.LCM_API_BASE_PATH + sdncLcmMessageBuilderTest.getOperation(); + String expectedLcmRestResponse = LcmRestResponseTest.getExpectedLcmRestResponse(); + wireMockServer.stubFor(post(urlPathEqualTo(testLcmApiPath)) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(expectedLcmRestResponse) + .withStatus(HttpStatus.SC_OK))); + + LcmInput lcmInput = sdncLcmMessageBuilderTest.buildLcmInputForPnf(); + LcmOutput lcmOutput = sdncLcmRestClient.sendRequest(lcmInput); + + clearSystemProperty(); + + String expectedLcmOutput = LcmOutputTest.getExpectedLcmOutput(); + try { + String lcmOutputString = sdncLcmMessageBuilderTest.convertToSting(lcmOutput); + assertEquals(expectedLcmOutput, lcmOutputString); + } catch (Exception e) { + fail("Convert LcmOutput to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmBeanTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmBeanTest.java new file mode 100644 index 0000000000..5562444a46 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmBeanTest.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.onap.so.client.sdnc.common.SDNCConstants; + +public class LcmBeanTest { + private static Logger logger = LoggerFactory.getLogger(LcmBeanTest.class); + + protected String requestId = "9f77f437-1515-44bd-a420-0aaf8a3c31a0"; + protected String subRequestId = "c197a4b5-18d9-48a2-ad2d-a3b56858501c"; + protected String timestamp = "2020-02-25T10:20:28.116Z"; + + protected String pnfName = "testpnf"; + protected String action = "TestAction"; + protected String operation = "test-operation"; + + protected String inputPayload = "{\"testPayload\": \"input test\"}"; + protected String outputPayload = "{\"testPayload\": \"output test\"}"; + + public String getOperation() { + return operation; + } + + public LcmFlags buildSDNCFlags() { + LcmFlags lcmFlags = new LcmFlags(); + + lcmFlags.setMode(SDNCConstants.LCM_FLAGS_MODE_NORMAL); + lcmFlags.setForce(SDNCConstants.LCM_FLAGS_FORCE_FALSE); + lcmFlags.setTtl(SDNCConstants.LCM_FLAGS_TTL); + + return lcmFlags; + } + + public LcmCommonHeader buildLcmCommonHeader() { + LcmCommonHeader lcmCommonHeader = new LcmCommonHeader(); + + lcmCommonHeader.setApiVer(SDNCConstants.LCM_API_VER); + lcmCommonHeader.setFlags(buildSDNCFlags()); + lcmCommonHeader.setOriginatorId(SDNCConstants.SYSTEM_NAME); + lcmCommonHeader.setRequestId(requestId); + lcmCommonHeader.setSubRequestId(subRequestId); + lcmCommonHeader.setTimestamp(timestamp); + + return lcmCommonHeader; + } + + public String convertToSting(Object msgObject) throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + + String msgString = mapper.writeValueAsString(msgObject); + logger.debug(msgObject.getClass().getSimpleName() + "\n" + msgString); + + return msgString; + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapRequestTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapRequestTest.java new file mode 100644 index 0000000000..709a557937 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapRequestTest.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import org.junit.Test; +import org.onap.so.client.sdnc.common.SDNCConstants; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class LcmDmaapRequestTest extends LcmBeanTest { + private static String expectedLcmDmaapRequest = "{" + "\"version\":\"1.0\"," + "\"type\":\"request\"," + + "\"cambria.partition\":\"MSO\"," + + "\"correlation-id\":\"9f77f437-1515-44bd-a420-0aaf8a3c31a0-c197a4b5-18d9-48a2-ad2d-a3b56858501c\"," + + "\"rpc-name\":\"test-operation\"," + "\"body\":" + LcmRestRequestTest.getExpectedLcmRestRequest() + "}"; + + public LcmDmaapRequest buildLcmDmaapRequest() { + LcmDmaapRequest lcmDmaapRequest = new LcmDmaapRequest(); + + LcmRestRequestTest lcmRestRequestTest = new LcmRestRequestTest(); + LcmRestRequest lcmRestRequest = lcmRestRequestTest.buildLcmRestRequest(); + LcmCommonHeader lcmCommonHeader = lcmRestRequest.getInput().getCommonHeader(); + String correlationId = lcmCommonHeader.getRequestId() + "-" + lcmCommonHeader.getSubRequestId(); + + lcmDmaapRequest.setVersion(SDNCConstants.LCM_DMAAP_MSG_VER); + lcmDmaapRequest.setType(SDNCConstants.LCM_DMAAP_MSG_TYPE_REQUEST); + lcmDmaapRequest.setCambriaPartition(SDNCConstants.SYSTEM_NAME); + lcmDmaapRequest.setCorrelationId(correlationId); + lcmDmaapRequest.setRpcName(operation); + lcmDmaapRequest.setBody(lcmRestRequest); + + return lcmDmaapRequest; + } + + public static String getExpectedLcmDmaapRequest() { + return expectedLcmDmaapRequest; + } + + @Test + public final void testLcmDmaapRequest() { + LcmDmaapRequest lcmDmaapRequest = buildLcmDmaapRequest(); + + try { + String lcmDmaapRequestString = convertToSting(lcmDmaapRequest); + assertEquals(expectedLcmDmaapRequest, lcmDmaapRequestString); + } catch (Exception e) { + fail("Convert LcmDmaapRequest to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapResponseTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapResponseTest.java new file mode 100644 index 0000000000..0cdbeebb27 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmDmaapResponseTest.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import org.junit.Test; +import org.onap.so.client.sdnc.common.SDNCConstants; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class LcmDmaapResponseTest extends LcmBeanTest { + private static String expectedLcmDmaapResponse = "{" + "\"version\":\"1.0\"," + "\"type\":\"response\"," + + "\"cambria.partition\":\"MSO\"," + + "\"correlation-id\":\"9f77f437-1515-44bd-a420-0aaf8a3c31a0-c197a4b5-18d9-48a2-ad2d-a3b56858501c\"," + + "\"rpc-name\":\"test-operation\"," + "\"body\":" + LcmRestResponseTest.getExpectedLcmRestResponse() + "}"; + + public LcmDmaapResponse buildLcmDmaapResponse() { + LcmDmaapResponse lcmDmaapResponse = new LcmDmaapResponse(); + + LcmRestResponseTest lcmRestResponseTest = new LcmRestResponseTest(); + LcmRestResponse lcmRestResponse = lcmRestResponseTest.buildLcmRestResponse(); + LcmCommonHeader lcmCommonHeader = lcmRestResponse.getOutput().getCommonHeader(); + String correlationId = lcmCommonHeader.getRequestId() + "-" + lcmCommonHeader.getSubRequestId(); + + lcmDmaapResponse.setVersion(SDNCConstants.LCM_DMAAP_MSG_VER); + lcmDmaapResponse.setType(SDNCConstants.LCM_DMAAP_MSG_TYPE_RESPONSE); + lcmDmaapResponse.setCambriaPartition(SDNCConstants.SYSTEM_NAME); + lcmDmaapResponse.setCorrelationId(correlationId); + lcmDmaapResponse.setRpcName(operation); + lcmDmaapResponse.setBody(lcmRestResponse); + + return lcmDmaapResponse; + } + + public static String getExpectedLcmDmaapResponse() { + return expectedLcmDmaapResponse; + } + + @Test + public final void testLcmDmaapResponse() { + LcmDmaapResponse lcmDmaapResponse = buildLcmDmaapResponse(); + + try { + String lcmDmaapResponseString = convertToSting(lcmDmaapResponse); + assertEquals(expectedLcmDmaapResponse, lcmDmaapResponseString); + } catch (Exception e) { + fail("Convert LcmDmaapResponse to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmInputTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmInputTest.java new file mode 100644 index 0000000000..b8c34fcbc7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmInputTest.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class LcmInputTest extends LcmBeanTest { + private static String expectedLcmInput = "{" + "\"common-header\":{" + "\"api-ver\":\"2.00\"," + + "\"flags\":{\"mode\":\"NORMAL\",\"force\":\"FALSE\",\"ttl\":65000}," + "\"originator-id\":\"MSO\"," + + "\"request-id\":\"9f77f437-1515-44bd-a420-0aaf8a3c31a0\"," + + "\"sub-request-id\":\"c197a4b5-18d9-48a2-ad2d-a3b56858501c\"," + + "\"timestamp\":\"2020-02-25T10:20:28.116Z\"" + "}," + "\"action\":\"TestAction\"," + + "\"action-identifiers\":{\"pnf-name\":\"testpnf\"}," + + "\"payload\":\"{\\\"testPayload\\\": \\\"input test\\\"}\"}"; + + public LcmInput buildLcmInput() { + LcmInput lcmInput = new LcmInput(); + + LcmCommonHeader lcmCommonHeader = buildLcmCommonHeader(); + + LcmActionIdentifiers lcmActionIdentifiers = new LcmActionIdentifiers(); + lcmActionIdentifiers.setPnfName(pnfName); + + lcmInput.setCommonHeader(lcmCommonHeader); + lcmInput.setAction(action); + lcmInput.setActionIdentifiers(lcmActionIdentifiers); + lcmInput.setPayload(inputPayload); + + return lcmInput; + } + + public static String getExpectedLcmInput() { + return expectedLcmInput; + } + + @Test + public final void testLcmInput() { + LcmInput lcmInput = buildLcmInput(); + + try { + String lcmInputString = convertToSting(lcmInput); + assertEquals(expectedLcmInput, lcmInputString); + } catch (Exception e) { + fail("Convert LcmInput to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmOutputTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmOutputTest.java new file mode 100644 index 0000000000..1530be38a7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmOutputTest.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import org.onap.so.client.sdnc.common.SDNCConstants; + +public class LcmOutputTest extends LcmBeanTest { + private static String expectedLcmOutput = "{" + "\"common-header\":{" + "\"api-ver\":\"2.00\"," + + "\"originator-id\":\"MSO\"," + "\"request-id\":\"9f77f437-1515-44bd-a420-0aaf8a3c31a0\"," + + "\"sub-request-id\":\"c197a4b5-18d9-48a2-ad2d-a3b56858501c\"" + "}," + + "\"status\":{\"code\":400,\"message\":\"Test output message\"}," + + "\"payload\":\"{\\\"testPayload\\\": \\\"output test\\\"}\"}"; + + @Override + public LcmCommonHeader buildLcmCommonHeader() { + LcmCommonHeader lcmCommonHeader = new LcmCommonHeader(); + + lcmCommonHeader.setApiVer(SDNCConstants.LCM_API_VER); + lcmCommonHeader.setOriginatorId(SDNCConstants.SYSTEM_NAME); + lcmCommonHeader.setRequestId(requestId); + lcmCommonHeader.setSubRequestId(subRequestId); + + return lcmCommonHeader; + } + + public LcmStatus buildLcmStatus() { + LcmStatus lcmStatus = new LcmStatus(); + + lcmStatus.setCode(400); + lcmStatus.setMessage("Test output message"); + + return lcmStatus; + } + + public LcmOutput buildLcmOutput() { + LcmOutput lcmOutput = new LcmOutput(); + + LcmCommonHeader lcmCommonHeader = buildLcmCommonHeader(); + LcmStatus lcmStatus = buildLcmStatus(); + + lcmOutput.setCommonHeader(lcmCommonHeader); + lcmOutput.setStatus(lcmStatus); + lcmOutput.setPayload(outputPayload); + + return lcmOutput; + } + + public static String getExpectedLcmOutput() { + return expectedLcmOutput; + } + + @Test + public final void testLcmOutput() { + LcmOutput lcmOutput = buildLcmOutput(); + + try { + String lcmOutputString = convertToSting(lcmOutput); + assertEquals(expectedLcmOutput, lcmOutputString); + } catch (Exception e) { + fail("Convert LcmOutput to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmRestRequestTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmRestRequestTest.java new file mode 100644 index 0000000000..c078326c82 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmRestRequestTest.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class LcmRestRequestTest extends LcmBeanTest { + private static String expectedLcmRestRequest = "{" + "\"input\":" + LcmInputTest.getExpectedLcmInput() + "}"; + + public LcmRestRequest buildLcmRestRequest() { + LcmRestRequest lcmRestRequest = new LcmRestRequest(); + + LcmInputTest lcmInputTest = new LcmInputTest(); + lcmRestRequest.setInput(lcmInputTest.buildLcmInput()); + + return lcmRestRequest; + } + + public static String getExpectedLcmRestRequest() { + return expectedLcmRestRequest; + } + + @Test + public final void testLcmRestRequest() { + LcmRestRequest lcmRestRequest = buildLcmRestRequest(); + + try { + String lcmRestRequestString = convertToSting(lcmRestRequest); + assertEquals(expectedLcmRestRequest, lcmRestRequestString); + } catch (Exception e) { + fail("Convert LcmRestRequest to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmRestResponseTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmRestResponseTest.java new file mode 100644 index 0000000000..5867acb421 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/LcmRestResponseTest.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.onap.so.client.sdnc.lcm.beans; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class LcmRestResponseTest extends LcmBeanTest { + private static String expectedLcmRestResponse = "{" + "\"output\":" + LcmOutputTest.getExpectedLcmOutput() + "}"; + + public LcmRestResponse buildLcmRestResponse() { + LcmRestResponse lcmRestResponse = new LcmRestResponse(); + + LcmOutputTest lcmOutputTest = new LcmOutputTest(); + lcmRestResponse.setOutput(lcmOutputTest.buildLcmOutput()); + + return lcmRestResponse; + } + + public static String getExpectedLcmRestResponse() { + return expectedLcmRestResponse; + } + + @Test + public final void testLcmRestResponse() { + LcmRestResponse lcmRestResponse = buildLcmRestResponse(); + + try { + String lcmRestResponseString = convertToSting(lcmRestResponse); + assertEquals(expectedLcmRestResponse, lcmRestResponseString); + } catch (Exception e) { + fail("Convert LcmRestResponse to String error: " + e.toString()); + } + } +} diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java index f9db93e3f7..80fd3eede4 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java @@ -58,6 +58,12 @@ public class PnfManagementTestImpl implements PnfManagement { serviceAndPnfRelationMap.put(serviceInstanceId, pnfName); } + @Override + public void updateEntry(String pnfCorrelationId, Pnf entry) { + created.put(pnfCorrelationId, entry); + } + + public Map<String, Pnf> getCreated() { return created; } diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn index 11d77bf97a..88e5eadef2 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigAssignVnfBB.bpmn @@ -12,7 +12,7 @@ <bpmn:callActivity id="CallActivity_1gfzi2g" name="Abstract CDS (CDS Call) " calledElement="AbstractCDSProcessingBB"> <bpmn:extensionElements> <camunda:out source="WorkflowException" target="WorkflowException" /> - <camunda:out source="CDSStatus" target="CDSStatus" /> + <camunda:out source="ControllerStatus" target="ControllerStatus" /> <camunda:in source="executionObject" target="executionObject" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_05qembo</bpmn:incoming> @@ -34,7 +34,7 @@ </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_0cvsnuu" sourceRef="CallActivity_1gfzi2g" targetRef="ExclusiveGateway_13q340y" /> <bpmn:sequenceFlow id="SequenceFlow_07tqu82" name="success" sourceRef="ExclusiveGateway_13q340y" targetRef="Task_1hs1mn0"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("CDSStatus").equals("Success")}]]></bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("ControllerStatus").equals("Success")}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:endEvent id="EndEvent_0mnaj50"> <bpmn:incoming>SequenceFlow_15gxql1</bpmn:incoming> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn index 92ac5f9f5b..3993eca467 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ConfigDeployVnfBB.bpmn @@ -18,7 +18,7 @@ <bpmn:extensionElements> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="executionObject" target="executionObject" /> - <camunda:out source="CDSStatus" target="CDSStatus" /> + <camunda:out source="ControllerStatus" target="ControllerStatus" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0kruy8t</bpmn:incoming> <bpmn:outgoing>SequenceFlow_03xbj4e</bpmn:outgoing> @@ -39,7 +39,7 @@ <bpmn:outgoing>SequenceFlow_0o50k2d</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_1tb7fs1" name="success" sourceRef="ExclusiveGateway_0duh80v" targetRef="UpdateAAIConfigured"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_0o50k2d" sourceRef="ExclusiveGateway_0duh80v" targetRef="EndEvent_0wwnq4u" /> <bpmn:endEvent id="EndEvent_0wwnq4u"> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn index 32d3bce469..279fdc0983 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn @@ -13,7 +13,7 @@ <bpmn:callActivity id="CallActivity_1gfzi2g" name="Abstract CDS (CDS Call) " calledElement="AbstractCDSProcessingBB"> <bpmn:extensionElements> <camunda:out source="WorkflowException" target="WorkflowException" /> - <camunda:out source="CDSStatus" target="CDSStatus" /> + <camunda:out source="ControllerStatus" target="ControllerStatus" /> <camunda:in source="executionObject" target="executionObject" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_05qembo</bpmn:incoming> @@ -35,7 +35,7 @@ </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_0cvsnuu" sourceRef="CallActivity_1gfzi2g" targetRef="ExclusiveGateway_13q340y" /> <bpmn:sequenceFlow id="SequenceFlow_07tqu82" name="success" sourceRef="ExclusiveGateway_13q340y" targetRef="Task_1hs1mn0"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:endEvent id="EndEvent_0mnaj50"> <bpmn:incoming>SequenceFlow_15gxql1</bpmn:incoming> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java new file mode 100644 index 0000000000..4482d2a327 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java @@ -0,0 +1,165 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.pnf.delegate; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*; + +/** + * This implementation of {@link JavaDelegate} is used to populate the execution object for pnf software upgrade + */ +@Component +public class NfSoftwareUpgradeDispatcher implements JavaDelegate { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + private static final String SERVICE_INSTANCE_NAME = "serviceInstanceName"; + private static final String BPMN_REQUEST = "bpmnRequest"; + private static final String RESOURCE_CUSTOMIZATION_UUID_PARAM = "resource_customization_uuid"; + private static final String PNF_NAME = "pnfName"; + + // ERROR CODE for variable not found in the delegation Context + private static final int ERROR_CODE = 601; + + @Autowired + private PnfManagement pnfManagement; + + @Autowired + private ExceptionBuilder exceptionUtil; + + @Autowired + private CatalogDbClient catalogDbClient; + + @Autowired + private ObjectMapper mapper; + + @Override + public void execute(DelegateExecution delegateExecution) throws Exception { + logger.debug("Running execute block for activity id:{}, name:{}", delegateExecution.getCurrentActivityId(), + delegateExecution.getCurrentActivityName()); + + RequestDetails bpmnRequestDetails = requestVerification(delegateExecution); + + final String serviceInstanceName = bpmnRequestDetails.getRequestInfo().getInstanceName(); + final String pnfName = bpmnRequestDetails.getRequestParameters().getUserParamValue(PNF_NAME); + final String serviceModelUuid = bpmnRequestDetails.getModelInfo().getModelUuid(); + final List<Map<String, Object>> userParams = bpmnRequestDetails.getRequestParameters().getUserParams(); + final Pnf pnf = getPnfByPnfName(delegateExecution, pnfName); + final List<PnfResourceCustomization> pnfCustomizations = + getPnfResourceCustomizations(delegateExecution, serviceModelUuid); + final PnfResourceCustomization pnfResourceCustomization = pnfCustomizations.get(0); + + populateExecution(delegateExecution, bpmnRequestDetails, pnfResourceCustomization, pnf, serviceInstanceName, + pnfName, serviceModelUuid, userParams); + + logger.trace("Completed preProcessRequest PnfSoftwareUpgradeServiceRequest Request "); + } + + private RequestDetails requestVerification(DelegateExecution delegateExecution) throws IOException { + RequestDetails bpmnRequestDetails = mapper.readValue( + JsonUtils.getJsonValue(String.valueOf(delegateExecution.getVariable(BPMN_REQUEST)), "requestDetails"), + RequestDetails.class); + + throwIfNull(delegateExecution, bpmnRequestDetails.getModelInfo(), SERVICE_MODEL_INFO); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestInfo(), "RequestInfo"); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters(), "RequestParameters"); + throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters().getUserParams(), "UserParams"); + + return bpmnRequestDetails; + } + + private void populateExecution(DelegateExecution delegateExecution, RequestDetails bpmnRequestDetails, + PnfResourceCustomization pnfResourceCustomization, Pnf pnf, String serviceInstanceName, String pnfName, + String serviceModelUuid, List<Map<String, Object>> userParams) { + + delegateExecution.setVariable(SERVICE_MODEL_INFO, bpmnRequestDetails.getModelInfo()); + delegateExecution.setVariable(SERVICE_INSTANCE_NAME, serviceInstanceName); + delegateExecution.setVariable(PNF_CORRELATION_ID, pnfName); + delegateExecution.setVariable(MODEL_UUID, serviceModelUuid); + delegateExecution.setVariable(PNF_UUID, pnf.getPnfId()); + delegateExecution.setVariable(PRC_BLUEPRINT_NAME, pnfResourceCustomization.getBlueprintName()); + delegateExecution.setVariable(PRC_BLUEPRINT_VERSION, pnfResourceCustomization.getBlueprintVersion()); + delegateExecution.setVariable(PRC_CUSTOMIZATION_UUID, pnfResourceCustomization.getModelCustomizationUUID()); + delegateExecution.setVariable(RESOURCE_CUSTOMIZATION_UUID_PARAM, + pnfResourceCustomization.getModelCustomizationUUID()); + delegateExecution.setVariable(PRC_INSTANCE_NAME, pnfResourceCustomization.getModelInstanceName()); + delegateExecution.setVariable(PRC_CONTROLLER_ACTOR, pnfResourceCustomization.getControllerActor()); + + for (Map<String, Object> param : userParams) { + if (param.containsKey("name") && param.containsKey("value")) { + delegateExecution.setVariable(param.get("name").toString(), param.get("value").toString()); + } + } + } + + private Pnf getPnfByPnfName(DelegateExecution delegateExecution, String pnfName) { + Optional<Pnf> pnfOptional = null; + try { + pnfOptional = pnfManagement.getEntryFor(pnfName); + } catch (IOException e) { + logger.warn(e.getMessage(), e); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "Unable to fetch from AAI" + e.getMessage()); + } + if (pnfOptional == null || !pnfOptional.isPresent()) { + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "AAI entry for PNF: " + pnfName + " does not exist"); + } + return pnfOptional.get(); + } + + private List<PnfResourceCustomization> getPnfResourceCustomizations(DelegateExecution delegateExecution, + String serviceModelUuid) { + List<PnfResourceCustomization> pnfCustomizations = + catalogDbClient.getPnfResourceCustomizationByModelUuid(serviceModelUuid); + + if (pnfCustomizations == null || pnfCustomizations.isEmpty()) { + logger.warn("Unable to find the PNF resource customizations of model service UUID: {}", serviceModelUuid); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "Unable to find the PNF resource customizations of model service UUID: " + serviceModelUuid); + } + return pnfCustomizations; + } + + private void throwIfNull(DelegateExecution delegateExecution, Object obj, String param) { + if (obj == null) { + logger.warn("Unable to find the parameter: {} in the execution context", param); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "Unable to find parameter " + param); + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAai.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAai.java new file mode 100644 index 0000000000..f85be8aab7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAai.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.pnf.delegate; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.onap.so.client.exception.ExceptionBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.util.Optional; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; +import static org.onap.so.client.cds.PayloadConstants.PRC_TARGET_SOFTWARE_VERSION; + + +@Component +public class UpdatePnfEntryInAai implements JavaDelegate { + + private final Logger logger = LoggerFactory.getLogger(UpdatePnfEntryInAai.class); + + @Autowired + private PnfManagement pnfManagement; + + @Autowired + private ExceptionBuilder exceptionUtil; + + @Override + public void execute(DelegateExecution execution) throws Exception { + String pnfCorrelationId = String.valueOf(execution.getVariable(PNF_CORRELATION_ID)); + Optional<Pnf> pnfAaiEntry = pnfManagement.getEntryFor(pnfCorrelationId); + + if (!pnfAaiEntry.isPresent()) { + exceptionUtil.buildAndThrowWorkflowException(execution, 404, + "AAI entry for PNF: " + PNF_CORRELATION_ID + " does not exist"); + } + + Pnf pnf = pnfAaiEntry.get(); + String pnfSoftwareVersion = String.valueOf(execution.getVariable(PRC_TARGET_SOFTWARE_VERSION)); + pnf.setSwVersion(pnfSoftwareVersion); + + pnfManagement.updateEntry(pnfCorrelationId, pnf); + logger.debug("AAI entry is updated for pnf correlation id: {}, pnf uuid: {} with swVersion: {}", + pnf.getPnfName(), pnfCorrelationId, pnfSoftwareVersion); + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java index 9e720fe0a4..46937d0d8c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java @@ -30,5 +30,7 @@ public interface PnfManagement { void createEntry(String pnfCorrelationId, Pnf entry) throws IOException; + void updateEntry(String pnfCorrelationId, Pnf entry) throws IOException; + void createRelation(String serviceInstanceId, String pnfName) throws IOException; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java index b1af8b1e0b..e6df8070a3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java @@ -44,6 +44,11 @@ public class PnfManagementImpl implements PnfManagement { restClient.createPnf(pnfCorrelationId, entry); } + public void updateEntry(String pnfCorrelationId, Pnf entry) { + AAIRestClientImpl restClient = new AAIRestClientImpl(); + restClient.updatePnf(pnfCorrelationId, entry); + } + @Override public void createRelation(String serviceInstanceId, String pnfName) { AAIResourceUri serviceInstanceURI = diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatusTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatusTest.groovy new file mode 100644 index 0000000000..f066f9e878 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatusTest.groovy @@ -0,0 +1,344 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + +import static org.junit.Assert.assertEquals +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class CheckServiceProcessStatusTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("CheckServiceProcessStatus") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + + @Test + void testPreProcessRequest () { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + + def successConditions = new ArrayList<>() + successConditions.add("finished") + successConditions.add("completed") + + def errorConditions = new ArrayList<>() + errorConditions.add("error") + errorConditions.add("failed") + + when(mockExecution.getVariable("successConditions")).thenReturn(successConditions) + when(mockExecution.getVariable("errorConditions")).thenReturn(errorConditions) + + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(9)).setVariable(captor.capture(), captor.capture()) + } + + + @Test + void testPreCheckServiceStatusReq() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + + serviceProcessStatus.preCheckServiceStatusReq(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("getOperationStatus"), captor.capture()) + String res = captor.getValue() + String expect = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:getServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>12345</serviceId> + <operationId>54321</operationId> + </ns:getServiceOperationStatus> + </soapenv:Body> + </soapenv:Envelope> + """ + assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", "")) + } + + + @Test + void testHandlerServiceStatusRespSuccess() { + mockData() + when(mockExecution.getVariable("dbResponseCode")).thenReturn(200) + when(mockExecution.getVariable("dbResponse")).thenReturn(getDBResponse("finished")) + def successConditions = new ArrayList<>() + successConditions.add("finished") + successConditions.add("completed") + + when(mockExecution.getVariable("successConditions")).thenReturn(successConditions) + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.handlerServiceStatusResp(mockExecution) + + Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + + def expect = new ArrayList<>() + expect.add("operationStatus") + expect.add("finished") + expect.add("operationContent") + expect.add("communication service create operation finished success") + expect.add("orchestrationStatus") + expect.add("deactivated") + expect.add("isAllFinished") + expect.add("true") + + assertEquals(expect, resultSuccess) + } + + + @Test + void testHandlerServiceStatusRespError() { + mockData() + when(mockExecution.getVariable("dbResponseCode")).thenReturn(200) + when(mockExecution.getVariable("dbResponse")).thenReturn(getDBResponse("error")) + + def successConditions = new ArrayList<>() + successConditions.add("finished") + successConditions.add("completed") + + def errorConditions = new ArrayList<>() + errorConditions.add("error") + errorConditions.add("failed") + + when(mockExecution.getVariable("successConditions")).thenReturn(successConditions) + when(mockExecution.getVariable("errorConditions")).thenReturn(errorConditions) + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.handlerServiceStatusResp(mockExecution) + + Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + + def expect = new ArrayList<>() + expect.add("operationStatus") + expect.add("error") + expect.add("operationContent") + expect.add("communication service create operation finished with error") + expect.add("orchestrationStatus") + expect.add("error") + expect.add("isAllFinished") + expect.add("true") + + assertEquals(expect, resultSuccess) + } + + + @Test + void testHandlerServiceStatusRespProcessingNo() { + mockData() + when(mockExecution.getVariable("dbResponseCode")).thenReturn(200) + when(mockExecution.getVariable("dbResponse")).thenReturn(getDBResponse("processing")) + when(mockExecution.getVariable("progress")).thenReturn(50) + + def successConditions = new ArrayList<>() + successConditions.add("finished") + successConditions.add("completed") + + def errorConditions = new ArrayList<>() + errorConditions.add("error") + errorConditions.add("failed") + + when(mockExecution.getVariable("successConditions")).thenReturn(successConditions) + when(mockExecution.getVariable("errorConditions")).thenReturn(errorConditions) + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.handlerServiceStatusResp(mockExecution) + + Mockito.verify(mockExecution, times(2)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + + def expect = new ArrayList<>() + expect.add("isNeedUpdateDB") + expect.add("false") + expect.add("isAllFinished") + expect.add("false") + + assertEquals(expect as String, resultSuccess as String) + } + + + @Test + void testHandlerServiceStatusRespProcessingYes() { + mockData() + when(mockExecution.getVariable("dbResponseCode")).thenReturn(200) + when(mockExecution.getVariable("dbResponse")).thenReturn(getDBResponse("processing")) + when(mockExecution.getVariable("progress")).thenReturn(60) + + def successConditions = new ArrayList<>() + successConditions.add("finished") + successConditions.add("completed") + + def errorConditions = new ArrayList<>() + errorConditions.add("error") + errorConditions.add("failed") + + when(mockExecution.getVariable("successConditions")).thenReturn(successConditions) + when(mockExecution.getVariable("errorConditions")).thenReturn(errorConditions) + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.handlerServiceStatusResp(mockExecution) + + Mockito.verify(mockExecution, times(3)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + + def expect = new ArrayList<>() + expect.add("progress") + expect.add("50") + expect.add("isNeedUpdateDB") + expect.add("true") + expect.add("isAllFinished") + expect.add("false") + + assertEquals(expect as String, resultSuccess as String) + } + + + @Test + void testTimeWaitDelayNo() { + mockData() + when(mockExecution.getVariable("startTime")).thenReturn(System.currentTimeMillis()) + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + + serviceProcessStatus.timeWaitDelay(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("isTimeOut"), captor.capture()) + def res = captor.getValue() + + assertEquals("NO", res) + } + + + @Test + void testTimeWaitDelayYes() { + mockData() + when(mockExecution.getVariable("startTime")).thenReturn(1000000) + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + + serviceProcessStatus.timeWaitDelay(mockExecution) + Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture()) + def res = captor.getAllValues() + def expect = new ArrayList<>() + expect.add("operationStatus") + expect.add("error") + expect.add("operationContent") + expect.add("communication service create operation finished with timeout") + expect.add("orchestrationStatus") + expect.add("error") + expect.add("isTimeOut") + expect.add("YES") + + assertEquals(expect, res) + } + + + @Test + void testPreUpdateOperationProgress() { + mockData() + when(mockExecution.getVariable("progress")).thenReturn(50) + when(mockExecution.getVariable("initProgress")).thenReturn(20) + when(mockExecution.getVariable("endProgress")).thenReturn(90) + when(mockExecution.getVariable("operationType")).thenReturn("CREATE") + when(mockExecution.getVariable("processServiceType")).thenReturn("communication service") + when(mockExecution.getVariable("parentServiceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("parentOperationId")).thenReturn("54321") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + + CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus() + serviceProcessStatus.preUpdateOperationProgress(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + + String expect = getExpectPayload("55", + "communication service CREATE operation processing 55") + + assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", "")) + + + } + + + private static String getExpectPayload(String progress, String operationContent) { + String expect = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:updateServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>12345</serviceId> + <operationId>54321</operationId> + <operationType>CREATE</operationType> + <userId>11111</userId> + <result>processing</result> + <operationContent>${operationContent}</operationContent> + <progress>${progress}</progress> + <reason></reason> + </ns:updateServiceOperationStatus> + </soapenv:Body> + </soapenv:Envelope> + """ + return expect + } + + + private static String getDBResponse(String result) { + String response = + """<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> + <soap:Body> + <ns2:getServiceOperationStatusResponse xmlns:ns2="http://org.onap.so/requestsdb"> + <return><operation>CREATE</operation> + <operationContent>Prepare service creation</operationContent> + <operationId>077995e3-eb32-44ae-b35d-491fc6983a44</operationId> + <progress>50</progress> + <reason></reason> + <result>${result}</result> + <serviceId>3324f117-696d-4518-b8b5-b01fcc127a03</serviceId> + <userId>5GCustomer</userId> + </return></ns2:getServiceOperationStatusResponse> + </soap:Body> + </soap:Envelope> + """ + return response + } + + + private mockData() { + when(mockExecution.getVariable("processServiceType")).thenReturn("communication service") + when(mockExecution.getVariable("operationType")).thenReturn("create") + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcherTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcherTest.java new file mode 100644 index 0000000000..3c568ffc83 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcherTest.java @@ -0,0 +1,182 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.pnf.delegate; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestInfo; +import org.onap.so.serviceinstancebeans.RequestParameters; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import java.io.IOException; +import java.util.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*; +import static org.onap.so.client.cds.PayloadConstants.PRC_TARGET_SOFTWARE_VERSION; + + +@RunWith(SpringJUnit4ClassRunner.class) +public class NfSoftwareUpgradeDispatcherTest { + + private static final String TEST_PROCESS_KEY = "processKey1"; + private static final String PROCESS_KEY = "testProcessKey"; + private static final String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource"; + private static final String TEST_PNF_RESOURCE_BLUEPRINT_NAME = "blueprintOnap"; + private static final String TEST_PNF_RESOURCE_BLUEPRINT_VERSION = "1.0.1"; + private static final String TEST_PNF_RESOURCE_CUSTOMIZATION_UUID = "9acb3a83-8a52-412c-9a45-901764938144"; + private static final String TEST_PNF_CORRELATION_ID = "PNFDemo"; + private static final String TEST_PNF_UUID = "FakeID"; + private static final String TEST_PRC_CONTROLLER_ACTOR = "cds"; + private static final String TEST_TARGET_SOFTWARE_VERSION = "demo-sw-ver2.0.0"; + + private static final String TEST_BPMN_REQUEST = "{\"requestDetails\":{" + "\"requestInfo\":{" + + "\"source\":\"VID\"," + "\"suppressRollback\":false," + "\"requestorId\":\"demo\"," + + "\"productFamilyId\":\"SWUPid\"}," + "\"modelInfo\":{" + + "\"modelType\":\"service\",\"modelInvariantUuid\":\"439b7a2f-9524-4dbf-9eee-f2e05521df3f\"," + + "\"modelInvariantId\":\"439b7a2f-9524-4dbf-9eee-f2e05521df3f\"," + + "\"modelUuid\":\"42daaac6-5017-4e1e-96c8-6a27dfbe1421\",\"modelName\":\"PNF_int_service_2\"," + + "\"modelVersion\":\"1.0\"},\"requestParameters\":{\"userParams\":[{\"name\":\"aic_zone\"," + + "\"value\":\"nova\"},{\"name\":\"pnfId\",\"value\":\"PNFDemo\"},{\"name\":\"targetSoftwareVersion\",\"value\":\"demo-sw-ver2.0.0\"}]," + + "\"subscriptionServiceType\":\"SWUP\",\"aLaCarte\":false,\"pnfCorrelationId\":\"PNFDemo\"}," + + "\"cloudConfiguration\":{\"lcpCloudRegionId\":\"regionOne\",\"tenantId\":\"09a63533072f4a579d5c99c3b8fe94c6\"}," + + "\"subscriberInfo\":{\"globalSubscriberId\":\"ADemoCustomerInEric\"},\"project\":{\"projectName\":\"Project-Demonstration\"}," + + "\"owningEntity\":{\"owningEntityId\":\"5eae949c-1c50-4780-b8b5-7cbeb08856b4\",\"owningEntityName\":\"OE-Demonstration\"}}}"; + /** + * Testing model UUID, should be the same as specified in the TEST_SERVICE_MODEL_INFO. + */ + private static final String TEST_MODEL_UUID = "42daaac6-5017-4e1e-96c8-6a27dfbe1421"; + + @InjectMocks + private NfSoftwareUpgradeDispatcher nfSoftwareUpgradeDispatcher; + + @Mock + private PnfManagement pnfManagement; + + @Mock + private CatalogDbClient catalogDbClient; + + @Mock + private ObjectMapper mapper; + + private DelegateExecution execution = new DelegateExecutionFake(); + + @Before + public void setUp() throws IOException { + List<PnfResourceCustomization> pnfResourceCustomizations = new ArrayList<>(); + pnfResourceCustomizations.add(buildPnfResourceCustomization()); + given(catalogDbClient.getPnfResourceCustomizationByModelUuid(TEST_MODEL_UUID)) + .willReturn(pnfResourceCustomizations); + execution.setVariable(PROCESS_KEY, TEST_PROCESS_KEY); + execution.setVariable("bpmnRequest", TEST_BPMN_REQUEST); + mockMapper(); + mockAai(); + + } + + + @Test + public void testExecution_validCatalogDb_skipVariableSet() { + try { + nfSoftwareUpgradeDispatcher.execute(execution); + assertThat(execution.getVariable(MODEL_UUID)).isEqualTo(TEST_MODEL_UUID); + assertThat(execution.getVariable(PRC_TARGET_SOFTWARE_VERSION)).isEqualTo(TEST_TARGET_SOFTWARE_VERSION); + assertThat(execution.getVariable(PRC_BLUEPRINT_NAME)).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_NAME); + assertThat(execution.getVariable(PRC_BLUEPRINT_VERSION)).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_VERSION); + assertThat(execution.getVariable(PRC_CUSTOMIZATION_UUID)).isEqualTo(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID); + assertThat(execution.getVariable(PRC_INSTANCE_NAME)).isEqualTo(TEST_PNF_RESOURCE_INSTANCE_NAME); + assertThat(execution.getVariable(PNF_CORRELATION_ID)).isEqualTo(TEST_PNF_CORRELATION_ID); + assertThat(execution.getVariable(PNF_UUID)).isEqualTo(TEST_PNF_UUID); + assertThat(execution.getVariable(PRC_CONTROLLER_ACTOR)).isEqualTo(TEST_PRC_CONTROLLER_ACTOR); + } catch (Exception e) { + e.printStackTrace(); + fail("Exception thrown" + e.getMessage()); + } + } + + private void mockAai() throws IOException { + Pnf pnf = new Pnf(); + pnf.setPnfId(TEST_PNF_UUID); + when(pnfManagement.getEntryFor(TEST_PNF_CORRELATION_ID)).thenReturn(Optional.of(pnf)); + } + + private PnfResourceCustomization buildPnfResourceCustomization() { + PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization(); + pnfResourceCustomization.setSkipPostInstConf(true); + pnfResourceCustomization.setBlueprintName(TEST_PNF_RESOURCE_BLUEPRINT_NAME); + pnfResourceCustomization.setBlueprintVersion(TEST_PNF_RESOURCE_BLUEPRINT_VERSION); + pnfResourceCustomization.setModelInstanceName(TEST_PNF_RESOURCE_INSTANCE_NAME); + pnfResourceCustomization.setModelCustomizationUUID(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID); + pnfResourceCustomization.setControllerActor(TEST_PRC_CONTROLLER_ACTOR); + return pnfResourceCustomization; + } + + private void mockMapper() throws IOException { + RequestDetails bpmnRequestDetails = new RequestDetails(); + + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setInstanceName("demo"); + bpmnRequestDetails.setRequestInfo(requestInfo); + + RequestParameters requestParameters = new RequestParameters(); + List<Map<String, Object>> userParams = new ArrayList<>(); + Map<String, Object> map = new HashMap<>(); + map.put("name", "targetSoftwareVersion"); + map.put("value", TEST_TARGET_SOFTWARE_VERSION); + userParams.add(map); + map = new HashMap<>(); + map.put("name", "pnfName"); + map.put("value", "PNFDemo"); + userParams.add(map); + requestParameters.setUserParams(userParams); + + bpmnRequestDetails.setRequestParameters(requestParameters); + + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelInvariantUuid("439b7a2f-9524-4dbf-9eee-f2e05521df3f"); + modelInfo.setModelInvariantId("439b7a2f-9524-4dbf-9eee-f2e05521df3f"); + modelInfo.setModelUuid("42daaac6-5017-4e1e-96c8-6a27dfbe1421"); + modelInfo.setModelName("PNF_int_service_2"); + modelInfo.setModelVersion("1.0"); + + bpmnRequestDetails.setModelInfo(modelInfo); + + + doReturn(bpmnRequestDetails).when(mapper).readValue( + JsonUtils.getJsonValue(String.valueOf(execution.getVariable("bpmnRequest")), "requestDetails"), + RequestDetails.class); + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java index 8577d9555b..b93902d9f7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java @@ -50,6 +50,11 @@ public class PnfManagementTestImpl implements PnfManagement { } @Override + public void updateEntry(String pnfCorrelationId, Pnf entry) throws IOException { + created.put(pnfCorrelationId, entry); + } + + @Override public void createRelation(String serviceInstanceId, String pnfName) {} public Map<String, Pnf> getCreated() { diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java index f9b467c650..77377db9d9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java @@ -38,6 +38,11 @@ public class PnfManagementThrowingException implements PnfManagement { } @Override + public void updateEntry(String pnfCorrelationId, Pnf entry) throws IOException { + throw new IOException(); + } + + @Override public void createRelation(String serviceInstanceId, String pnfName) throws IOException { throw new IOException(); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAaiTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAaiTest.java new file mode 100644 index 0000000000..bddfe5b180 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAaiTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.pnf.delegate; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import static org.junit.Assert.*; +import java.io.IOException; +import java.util.Optional; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.*; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; +import static org.onap.so.client.cds.PayloadConstants.PRC_TARGET_SOFTWARE_VERSION; + +@RunWith(SpringJUnit4ClassRunner.class) +public class UpdatePnfEntryInAaiTest { + + @InjectMocks + private UpdatePnfEntryInAai updatePnfEntryInAai; + + @Mock + private PnfManagement pnfManagementTest; + + private DelegateExecution execution; + + + + @Test + public void shouldSetSwVersion() throws Exception { + // given + setupPnf(); + setupExecution(); + + // when + updatePnfEntryInAai.execute(execution); + + // verify + Optional<Pnf> modifiedEntry = pnfManagementTest.getEntryFor("testPnfCorrelationId"); + assertNotNull(modifiedEntry.get()); + assertThat(modifiedEntry.get().getPnfId()).isEqualTo("testtest"); + assertThat(modifiedEntry.get().getPnfName()).isEqualTo("testPnfCorrelationId"); + assertThat(modifiedEntry.get().getSwVersion()).isEqualTo("demo-1.2"); + verify(pnfManagementTest, times(2)).getEntryFor(anyString()); + } + + private void setupPnf() { + try { + Pnf pnf = new Pnf(); + pnf.setSwVersion("1"); + pnf.setPnfId("testtest"); + pnf.setPnfName("testPnfCorrelationId"); + doReturn(Optional.of(pnf)).when(pnfManagementTest).getEntryFor(anyString()); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private void setupExecution() { + execution = mock(DelegateExecution.class); + given(execution.getVariable(eq(PNF_CORRELATION_ID))).willReturn("testPnfCorrelationId"); + given(execution.getVariable(eq(PNF_UUID))).willReturn("testtest"); + given(execution.getVariable(eq(PRC_TARGET_SOFTWARE_VERSION))).willReturn("demo-1.2"); + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn index 693dd922e2..234c744e4a 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn @@ -22,7 +22,7 @@ <bpmn:outgoing>SequenceFlow_1w4p9f7</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_1owbpsy" name="Success" sourceRef="ExclusiveGateway_0vtv1wi" targetRef="Task_14cwhgk"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:exclusiveGateway id="ExclusiveGateway_01jwwmc" default="SequenceFlow_0d24h26"> <bpmn:incoming>SequenceFlow_02919fh</bpmn:incoming> @@ -30,7 +30,7 @@ <bpmn:outgoing>SequenceFlow_0d24h26</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_1n080up" name="Success" sourceRef="ExclusiveGateway_01jwwmc" targetRef="EndEvent_0xky46v"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_1w4p9f7" name="Failure" sourceRef="ExclusiveGateway_0vtv1wi" targetRef="EndEvent_16620h9" /> <bpmn:endEvent id="EndEvent_16620h9"> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn new file mode 100644 index 0000000000..24ca7104a7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0474hns" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.3.4"> + <bpmn:process id="PNFSWUPDownload" name="PNFSWUPDownload" isExecutable="true"> + <bpmn:startEvent id="download_StartEvent" name="Start Flow"> + <bpmn:outgoing>SequenceFlow_1fdclh0</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:serviceTask id="ServiceTask_1mpt2eq" name="NF Download Dispatcher" camunda:delegateExpression="${NfSoftwareUpgradeDispatcher}"> + <bpmn:incoming>SequenceFlow_1fdclh0</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_12155q6</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:endEvent id="download_EndEvent" name="End"> + <bpmn:incoming>SequenceFlow_1d2rfyx</bpmn:incoming> + <bpmn:terminateEventDefinition id="TerminateEventDefinition_1kiurmf" /> + </bpmn:endEvent> + <bpmn:exclusiveGateway id="ExclusiveGateway_1ja7grm" default="SequenceFlow_078xmlz"> + <bpmn:incoming>SequenceFlow_0o6b6a8</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_078xmlz</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0qznt4u</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_1j64ij1"> + <bpmn:incoming>SequenceFlow_078xmlz</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0b3kbjs" errorRef="Error_1q14dnd" /> + </bpmn:endEvent> + <bpmn:exclusiveGateway id="ExclusiveGateway_1rj84ne" default="SequenceFlow_1tfbzn1"> + <bpmn:incoming>SequenceFlow_1ccldpp</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0s6i4o9</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1tfbzn1</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_1ubpef4"> + <bpmn:incoming>SequenceFlow_1tfbzn1</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0wevx6s" errorRef="Error_1q14dnd" /> + </bpmn:endEvent> + <bpmn:exclusiveGateway id="ExclusiveGateway_08lusga" default="SequenceFlow_1gawssm"> + <bpmn:incoming>SequenceFlow_1kaikh5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1d2rfyx</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1gawssm</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_11hee4g"> + <bpmn:incoming>SequenceFlow_1gawssm</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_12tyzwb" errorRef="Error_1q14dnd" /> + </bpmn:endEvent> + <bpmn:serviceTask id="ServiceTask_0yavde3" name="Download" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">downloadNESw</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0s6i4o9</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0o6b6a8</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="ServiceTask_1wxo7xz" name="Post check" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">postCheck</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0qznt4u</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1kaikh5</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="ServiceTask_1nl90ao" name="Pre check" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">preCheck</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_12155q6</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1ccldpp</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_1fdclh0" sourceRef="download_StartEvent" targetRef="ServiceTask_1mpt2eq" /> + <bpmn:sequenceFlow id="SequenceFlow_12155q6" sourceRef="ServiceTask_1mpt2eq" targetRef="ServiceTask_1nl90ao" /> + <bpmn:sequenceFlow id="SequenceFlow_1d2rfyx" name="Success" sourceRef="ExclusiveGateway_08lusga" targetRef="download_EndEvent"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0o6b6a8" sourceRef="ServiceTask_0yavde3" targetRef="ExclusiveGateway_1ja7grm" /> + <bpmn:sequenceFlow id="SequenceFlow_078xmlz" name="Failure" sourceRef="ExclusiveGateway_1ja7grm" targetRef="EndEvent_1j64ij1" /> + <bpmn:sequenceFlow id="SequenceFlow_1ccldpp" sourceRef="ServiceTask_1nl90ao" targetRef="ExclusiveGateway_1rj84ne" /> + <bpmn:sequenceFlow id="SequenceFlow_0s6i4o9" name="Success" sourceRef="ExclusiveGateway_1rj84ne" targetRef="ServiceTask_0yavde3"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1tfbzn1" name="Failure" sourceRef="ExclusiveGateway_1rj84ne" targetRef="EndEvent_1ubpef4" /> + <bpmn:sequenceFlow id="SequenceFlow_1kaikh5" sourceRef="ServiceTask_1wxo7xz" targetRef="ExclusiveGateway_08lusga" /> + <bpmn:sequenceFlow id="SequenceFlow_1gawssm" name="Failure" sourceRef="ExclusiveGateway_08lusga" targetRef="EndEvent_11hee4g" /> + <bpmn:sequenceFlow id="SequenceFlow_0qznt4u" name="Success" sourceRef="ExclusiveGateway_1ja7grm" targetRef="ServiceTask_1wxo7xz"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + </bpmn:process> + <bpmn:error id="Error_1q14dnd" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="PNFSWUPDownload"> + <bpmndi:BPMNShape id="StartEvent_1k8gssq_di" bpmnElement="download_StartEvent"> + <dc:Bounds x="162" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="157" y="145" width="50" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1mpt2eq_di" bpmnElement="ServiceTask_1mpt2eq"> + <dc:Bounds x="280" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1e4dq7w_di" bpmnElement="download_EndEvent"> + <dc:Bounds x="1312" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1321" y="145" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_1ja7grm_di" bpmnElement="ExclusiveGateway_1ja7grm" isMarkerVisible="true"> + <dc:Bounds x="895" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1j64ij1_di" bpmnElement="EndEvent_1j64ij1"> + <dc:Bounds x="902" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_1rj84ne_di" bpmnElement="ExclusiveGateway_1rj84ne" isMarkerVisible="true"> + <dc:Bounds x="635" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1ubpef4_di" bpmnElement="EndEvent_1ubpef4"> + <dc:Bounds x="642" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_08lusga_di" bpmnElement="ExclusiveGateway_08lusga" isMarkerVisible="true"> + <dc:Bounds x="1155" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_11hee4g_di" bpmnElement="EndEvent_11hee4g"> + <dc:Bounds x="1162" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0yavde3_di" bpmnElement="ServiceTask_0yavde3"> + <dc:Bounds x="760" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1wxo7xz_di" bpmnElement="ServiceTask_1wxo7xz"> + <dc:Bounds x="1000" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1nl90ao_di" bpmnElement="ServiceTask_1nl90ao"> + <dc:Bounds x="480" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1fdclh0_di" bpmnElement="SequenceFlow_1fdclh0"> + <di:waypoint x="198" y="120" /> + <di:waypoint x="280" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_12155q6_di" bpmnElement="SequenceFlow_12155q6"> + <di:waypoint x="380" y="120" /> + <di:waypoint x="480" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1d2rfyx_di" bpmnElement="SequenceFlow_1d2rfyx"> + <di:waypoint x="1205" y="120" /> + <di:waypoint x="1312" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1214" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0o6b6a8_di" bpmnElement="SequenceFlow_0o6b6a8"> + <di:waypoint x="860" y="120" /> + <di:waypoint x="895" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_078xmlz_di" bpmnElement="SequenceFlow_078xmlz"> + <di:waypoint x="920" y="145" /> + <di:waypoint x="920" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="918" y="217" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ccldpp_di" bpmnElement="SequenceFlow_1ccldpp"> + <di:waypoint x="580" y="120" /> + <di:waypoint x="635" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0s6i4o9_di" bpmnElement="SequenceFlow_0s6i4o9"> + <di:waypoint x="685" y="120" /> + <di:waypoint x="760" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="678" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1tfbzn1_di" bpmnElement="SequenceFlow_1tfbzn1"> + <di:waypoint x="660" y="145" /> + <di:waypoint x="660" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="658" y="217" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1kaikh5_di" bpmnElement="SequenceFlow_1kaikh5"> + <di:waypoint x="1100" y="120" /> + <di:waypoint x="1155" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1gawssm_di" bpmnElement="SequenceFlow_1gawssm"> + <di:waypoint x="1180" y="145" /> + <di:waypoint x="1180" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1178" y="172" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0qznt4u_di" bpmnElement="SequenceFlow_0qznt4u"> + <di:waypoint x="945" y="120" /> + <di:waypoint x="1000" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="951" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn new file mode 100644 index 0000000000..8d59dac8ac --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn @@ -0,0 +1,273 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1yd8m0g" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.3.4"> + <bpmn:process id="PNFSoftwareUpgrade" name="PNFSoftwareUpgrade" isExecutable="true"> + <bpmn:startEvent id="softwareUpgrade_startEvent" name="Start Flow"> + <bpmn:outgoing>SequenceFlow_1ng4b6l</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:serviceTask id="ServiceTask_042uz7n" name="NF Upgrade Dispatcher" camunda:delegateExpression="${NfSoftwareUpgradeDispatcher}"> + <bpmn:incoming>SequenceFlow_1ng4b6l</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_12ejx4m</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_12ejx4m" sourceRef="ServiceTask_042uz7n" targetRef="ServiceTask_0slpahe" /> + <bpmn:endEvent id="softwareUpgrade_endEvent" name="End"> + <bpmn:incoming>SequenceFlow_1atiydu</bpmn:incoming> + <bpmn:terminateEventDefinition /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1ng4b6l" sourceRef="softwareUpgrade_startEvent" targetRef="ServiceTask_042uz7n" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_0v3l3wv" default="SequenceFlow_1lr7vgu"> + <bpmn:incoming>SequenceFlow_0cchgih</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1lr7vgu</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1eljvek</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_0bnbfds"> + <bpmn:incoming>SequenceFlow_1lr7vgu</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1sjbsm2" errorRef="Error_12cpov5" /> + </bpmn:endEvent> + <bpmn:exclusiveGateway id="ExclusiveGateway_0x6h0ni" default="SequenceFlow_0piri91"> + <bpmn:incoming>SequenceFlow_0j26xlx</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1nsmyr5</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0piri91</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1nsmyr5" name="Success" sourceRef="ExclusiveGateway_0x6h0ni" targetRef="ServiceTask_0x5cje8"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:endEvent id="EndEvent_180lm4y"> + <bpmn:incoming>SequenceFlow_0piri91</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0fm5he7" errorRef="Error_12cpov5" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_0piri91" name="Failure" sourceRef="ExclusiveGateway_0x6h0ni" targetRef="EndEvent_180lm4y" /> + <bpmn:sequenceFlow id="SequenceFlow_1lr7vgu" name="Failure" sourceRef="ExclusiveGateway_0v3l3wv" targetRef="EndEvent_0bnbfds" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_0ch3fef" default="SequenceFlow_0dqnb6c"> + <bpmn:incoming>SequenceFlow_015y785</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0dqnb6c</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0eiif6e</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_1ms4wdz"> + <bpmn:incoming>SequenceFlow_0dqnb6c</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_15s8fgk" errorRef="Error_12cpov5" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_0dqnb6c" name="Failure" sourceRef="ExclusiveGateway_0ch3fef" targetRef="EndEvent_1ms4wdz" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_1ny9b1z" default="SequenceFlow_1p0axph"> + <bpmn:incoming>SequenceFlow_0g3qcd0</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1p0axph</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1atiydu</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:endEvent id="EndEvent_0l6n6x5"> + <bpmn:incoming>SequenceFlow_1p0axph</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1l0gsy0" errorRef="Error_12cpov5" /> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1p0axph" name="Failure" sourceRef="ExclusiveGateway_1ny9b1z" targetRef="EndEvent_0l6n6x5" /> + <bpmn:sequenceFlow id="SequenceFlow_1eljvek" name="Success" sourceRef="ExclusiveGateway_0v3l3wv" targetRef="ServiceTask_02lxf48"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1atiydu" name="Success" sourceRef="ExclusiveGateway_1ny9b1z" targetRef="softwareUpgrade_endEvent"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0eiif6e" name="Success" sourceRef="ExclusiveGateway_0ch3fef" targetRef="ServiceTask_1jo8vn7"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:serviceTask id="ServiceTask_0x5cje8" name="Download" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">downloadNESw</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1nsmyr5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0cchgih</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0cchgih" sourceRef="ServiceTask_0x5cje8" targetRef="ExclusiveGateway_0v3l3wv" /> + <bpmn:serviceTask id="ServiceTask_02lxf48" name="Activate" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">activateNESw</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1eljvek</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_015y785</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_015y785" sourceRef="ServiceTask_02lxf48" targetRef="ExclusiveGateway_0ch3fef" /> + <bpmn:serviceTask id="ServiceTask_0y2uysu" name="Post check" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">postCheck</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_084orr1</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0g3qcd0</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0g3qcd0" sourceRef="ServiceTask_0y2uysu" targetRef="ExclusiveGateway_1ny9b1z" /> + <bpmn:serviceTask id="ServiceTask_0slpahe" name="Pre check" camunda:delegateExpression="${ControllerExecutionDE}"> + <bpmn:extensionElements> + <camunda:inputOutput> + <camunda:inputParameter name="action">preCheck</camunda:inputParameter> + <camunda:inputParameter name="scope">pnf</camunda:inputParameter> + <camunda:inputParameter name="mode">async</camunda:inputParameter> + </camunda:inputOutput> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_12ejx4m</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0j26xlx</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0j26xlx" sourceRef="ServiceTask_0slpahe" targetRef="ExclusiveGateway_0x6h0ni" /> + <bpmn:serviceTask id="ServiceTask_1jo8vn7" name="Update Pnf in AAI" camunda:delegateExpression="${UpdatePnfEntryInAai}"> + <bpmn:incoming>SequenceFlow_0eiif6e</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_084orr1</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_084orr1" sourceRef="ServiceTask_1jo8vn7" targetRef="ServiceTask_0y2uysu" /> + </bpmn:process> + <bpmn:error id="Error_12cpov5" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn:error id="Error_0nmskzh" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="PNFSoftwareUpgrade"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="softwareUpgrade_startEvent"> + <dc:Bounds x="162" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="157" y="145" width="50" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_042uz7n_di" bpmnElement="ServiceTask_042uz7n"> + <dc:Bounds x="280" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_12ejx4m_di" bpmnElement="SequenceFlow_12ejx4m"> + <di:waypoint x="380" y="120" /> + <di:waypoint x="480" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_1w3jv30_di" bpmnElement="softwareUpgrade_endEvent"> + <dc:Bounds x="1662" y="102" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1671" y="145" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1ng4b6l_di" bpmnElement="SequenceFlow_1ng4b6l"> + <di:waypoint x="198" y="120" /> + <di:waypoint x="280" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_0v3l3wv_di" bpmnElement="ExclusiveGateway_0v3l3wv" isMarkerVisible="true"> + <dc:Bounds x="895" y="95" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1040" y="65" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0bnbfds_di" bpmnElement="EndEvent_0bnbfds"> + <dc:Bounds x="902" y="252" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1044" y="295" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0x6h0ni_di" bpmnElement="ExclusiveGateway_0x6h0ni" isMarkerVisible="true"> + <dc:Bounds x="635" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1nsmyr5_di" bpmnElement="SequenceFlow_1nsmyr5"> + <di:waypoint x="685" y="120" /> + <di:waypoint x="760" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="678" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_180lm4y_di" bpmnElement="EndEvent_180lm4y"> + <dc:Bounds x="642" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0piri91_di" bpmnElement="SequenceFlow_0piri91"> + <di:waypoint x="660" y="145" /> + <di:waypoint x="660" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="658" y="217" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1lr7vgu_di" bpmnElement="SequenceFlow_1lr7vgu"> + <di:waypoint x="920" y="145" /> + <di:waypoint x="920" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="918" y="217" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_0ch3fef_di" bpmnElement="ExclusiveGateway_0ch3fef" isMarkerVisible="true"> + <dc:Bounds x="1125" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1ms4wdz_di" bpmnElement="EndEvent_1ms4wdz"> + <dc:Bounds x="1132" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0dqnb6c_di" bpmnElement="SequenceFlow_0dqnb6c"> + <di:waypoint x="1150" y="145" /> + <di:waypoint x="1150" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1148" y="230" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_1ny9b1z_di" bpmnElement="ExclusiveGateway_1ny9b1z" isMarkerVisible="true"> + <dc:Bounds x="1505" y="95" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0l6n6x5_di" bpmnElement="EndEvent_0l6n6x5"> + <dc:Bounds x="1512" y="252" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1p0axph_di" bpmnElement="SequenceFlow_1p0axph"> + <di:waypoint x="1530" y="145" /> + <di:waypoint x="1530" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1528" y="172" width="34" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1eljvek_di" bpmnElement="SequenceFlow_1eljvek"> + <di:waypoint x="945" y="120" /> + <di:waypoint x="1010" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="938" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1atiydu_di" bpmnElement="SequenceFlow_1atiydu"> + <di:waypoint x="1555" y="120" /> + <di:waypoint x="1662" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1564" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0eiif6e_di" bpmnElement="SequenceFlow_0eiif6e"> + <di:waypoint x="1175" y="120" /> + <di:waypoint x="1210" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1169" y="102" width="43" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0x5cje8_di" bpmnElement="ServiceTask_0x5cje8"> + <dc:Bounds x="760" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0cchgih_di" bpmnElement="SequenceFlow_0cchgih"> + <di:waypoint x="860" y="120" /> + <di:waypoint x="895" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_02lxf48_di" bpmnElement="ServiceTask_02lxf48"> + <dc:Bounds x="1010" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_015y785_di" bpmnElement="SequenceFlow_015y785"> + <di:waypoint x="1110" y="120" /> + <di:waypoint x="1125" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0y2uysu_di" bpmnElement="ServiceTask_0y2uysu"> + <dc:Bounds x="1370" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0g3qcd0_di" bpmnElement="SequenceFlow_0g3qcd0"> + <di:waypoint x="1470" y="120" /> + <di:waypoint x="1505" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0slpahe_di" bpmnElement="ServiceTask_0slpahe"> + <dc:Bounds x="480" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0j26xlx_di" bpmnElement="SequenceFlow_0j26xlx"> + <di:waypoint x="580" y="120" /> + <di:waypoint x="635" y="120" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_1jo8vn7_di" bpmnElement="ServiceTask_1jo8vn7"> + <dc:Bounds x="1210" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_084orr1_di" bpmnElement="SequenceFlow_084orr1"> + <di:waypoint x="1310" y="120" /> + <di:waypoint x="1370" y="120" /> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java index aea06b5fc9..d426dc3f66 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java @@ -20,22 +20,9 @@ package org.onap.so.bpmn.infrastructure.process; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; -import static com.github.tomakehurst.wiremock.client.WireMock.okJson; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; -import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; -import java.io.IOException; -import java.util.List; -import java.util.UUID; +import com.google.protobuf.Struct; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; @@ -47,7 +34,21 @@ import org.onap.so.client.aai.AAIVersion; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import com.google.protobuf.Struct; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; /** @@ -62,10 +63,10 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { private static final String TEST_PROCESSINSTANCE_KEY = "CreateVcpeResCustService_simplified"; private static final AAIVersion VERSION = AAIVersion.LATEST; + private static final Map<String, Object> executionVariables = new HashMap(); private String testBusinessKey; private String requestObject; private String responseObject; - private String msoRequestId; @Autowired private GrpcNettyServer grpcNettyServer; @@ -76,25 +77,25 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { requestObject = FileUtil.readResourceFile("request/" + getClass().getSimpleName() + ".json"); responseObject = FileUtil.readResourceFile("response/" + getClass().getSimpleName() + ".json"); - variables.put("bpmnRequest", requestObject); + executionVariables.clear(); + + executionVariables.put("bpmnRequest", requestObject); /** * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}. */ - variables.put("isAsyncProcess", "true"); + executionVariables.put("isAsyncProcess", "true"); /** * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api * handler and then convert to CamudaInput */ - variables.put("pnfCorrelationId", "PNFDemo"); + executionVariables.put("pnfCorrelationId", "PNFDemo"); /** * Create mso-request-id. */ - msoRequestId = UUID.randomUUID().toString(); - variables.put("mso-request-id", msoRequestId); /** * Create Business key for the process instance @@ -113,8 +114,11 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { mockAai(); mockDmaapForPnf(); + final String msoRequestId = UUID.randomUUID().toString(); + executionVariables.put("mso-request-id", msoRequestId); + ProcessInstance pi = - runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, variables); + runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables); int waitCount = 10; while (!isProcessInstanceEnded() && waitCount >= 0) { @@ -129,14 +133,24 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { "callCompleteMsoProcess_CallActivity", "ScriptTask_2", "CreateVCPE_EndEvent"); List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages(); - assertThat(detailedMessages).hasSize(2); + assertThat(detailedMessages.size() == 2); + int count = 0; try { - checkConfigAssign(detailedMessages.get(0)); - checkConfigDeploy(detailedMessages.get(1)); + for (ExecutionServiceInput eSI : detailedMessages) { + if ("config-assign".equals(eSI.getActionIdentifiers().getActionName())) { + checkConfigAssign(eSI, msoRequestId); + count++; + } + if ("config-deploy".equals(eSI.getActionIdentifiers().getActionName())) { + checkConfigDeploy(eSI, msoRequestId); + count++; + } + } } catch (Exception e) { e.printStackTrace(); fail("ConfigAssign/deploy request exception", e); } + assertThat(count == 2); } private boolean isProcessInstanceEnded() { @@ -144,7 +158,7 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { .singleResult() == null; } - private void checkConfigAssign(ExecutionServiceInput executionServiceInput) { + private void checkConfigAssign(ExecutionServiceInput executionServiceInput, String msoRequestId) { logger.info("Checking the configAssign request"); ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); @@ -175,7 +189,7 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { .isEqualTo("68dc9a92-214c-11e7-93ae-92361f002680"); } - private void checkConfigDeploy(ExecutionServiceInput executionServiceInput) { + private void checkConfigDeploy(ExecutionServiceInput executionServiceInput, String msoRequestId) { logger.info("Checking the configDeploy request"); ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java new file mode 100644 index 0000000000..065d2a54a8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java @@ -0,0 +1,230 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.process; + +import com.google.protobuf.Struct; +import org.assertj.core.api.Assertions; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.so.BaseBPMNTest; +import org.onap.so.GrpcNettyServer; +import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames; +import org.onap.so.bpmn.mock.FileUtil; +import org.onap.so.client.aai.AAIVersion; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static org.assertj.core.api.Assertions.fail; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; + +/** + * Basic Integration test for PNFSWUPDownloadTest.bpmn workflow. + */ +public class PNFSWUPDownloadTest extends BaseBPMNTest { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + private static final long WORKFLOW_WAIT_TIME = 1000L; + + private static final String TEST_PROCESSINSTANCE_KEY = "PNFSWUPDownload"; + private static final AAIVersion VERSION = AAIVersion.LATEST; + private static final Map<String, Object> executionVariables = new HashMap(); + private final String[] actionNames = new String[3]; + private String responseObject; + private String requestObject; + + @Autowired + private GrpcNettyServer grpcNettyServer; + + @Before + public void setUp() throws IOException { + + actionNames[0] = "preCheck"; + actionNames[1] = "downloadNESw"; + actionNames[2] = "postCheck"; + + executionVariables.clear(); + + requestObject = FileUtil.readResourceFile("request/PNFSoftwareUpgradeTest.json"); + responseObject = FileUtil.readResourceFile("response/PNFSoftwareUpgradeTest.json"); + + executionVariables.put("bpmnRequest", requestObject); + + /** + * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}. + */ + executionVariables.put("isAsyncProcess", "true"); + executionVariables.put(ExecutionVariableNames.PRC_CUSTOMIZATION_UUID, "38dc9a92-214c-11e7-93ae-92361f002680"); + + /** + * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api + * handler and then convert to CamudaInput + */ + executionVariables.put(ExecutionVariableNames.PNF_CORRELATION_ID, "PNFDemo"); + } + + + @Test + public void workflow_validInput_expectedOutput() throws InterruptedException { + + mockCatalogDb(); + mockAai(); + + final String msoRequestId = UUID.randomUUID().toString(); + executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId); + + final String testBusinessKey = UUID.randomUUID().toString(); + logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey); + + ProcessInstance pi = + runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables); + + int waitCount = 10; + while (!isProcessInstanceEnded() && waitCount >= 0) { + Thread.sleep(WORKFLOW_WAIT_TIME); + waitCount--; + } + + // Layout is to reflect the bpmn visual layout + assertThat(pi).isEnded().hasPassedInOrder("download_StartEvent", "ServiceTask_1mpt2eq", "ServiceTask_1nl90ao", + "ExclusiveGateway_1rj84ne", "ServiceTask_0yavde3", "ExclusiveGateway_1ja7grm", "ServiceTask_1wxo7xz", + "ExclusiveGateway_08lusga", "download_EndEvent"); + + List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages(); + assertThat(detailedMessages.size() == 3); + int count = 0; + try { + for (ExecutionServiceInput eSI : detailedMessages) { + for (String action : actionNames) { + if (action.equals(eSI.getActionIdentifiers().getActionName()) + && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) { + checkWithActionName(eSI, action, msoRequestId); + count++; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + fail("PNFSWUPDownload request exception", e); + } + assertThat(count == actionNames.length); + } + + private boolean isProcessInstanceEnded() { + return runtimeService.createProcessInstanceQuery().processDefinitionKey(TEST_PROCESSINSTANCE_KEY) + .singleResult() == null; + } + + private void checkWithActionName(ExecutionServiceInput executionServiceInput, String action, String msoRequestId) { + + logger.info("Checking the " + action + " request"); + ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); + + /** + * the fields of actionIdentifiers should match the one in the response/PNFSoftwareUpgrade_catalogdb.json. + */ + Assertions.assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf"); + Assertions.assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); + Assertions.assertThat(actionIdentifiers.getActionName()).isEqualTo(action); + Assertions.assertThat(actionIdentifiers.getMode()).isEqualTo("async"); + + CommonHeader commonHeader = executionServiceInput.getCommonHeader(); + Assertions.assertThat(commonHeader.getOriginatorId()).isEqualTo("SO"); + Assertions.assertThat(commonHeader.getRequestId()).isEqualTo(msoRequestId); + + Struct payload = executionServiceInput.getPayload(); + Struct requeststruct = payload.getFieldsOrThrow(action + "-request").getStructValue(); + + Assertions.assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo"); + Struct propertiesStruct = requeststruct.getFieldsOrThrow(action + "-properties").getStructValue(); + + Assertions.assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo"); + Assertions.assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()) + .isEqualTo("32daaac6-5017-4e1e-96c8-6a27dfbe1421"); + Assertions.assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()) + .isEqualTo("38dc9a92-214c-11e7-93ae-92361f002680"); + Assertions.assertThat(propertiesStruct.getFieldsOrThrow("target-software-version").getStringValue()) + .isEqualTo("demo-sw-ver2.0.0"); + } + + private void mockAai() { + + String aaiPnfEntry = + "{ \n" + " \"pnf-name\":\"PNFDemo\",\n" + " \"pnf-id\":\"testtest\",\n" + " \"in-maint\":true,\n" + + " \"resource-version\":\"1541720264047\",\n" + " \"swVersion\":\"demo-1.1\",\n" + + " \"ipaddress-v4-oam\":\"1.1.1.1\",\n" + " \"ipaddress-v6-oam\":\"::/128\"\n" + "}"; + + /** + * PUT the PNF correlation ID to AAI. + */ + wireMockServer.stubFor(put(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); + + /** + * Get the PNF entry from AAI. + */ + wireMockServer.stubFor( + get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry))); + } + + /** + * Mock the catalobdb rest interface. + */ + private void mockCatalogDb() { + + String catalogdbClientResponse = FileUtil.readResourceFile("response/PNFSoftwareUpgradeTest_catalogdb.json"); + + + /** + * Return valid json for the model UUID in the request file. + */ + wireMockServer + .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(responseObject))); + + /** + * Return valid json for the service model InvariantUUID as specified in the request file. + */ + wireMockServer.stubFor( + get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=339b7a2f-9524-4dbf-9eee-f2e05521df3f")) + .willReturn(okJson(responseObject))); + + /** + * Return valid spring data rest json for the service model UUID as specified in the request file. + */ + wireMockServer.stubFor(get(urlEqualTo( + "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(catalogdbClientResponse))); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java new file mode 100644 index 0000000000..a9bf4352bf --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java @@ -0,0 +1,236 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.process; + +import com.google.protobuf.Struct; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.so.BaseBPMNTest; +import org.onap.so.GrpcNettyServer; +import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames; +import org.onap.so.bpmn.mock.FileUtil; +import org.onap.so.client.aai.AAIVersion; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static org.assertj.core.api.Assertions.fail; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; + +/** + * Basic Integration test for PNFSoftwareUpgrade.bpmn workflow. + */ +public class PNFSoftwareUpgradeTest extends BaseBPMNTest { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + private static final long WORKFLOW_WAIT_TIME = 1000L; + + private static final String TEST_PROCESSINSTANCE_KEY = "PNFSoftwareUpgrade"; + private static final AAIVersion VERSION = AAIVersion.LATEST; + private static final Map<String, Object> executionVariables = new HashMap(); + private final String[] actionNames = new String[4]; + private String requestObject; + private String responseObject; + + @Autowired + private GrpcNettyServer grpcNettyServer; + + @Before + public void setUp() throws IOException { + actionNames[0] = "preCheck"; + actionNames[1] = "downloadNESw"; + actionNames[2] = "activateNESw"; + actionNames[3] = "postCheck"; + + executionVariables.clear(); + + requestObject = FileUtil.readResourceFile("request/" + getClass().getSimpleName() + ".json"); + responseObject = FileUtil.readResourceFile("response/" + getClass().getSimpleName() + ".json"); + + executionVariables.put("bpmnRequest", requestObject); + + /** + * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}. + */ + executionVariables.put("isAsyncProcess", "true"); + executionVariables.put(ExecutionVariableNames.PRC_CUSTOMIZATION_UUID, "38dc9a92-214c-11e7-93ae-92361f002680"); + + /** + * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api + * handler and then convert to CamudaInput + */ + executionVariables.put(ExecutionVariableNames.PNF_CORRELATION_ID, "PNFDemo"); + } + + + @Test + public void workflow_validInput_expectedOutput() throws InterruptedException { + + mockCatalogDb(); + mockAai(); + + final String msoRequestId = UUID.randomUUID().toString(); + executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId); + + final String testBusinessKey = UUID.randomUUID().toString(); + logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey); + + ProcessInstance pi = + runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables); + + int waitCount = 10; + while (!isProcessInstanceEnded() && waitCount >= 0) { + Thread.sleep(WORKFLOW_WAIT_TIME); + waitCount--; + } + + // Layout is to reflect the bpmn visual layout + assertThat(pi).isEnded().hasPassedInOrder("softwareUpgrade_startEvent", "ServiceTask_042uz7n", + "ServiceTask_0slpahe", "ExclusiveGateway_0x6h0ni", "ServiceTask_0x5cje8", "ExclusiveGateway_0v3l3wv", + "ServiceTask_02lxf48", "ExclusiveGateway_0ch3fef", "ServiceTask_0y2uysu", "ExclusiveGateway_1ny9b1z", + "softwareUpgrade_endEvent"); + + List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages(); + assertThat(detailedMessages.size() == 4); + int count = 0; + try { + for (ExecutionServiceInput eSI : detailedMessages) { + for (String action : actionNames) { + if (action.equals(eSI.getActionIdentifiers().getActionName()) + && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) { + checkWithActionName(eSI, action); + count++; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + fail("PNFSoftwareUpgrade request exception", e); + } + assertThat(count == actionNames.length); + } + + private boolean isProcessInstanceEnded() { + return runtimeService.createProcessInstanceQuery().processDefinitionKey(TEST_PROCESSINSTANCE_KEY) + .singleResult() == null; + } + + private void checkWithActionName(ExecutionServiceInput executionServiceInput, String action) { + + logger.info("Checking the " + action + " request"); + ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); + + /** + * the fields of actionIdentifiers should match the one in the response/PNFSoftwareUpgrade_catalogdb.json. + */ + assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf"); + assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); + assertThat(actionIdentifiers.getActionName()).isEqualTo(action); + assertThat(actionIdentifiers.getMode()).isEqualTo("async"); + + CommonHeader commonHeader = executionServiceInput.getCommonHeader(); + assertThat(commonHeader.getOriginatorId()).isEqualTo("SO"); + + Struct payload = executionServiceInput.getPayload(); + Struct requeststruct = payload.getFieldsOrThrow(action + "-request").getStructValue(); + + assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo"); + Struct propertiesStruct = requeststruct.getFieldsOrThrow(action + "-properties").getStructValue(); + + assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo"); + assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()) + .isEqualTo("32daaac6-5017-4e1e-96c8-6a27dfbe1421"); + assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()) + .isEqualTo("38dc9a92-214c-11e7-93ae-92361f002680"); + assertThat(propertiesStruct.getFieldsOrThrow("target-software-version").getStringValue()) + .isEqualTo("demo-sw-ver2.0.0"); + } + + private void mockAai() { + + String aaiPnfEntry = + "{ \n" + " \"pnf-name\":\"PNFDemo\",\n" + " \"pnf-id\":\"testtest\",\n" + " \"in-maint\":true,\n" + + " \"resource-version\":\"1541720264047\",\n" + " \"swVersion\":\"demo-1.1\",\n" + + " \"ipaddress-v4-oam\":\"1.1.1.1\",\n" + " \"ipaddress-v6-oam\":\"::/128\"\n" + "}"; + + /** + * PUT the PNF correlation ID to AAI. + */ + wireMockServer.stubFor(put(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); + + /** + * Get the PNF entry from AAI. + */ + wireMockServer.stubFor( + get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry))); + + /* + * Post the pnf to AAI + */ + wireMockServer.stubFor(post(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); + } + + /** + * Mock the catalobdb rest interface. + */ + private void mockCatalogDb() { + + String catalogdbClientResponse = + FileUtil.readResourceFile("response/" + getClass().getSimpleName() + "_catalogdb.json"); + + + /** + * Return valid json for the model UUID in the request file. + */ + wireMockServer + .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(responseObject))); + + /** + * Return valid json for the service model InvariantUUID as specified in the request file. + */ + wireMockServer.stubFor( + get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=339b7a2f-9524-4dbf-9eee-f2e05521df3f")) + .willReturn(okJson(responseObject))); + + /** + * Return valid spring data rest json for the service model UUID as specified in the request file. + */ + wireMockServer.stubFor(get(urlEqualTo( + "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(catalogdbClientResponse))); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json new file mode 100644 index 0000000000..a101118623 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json @@ -0,0 +1,54 @@ +{ + "requestDetails":{ + "requestInfo":{ + "source":"VID", + "suppressRollback":false, + "requestorId":"demo", + "productFamilyId":"SWUPid" + }, + "modelInfo":{ + "modelType":"service", + "modelInvariantUuid":"339b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelInvariantId":"339b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelUuid":"32daaac6-5017-4e1e-96c8-6a27dfbe1421", + "modelName":"PNF_int_service_2", + "modelVersion":"1.0" + }, + "requestParameters":{ + "userParams":[ + { + "name":"aic_zone", + "value":"nova" + }, + { + "name":"pnfId", + "value":"PNFDemo" + }, + { + "name":"targetSoftwareVersion", + "value":"demo-sw-ver2.0.0" + }, + { + "name":"pnfName", + "value":"PNFDemo" + } + ], + "subscriptionServiceType":"SWUP", + "aLaCarte":false + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"regionOne", + "tenantId":"09a63533072f4a579d5c99c3b8fe94c6" + }, + "subscriberInfo":{ + "globalSubscriberId":"ADemoCustomerInEric" + }, + "project":{ + "projectName":"Project-Demonstration" + }, + "owningEntity":{ + "owningEntityId":"5eae949c-1c50-4780-b8b5-7cbeb08856b4", + "owningEntityName":"OE-Demonstration" + } + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json new file mode 100644 index 0000000000..32539844ba --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json @@ -0,0 +1,26 @@ +{ + "serviceResources":{ + "modelInfo":{ + "modelInvariantId":"439b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelUuid":"42daaac6-5017-4e1e-96c8-6a27dfbe1421", + "modelName":"PNF_int_service_2", + "modelVersion":"1.0" + }, + "serviceType":"NA", + "environmentContext":"Luna", + "serviceRole":"NA", + "workloadContext":"Oxygen", + "serviceVnfs":[ + + ], + "serviceNetworks":[ + + ], + "serviceAllottedResources":[ + + ], + "configResource":[ + + ] + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json new file mode 100644 index 0000000000..faec947fec --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json @@ -0,0 +1,39 @@ +{ + "_embedded": { + "pnfResourceCustomization": [ + { + "modelCustomizationUUID": "38dc9a92-214c-11e7-93ae-92361f002680", + "modelInstanceName": "PNF routing", + "created": "2019-03-08 12:00:29.000", + "nfFunction": "routing", + "nfType": "routing", + "nfRole": "routing", + "nfNamingCode": "routing", + "multiStageDesign": null, + "resourceInput": null, + "blueprintName": "test_pnf_software_upgrade_restconf", + "blueprintVersion": "1.0.0", + "skipPostInstConf": false, + "softwareVersion": "1.0.0", + "creationTimestamp": "2019-03-08T12:00:29.000+0000", + "controllerActor": "cds", + "_links": { + "self": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680" + }, + "pnfResourceCustomization": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680" + }, + "pnfResources": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680/pnfResources" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:41023/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=4df8b6de-2083-11e7-93ae-92361f002676" + } + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java index 275cd18f0b..d2f52dac4c 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java @@ -56,8 +56,8 @@ public class ControllerExecutionDETestIT extends BaseIntegrationTest { @Rule public final SpringMethodRule smr = new SpringMethodRule(); - private static final String DOWNLOAD_ACTION = "downloadNeSw"; - private static final String ACTIVATE_ACTION = "activateNeSw"; + private static final String DOWNLOAD_ACTION = "downloadNESw"; + private static final String ACTIVATE_ACTION = "activateNESw"; private static final String PRECHECK_ACTION = "precheck"; private static final String POSTCHECK_ACTION = "postcheck"; private static final String ASSIGN_ACTION = "config-assign"; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java index c69adeec50..583e139edd 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java @@ -66,8 +66,8 @@ public class GenericPnfCDSProcessingDETest extends BaseTaskTest { private AbstractCDSProcessingBBUtils cdsDispather; private static final String PRECHECK_ACTION = "precheck"; - private static final String DOWNLOAD_ACTION = "downloadNeSw"; - private static final String ACTIVATE_ACTION = "activateNeSw"; + private static final String DOWNLOAD_ACTION = "downloadNESw"; + private static final String ACTIVATE_ACTION = "activateNESw"; private static final String POSTCHECK_ACTION = "postcheck"; private String description; diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java index 8bc709b276..2698bc347f 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java @@ -38,4 +38,6 @@ public interface AAIRestClientI { Optional<Pnf> getPnfByName(String pnfId); void createPnf(String pnfId, Pnf pnf); + + void updatePnf(String pnfId, Pnf pnf); } diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java index 03e2eaea1f..f2f96ca905 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java @@ -92,4 +92,9 @@ public class AAIRestClientImpl implements AAIRestClientI { new AAIResourcesClient().createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId), Optional.of(pnf)); } + + @Override + public void updatePnf(String pnfId, Pnf pnf) { + new AAIResourcesClient().update(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId), pnf); + } } diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java index 3cf3907424..2101252ad0 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java @@ -45,6 +45,7 @@ public class RequestClientParameter { private String requestUri; private String instanceGroupId; private boolean generateIdsOnly; + private String operationType; private RequestClientParameter(Builder builder) { requestId = builder.requestId; @@ -69,6 +70,11 @@ public class RequestClientParameter { requestUri = builder.requestUri; instanceGroupId = builder.instanceGroupId; generateIdsOnly = builder.generateIdsOnly; + operationType = builder.operationType; + } + + public String getOperationType() { + return operationType; } public String getRequestId() { @@ -186,6 +192,12 @@ public class RequestClientParameter { private String requestUri; private String instanceGroupId; private boolean generateIdsOnly; + private String operationType; + + public Builder setOperationType(String operationType) { + this.operationType = operationType; + return this; + } public Builder setRequestId(String requestId) { this.requestId = requestId; @@ -302,4 +314,6 @@ public class RequestClientParameter { } } + + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java index 0bcb0f1c86..94e03f1452 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java @@ -23,11 +23,7 @@ package org.onap.so.apihandlerinfra; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -38,6 +34,12 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.*; +import org.onap.aai.domain.yang.v16.ServiceInstance; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.logger.LoggingAnchor; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; @@ -174,6 +176,30 @@ public class E2EServiceInstances { return deleteE2EserviceInstances(request, Action.deleteInstance, instanceIdMap, version); } + /** + * Activate Requests for 5G slice Service on a specified version and serviceId + * + * @throws ApiException + */ + + @POST + @Path("/{version:[vV][3-5]}/{serviceId}/{operationType}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(description = "Activate 5G slice Service on a specified version and serviceId", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + public Response Activate5GSliceServiceInstance(String request, @PathParam("version") String version, + @PathParam("operationType") String operationType, @PathParam(SERVICE_ID) String serviceId) + throws ApiException { + if (operationType.equals("activate")) { + instanceIdMap.put("operationType", "activation"); + } else { + instanceIdMap.put("operationType", "deactivation"); + } + instanceIdMap.put(SERVICE_ID, serviceId); + return Activate5GSliceServiceInstances(request, Action.activateInstance, instanceIdMap, version); + } + @GET @Path("/{version:[vV][3-5]}/{serviceId}/operations/{operationId}") @Operation(description = "Find e2eServiceInstances Requests for a given serviceId and operationId", @@ -345,6 +371,116 @@ public class E2EServiceInstances { return builder.buildResponse(HttpStatus.SC_OK, null, e2eServiceResponse, apiVersion); } + private Response Activate5GSliceServiceInstances(String requestJSON, Action action, + HashMap<String, String> instanceIdMap, String version) throws ApiException { + // TODO should be a new one or the same service instance Id + E2ESliceServiceActivateRequest e2eActReq; + + ObjectMapper mapper = new ObjectMapper(); + try { + e2eActReq = mapper.readValue(requestJSON, E2ESliceServiceActivateRequest.class); + + } catch (Exception e) { + + logger.debug("Mapping of request to JSON object failed : ", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, + MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), + ErrorNumbers.SVC_BAD_PARAMETER, null, version); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.SchemaError.getValue(), requestJSON, e); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + String requestId = UUID.randomUUID().toString(); + RecipeLookupResult recipeLookupResult; + try { + // TODO Get the service template model version uuid from AAI. + String modelVersionId = null; + AAIResourcesClient client = new AAIResourcesClient(); + AAIResourceUri url = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + e2eActReq.getGlobalSubscriberId(), e2eActReq.getServiceType(), instanceIdMap.get(SERVICE_ID)); + Optional<ServiceInstance> serviceInstanceOpt = client.get(ServiceInstance.class, url); + if (serviceInstanceOpt.isPresent()) { + modelVersionId = serviceInstanceOpt.get().getModelVersionId(); + } + recipeLookupResult = getServiceInstanceOrchestrationURI(modelVersionId, action); + } catch (Exception e) { + logger.error(MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); + + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), + ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + + msoRequest.createErrorRequestRecord(Status.FAILED, requestId, + "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + if (recipeLookupResult == null) { + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.DataError.getValue(), "No recipe found in DB"); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "Recipe does not exist in catalog DB", + ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); + + msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "Recipe does not exist in catalog DB", action, + ModelType.service.name(), requestJSON); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + RequestClient requestClient; + HttpResponse response; + + try { + requestClient = requestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI()); + + JSONObject jjo = new JSONObject(requestJSON); + jjo.put("operationId", requestId); + + String bpmnRequest = jjo.toString(); + + // Capture audit event + logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); + String serviceId = instanceIdMap.get(SERVICE_ID); + String operationType = instanceIdMap.get("operationType"); + String serviceInstanceType = e2eActReq.getServiceType(); + RequestClientParameter clientParam = new RequestClientParameter.Builder().setRequestId(requestId) + .setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) + .setRequestAction(action.name()).setServiceInstanceId(serviceId).setOperationType(operationType) + .setServiceType(serviceInstanceType).setRequestDetails(bpmnRequest).setApiVersion(version) + .setALaCarte(false).setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build(); + response = requestClient.post(clientParam); + + } catch (Exception e) { + Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, + MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(), + ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(), + "Exception while communicate with BPMN engine"); + logger.debug("End of the transaction, the final response is: " + resp.getEntity()); + return resp; + } + + if (response == null) { + Response resp = + msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, + "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.BusinessProcessError.getValue(), "Null response from BPEL"); + logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); + return resp; + } + + ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType()); + int bpelStatus = respHandler.getStatus(); + + return beplStatusUpdate(requestClient, respHandler, bpelStatus, version); + } + private Response deleteE2EserviceInstances(String requestJSON, Action action, HashMap<String, String> instanceIdMap, String version) throws ApiException { // TODO should be a new one or the same service instance Id @@ -370,7 +506,15 @@ public class E2EServiceInstances { RecipeLookupResult recipeLookupResult; try { // TODO Get the service template model version uuid from AAI. - recipeLookupResult = getServiceInstanceOrchestrationURI(null, action); + String modelVersionId = null; + AAIResourcesClient client = new AAIResourcesClient(); + AAIResourceUri url = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + e2eDelReq.getGlobalSubscriberId(), e2eDelReq.getServiceType(), instanceIdMap.get(SERVICE_ID)); + Optional<ServiceInstance> serviceInstanceOpt = client.get(ServiceInstance.class, url); + if (serviceInstanceOpt.isPresent()) { + modelVersionId = serviceInstanceOpt.get().getModelVersionId(); + } + recipeLookupResult = getServiceInstanceOrchestrationURI(modelVersionId, action); } catch (Exception e) { logger.error(MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2ESliceServiceActivateRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2ESliceServiceActivateRequest.java new file mode 100644 index 0000000000..2fb219c182 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2ESliceServiceActivateRequest.java @@ -0,0 +1,23 @@ +package org.onap.so.apihandlerinfra.e2eserviceinstancebeans; + +public class E2ESliceServiceActivateRequest { + private String globalSubscriberId; + + private String serviceType; + + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } +} diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InstanceNfvoMappingRepository.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InstanceNfvoMappingRepository.java new file mode 100644 index 0000000000..2e2c0872b6 --- /dev/null +++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InstanceNfvoMappingRepository.java @@ -0,0 +1,28 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.db.request.data.repository; + +import org.onap.so.db.request.beans.InstanceNfvoMapping; +import org.onap.so.db.request.beans.OperationStatus; +import org.onap.so.db.request.beans.OperationStatusId; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "instanceNfvoMapping", path = "instanceNfvoMapping") +public interface InstanceNfvoMappingRepository extends JpaRepository<InstanceNfvoMapping, String> { + + public InstanceNfvoMapping findOneByInstanceId(String instanceId); + + public InstanceNfvoMapping findOneByJobId(String jobId); + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InstanceNfvoMapping.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InstanceNfvoMapping.java new file mode 100644 index 0000000000..53b3fcde55 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InstanceNfvoMapping.java @@ -0,0 +1,123 @@ +/*** + * Copyright (C) 2019 Verizon. 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. + */ + +package org.onap.so.db.request.beans; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import java.util.Objects; + +@Entity +@Table(name = "instance_nfvo_mapping") +public class InstanceNfvoMapping implements java.io.Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Column(name = "INSTANCE_ID") + private String instanceId; + @Column(name = "NFVO_NAME", length = 256) + private String nfvoName; + @Column(name = "ENDPOINT", length = 256) + private String endpoint; + @Column(name = "USERNAME", length = 256) + private String username; + @Column(name = "PASSWORD", length = 256) + private String password; + @Column(name = "API_ROOT", length = 256) + private String apiRoot; + @Column(name = "JOB_ID", length = 256) + private String jobId; + + public InstanceNfvoMapping() {} + + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof InstanceNfvoMapping)) { + return false; + } + final InstanceNfvoMapping castOther = (InstanceNfvoMapping) other; + return Objects.equals(getInstanceId(), castOther.getInstanceId()); + } + + @Override + public int hashCode() { + return Objects.hash(getInstanceId()); + } + + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getNfvoName() { + return nfvoName; + } + + public void setNfvoName(String nfvoName) { + this.nfvoName = nfvoName; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getApiRoot() { + return apiRoot; + } + + public void setApiRoot(String apiRoot) { + this.apiRoot = apiRoot; + } + + @Override + public String toString() { + return "InstanceNfvoMapping{" + "instanceId='" + instanceId + '\'' + ", nfvoName='" + nfvoName + '\'' + + ", endpoint='" + endpoint + '\'' + ", username='" + username + '\'' + ", password='" + password + '\'' + + ", apiRoot='" + apiRoot + '\'' + '}'; + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceArtifact.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceArtifact.java new file mode 100644 index 0000000000..a8884a81bb --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceArtifact.java @@ -0,0 +1,168 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2019, CMCC Technologies Co., Ltd. + * ================================================================================ + * 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.onap.so.db.catalog.beans; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.openpojo.business.annotation.BusinessKey; +import org.apache.commons.lang3.builder.ToStringBuilder; +import javax.persistence.*; +import java.io.Serializable; +import java.util.Date; +import java.util.Objects; + +@Entity +@Table(name = "service_artifact") +public class ServiceArtifact implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + @BusinessKey + @Id + @Column(name = "ARTIFACT_UUID") + private String artifactUUID; + + @Column(name = "TYPE") + private String type; + + @Column(name = "NAME") + private String name; + + @Column(name = "VERSION") + private String version; + + @Column(name = "DESCRIPTION") + private String description; + + @Column(name = "CONTENT", columnDefinition = "LONGTEXT") + private String content; + + @Column(name = "CHECKSUM") + private String checksum; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + @Temporal(TemporalType.TIMESTAMP) + private Date creationTimestamp; + + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "SERVICE_MODEL_UUID") + private Service service; + + @PrePersist + protected void onCreate() { + this.creationTimestamp = new Date(); + } + + public String getArtifactUUID() { + return artifactUUID; + } + + public void setArtifactUUID(String artifactUUID) { + this.artifactUUID = artifactUUID; + } + + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getChecksum() { + return checksum; + } + + public void setChecksum(String checksum) { + this.checksum = checksum; + } + + public Date getCreationTimestamp() { + return creationTimestamp; + } + + public void setCreationTimestamp(Date creationTimestamp) { + this.creationTimestamp = creationTimestamp; + } + + public Service getService() { + return service; + } + + public void setService(Service service) { + this.service = service; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("artifactUUID", artifactUUID).append("type", type).append("name", name) + .append("version", version).append("description", description).append("content", content) + .append("checksum", checksum).append("creationTimestamp", creationTimestamp).toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ServiceArtifact that = (ServiceArtifact) o; + return artifactUUID.equals(that.artifactUUID); + } + + @Override + public int hashCode() { + return Objects.hash(artifactUUID); + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceInfo.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceInfo.java new file mode 100644 index 0000000000..f9c95767f6 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceInfo.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2019, CMCC Technologies Co., Ltd. + * ================================================================================ + * 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.onap.so.db.catalog.beans; + +import com.openpojo.business.annotation.BusinessKey; +import org.apache.commons.lang3.builder.ToStringBuilder; +import uk.co.blackpepper.bowman.annotation.LinkedResource; +import javax.persistence.*; +import java.io.Serializable; +import java.util.Objects; + +@Entity +@Table(name = "service_info") +public class ServiceInfo implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + @Id + @BusinessKey + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "ID") + private Integer id; + + @Column(name = "SERVICE_INPUT") + private String serviceInput; + + @Column(name = "SERVICE_PROPERTIES") + private String serviceProperties; + + @OneToOne(cascade = CascadeType.ALL) + @JoinTable(name = "service_to_service_info", joinColumns = @JoinColumn(name = "SERVICE_INFO_ID"), + inverseJoinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID")) + private Service service; + + public Integer getId() { + return id; + } + + public void setId(Integer serviceInfoId) { + this.id = serviceInfoId; + } + + public String getServiceInput() { + return serviceInput; + } + + public void setServiceInput(String serviceInput) { + this.serviceInput = serviceInput; + } + + public String getServiceProperties() { + return serviceProperties; + } + + public void setServiceProperties(String serviceProperties) { + this.serviceProperties = serviceProperties; + } + + @LinkedResource + public Service getService() { + return service; + } + + public void setService(Service service) { + this.service = service; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("id", id).append("serviceProperties", serviceProperties) + .append("serviceInput", serviceInput).toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ServiceInfo that = (ServiceInfo) o; + return id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceInfoRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceInfoRepository.java new file mode 100644 index 0000000000..e3a4ca264e --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceInfoRepository.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2019, CMCC Technologies Co., Ltd. + * ================================================================================ + * 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.onap.so.db.catalog.data.repository; + +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ServiceInfo; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "serviceInfo", path = "serviceInfo") +public interface ServiceInfoRepository extends JpaRepository<ServiceInfo, Integer> { + + ServiceInfo findByService(Service service); + +} diff --git a/packages/docker/pom.xml b/packages/docker/pom.xml index 545fc926a8..8d95d063da 100644 --- a/packages/docker/pom.xml +++ b/packages/docker/pom.xml @@ -257,6 +257,31 @@ </build> </image> <image> + <name>${docker.image.prefix}/nssmf-adapter</name> + <build> + <cleanup>try</cleanup> + <dockerFileDir>docker-files</dockerFileDir> + <dockerFile>Dockerfile.so-app</dockerFile> + <tags> + <tag>${project.version}</tag> + <tag>${project.version}-${maven.build.timestamp}</tag> + <tag>${project.docker.latesttag.version}</tag> + </tags> + <assembly> + <inline> + <dependencySets> + <dependencySet> + <includes> + <include>org.onap.so.adapters:mso-nssmf-adapter</include> + </includes> + <outputFileNameMapping>app.jar</outputFileNameMapping> + </dependencySet> + </dependencySets> + </inline> + </assembly> + </build> + </image> + <image> <name>${docker.image.prefix}/so-appc-orchestrator</name> <build> <cleanup>try</cleanup> @@ -437,7 +462,7 @@ <goal>push</goal> </goals> <configuration> - <image>${docker.image.prefix}/catalog-db-adapter,${docker.image.prefix}/request-db-adapter,${docker.image.prefix}/sdnc-adapter,${docker.image.prefix}/openstack-adapter,${docker.image.prefix}/vfc-adapter,${docker.image.prefix}/sdc-controller,${docker.image.prefix}/bpmn-infra,${docker.image.prefix}/api-handler-infra,${docker.image.prefix}/so-monitoring,${docker.image.prefix}/so-simulator</image> + <image>${docker.image.prefix}/catalog-db-adapter,${docker.image.prefix}/request-db-adapter,${docker.image.prefix}/sdnc-adapter,${docker.image.prefix}/openstack-adapter,${docker.image.prefix}/vfc-adapter,${docker.image.prefix}/sdc-controller,${docker.image.prefix}/bpmn-infra,${docker.image.prefix}/api-handler-infra,${docker.image.prefix}/so-monitoring,${docker.image.prefix}/so-simulator,${docker.image.prefix}/mso-nssmf-adapter</image> </configuration> </execution> </executions> @@ -492,6 +517,11 @@ </dependency> <dependency> <groupId>org.onap.so.adapters</groupId> + <artifactId>mso-nssmf-adapter</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> <artifactId>so-appc-orchestrator</artifactId> <version>${project.version}</version> </dependency> |