diff options
Diffstat (limited to 'appc-provider/appc-provider-bundle/src/main')
3 files changed, 30 insertions, 154 deletions
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java index de77c8ea6..90097aea8 100644 --- a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java +++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java @@ -25,6 +25,7 @@ package org.openecomp.appc.provider; import java.text.ParseException; +import java.util.Collection; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; @@ -42,6 +43,7 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.openecomp.appc.Constants; import org.openecomp.appc.configuration.Configuration; import org.openecomp.appc.configuration.ConfigurationFactory; +import org.openecomp.appc.domainmodel.lcm.ActionLevel; import org.openecomp.appc.domainmodel.lcm.ResponseContext; import org.openecomp.appc.domainmodel.lcm.RuntimeContext; import org.openecomp.appc.executor.objects.LCMCommandStatus; @@ -59,6 +61,7 @@ import com.att.eelf.configuration.EELFManager; import com.att.eelf.i18n.EELFResourceManager; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.ServiceReference; import com.google.common.util.concurrent.Futures; @@ -179,7 +182,7 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService { /** * Restarts a specific VNF * - * @see org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AppcProviderLcmService#restart(RestartInput) + * @see org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.AppcProviderLcmService#restart(RestartInput) */ @Override public Future<RpcResult<RestartOutput>> restart(RestartInput input) { @@ -402,7 +405,7 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService { private RequestHandlerOutput executeRequest(RequestHandlerInput request){ - RequestHandler handler = getRequestHandler(); + RequestHandler handler = getRequestHandler(request.getRequestContext().getActionLevel()); RequestHandlerOutput requestHandlerOutput; try { requestHandlerOutput = handler.handleRequest(request); @@ -432,16 +435,21 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService { return requestHandlerOutput; } - private RequestHandler getRequestHandler(){ + private RequestHandler getRequestHandler(ActionLevel actionLevel){ RequestHandler handler ; final BundleContext context = FrameworkUtil.getBundle(RequestHandler.class).getBundleContext(); - final ServiceReference reference = context.getServiceReference(RequestHandler.class.getName()); - - if (reference != null) { - handler = (RequestHandler) context.getService(reference); - } else { - logger.error("Cannot find service reference for " + RequestHandler.class.getName()); - throw new RuntimeException(); + String filter = "(level=" + actionLevel.name() + ")"; + try { + Collection<ServiceReference<RequestHandler>> serviceReferences = context.getServiceReferences(RequestHandler.class, filter); + if (serviceReferences.size() != 1) { + logger.error("Cannot find service reference for " + RequestHandler.class.getName()); + throw new RuntimeException(); + } + ServiceReference<RequestHandler> serviceReference = serviceReferences.iterator().next(); + handler = context.getService(serviceReference); + } catch (InvalidSyntaxException e) { + logger.error("Cannot find service reference for " + RequestHandler.class.getName() + ": Invalid Syntax " + filter, e); + throw new RuntimeException(e); } return handler ; } diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/RequestInputBuilder.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/RequestInputBuilder.java index 0c4fc7341..495fa82a6 100644 --- a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/RequestInputBuilder.java +++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/RequestInputBuilder.java @@ -28,11 +28,13 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.TimeZone; +import org.apache.commons.lang.StringUtils; import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.Payload; import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.action.identifiers.ActionIdentifiers; import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.CommonHeader; import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.Flags; import org.openecomp.appc.domainmodel.lcm.Flags.Mode; +import org.openecomp.appc.domainmodel.lcm.ActionLevel; import org.openecomp.appc.domainmodel.lcm.RequestContext; import org.openecomp.appc.domainmodel.lcm.VNFOperation; import org.openecomp.appc.requesthandler.objects.RequestHandlerInput; @@ -139,11 +141,21 @@ public class RequestInputBuilder { actionIds.setvServerId(actionIdentifiers.getVserverId()); actionIds.setVnfId(actionIdentifiers.getVnfId()); this.requestContext.setActionIdentifiers(actionIds); + + ActionLevel actionLevel = readActionLevel(actionIds); + this.requestContext.setActionLevel(actionLevel); return this; }else{ throw new ParseException("Missing action identifier" , 0); } } + private ActionLevel readActionLevel(org.openecomp.appc.domainmodel.lcm.ActionIdentifiers actionIds) { + if(!StringUtils.isEmpty(actionIds.getVserverId())){ + return ActionLevel.VM; + } + return ActionLevel.VNF; + } + } diff --git a/appc-provider/appc-provider-bundle/src/main/resources/org/openecomp/appc/org.ops4j.pax.logging.cfg b/appc-provider/appc-provider-bundle/src/main/resources/org/openecomp/appc/org.ops4j.pax.logging.cfg deleted file mode 100644 index be5863291..000000000 --- a/appc-provider/appc-provider-bundle/src/main/resources/org/openecomp/appc/org.ops4j.pax.logging.cfg +++ /dev/null @@ -1,144 +0,0 @@ - ################################################################################ - # - # Licensed to the Apache Software Foundation (ASF) under one or more - # contributor license agreements. See the NOTICE file distributed with - # this work for additional information regarding copyright ownership. - # The ASF licenses this file to You 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, - # WITH WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - # - ################################################################################ - - # Root - #log4j.rootLogger=TRACE, osgi:VmLogAppender - log4j.rootLogger=TRACE, out, sift, osgi:* - log4j.throwableRenderer=org.apache.log4j.OsgiThrowableRenderer - - # CONSOLE appender not used by default - log4j.appender.stdout=org.apache.log4j.ConsoleAppender - log4j.appender.stdout.layout=org.apache.log4j.PatternLayout - log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n - - # Async appender forwarding to file appender - log4j.appender.async=org.apache.log4j.AsyncAppender - log4j.appender.async.appenders=out - - # Karaf appenders - # File appender - log4j.appender.out=org.apache.log4j.RollingFileAppender - log4j.appender.out.layout=org.apache.log4j.PatternLayout - log4j.appender.out.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n - log4j.appender.out.file=${karaf.data}/log/karaf.log - log4j.appender.out.append=true - log4j.appender.out.maxFileSize=10MB - log4j.appender.out.maxBackupIndex=100 - - - # Sift appender - log4j.appender.sift=org.apache.log4j.sift.MDCSiftingAppender - log4j.appender.sift.key=bundle.name - log4j.appender.sift.default=karaf - log4j.appender.sift.appender=org.apache.log4j.RollingFileAppender - log4j.appender.sift.appender.layout=org.apache.log4j.PatternLayout - log4j.appender.sift.appender.layout.ConversionPattern=%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%t|%X{ServiceName} - %X{bundle.id} - %X{bundle.name} - %X{bundle.version}|%-5.5p|%X{AlertSeverity}|%X{ServerFQDN}|%X{ServerIPAddress}|[%c{3}]|%m%n - log4j.appender.sift.appender.file=${karaf.data}/log/eelf/karaf.log - log4j.appender.sift.appender.append=true - - log4j.category.org.opendaylight.controller.netconf.persist.impl.osgi.ConfigPusherImpl=DEBUG - log4j.category.org.opendaylight.controller.netconf.persist.impl.osgi.ConfigPersisterActivator=DEBUG - - - #ECOMP Debug appender - log4j.appender.debug=org.apache.log4j.RollingFileAppender - log4j.appender.debug.key=bundle.name - log4j.appender.debug.default=karaf - - log4j.appender.debug.appName=EELFDebug - log4j.appender.debug.layout=org.apache.log4j.PatternLayout - log4j.appender.debug.layout.ConversionPattern=%d{yyyy-MM-dd'T'hh:mm:ss.SSSXXX}|%X{RequestId}|%m%n - #log4j.appender.debug.filter.f1=org.apache.log4j.varia.LevelRangeFilter - #log4j.appender.debug.filter.f1.LevelMax=WARN - #log4j.appender.debug.filter.f1.LevelMin=TRACE - - - log4j.appender.debug.file=${karaf.data}/log/APPC/appc-debug.log - log4j.appender.debug.append=true - log4j.appender.debug.maxFileSize=100MB - log4j.appender.debug.maxBackupIndex=10 - - - #Error appender - log4j.appender.error=org.apache.log4j.RollingFileAppender - log4j.appender.error.appName=EELFError - log4j.appender.error.File=${karaf.data}/log/APPC/appc-error.log - log4j.appender.error.Threshold=ERROR - log4j.appender.error.MaxBackupIndex=1 - log4j.appender.error.MaxFileSize=100MB - log4j.appender.error.layout=org.apache.log4j.PatternLayout - log4j.appender.error.layout.ConversionPattern=%d{yyyy-MM-dd'T'hh:mm:ss.SSSXXX}|%X{RequestId}|%t|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%-5.5p|%X{ErrorCode}|%X{ErrorDescription}|%m%n - - #Metrics appender - log4j.appender.metric=org.apache.log4j.RollingFileAppender - log4j.appender.metric.appName=EELFMetrics - log4j.appender.metric.File=${karaf.data}/log/APPC/appc-metric.log - log4j.appender.metric.MaxBackupIndex=1 - log4j.appender.metric.MaxFileSize=100MB - log4j.appender.metric.layout=org.apache.log4j.PatternLayout - log4j.appender.metric.layout.ConversionPattern=%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%t|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%-5.5p|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{ClientIPAddress}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%m%n - - #Audit appender - log4j.appender.audit=org.apache.log4j.RollingFileAppender - log4j.appender.audit.appName=EELFAudit - log4j.appender.audit.File=${karaf.data}/log/APPC/appc-audit.log - log4j.appender.audit.MaxBackupIndex=1 - log4j.appender.audit.MaxFileSize=100MB - log4j.appender.audit.layout=org.apache.log4j.PatternLayout - log4j.appender.audit.layout.ConversionPattern=%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%t|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%-5.5p|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{ClientIPAddress}|%X{ClassName}||%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%m%n - - #Loggers - #Routing of all messages from root logger - log4j.logger.com.att=TRACE, debug, error - #Store to the same log file messages from upper level appender or not - log4j.additivity.com.att=false - - #EELFManager loggers - #EELF parent logger - log4j.logger.com.att.eelf=TRACE, debug - log4j.additivity.com.att.eelf=false - - #Audit logger routing - log4j.logger.com.att.eelf.audit=DEBUG, audit - log4j.additivity.com.att.eelf.audit=false - - #Metric logger routing - log4j.logger.com.att.eelf.metrics=DEBUG, metric - log4j.additivity.com.att.eelf.metrics=false - - #Performance logger routing - log4j.logger.com.att.eelf.perf=DEBUG, metric - log4j.additivity.com.att.eelf.perf=false - - #Server logger routing - log4j.logger.com.att.eelf.server=DEBUG, debug - log4j.additivity.com.att.eelf.server=false - - #Policy logger routing - log4j.logger.com.att.eelf.policy=DEBUG, debug - log4j.additivity.com.att.eelf.policy=false - - #Error logger routing - log4j.logger.com.att.eelf.error=DEBUG, error - log4j.additivity.com.att.eelf.error=false - - #Debug logger routing - log4j.logger.com.att.eelf.debug=DEBUG, debug - log4j.additivity.com.att.eelf.debug=false - |