diff options
author | Patrick Brady <pb071s@att.com> | 2017-06-01 10:45:37 -0700 |
---|---|---|
committer | Patrick Brady <pb071s@att.com> | 2017-06-02 13:05:15 -0700 |
commit | c7d0075d223eab9f89fd28853c4b138792059be9 (patch) | |
tree | 40aa3e41e598ea7a59bcf6899a2004c1abab11c2 /appc-dispatcher/appc-command-executor | |
parent | 8aac2df744820304ee29354333661699e9695939 (diff) |
Merge of new rebased code
Change-Id: I9b8d1f69eb3e0af1935ed8304fea4bf54c1aac47
Signed-off-by: Patrick Brady <pb071s@att.com>
Diffstat (limited to 'appc-dispatcher/appc-command-executor')
9 files changed, 118 insertions, 80 deletions
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/pom.xml b/appc-dispatcher/appc-command-executor/appc-command-executor-api/pom.xml index 6841b8224..7e6f01b32 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-api/pom.xml +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/pom.xml @@ -30,13 +30,13 @@ <groupId>org.openecomp.appc</groupId> <artifactId>appc-common</artifactId> <version>${project.version}</version> + <scope>compile</scope> </dependency> <!--<dependency>--> <!--<groupId>org.apache.commons</groupId>--> <!--<artifactId>commons-lang3</artifactId>--> <!--<version>3.4</version>--> <!--<scope>provided</scope>--> - <!--<type>bundle</type>--> <!--</dependency>--> </dependencies> <build> @@ -49,9 +49,13 @@ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> <Bundle-Version>${project.version}</Bundle-Version> <Export-Package>org.openecomp.appc.executor,org.openecomp.appc.executor.objects,org.openecomp.appc.executor.conv,org.openecomp.appc.executor.helper</Export-Package> - <Embed-Dependency>appc-common,eelf-core,logback-core,logback-classic,javax.json;scope=compile|runtime;inline=false</Embed-Dependency> + <Embed-Dependency> + javax.json;scope=compile|runtime;inline=false + </Embed-Dependency> <Embed-Transitive>true</Embed-Transitive> - <Import-Package>!groovy.lang,!javax.*,!org.apache.log,!org.apache.log4j.*,!org.codehaus.jackson.*,!org.codehaus.jackson.map.*,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!org.jasypt.*,!com.ibm.icu.*,!com.sun.faces.*,*</Import-Package> + <Import-Package> + *;resolution:=optional + </Import-Package> </instructions> </configuration> </plugin> diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/LCMCommandStatus.java b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/LCMCommandStatus.java index 14bd8152c..6b1b67481 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/LCMCommandStatus.java +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-api/src/main/java/org/openecomp/appc/executor/objects/LCMCommandStatus.java @@ -41,7 +41,7 @@ public enum LCMCommandStatus { MISSING_MANDATORY_PARAMETER(302,"MISSING MANDATORY PARAMETER - Parameter/s ${paramName} is/are missing" ), REQUEST_PARSING_FAILED(303,"REQUEST PARSING FAILED - ${errorMsg}"), NO_TRANSITION_DEFINE(304,"ACTION IS NOT ALLOWED - Action ${actionName} is not allowed for VNF in state ${currentState}"), - ACTION_NOT_SUPPORTED(305,"ACTION NOT SUPPORTED - ${actionName} action is not supported" ), + INVALID_VNF_STATE(305,"Request rejected because VNF status in A&AI is - ${currentState}" ), VNF_NOT_FOUND(306,"VNF NOT FOUND - VNF with ID ${vnfId} was not found" ), DG_WORKFLOW_NOT_FOUND(307,"DG WORKFLOW NOT FOUND - No DG workflow found for the combination of ${dgModule} module ${dgName} name and ${dgVersion} version"),//TODO need to support it WORKFLOW_NOT_FOUND(308,"WORKFLOW NOT FOUND - No workflow found for VNF type ${vnfTypeVersion} and ${actionName} action"), @@ -49,6 +49,7 @@ public enum LCMCommandStatus { LOCKING_FAILURE(310,"LOCKING FAILURE - ${errorMsg}" ), EXPIRED_REQUEST(311,"EXPIRED REQUEST"), DUPLICATE_REQUEST(312,"DUPLICATE REQUEST"), + MISSING_VNF_DATA_IN_AAI(313,"MISSING VNF DATA IN A&AI - ${attributeName} not found for VNF ID = ${vnfId}"), SUCCESS(400,"SUCCESS - request has been processed successfully"), diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml b/appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml index ef73055f8..d827fba8b 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/pom.xml @@ -40,7 +40,6 @@ <dependency> <groupId>org.openecomp.appc</groupId> <artifactId>appc-command-executor-api</artifactId> - <version>${project.version}</version> </dependency> <dependency> <groupId>org.openecomp.appc</groupId> @@ -92,14 +91,28 @@ <instructions> <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> <Bundle-Version>${project.version}</Bundle-Version> - <Embed-Dependency>appc-common,eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false</Embed-Dependency> + <Embed-Dependency>eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false</Embed-Dependency> <Embed-Transitive>true</Embed-Transitive> <Export-Service>org.openecomp.appc.executor.CommandExecutor</Export-Service> - <Import-Package>org.openecomp.appc.executionqueue.*,org.openecomp.appc.executor,org.openecomp.appc.executor.objects,!groovy.lang,!javax.jms,!org.apache.log,!org.apache.log4j.*,!org.codehaus.jackson.*,!org.codehaus.jackson.map.*,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!org.jasypt.*,!com.ibm.icu.*,!com.sun.faces.*,*;resolution:=optional</Import-Package> + <Import-Package> + org.openecomp.appc.executionqueue.*, + org.openecomp.appc.executor, + org.openecomp.appc.executor.objects, + *;resolution:=optional + </Import-Package> </instructions> </configuration> </plugin> </plugins> </build> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.openecomp.appc</groupId> + <artifactId>appc-command-executor-api</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + </dependencyManagement> </project> diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandExecutorImpl.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandExecutorImpl.java index fcc4f9156..7e1281ac4 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandExecutorImpl.java +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandExecutorImpl.java @@ -87,6 +87,34 @@ public class CommandExecutorImpl implements CommandExecutor { } } + private RuntimeContext getCommandRequest(RuntimeContext commandExecutorInput){ + if (logger.isTraceEnabled()) { + logger.trace("Entering to getCommandRequest with CommandExecutorInput = "+ ObjectUtils.toString(commandExecutorInput)); + } + RuntimeContext commandRequest; + commandRequest = commandExecutorInput; + /* + CommandRequest commandRequest; + + switch(commandExecutorInput.getRequestContext().getAction()){ + case Sync: + case Audit: + case ConfigBackup: + case ConfigBackupDelete: + case ConfigExport: + commandRequest = new LCMReadOnlyCommandRequest(commandExecutorInput); + break; + default: + commandRequest = new LCMCommandRequest(commandExecutorInput); + break; + } + */ + if (logger.isTraceEnabled()) { + logger.trace("Exiting from getCommandRequest with (CommandRequest = "+ ObjectUtils.toString(commandRequest)+")"); + } + return commandRequest; + } + @SuppressWarnings("unchecked") private void enqueRequest(RuntimeContext request) throws APPCException{ if (logger.isTraceEnabled()) { diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java index 21a00861e..66b98bb28 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java @@ -21,29 +21,17 @@ package org.openecomp.appc.executor.impl; -import static com.att.eelf.configuration.Configuration.MDC_ALERT_SEVERITY; -import static com.att.eelf.configuration.Configuration.MDC_INSTANCE_UUID; -import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID; -import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN; -import static com.att.eelf.configuration.Configuration.MDC_SERVER_IP_ADDRESS; -import static com.att.eelf.configuration.Configuration.MDC_SERVICE_INSTANCE_ID; -import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME; - -import java.net.InetAddress; - -import org.openecomp.appc.domainmodel.lcm.RuntimeContext; import org.openecomp.appc.domainmodel.lcm.Status; import org.openecomp.appc.executor.objects.CommandResponse; import org.openecomp.appc.executor.objects.LCMCommandStatus; import org.openecomp.appc.executor.objects.Params; -import org.openecomp.appc.logging.LoggingConstants; import org.openecomp.appc.requesthandler.RequestHandler; +import org.openecomp.appc.domainmodel.lcm.RuntimeContext; import org.openecomp.appc.workflow.WorkFlowManager; import org.openecomp.appc.workflow.objects.WorkflowRequest; import org.openecomp.appc.workflow.objects.WorkflowResponse; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import org.slf4j.MDC; /** * This abstract class is base class for all Command tasks. All command task must inherit this class. @@ -80,19 +68,6 @@ public abstract class CommandTask implements Runnable { public void execute() { final RuntimeContext runtimeContext = commandRequest; - MDC.put(MDC_KEY_REQUEST_ID, runtimeContext.getRequestContext().getCommonHeader().getRequestId()); - if (runtimeContext.getRequestContext().getActionIdentifiers().getServiceInstanceId() != null) - MDC.put(MDC_SERVICE_INSTANCE_ID, runtimeContext.getRequestContext().getActionIdentifiers().getServiceInstanceId()); - MDC.put(LoggingConstants.MDCKeys.PARTNER_NAME, runtimeContext.getRequestContext().getCommonHeader().getOriginatorId()); - MDC.put(MDC_SERVICE_NAME, runtimeContext.getRequestContext().getAction().name()); - try { - MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getCanonicalHostName()); //Don't change it to a .getLocalHostName() again please. It's wrong! - MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress()); - }catch(Exception e){ - logger.debug(e.getMessage()); - } - MDC.put(MDC_INSTANCE_UUID, ""); //TODO make instanse_UUID generation once during APPC-instanse deploying - WorkflowRequest workflowRequest = new WorkflowRequest(); workflowRequest.setRequestContext(runtimeContext.getRequestContext()); workflowRequest.setResponseContext(runtimeContext.getResponseContext()); diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTaskFactory.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTaskFactory.java index 2f9d2c970..5e47860a7 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTaskFactory.java +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTaskFactory.java @@ -51,7 +51,8 @@ public class CommandTaskFactory { public synchronized CommandTask getExecutionTask(String action, RuntimeContext commandRequest){ - if (VNFOperation.Sync.toString().equals(action) || VNFOperation.Audit.toString().equals(action)){ + if (VNFOperation.Sync.toString().equals(action) || VNFOperation.Audit.toString().equals(action) || VNFOperation.ConfigBackup.toString().equals(action) || + VNFOperation.ConfigBackupDelete.toString().equals(action) || VNFOperation.ConfigExport.toString().equals(action)){ return new LCMReadonlyCommandTask(commandRequest, requestHandler,workflowManager); }else { return new LCMCommandTask(commandRequest, requestHandler,workflowManager, diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java index ef25c67bc..be9f94f68 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java @@ -28,6 +28,7 @@ import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.openecomp.appc.domainmodel.lcm.CommonHeader; import org.openecomp.appc.domainmodel.lcm.RuntimeContext; +import org.openecomp.appc.domainmodel.lcm.Status; import org.openecomp.appc.domainmodel.lcm.VNFOperation; import org.openecomp.appc.executor.UnstableVNFException; import org.openecomp.appc.executor.objects.CommandResponse; @@ -38,6 +39,7 @@ import org.openecomp.appc.lifecyclemanager.LifecycleManager; import org.openecomp.appc.lifecyclemanager.objects.LifecycleException; import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException; import org.openecomp.appc.lifecyclemanager.objects.VNFOperationOutcome; +import org.openecomp.appc.logging.LoggingConstants; import org.openecomp.appc.requesthandler.RequestHandler; import org.openecomp.appc.workflow.WorkFlowManager; import org.openecomp.appc.workflow.objects.WorkflowResponse; @@ -48,10 +50,16 @@ import org.openecomp.sdnc.sli.aai.AAIService; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceReference; +import org.slf4j.MDC; +import java.net.InetAddress; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; +import static com.att.eelf.configuration.Configuration.*; +import static com.att.eelf.configuration.Configuration.MDC_SERVICE_INSTANCE_ID; +import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME; + public class LCMCommandTask extends CommandTask { @@ -103,9 +111,15 @@ public class LCMCommandTask extends CommandTask { isAAIUpdated = updateAAI(request.getVnfContext().getId() , false, isSuccess); } logger.debug("isAAIUpdated = " + isAAIUpdated); + if(!isAAIUpdated){ + throw new Exception(); + } } catch(Exception e1) { logger.error("Exception = " + e1); + // In case of any errors we are updating the response status code and message + Status updatedStatus = new Status(401, "Fail to update VNF status in A&AI"); + request.getResponseContext().setStatus(updatedStatus); throw new RuntimeException(e1); } finally { @@ -115,8 +129,9 @@ public class LCMCommandTask extends CommandTask { @Override public void run() { - final RuntimeContext request = commandRequest; - boolean isAAIUpdated = false; + final RuntimeContext request = commandRequest; + setInitialLogProperties(request); + boolean isAAIUpdated = false; final String vnfId = request.getVnfContext().getId(); final String vnfType = request.getVnfContext().getType(); try { @@ -163,11 +178,12 @@ public class LCMCommandTask extends CommandTask { CommandResponse commandResponse = super.buildCommandResponse(response); this.onRequestCompletion(commandResponse); } - } + clearRequestLogProperties(); + } - private boolean updateAAI(String vnf_id , boolean isTTLEnd , boolean executionStatus) + private boolean updateAAI(String vnf_id, boolean isTTLEnd, boolean executionStatus) { String orchestrationStatus = null; String nextState; @@ -203,7 +219,7 @@ public class LCMCommandTask extends CommandTask { private SvcLogicContext getVnfdata(String vnf_id, String prefix,SvcLogicContext ctx) { - String key="vnf-id = '"+ vnf_id+"'"; + String key="generic-vnf.vnf-id = '"+ vnf_id+"'"+" AND http-header.Real-Time = 'true'"; logger.debug("inside getVnfdata=== "+key); try { SvcLogicResource.QueryStatus response = aaiService.query("generic-vnf", false, null, key,prefix, null, ctx); @@ -245,4 +261,31 @@ public class LCMCommandTask extends CommandTask { return false; } + protected void setInitialLogProperties(RuntimeContext request) + { + MDC.put(MDC_KEY_REQUEST_ID, request.getRequestContext().getCommonHeader().getRequestId()); + if (request.getRequestContext().getActionIdentifiers().getServiceInstanceId() != null) + MDC.put(MDC_SERVICE_INSTANCE_ID, request.getRequestContext().getActionIdentifiers().getServiceInstanceId()); + MDC.put(LoggingConstants.MDCKeys.PARTNER_NAME, request.getRequestContext().getCommonHeader().getOriginatorId()); + MDC.put(MDC_SERVICE_NAME, request.getRequestContext().getAction().name()); + try { + MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getCanonicalHostName()); + MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress()); + } catch (Exception e) { + logger.debug(e.getMessage()); + } + MDC.put(MDC_INSTANCE_UUID, ""); //TODO make instanse_UUID generation once during APPC-instanse deploying + } + + protected void clearRequestLogProperties() + { + try { + MDC.remove(MDC_KEY_REQUEST_ID); + MDC.remove(MDC_SERVICE_INSTANCE_ID); + MDC.remove(MDC_SERVICE_NAME); + MDC.remove(LoggingConstants.MDCKeys.PARTNER_NAME); + } catch (Exception e) { + + } + } } diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/resources/org/openecomp/appc/default.properties b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/resources/org/openecomp/appc/default.properties index 2e5f26a0f..b4cdae5e6 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/resources/org/openecomp/appc/default.properties +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/resources/org/openecomp/appc/default.properties @@ -24,25 +24,12 @@ org.openecomp.appc.bootstrap.file=appc.properties org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},. - #Property below provided by appc.properties -#dmaap.poolMembers=<DMAAP_IP>:3904 - -dmaap.topic.read=APPC-TEST2 -dmaap.topic.write=APPC-TEST2 -dmaap.topic.read.filter={"class": "And","filters": [{"class": "Assigned","field": "request"},{"class": "Unassigned","field": "response"}]} -dmaap.client.name=APPC-TEST-CLIENT-CMD-EXECUTOR-MAIN -dmaap.client.name.id=0 -#dmaap.client.key=random -#dmaap.client.secret=random +appc.LCM.provider.url=https://localhost:8443/restconf/operations/appc-provider-lcm +appc.LCM.poolMembers=<DMAAP_IP>:3904 +appc.LCM.service=dmaap +appc.LCM.topic.write=APPC-TEST2 +appc.LCM.client.name=APPC-TEST-CLIENT-CMD-EXECUTOR-MAIN +appc.LCM.provider.user=test +appc.LCM.provider.pass=test -dmaap.threads.queuesize.min=1 -dmaap.threads.queuesize.max=1000 -dmaap.threads.poolsize.min=2 -dmaap.threads.poolsize.max=2 - -# -# This needs to be changed so that the action can be appended to the end of the URL path -# -#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:topology-service -#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider: diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/resources/org/openecomp/appc/default.properties b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/resources/org/openecomp/appc/default.properties index 74552a9d7..fc0330d75 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/resources/org/openecomp/appc/default.properties +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/resources/org/openecomp/appc/default.properties @@ -76,27 +76,13 @@ org.openecomp.appc.db.url.%s", schema), ""); org.openecomp.appc.db.user.%s", schema), ""); org.openecomp.appc.db.pass.%s", schema), ""); - #Property below provided by appc.properties -#dmaap.poolMembers=<DMAAP_IP>:3904 - -dmaap.topic.read=APPC-TEST2 -dmaap.topic.write=APPC-TEST2 -#dmaap.topic.read.filter={"class":"Assigned","field":"request"} -dmaap.topic.read.filter={"class": "And","filters": [{"class": "Assigned","field": "request"},{"class": "Unassigned","field": "response"}]} -dmaap.client.name=APPC-TEST-CLIENT-CMD-EXECUTOR-TEST -dmaap.client.name.id=0 -#dmaap.client.key=random -#dmaap.client.secret=random - -dmaap.threads.queuesize.min=1 -dmaap.threads.queuesize.max=1000 -dmaap.threads.poolsize.min=2 -dmaap.threads.poolsize.max=2 +appc.LCM.provider.url=https://localhost:8443/restconf/operations/appc-provider-lcm +appc.LCM.poolMembers=<DMAAP_IP>:3904 +appc.LCM.service=dmaap +appc.LCM.topic.write=APPC-TEST2 +appc.LCM.client.name=APPC-TEST-CLIENT-CMD-EXECUTOR-TEST +appc.LCM.provider.user=test +appc.LCM.provider.pass=test -# -# This needs to be changed so that the action can be appended to the end of the URL path -# -#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:topology-service -#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider: |