summaryrefslogtreecommitdiffstats
path: root/appc-provider/appc-provider-bundle/src/main/java/org/openecomp
diff options
context:
space:
mode:
authorPatrick Brady <pb071s@att.com>2017-07-28 11:29:23 -0700
committerPatrick Brady <pb071s@att.com>2017-08-02 15:43:44 +0000
commit38713207b817ed4700f630748c681116338d32f0 (patch)
tree9eb2097cee8d85ac14f17e3a280ae8aefb69d9de /appc-provider/appc-provider-bundle/src/main/java/org/openecomp
parent771ac55e29d099d8bbf783612de975047d75ab12 (diff)
Merging in bug fixes
Change-Id: I85da90b9ba0d03149f42035a820c76ef0285e413 Signed-off-by: Patrick Brady <pb071s@att.com> Issue: APPC-100
Diffstat (limited to 'appc-provider/appc-provider-bundle/src/main/java/org/openecomp')
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java28
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/RequestInputBuilder.java12
2 files changed, 30 insertions, 10 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;
+ }
+
}