aboutsummaryrefslogtreecommitdiffstats
path: root/appc-provider/appc-provider-bundle/src
diff options
context:
space:
mode:
authorPatrick Brady <pb071s@att.com>2017-06-01 10:45:37 -0700
committerPatrick Brady <pb071s@att.com>2017-06-02 13:05:15 -0700
commitc7d0075d223eab9f89fd28853c4b138792059be9 (patch)
tree40aa3e41e598ea7a59bcf6899a2004c1abab11c2 /appc-provider/appc-provider-bundle/src
parent8aac2df744820304ee29354333661699e9695939 (diff)
Merge of new rebased code
Change-Id: I9b8d1f69eb3e0af1935ed8304fea4bf54c1aac47 Signed-off-by: Patrick Brady <pb071s@att.com>
Diffstat (limited to 'appc-provider/appc-provider-bundle/src')
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProvider.java17
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderClient.java58
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java299
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/RequestInputBuilder.java10
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/ValidationService.java8
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/topology/TopologyService.java79
6 files changed, 382 insertions, 89 deletions
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProvider.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProvider.java
index c65cc656e..1177504d4 100644
--- a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProvider.java
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProvider.java
@@ -155,10 +155,7 @@ public class AppcProvider implements AutoCloseable, AppcProviderService {
rpcRegistry = rpcProviderRegistry;
if (rpcRegistry != null) {
- logger.info("rpcRegistry was not null");
rpcRegistration = rpcRegistry.addRpcImplementation(AppcProviderService.class, this);
- } else {
- logger.error("rpcRegistry WAS NULL");
}
logger.info(Msg.COMPONENT_INITIALIZED, appName, "provider");
@@ -263,5 +260,19 @@ public Future<RpcResult<ModifyConfigOutput>> modifyConfig(ModifyConfigInput inpu
RpcResult<SnapshotOutput> result = topology.snapshot(hdr, vnf);
return Futures.immediateFuture(result);
}
+
+
+ /**
+ * Checks status of a VM
+ */
+ @Override
+ public Future<RpcResult<VmstatuscheckOutput>> vmstatuscheck(VmstatuscheckInput input) {
+ CommonRequestHeader hdr = input.getCommonRequestHeader();
+ VnfResource vnf = input.getVnfResource();
+
+ TopologyService topology = new TopologyService(this);
+ RpcResult<VmstatuscheckOutput> result = topology.vmstatuscheck(hdr, vnf);
+ return Futures.immediateFuture(result);
+ }
}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderClient.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderClient.java
index 0224784d6..4dd026127 100644
--- a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderClient.java
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderClient.java
@@ -30,10 +30,15 @@ import org.openecomp.sdnc.sli.provider.SvcLogicService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
+import org.slf4j.MDC;
import static com.att.eelf.configuration.Configuration.*;
import java.util.Properties;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
public class AppcProviderClient {
@@ -44,15 +49,20 @@ public class AppcProviderClient {
public AppcProviderClient() {
BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext();
-
- // Get SvcLogicService reference
- ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME);
- if (sref != null) {
- svcLogic = (SvcLogicService) bctx.getService(sref);
-
- } else {
- LOG.warn("Cannot find service reference for " + SvcLogicService.NAME);
-
+ //Handle BundleContext returning null
+ if (bctx == null){
+ LOG.warn("Cannot find bundle context for " + SvcLogicService.NAME);
+ }
+ else{
+ // Get SvcLogicService reference
+ ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME);
+ if (sref != null) {
+ svcLogic = (SvcLogicService) bctx.getService(sref);
+
+ } else {
+ LOG.warn("Cannot find service reference for " + SvcLogicService.NAME);
+
+ }
}
}
@@ -64,10 +74,40 @@ public class AppcProviderClient {
public Properties execute(String module, String rpc, String version, String mode, Properties parms)
throws SvcLogicException {
+ /*
+ * Set End time for Metrics Logger
+ */
+ long startTime = System.currentTimeMillis();
+ TimeZone tz = TimeZone.getTimeZone("UTC");
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
+ df.setTimeZone(tz);
+ String startTimeStr = df.format(new Date());
+ long endTime = System.currentTimeMillis();
+ long duration = endTime - startTime;
+ String endTimeStr = String.valueOf(endTime);
+ String durationStr = String.valueOf(duration);
+ String endTimeStrUTC = df.format(new Date());
+ MDC.put("EndTimestamp", endTimeStrUTC);
+ MDC.put("ElapsedTime", durationStr);
+ MDC.put("TargetEntity", "sli");
+ MDC.put("TargetServiceName", "execute");
+ MDC.put("ClassName", "org.openecomp.appc.provider.AppcProviderClient");
+
LOG.debug("Parameters passed to SLI: " + StringHelper.propertiesToString(parms));
metricsLogger.info("Parameters passed to SLI: " + StringHelper.propertiesToString(parms));
Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
+
+ /*
+ * Set End time for Metrics Logger
+ */
+ endTime = System.currentTimeMillis();
+ duration = endTime - startTime;
+ endTimeStr = String.valueOf(endTime);
+ durationStr = String.valueOf(duration);
+ endTimeStrUTC = df.format(new Date());
+ MDC.put("EndTimestamp", endTimeStrUTC);
+ MDC.put("ElapsedTime", durationStr);
LOG.debug("Parameters returned by SLI: " + StringHelper.propertiesToString(respProps));
metricsLogger.info("Parameters returned by SLI: " + StringHelper.propertiesToString(respProps));
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 6d186ab5f..a340aa046 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
@@ -30,64 +30,10 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.Action;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AppcProviderLcmService;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AuditInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AuditOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AuditOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.CheckLockInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.CheckLockOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.CheckLockOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.EvacuateInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.EvacuateOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.EvacuateOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.HealthCheckInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.HealthCheckOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.HealthCheckOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.LiveUpgradeInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.LiveUpgradeOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.LiveUpgradeOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.LockInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.LockOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.LockOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.MigrateInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.MigrateOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.MigrateOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.ModifyConfigInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.ModifyConfigOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.ModifyConfigOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RebuildInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RebuildOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RebuildOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RestartInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RestartOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RestartOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RollbackInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RollbackOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RollbackOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SnapshotInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SnapshotOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SnapshotOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SoftwareUploadInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SoftwareUploadOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SoftwareUploadOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.StopInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.StopOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.StopOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SyncInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SyncOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SyncOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.TerminateInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.TerminateOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.TerminateOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.TestInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.TestOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.TestOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.UnlockInput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.UnlockOutput;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.UnlockOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.status.Status;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.status.StatusBuilder;
+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.*;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.status.Status;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.status.StatusBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.openecomp.appc.Constants;
@@ -153,13 +99,13 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService {
* @param rpcProviderRegistry
*/
@SuppressWarnings({
- "javadoc", "nls"
+ "javadoc", "nls"
})
public AppcProviderLcm(DataBroker dataBroker, NotificationProviderService notificationProviderService,
RpcProviderRegistry rpcProviderRegistry) {
String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
- logger.info(Msg.COMPONENT_INITIALIZING, appName, "provider");
+ logger.info(Msg.COMPONENT_INITIALIZING, appName, "provider-lcm");
executor = Executors.newFixedThreadPool(1);
this.dataBroker = dataBroker;
@@ -242,7 +188,14 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService {
Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
if(null == status) {
try {
- RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ RequestHandlerInput request = new RequestInputBuilder().requestContext()
+ .commonHeader(input.getCommonHeader())
+ .actionIdentifiers(input.getActionIdentifiers())
+ .payload(input.getPayload())
+ .action(action)
+ .rpcName(rpcName)
+ .build();
+
status = buildStatusWithDispatcherOutput(executeRequest(request));
logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
} catch (ParseException e) {
@@ -405,7 +358,7 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService {
Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
if(null == status) {
try {
- RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).action(action).rpcName(rpcName).build();
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
status = buildStatusWithDispatcherOutput(executeRequest(request));
logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
} catch (ParseException e) {
@@ -447,7 +400,7 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService {
private RequestHandlerOutput executeRequest(RequestHandlerInput request){
RequestHandler handler = getRequestHandler();
- RequestHandlerOutput requestHandlerOutput=null;
+ RequestHandlerOutput requestHandlerOutput;
try {
requestHandlerOutput = handler.handleRequest(request);
} catch (Exception e) {
@@ -521,14 +474,96 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService {
return Futures.immediateFuture(result);
}
+ @Override
+ public Future<RpcResult<ConfigureOutput>> configure(ConfigureInput input) {
+ logger.debug("Input received : " + input.toString());
+ ConfigureOutputBuilder outputBuilder = new ConfigureOutputBuilder();
+ String action = Action.Configure.toString() ;
+ String rpcName = "configure";
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<ConfigureOutput> result = RpcResultBuilder.<ConfigureOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public Future<RpcResult<ConfigModifyOutput>> configModify(ConfigModifyInput input) {
+ logger.debug("Input received : " + input.toString());
+ ConfigModifyOutputBuilder outputBuilder = new ConfigModifyOutputBuilder();
+ String action = Action.ConfigModify.toString() ;
+ String rpcName = "config-modify";
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<ConfigModifyOutput> result = RpcResultBuilder.<ConfigModifyOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public Future<RpcResult<ConfigScaleoutOutput>> configScaleout(ConfigScaleoutInput input) {
+ logger.debug("Input received : " + input.toString());
+ ConfigScaleoutOutputBuilder outputBuilder = new ConfigScaleoutOutputBuilder();
+ String action = Action.ConfigScaleOut.toString() ;
+ String rpcName = "config-scaleout";
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<ConfigScaleoutOutput> result = RpcResultBuilder.<ConfigScaleoutOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
@Override
- public Future<RpcResult<ModifyConfigOutput>> modifyConfig(ModifyConfigInput input) {
+ public Future<RpcResult<ConfigRestoreOutput>> configRestore(ConfigRestoreInput input) {
logger.debug("Input received : " + input.toString());
- ModifyConfigOutputBuilder outputBuilder = new ModifyConfigOutputBuilder();
- String action = Action.ModifyConfig.toString() ;
- String rpcName = "modify-config";
+ ConfigRestoreOutputBuilder outputBuilder = new ConfigRestoreOutputBuilder();
+ String action = Action.ConfigRestore.toString() ;
+ String rpcName = "config-restore";
Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
if(null == status) {
try {
@@ -547,7 +582,7 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService {
}
outputBuilder.setCommonHeader(input.getCommonHeader());
outputBuilder.setStatus(status);
- RpcResult<ModifyConfigOutput> result = RpcResultBuilder.<ModifyConfigOutput> status(true).withResult(outputBuilder.build()).build();
+ RpcResult<ConfigRestoreOutput> result = RpcResultBuilder.<ConfigRestoreOutput> status(true).withResult(outputBuilder.build()).build();
return Futures.immediateFuture(result);
}
@@ -608,6 +643,46 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService {
return Futures.immediateFuture(result);
}
+ /**
+ * Starts a specific VNF
+ *
+ * @see org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AppcProviderLcmService#start(StartInput)
+ */
+ @Override
+ public Future<RpcResult<StartOutput>> start(StartInput input) {
+ logger.debug("Input received : " + input.toString());
+
+ StartOutputBuilder outputBuilder = new StartOutputBuilder();
+ String action = Action.Start.toString() ;
+ String rpcName = Action.Start.name().toLowerCase();
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext()
+ .commonHeader(input.getCommonHeader())
+ .actionIdentifiers(input.getActionIdentifiers())
+ .payload(input.getPayload())
+ .action(action)
+ .rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<StartOutput> result = RpcResultBuilder.<StartOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+
@Override
public Future<RpcResult<AuditOutput>> audit(AuditInput input) {
logger.debug("Input received : " + input.toString());
@@ -617,7 +692,7 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService {
Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
if(null == status) {
try {
- RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).action(action).rpcName(rpcName).build();
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
status = buildStatusWithDispatcherOutput(executeRequest(request));
logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
} catch (ParseException e) {
@@ -813,6 +888,92 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService {
return Futures.immediateFuture(result);
}
+ @Override
+ public Future<RpcResult<ConfigBackupOutput>> configBackup(ConfigBackupInput input) {
+ logger.debug("Input received : " + input.toString());
+ ConfigBackupOutputBuilder outputBuilder = new ConfigBackupOutputBuilder();
+ String action = Action.ConfigBackup.toString() ;
+ String rpcName = Action.ConfigBackup.name().toLowerCase();
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<ConfigBackupOutput> result = RpcResultBuilder.<ConfigBackupOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+
+ @Override
+ public Future<RpcResult<ConfigBackupDeleteOutput>> configBackupDelete(ConfigBackupDeleteInput input) {
+ logger.debug("Input received : " + input.toString());
+ ConfigBackupDeleteOutputBuilder outputBuilder = new ConfigBackupDeleteOutputBuilder();
+ String action = Action.ConfigBackupDelete.toString() ;
+ String rpcName = Action.ConfigBackupDelete.name().toLowerCase();
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<ConfigBackupDeleteOutput> result = RpcResultBuilder.<ConfigBackupDeleteOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+
+ @Override
+ public Future<RpcResult<ConfigExportOutput>> configExport(ConfigExportInput input) {
+ logger.debug("Input received : " + input.toString());
+ ConfigExportOutputBuilder outputBuilder = new ConfigExportOutputBuilder();
+ String action = Action.ConfigExport.toString() ;
+ String rpcName = Action.ConfigExport.name().toLowerCase();
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<ConfigExportOutput> result = RpcResultBuilder.<ConfigExportOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
private String convertActionNameToUrl(String action) {
String regex = "([a-z])([A-Z]+)";
String replacement = "$1-$2";
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 248492df8..0a535f28a 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
@@ -23,11 +23,12 @@ package org.openecomp.appc.provider.lcm.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.TimeZone;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.Payload;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.action.identifiers.ActionIdentifiers;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.CommonHeader;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.Flags;
+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.RequestContext;
import org.openecomp.appc.domainmodel.lcm.VNFOperation;
@@ -92,6 +93,7 @@ public class RequestInputBuilder {
if(null != commonHeader.getTimestamp()) {
SimpleDateFormat format = new SimpleDateFormat(FORMAT);
format.setLenient(false);
+ format.setTimeZone(TimeZone.getTimeZone("UTC"));
header.setTimestamp(format.parse(commonHeader.getTimestamp().getValue()).toInstant());
}else{
throw new ParseException("Missing mandatory parameter : timestamp " , 0);
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/ValidationService.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/ValidationService.java
index fe2fdc142..a16ab0bed 100644
--- a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/ValidationService.java
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/ValidationService.java
@@ -21,10 +21,10 @@
package org.openecomp.appc.provider.lcm.util;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.Action;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.CommonHeader;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.status.Status;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.status.StatusBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.Action;
+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.status.Status;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.status.StatusBuilder;
import org.openecomp.appc.Constants;
import org.openecomp.appc.configuration.Configuration;
import org.openecomp.appc.configuration.ConfigurationFactory;
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/topology/TopologyService.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/topology/TopologyService.java
index ea88982c1..166fb9612 100644
--- a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/topology/TopologyService.java
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/topology/TopologyService.java
@@ -51,6 +51,8 @@ import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.UUID;
import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.common.request.header.CommonRequestHeader;
import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.vnf.resource.VnfResource;
import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.config.payload.ConfigPayload;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.VmstatuscheckOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.VmstatuscheckOutputBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.openecomp.appc.Constants;
@@ -616,6 +618,83 @@ public class TopologyService {
RpcResultBuilder.<SnapshotOutput> status(true).withResult(sob.build()).build();
return rpcResult;
}
+
+/**************************************************/
+
+ public RpcResult<VmstatuscheckOutput> vmstatuscheck(CommonRequestHeader hdr, VnfResource vnf) {
+ long startTime = System.currentTimeMillis();
+ String requestId = hdr.getServiceRequestId();
+
+ MDC.clear();
+ MDC.put(MDC_REMOTE_HOST, "");
+ MDC.put(MDC_KEY_REQUEST_ID, requestId);
+ MDC.put(MDC_SERVICE_NAME, "App-C Provider:vmstatuscheck");
+ MDC.put(MDC_SERVICE_INSTANCE_ID, "");
+ try {
+ MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName());
+ MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ MDC.put(MDC_INSTANCE_UUID, java.util.UUID.randomUUID().toString());
+ MDC.put(MDC_ALERT_SEVERITY, "0");
+ logger.info(String.format("Starting VMSTATUSCHECK for request with id [%s]", requestId));
+
+ performanceLogger.info(String.format("Performance Logger: App-C vmstatuscheck initiated. Start Time: [%s]. Request ID: [%s]", startTime, requestId));
+ auditLogger.info(String.format("Audit Logger: App-C vmstatuscheck initiated. Start Time: [%s]. Request ID: [%s]", startTime, requestId));
+ metricsLogger.info(String.format("Metrics Logger: App-C vmstatuscheck initiated. Start Time: [%s]. Request ID: [%s]", startTime, requestId));
+
+ /*
+ * Copy any needed inputs or other values into the properties to be passed to the DG model
+ */
+ UUID vmId = vnf.getVmId();
+ Properties properties = new Properties();
+ properties.put(Constants.CONTEXT_ACTION, "vmstatuschecking");
+ properties.put(Constants.CONTEXT_REQID, requestId);
+ properties.put(Constants.CONTEXT_VMID, vmId.getValue());
+ properties.put(Constants.STATUS_GETTER, "checking");
+
+
+
+
+ UUID identityUrl = vnf.getIdentityUrl();
+ if (identityUrl != null) {
+ properties.put(Constants.CONTEXT_IDENTITY_URL, identityUrl.getValue());
+ }
+ /*
+ * Attempt to call the DG with the appropriate properties
+ */
+ boolean success = callGraph(properties);
+
+ /*
+ * Generate the appropriate response
+ */
+ String statusStr = success ? "SUCCESS" : "FAILURE";
+ String infomsg =
+ String.format("VMSTATUSCHECK '%s' finished with status %s. Reason: %s", requestId, statusStr, reason);
+ logger.info(infomsg);
+ long endTime = System.currentTimeMillis();
+ auditLogger.info(String.format("Audit Logger: VMSTATUSCHECK '%s' finished with status %s. Start Time: [%s]. End Time: [%s]. Request ID: [%s]. Reason:%s", requestId, statusStr, startTime, endTime, requestId, reason));
+ metricsLogger.info(String.format("Metrics Logger: VMSTATUSCHECK '%s' finished with status %s. Start Time: [%s]. End Time: [%s]. Request ID: [%s]. Reason:%s", requestId, statusStr, startTime, endTime, requestId, reason));
+ //logger.info(String.format("Step1 [%s]", Constants.STATUS_GETTER));
+ String tempstring2 = properties.getProperty(Constants.STATUS_GETTER).trim();
+ //logger.info(String.format("Step2 [%s]", tempstring2));
+
+
+ VmstatuscheckOutputBuilder vob = new VmstatuscheckOutputBuilder();
+ long duration = System.currentTimeMillis() - startTime;
+ vob.setCommonResponseHeader(ResponseHeaderBuilder.buildHeader(success, requestId, reason, duration));
+ vob.setStatMsg(tempstring2);
+
+ // Status must be set to true to indicate that our return is expected
+ RpcResult<VmstatuscheckOutput> rpcResult =
+ RpcResultBuilder.<VmstatuscheckOutput> status(true).withResult(vob.build()).build();
+ return rpcResult;
+ }
+
+ /*************************************************/
+
+
private boolean callGraph(Properties props) {
String moduleName = configuration.getProperty(Constants.PROPERTY_MODULE_NAME);