From 108ff43f43cb3a662514c6f27d806fe3a86caade Mon Sep 17 00:00:00 2001 From: Dilip kumar Pampana Date: Mon, 8 Jan 2018 15:08:21 -0500 Subject: Appc Interface Services Scope Overlap API Or REST service Issue-ID: APPC-348 Change-Id: Id32b4c88f57a9f9ce2234598d03dcca5946d4683 Signed-off-by: Dilip kumar Pampana --- appc-inbound/appc-interfaces-service/.gitignore | 22 +++ appc-inbound/appc-interfaces-service/.pydevproject | 5 + .../appc-interfaces-service/bundle/.gitignore | 1 + .../appc-interfaces-service/bundle/pom.xml | 129 +++++++++++++++++ .../service/InterfacesServiceProvider.java | 66 +++++++++ .../service/InterfacesServiceProviderImpl.java | 76 ++++++++++ .../interfaces/service/data/ActionIdentifier.java | 86 ++++++++++++ .../onap/appc/interfaces/service/data/Request.java | 53 +++++++ .../appc/interfaces/service/data/ScopeOverlap.java | 76 ++++++++++ .../service/executor/RequestValidator.java | 78 +++++++++++ .../service/executor/ServiceExecutor.java | 79 +++++++++++ .../service/executorImpl/ServiceExecutorImpl.java | 156 +++++++++++++++++++++ .../interfaces/service/utils/ServiceConstants.java | 40 ++++++ .../org/opendaylight/blueprint/impl-blueprint.xml | 44 ++++++ .../serviceExecutor/TestServiceExecutor.java | 41 ++++++ .../appc-interfaces-service/features/.gitignore | 1 + .../appc-interfaces-service/features/pom.xml | 83 +++++++++++ .../features/src/main/resources/features.xml | 52 +++++++ .../appc-interfaces-service/installer/.gitignore | 1 + .../appc-interfaces-service/installer/pom.xml | 134 ++++++++++++++++++ .../installer/resources/scripts/install-feature.sh | 39 ++++++ .../src/assembly/assemble_installer_zip.xml | 62 ++++++++ .../src/assembly/assemble_mvnrepo_zip.xml | 50 +++++++ .../src/main/resources/scripts/install-feature.sh | 43 ++++++ appc-inbound/appc-interfaces-service/jacoco.exec | Bin 0 -> 771339 bytes .../appc-interfaces-service/model/.gitignore | 1 + appc-inbound/appc-interfaces-service/model/pom.xml | 156 +++++++++++++++++++++ .../model/scripts/python/yang2props.py | 57 ++++++++ .../src/main/yang/appc-interfaces-service.yang | 122 ++++++++++++++++ appc-inbound/appc-interfaces-service/pom.xml | 94 +++++++++++++ appc-inbound/pom.xml | 57 ++++---- 31 files changed, 1876 insertions(+), 28 deletions(-) create mode 100644 appc-inbound/appc-interfaces-service/.gitignore create mode 100644 appc-inbound/appc-interfaces-service/.pydevproject create mode 100644 appc-inbound/appc-interfaces-service/bundle/.gitignore create mode 100644 appc-inbound/appc-interfaces-service/bundle/pom.xml create mode 100644 appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProvider.java create mode 100644 appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProviderImpl.java create mode 100644 appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/ActionIdentifier.java create mode 100644 appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/Request.java create mode 100644 appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/ScopeOverlap.java create mode 100644 appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executor/RequestValidator.java create mode 100644 appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executor/ServiceExecutor.java create mode 100644 appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImpl.java create mode 100644 appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/utils/ServiceConstants.java create mode 100644 appc-inbound/appc-interfaces-service/bundle/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml create mode 100644 appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaceService/serviceExecutor/TestServiceExecutor.java create mode 100644 appc-inbound/appc-interfaces-service/features/.gitignore create mode 100644 appc-inbound/appc-interfaces-service/features/pom.xml create mode 100644 appc-inbound/appc-interfaces-service/features/src/main/resources/features.xml create mode 100644 appc-inbound/appc-interfaces-service/installer/.gitignore create mode 100644 appc-inbound/appc-interfaces-service/installer/pom.xml create mode 100644 appc-inbound/appc-interfaces-service/installer/resources/scripts/install-feature.sh create mode 100644 appc-inbound/appc-interfaces-service/installer/src/assembly/assemble_installer_zip.xml create mode 100644 appc-inbound/appc-interfaces-service/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 appc-inbound/appc-interfaces-service/installer/src/main/resources/scripts/install-feature.sh create mode 100644 appc-inbound/appc-interfaces-service/jacoco.exec create mode 100644 appc-inbound/appc-interfaces-service/model/.gitignore create mode 100644 appc-inbound/appc-interfaces-service/model/pom.xml create mode 100644 appc-inbound/appc-interfaces-service/model/scripts/python/yang2props.py create mode 100644 appc-inbound/appc-interfaces-service/model/src/main/yang/appc-interfaces-service.yang create mode 100644 appc-inbound/appc-interfaces-service/pom.xml diff --git a/appc-inbound/appc-interfaces-service/.gitignore b/appc-inbound/appc-interfaces-service/.gitignore new file mode 100644 index 000000000..75b68b80e --- /dev/null +++ b/appc-inbound/appc-interfaces-service/.gitignore @@ -0,0 +1,22 @@ +# Target dirs in all projects +**/target/* + +# Generated models and features +**/bin/* + +# MANIFEST.MF is updated on every clean install +**/src/main/resources/META-INF/ +**/src/main/yang-gen-sal +**/src/main/yang-gen-config + +.project + +*.prefs +.classpath +**/.classpath +/target/ +logs/ +debug-logs/ +/.settings/ +**/*.iml +/.idea/ diff --git a/appc-inbound/appc-interfaces-service/.pydevproject b/appc-inbound/appc-interfaces-service/.pydevproject new file mode 100644 index 000000000..40e9f40a0 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/.pydevproject @@ -0,0 +1,5 @@ + + +Default +python 2.7 + diff --git a/appc-inbound/appc-interfaces-service/bundle/.gitignore b/appc-inbound/appc-interfaces-service/bundle/.gitignore new file mode 100644 index 000000000..b83d22266 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/bundle/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-inbound/appc-interfaces-service/bundle/pom.xml b/appc-inbound/appc-interfaces-service/bundle/pom.xml new file mode 100644 index 000000000..db24f603c --- /dev/null +++ b/appc-inbound/appc-interfaces-service/bundle/pom.xml @@ -0,0 +1,129 @@ + + + 4.0.0 + + appc-interfaces-service + org.onap.appc + 1.3.0-SNAPSHOT + + appc-interfaces-service-bundle + bundle + + + + + org.apache.felix + maven-bundle-plugin + true + + + org.onap.appc.interfaces.services + org.onap.appc.aai.client,*;resolution:=optional + * + true + + + + + + + + + org.onap.appc + appc-interfaces-service-model + ${project.version} + + + org.onap.appc + appc-aai-client-provider + ${project.version} + + + + com.google.code.gson + gson + 2.8.0 + + + org.onap.ccsdk.sli.adaptors + aai-service-provider + compile + + + org.apache.commons + commons-lang3 + + + + junit + junit + test + + + + org.opendaylight.controller + config-api + + + org.opendaylight.controller + sal-binding-config + + + org.opendaylight.controller + sal-binding-api + + + org.opendaylight.controller + sal-common-util + + + sal-test-model + org.opendaylight.controller + test + + + sal-rest-connector + org.opendaylight.netconf + test + + + org.opendaylight.controller + sal-binding-broker-impl + test + + + + com.att.eelf + eelf-core + + + com.sun.jersey + jersey-client + 1.17 + provided + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + 2.3.0 + + + com.fasterxml.jackson.core + jackson-databind + + + org.apache.commons + commons-lang3 + + + org.apache.velocity + velocity + 1.7 + + + commons-io + commons-io + + + diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProvider.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProvider.java new file mode 100644 index 000000000..df9371f66 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProvider.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.interfaces.service; + +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.InterfacesServiceService; +import org.onap.appc.interfaces.service.InterfacesServiceProviderImpl; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class InterfacesServiceProvider{ + + private static final EELFLogger log = EELFManager.getInstance().getLogger(InterfacesServiceProvider.class); + + private final DataBroker dataBroker; + private final RpcProviderRegistry rpcProviderRegistry; + private RpcRegistration serviceRegistration; + + public InterfacesServiceProvider(final DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry) { + this.dataBroker = dataBroker; + this.rpcProviderRegistry = rpcProviderRegistry; + } + /** + * Method called when the blueprint container is created. + */ + public void init() { + // initialize data broker + this.serviceRegistration = this.rpcProviderRegistry.addRpcImplementation(InterfacesServiceService.class, + new InterfacesServiceProviderImpl()); + log.info("DataCollectorProvider Session Initiated"); + } + /** + * Method called when the blueprint container is destroyed. + */ + public void close() { + if(this.serviceRegistration != null){ + this.serviceRegistration.close(); + } + log.info("DataCollectorProvider Closed"); + } +} diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProviderImpl.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProviderImpl.java new file mode 100644 index 000000000..8e114a3c6 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/InterfacesServiceProviderImpl.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.interfaces.service; + +import java.util.concurrent.Future; + +import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.ExecuteServiceInput; +import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.ExecuteServiceOutput; +import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.ExecuteServiceOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.InterfacesServiceService; +import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.response.info.ResponseInfoBuilder; +import org.opendaylight.yang.gen.v1.org.onap.appc.interfaces.service.rev170818.status.StatusBuilder; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.onap.appc.interfaces.service.executor.ServiceExecutor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.util.concurrent.Futures; + +public class InterfacesServiceProviderImpl implements InterfacesServiceService{ + + private static final Logger log = LoggerFactory.getLogger(InterfacesServiceProviderImpl.class); + + @Override + public Future> executeService(ExecuteServiceInput input) { + + log.info("Received Request: " + input.getRequest().getRequestId() + " Action : " + + input.getRequest().getAction() + " with RequestData :" + input.getRequest().getRequestData() + " and data-Type : " + input.getRequest().getRequestDataType()); + String request_id = input.getRequest().getRequestId(); + String action = input.getRequest().getAction(); + ResponseInfoBuilder responseInfoBuilder = new ResponseInfoBuilder(); + ExecuteServiceOutputBuilder executeServicebuilder = new ExecuteServiceOutputBuilder(); + ServiceExecutor serviceExecutor = new ServiceExecutor(); + StatusBuilder statusBuilder = new StatusBuilder(); + try{ + String response = serviceExecutor.execute(action, input.getRequest().getRequestData(), input.getRequest().getRequestDataType()); + responseInfoBuilder.setBlock(response); + responseInfoBuilder.setRequestId(request_id); + statusBuilder.setCode("400"); + statusBuilder.setMessage("success"); + } + catch(Exception e){ + log.error("Error" + e.getMessage()); + e.printStackTrace(); + statusBuilder.setCode("401"); + statusBuilder.setMessage("failuer"); + } + executeServicebuilder.setResponseInfo(responseInfoBuilder.build()); + executeServicebuilder.setStatus(statusBuilder.build()); + RpcResult result = RpcResultBuilder.status(true).withResult(executeServicebuilder.build()).build(); + return Futures.immediateFuture(result); + } +} diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/ActionIdentifier.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/ActionIdentifier.java new file mode 100644 index 000000000..50a47831d --- /dev/null +++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/ActionIdentifier.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.interfaces.service.data; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ActionIdentifier { + + @JsonProperty("service-instance-id") + private String serviceInstanceID; + + @JsonProperty("vnf-id") + private String vnfId; + + @JsonProperty("vf-module-id") + private String vfModuleId; + + @JsonProperty("vserver-id") + private String vServerId; + + @JsonProperty("vnfc-name") + private String vnfcName; + + public String getServiceInstanceID() { + return serviceInstanceID; + } + + public void setServiceInstanceID(String serviceInstanceID) { + this.serviceInstanceID = serviceInstanceID; + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVfModuleId() { + return vfModuleId; + } + + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + + public String getvServerId() { + return vServerId; + } + + public void setvServerId(String vServerId) { + this.vServerId = vServerId; + } + + public String getVnfcName() { + return vnfcName; + } + + public void setVnfcName(String vnfcName) { + this.vnfcName = vnfcName; + } + +} diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/Request.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/Request.java new file mode 100644 index 000000000..eff4814de --- /dev/null +++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/Request.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.interfaces.service.data; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Request { + + @JsonProperty("action") + private String action; + + @JsonProperty("action-identifiers") + private ActionIdentifier actionIdentifiers; + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public ActionIdentifier getActionIdentifiers() { + return actionIdentifiers; + } + + public void setActionIdentifiers(ActionIdentifier actionIdentifiers) { + this.actionIdentifiers = actionIdentifiers; + } + +} diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/ScopeOverlap.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/ScopeOverlap.java new file mode 100644 index 000000000..bfeb70fce --- /dev/null +++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/data/ScopeOverlap.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.interfaces.service.data; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ScopeOverlap { + + @JsonProperty("vnf-id") + private String vnfId; + + @JsonProperty("current-request") + private Request currentRequest; + + @JsonProperty("in-progress-requests") + private List inProgressRequests; + + private String overlap; + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public Request getCurrentRequest() { + return currentRequest; + } + + public void setCurrentRequest(Request currentRequest) { + this.currentRequest = currentRequest; + } + + public List getInProgressRequest() { + return inProgressRequests; + } + + public void setInProgressRequest(List inProgressRequests) { + this.inProgressRequests = inProgressRequests; + } + + public String getOverlap() { + return overlap; + } + + public void setOverlap(String overlap) { + this.overlap = overlap; + } + +} diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executor/RequestValidator.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executor/RequestValidator.java new file mode 100644 index 000000000..b37a5e4c8 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executor/RequestValidator.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.interfaces.service.executor; + +import java.util.ArrayList; +import java.util.List; + +import org.onap.appc.interfaces.service.utils.ServiceConstants; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class RequestValidator { + + private static final Logger log = LoggerFactory.getLogger(RequestValidator.class); + + public static void validate(String action, String requestData, String requestDataType) throws Exception { + log.debug("Received validation for action= " + action + " Data :" + requestData); + try { + if (requestData.isEmpty()) { + throw new Exception("Request Data is Empty"); + } + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode payloadObject = objectMapper.readTree(requestData); + log.info("payloadObject" + payloadObject); + if (payloadObject.get(ServiceConstants.VNF) == null) + throw new Exception("VNF-ID is null"); + String vnfId = payloadObject.get(ServiceConstants.VNF).toString(); + if (vnfId.isEmpty()) + throw new Exception("VNF-ID is blank"); + if (payloadObject.get(ServiceConstants.CURRENTREQUEST) == null) + throw new Exception("Current request is null"); + String cRequest = payloadObject.get(ServiceConstants.CURRENTREQUEST).toString(); + if (cRequest.isEmpty()) + throw new Exception("Current Request is blank"); + JsonNode currentRequest = payloadObject.get(ServiceConstants.CURRENTREQUEST); + if (currentRequest.get(ServiceConstants.ACTION) == null) + throw new Exception("Action is null in Current Request"); + String cRequestAction = currentRequest.get(ServiceConstants.ACTION).toString(); + if (cRequestAction.isEmpty()) + throw new Exception("Action is blank in Current Request"); + if (currentRequest.get(ServiceConstants.ACTIONIDENTIFIER) == null) + throw new Exception("Action Identifier is null in Current Request"); + String cRequestActionIdentifier = currentRequest.get(ServiceConstants.ACTIONIDENTIFIER).toString(); + if (cRequestActionIdentifier.isEmpty()) + throw new Exception("Action Identifier is blank in Current Request"); + } catch (Exception e) { + e.printStackTrace(); + log.debug("Error while validating: " + e.getMessage()); + throw e; + } + } + +} diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executor/ServiceExecutor.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executor/ServiceExecutor.java new file mode 100644 index 000000000..f72157656 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executor/ServiceExecutor.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.interfaces.service.executor; + +import java.io.IOException; + +import org.onap.appc.interfaces.service.InterfacesServiceProviderImpl; +import org.onap.appc.interfaces.service.executorImpl.ServiceExecutorImpl; +import org.onap.appc.interfaces.service.utils.ServiceConstants; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; + +public class ServiceExecutor { + + private static final Logger log = LoggerFactory.getLogger(ServiceExecutor.class); + public String execute(String action, String requestData, String requestDataType) throws Exception{ + String response = null; + log.info("Received execute request for action : " + action + " with Payload : " + requestData); + try{ + RequestValidator.validate(action, requestData, requestData); + switch (action) { + case ServiceConstants.REQUESTOVERLAP: + response = isRequestOverLap(requestData); + break; + case ServiceConstants.GEDATABYMODEL: + response = getDataByModel(action, requestData, requestDataType); + break; + default: + throw new Exception(" Action " + action + " not found while processing request "); + } + }catch(Exception e){ + log.info("Error while checking for ScopeOverlap " + e.getMessage()); + e.printStackTrace(); + throw e; + } + return response; + } + + private String getDataByModel(String action, String requestData, String requestDataType) { + + return null; + } + + private String isRequestOverLap(String requestData) throws Exception { + + ServiceExecutorImpl serviceExecutor = new ServiceExecutorImpl(); + try { + return serviceExecutor.isRequestOverLap(requestData); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } +} diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImpl.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImpl.java new file mode 100644 index 000000000..3b30c3e8c --- /dev/null +++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/executorImpl/ServiceExecutorImpl.java @@ -0,0 +1,156 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.interfaces.service.executorImpl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.onap.appc.aai.client.aai.AaiService; +import org.onap.appc.interfaces.service.data.Request; +import org.onap.appc.interfaces.service.data.ScopeOverlap; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.adaptors.aai.AAIClient; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.Strings; + +public class ServiceExecutorImpl { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(ServiceExecutorImpl.class); + private AAIClient aaiClient; + public String isRequestOverLap(String requestData) throws Exception { + String response = "\"requestOverlap\" : "; + log.info("Response from ServiceExecutorImpl"); + ScopeOverlap scopeOverlap = new ScopeOverlap(); + ObjectMapper mapper = new ObjectMapper(); + scopeOverlap = mapper.readValue(requestData, ScopeOverlap.class); + // return response + String.valueOf(checkForOverLap(scopeOverlap)); + boolean isOverlap = checkForOverLap(scopeOverlap); + scopeOverlap.setOverlap(String.valueOf(isOverlap)); + if (scopeOverlap.getOverlap() != null && scopeOverlap.getOverlap().equalsIgnoreCase("false")){ + log.info(response + "false"); + return response + "false"; + } + else{ + log.info(response + "true"); + return response + "true"; + } + } + + private boolean checkForOverLap(ScopeOverlap scopeOverlap) throws Exception { + log.info("Checking for isScopeOverlap"); + if (scopeOverlap.getInProgressRequest() == null) { + return Boolean.FALSE; + }else if ( scopeOverlap.getInProgressRequest().isEmpty()){ + return Boolean.FALSE; + } + else if (scopeOverlap.getInProgressRequest().size() == 0) { + return Boolean.FALSE; + } + if (scopeOverlap.getCurrentRequest().getActionIdentifiers().getVnfId() != null) { + return Boolean.TRUE; + } else if (scopeOverlap.getCurrentRequest().getActionIdentifiers().getVfModuleId() != null) { + return Boolean.TRUE; + } else if (scopeOverlap.getCurrentRequest().getActionIdentifiers().getvServerId() != null) { + return isVserverOrVnfcIdOverLap(scopeOverlap); + } else if (scopeOverlap.getCurrentRequest().getActionIdentifiers().getVnfcName() != null) { + return isVserverOrVnfcIdOverLap(scopeOverlap); + } else { + throw new Exception(" Action Identifier doesn't have VnfId, VfModuleId, VServerId, VnfcName "); + } + } + + private boolean isVnfcNameOverLap(ScopeOverlap scopeOverlap) throws Exception { + + AaiService aaiService =new AaiService(aaiClient); + SvcLogicContext ctx = new SvcLogicContext(); + Map params = new HashMap(); + List inProgressVServerIds = new ArrayList(); + String currentVnfcVserverId = new String(); + String currentRequestVnfcName = scopeOverlap.getCurrentRequest().getActionIdentifiers().getVnfcName(); + String currentRequestVServerId = scopeOverlap.getCurrentRequest().getActionIdentifiers().getvServerId(); + List inProgressRequests = scopeOverlap.getInProgressRequest(); + params.put("vnfId", scopeOverlap.getVnfId()); + try { + aaiService.getGenericVnfInfo(params, ctx); + int vm_count = Integer.parseInt(ctx.getAttribute("vm-count")); + for(Request inprogressRequest:inProgressRequests){ + if(inprogressRequest.getActionIdentifiers().getVnfcName() != null){ + for (int i = 0; i < vm_count; i++){ + if (ctx.getAttribute("vm[" + i + "].vnfc-name") != null && ctx.getAttribute("vm[" + i + "].vnfc-name") + .equals(inprogressRequest.getActionIdentifiers().getVnfcName())) + inProgressVServerIds.add(ctx.getAttribute("vm[" + i + "].vserver-id")); + log.debug("Received vserver-id from AAI: "+ inProgressVServerIds); + } + } + } + for(Request inProgVserverIds:inProgressRequests) + if(inProgVserverIds.getActionIdentifiers().getvServerId()!=null) + inProgressVServerIds.add(inProgVserverIds.getActionIdentifiers().getvServerId()); + if(currentRequestVnfcName != null){ + for (int i = 0; i < vm_count; i++) + if (ctx.getAttribute("vm[" + i + "].vnfc-name") != null && ctx.getAttribute("vm[" + i + "].vnfc-name") + .equals(currentRequestVnfcName)) + currentVnfcVserverId = ctx.getAttribute("vm[" + i + "].vserver-id"); + log.debug("Received vserver-id from AAI: "+ currentVnfcVserverId); + return inProgressVServerIds.contains(currentVnfcVserverId); + } + for (Request request : inProgressRequests) { + if(!Strings.isNullOrEmpty(currentRequestVServerId) && currentRequestVServerId.equalsIgnoreCase(request.getActionIdentifiers().getvServerId())) + return Boolean.TRUE; + } + if(currentRequestVServerId != null) { + return inProgressVServerIds.contains(currentRequestVServerId); + } + return Boolean.FALSE; + } catch (Exception e) { + e.printStackTrace(); + log.debug(e.getMessage()); + throw e; + } + } + + private boolean isVserverOrVnfcIdOverLap(ScopeOverlap scopeOverlap) throws Exception { + List inProgressRequests = scopeOverlap.getInProgressRequest(); + for (Request request : inProgressRequests) { + if(request.getActionIdentifiers().getVnfId()!= null) + return Boolean.TRUE ; + } + for (Request request : inProgressRequests) { + if(request.getActionIdentifiers().getVfModuleId()!= null) + return Boolean.TRUE ; + } + String currentVserverID = scopeOverlap.getCurrentRequest().getActionIdentifiers().getvServerId(); + for (Request request : inProgressRequests) { + if(currentVserverID != null && currentVserverID.equalsIgnoreCase(request.getActionIdentifiers().getvServerId())) + return Boolean.TRUE ; + } + return isVnfcNameOverLap(scopeOverlap); + } +} diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/utils/ServiceConstants.java b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/utils/ServiceConstants.java new file mode 100644 index 000000000..2ac4172a8 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/bundle/src/main/java/org/onap/appc/interfaces/service/utils/ServiceConstants.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.interfaces.service.utils; + +public class ServiceConstants { + + public static final String REQUESTOVERLAP = "isScopeOverlap"; + public static final String GEDATABYMODEL = "getdatabymodel"; + public static final String VNF = "vnf-id"; + public static final String VNFCNAME = "vnfc-name"; + public static final String VFMODULE = "vf-module-id"; + public static final String VSERVER = "vserver-id"; + public static final String CURRENTREQUEST = "current-request"; + public static final String INPROGRESSREQUEST = "in-progress-requests"; + public static final String ACTION = "action"; + public static final String ACTIONIDENTIFIER = "action-identifiers"; + public static final String SERVICEINSTANCEID = "service-instance-id"; +} diff --git a/appc-inbound/appc-interfaces-service/bundle/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/appc-inbound/appc-interfaces-service/bundle/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml new file mode 100644 index 000000000..239aa2354 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/bundle/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + diff --git a/appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaceService/serviceExecutor/TestServiceExecutor.java b/appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaceService/serviceExecutor/TestServiceExecutor.java new file mode 100644 index 000000000..0c91964c2 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/bundle/src/test/java/org/onap/appc/interfaceService/serviceExecutor/TestServiceExecutor.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.interfaceService.serviceExecutor; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import org.onap.appc.interfaces.service.executorImpl.ServiceExecutorImpl; + +public class TestServiceExecutor { + + @Test + public void serviceExecutorTest() throws Exception { + ServiceExecutorImpl sei = new ServiceExecutorImpl(); + String requestData = "{\"vnf-id\":\"ibcx8888v\",\"current-request\" :{\"action\" : \"Audit\",\"action-identifiers\" : {\"service-instance-id\" : \"service-instance-id\",\"vnf-id\" : \"vnf-id\",\"vnfc-name\" : \"vnfc-name\",\"vf-module-id\" : \"vf-module-id\",\"vserver-id\": \"vserver-id\"}},\"in-progress-requests\" :[{\"action\" : \"HealthCheck\",\"action-identifiers\" : {\"service-instance-id\" : \"service-instance-id1\",\"vnf-id\" : \"vnf-id1\",\"vnfc-name\" : \"vnfc-name1\",\"vf-module-id\" : \"vf-module-id\",\"vserver-id\": \"vserver-id1\"}},{\"action\" : \"CheckLock\",\"action-identifiers\" : {\"service-instance-id\" : \"service-instance-id2\",\"vnf-id\" : \"vnf-id2\",\"vnfc-name\" : \"vnfc-name2\",\"vf-module-id\" : \"vf-module-id2\",\"vserver-id\": \"vserver-id2\"}}]}"; + sei.isRequestOverLap(requestData); + } +} diff --git a/appc-inbound/appc-interfaces-service/features/.gitignore b/appc-inbound/appc-interfaces-service/features/.gitignore new file mode 100644 index 000000000..b83d22266 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/features/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-inbound/appc-interfaces-service/features/pom.xml b/appc-inbound/appc-interfaces-service/features/pom.xml new file mode 100644 index 000000000..a1c8d1a18 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/features/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + + appc-interfaces-service + org.onap.appc + 1.3.0-SNAPSHOT + + appc-interfaces-service-features + APPC Interfaces Service - Feature + jar + + + + org.onap.appc + appc-interfaces-service-model + + + org.onap.appc + appc-interfaces-service-bundle + + + + org.opendaylight.controller + opendaylight-karaf-empty + zip + + + + org.opendaylight.odlparent + features-test + test + ${odl.commons.opendaylight.version} + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + diff --git a/appc-inbound/appc-interfaces-service/features/src/main/resources/features.xml b/appc-inbound/appc-interfaces-service/features/src/main/resources/features.xml new file mode 100644 index 000000000..2d3198cd7 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/features/src/main/resources/features.xml @@ -0,0 +1,52 @@ + + + + + + + mvn:org.opendaylight.yangtools/features-yangtools/${odl.yangtools.version}/xml/features + mvn:org.opendaylight.controller/features-mdsal/${odl.controller.mdsal.features.version}/xml/features + + + + + odl-mdsal-models + mvn:org.onap.appc/appc-interfaces-service-model/${project.version} + + + odl-mdsal-broker + sdnc-sli + mvn:org.onap.appc/appc-interfaces-service-bundle/${project.version} + mvn:org.onap.appc/appc-aai-client-provider/${project.version} + wrap:mvn:com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.3.0 + odl-restconf + + + + diff --git a/appc-inbound/appc-interfaces-service/installer/.gitignore b/appc-inbound/appc-interfaces-service/installer/.gitignore new file mode 100644 index 000000000..b83d22266 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/installer/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-inbound/appc-interfaces-service/installer/pom.xml b/appc-inbound/appc-interfaces-service/installer/pom.xml new file mode 100644 index 000000000..1716689bc --- /dev/null +++ b/appc-inbound/appc-interfaces-service/installer/pom.xml @@ -0,0 +1,134 @@ + + + 4.0.0 + + appc-interfaces-service + org.onap.appc + 1.3.0-SNAPSHOT + + appc-interfaces-service-installer + appc-interfaces-service-installer + pom + + + appc-interfaces-service + appc-interfaces-service + mvn:org.onap.appc/appc-interfaces-service-features/${project.version}/xml/features + false + + + + + + org.onap.appc + appc-interfaces-service-features + ${project.version} + features + xml + + + * + * + + + + + org.onap.appc + appc-interfaces-service-bundle + ${project.version} + + + + + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + false + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + + + + installer-zip + + single + + package + + false + true + ${application.name}-${project.version} + + src/assembly/assemble_installer_zip.xml + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.opendaylight + provided + + + + + + maven-resources-plugin + + + copy-version + + copy-resources + + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + diff --git a/appc-inbound/appc-interfaces-service/installer/resources/scripts/install-feature.sh b/appc-inbound/appc-interfaces-service/installer/resources/scripts/install-feature.sh new file mode 100644 index 000000000..f2f254bac --- /dev/null +++ b/appc-inbound/appc-interfaces-service/installer/resources/scripts/install-feature.sh @@ -0,0 +1,39 @@ +### +# ============LICENSE_START======================================================= +# ONAP : APP-C +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. 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========================================================= +### + +#!/bin/bash + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -n -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/appc-inbound/appc-interfaces-service/installer/src/assembly/assemble_installer_zip.xml b/appc-inbound/appc-interfaces-service/installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 000000000..8bb2ad925 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,62 @@ + + + + + + controller + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/appc-inbound/appc-interfaces-service/installer/src/assembly/assemble_mvnrepo_zip.xml b/appc-inbound/appc-interfaces-service/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 000000000..489d6f562 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,50 @@ + + + + + + controller + + zip + + + + false + + + + target/assembly/ + . + + + + + + diff --git a/appc-inbound/appc-interfaces-service/installer/src/main/resources/scripts/install-feature.sh b/appc-inbound/appc-interfaces-service/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..d0210eb06 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,43 @@ +### +# ============LICENSE_START======================================================= +# ONAP : APPC +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Copyright (C) 2017 Amdocs +# ============================================================================= +# 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. +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +# ============LICENSE_END========================================================= +### + +#!/bin/bash + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -n -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/appc-inbound/appc-interfaces-service/jacoco.exec b/appc-inbound/appc-interfaces-service/jacoco.exec new file mode 100644 index 000000000..9dbd5754a Binary files /dev/null and b/appc-inbound/appc-interfaces-service/jacoco.exec differ diff --git a/appc-inbound/appc-interfaces-service/model/.gitignore b/appc-inbound/appc-interfaces-service/model/.gitignore new file mode 100644 index 000000000..b83d22266 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/model/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-inbound/appc-interfaces-service/model/pom.xml b/appc-inbound/appc-interfaces-service/model/pom.xml new file mode 100644 index 000000000..63e855f06 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/model/pom.xml @@ -0,0 +1,156 @@ + + + 4.0.0 + + appc-interfaces-service + org.onap.appc + 1.3.0-SNAPSHOT + + appc-interfaces-service-model + bundle + + + + + org.apache.felix + maven-bundle-plugin + true + + + * + + + + + org.opendaylight.yangtools + yang-maven-plugin + ${odl.yangtools.version} + + + org.opendaylight.mdsal + maven-sal-api-gen-plugin + ${odl.sal.api.gen.plugin.version} + jar + + + + + + + generate-sources + + + ${yang.file.directory} + + + org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl + ${salGeneratorPath} + + + true + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + + python + + scripts/python/yang2props.py + src/main/yang/appc-interfaces-service.yang + target/appc-interfaces-service.properties + + + generation + generate-resources + + exec + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/appc-interfaces-service.properties + properties + appc-interfaces-service + + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.codehaus.mojo + + + exec-maven-plugin + + + [1.2.1,) + + + exec + + + + + + + + + + + + + + + + org.opendaylight.mdsal + yang-binding + + + org.opendaylight.yangtools + yang-common + + + org.opendaylight.mdsal.model + ietf-inet-types + + + org.opendaylight.mdsal.model + ietf-yang-types + + + diff --git a/appc-inbound/appc-interfaces-service/model/scripts/python/yang2props.py b/appc-inbound/appc-interfaces-service/model/scripts/python/yang2props.py new file mode 100644 index 000000000..559d31b8b --- /dev/null +++ b/appc-inbound/appc-interfaces-service/model/scripts/python/yang2props.py @@ -0,0 +1,57 @@ +#!/usr/bin/python + +import re +import sys + + +# Convert word from foo-bar to FooBar +# words begining with a digit will be converted to _digit +def to_enum(s): + if s[0].isdigit(): + s = "_" + s + else: + s = s[0].upper() + s[1:] + return re.sub(r'(?!^)-([a-zA-Z])', lambda m: m.group(1).upper(), s) + +leaf = "" +val = "" +li = [] + +if len(sys.argv) < 3: + print 'yang2props.py ' + sys.exit(2) + +with open(sys.argv[1], "r") as ins: + for line in ins: + # if we see a leaf save the name for later + if "leaf " in line: + match = re.search(r'leaf (\S+)', line) + if match: + leaf = match.group(1) + + # if we see enum convert the value to enum format and see if it changed + # if the value is different write a property entry + if "enum " in line: + match = re.search(r'enum "(\S+)";', line) + if match: + val = match.group(1) + enum = to_enum(val) + + # see if converting to enum changed the string + if val != enum: + property = "yang."+leaf+"."+enum+"="+val + if property not in li: + li.append( property) + + +# Open output file +fo = open(sys.argv[2], "wb") +fo.write("# yang conversion properties \n") +fo.write("# used to convert Enum back to the original yang value \n") +fo.write("\n".join(li)) +fo.write("\n") + +# Close opend file +fo.close() + + diff --git a/appc-inbound/appc-interfaces-service/model/src/main/yang/appc-interfaces-service.yang b/appc-inbound/appc-interfaces-service/model/src/main/yang/appc-interfaces-service.yang new file mode 100644 index 000000000..b6e0438a8 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/model/src/main/yang/appc-interfaces-service.yang @@ -0,0 +1,122 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +/* + * Yang model for the Application Controller (APP-C) component of ECOMP + * + * + *The main purpose of this model to provide an interface bewteen APPC Runtime and other interface + * to communicate. + * + * + * + * Author: Anand Chaturvedi (ac204h@att.com) + */ + +module interfaces-service { + + yang-version 1; + namespace "org:onap:appc:interfaces:service"; + prefix interfaces.service; + organization "AT&T. Copyright (C) 2015. All rights reserved."; + contact + "Anand Chaturvedi "; + + description + "Defines the services provided by Application Controller to external interfaces."; + + /* + * Note, the revision changes the package name of the generated java code. Do not + * change the revision unless you also update all references to the bindings. + */ + revision "2017-08-18" { + description + "APP-C Interface services version 1.1.0"; + } + + grouping request-info { + container request { + leaf request-id { + type string; + description "The request ID "; + mandatory true; + } + leaf action { + type string; + description "The Action Name"; + mandatory true; + } + leaf request-data { + type string; + description "The Payload"; + } + leaf request-data-type { + description "Data type for validation"; + type string; + } + } + } + + grouping response-info { + description "The Generic Data response which includes data key value pair as requested in Model"; + container response-info { + description "Data returned from APPC to external Interaface"; + leaf block { + description "Response message"; + type string; + } + leaf requestId { + description "Response message reqesut ID"; + type string; + mandatory true; + } + } + } + grouping status { + description "The specific response codes are to be aligned with APPC/ECOMP messaging Systems"; + container status { + description "The specific response codes are to be aligned with APPC."; + leaf code { + description "Response code"; + type string; + mandatory true; + } + leaf message { + description "Response message"; + type string; + } + } + } + + rpc execute-service { + description "Runs a given action if it exists."; + input { + uses request-info; + } + output { + uses response-info ; + uses status; + } + } +} diff --git a/appc-inbound/appc-interfaces-service/pom.xml b/appc-inbound/appc-interfaces-service/pom.xml new file mode 100644 index 000000000..91df11252 --- /dev/null +++ b/appc-inbound/appc-interfaces-service/pom.xml @@ -0,0 +1,94 @@ + + + 4.0.0 + + + org.onap.appc + appc-inbound + 1.3.0-SNAPSHOT + + + pom + appc-interfaces-service + APPC Interface Services + + + + + org.onap.appc + appc-interfaces-service-features + features + xml + ${project.version} + + + + org.onap.appc + appc-interfaces-service-model + ${project.version} + + + org.onap.appc + appc-interfaces-service-bundle + ${project.version} + config + xml + + + org.onap.appc + appc-interfaces-service-bundle + ${project.version} + + + + + + + + model + features + bundle + installer + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.codehaus.mojo + + + properties-maven-plugin + + + [1.0.0,) + + + + set-system-properties + + + + + + + + + + + + + + + diff --git a/appc-inbound/pom.xml b/appc-inbound/pom.xml index 76fe5856a..54dd636b3 100755 --- a/appc-inbound/pom.xml +++ b/appc-inbound/pom.xml @@ -1,28 +1,29 @@ - - 4.0.0 - - org.onap.appc - appc - 1.3.0-SNAPSHOT - - appc-inbound - pom - Application Controller Inbound - Application Controller Inbound - - - 2.3.2 - 1.12 - 1.7 - 1.3.7 - 3.2.1 - 2.5 - 1.1.0 - - - appc-artifact-handler - appc-design-services - - - + + 4.0.0 + + org.onap.appc + appc + 1.3.0-SNAPSHOT + + appc-inbound + pom + Application Controller Inbound + Application Controller Inbound + + + 2.3.2 + 1.12 + 1.7 + 1.3.7 + 3.2.1 + 2.5 + 1.1.0 + + + appc-artifact-handler + appc-design-services + appc-interfaces-service + + + -- cgit 1.2.3-korg