- long startTime = System.currentTimeMillis();
- TimeZone tz = TimeZone.getTimeZone("UTC");
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
- df.setTimeZone(tz);
- long endTime = System.currentTimeMillis();
- long duration = endTime - startTime;
- String durationStr = String.valueOf(duration);
- String endTimeStrUTC = df.format(new Date());
- MDC.put("EndTimestamp", endTimeStrUTC);
- MDC.put("ElapsedTime", durationStr);
- MDC.put("TargetEntity", "cdp");
- MDC.put("TargetServiceName", "migrate server");
- MDC.put("ClassName", "org.onap.appc.adapter.iaas.provider.operation.impl.MigrateServer");
+ String timestamp = LoggingUtils.generateTimestampStr((new Date()).toInstant());
+ MDC.put(LoggingConstants.MDCKeys.BEGIN_TIMESTAMP, timestamp);
+ MDC.put(LoggingConstants.MDCKeys.END_TIMESTAMP, timestamp);
+ MDC.put(LoggingConstants.MDCKeys.ELAPSED_TIME, "0");
+ MDC.put(LoggingConstants.MDCKeys.STATUS_CODE, LoggingConstants.StatusCodes.COMPLETE);
+ MDC.put(LoggingConstants.MDCKeys.TARGET_ENTITY, "cdp");
+ MDC.put(LoggingConstants.MDCKeys.TARGET_SERVICE_NAME, "migrate server");
+ MDC.put(LoggingConstants.MDCKeys.CLASS_NAME,
+ "org.onap.appc.adapter.iaas.provider.operation.impl.MigrateServer");
+
+ }
+
+ private Server conductServerMigration(RequestContext rc, String vmUrl, String identStr, SvcLogicContext ctx)
+ throws RequestFailedException {
+ String msg;
+ Context context = getContext(rc, vmUrl, identStr);
+ VMURL vm = VMURL.parseURL(vmUrl);
+ Server server = null;
+ try {
+ if (context != null) {
+ server = lookupServer(rc, context, vm.getServerId());
+ logger.debug(Msg.SERVER_FOUND, vmUrl, context.getTenantName(), server.getStatus().toString());
+ migrateServer(rc, server, ctx);
+ server.refreshStatus();
+ context.close();
+ doSuccess(rc);
+ }
+ } catch (IOException | ZoneException e1) {
+ msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(),
+ MIGRATE_SERVICE.toString(), vmUrl, context.getTenantName());
+ logger.error(msg, e1);
+ metricsLogger.error(msg);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ }
+ return server;