aboutsummaryrefslogtreecommitdiffstats
path: root/cmso-service
diff options
context:
space:
mode:
authorJerry Flood <jflood@att.com>2019-03-13 16:23:16 -0400
committerJerry Flood <jflood@att.com>2019-03-15 14:06:21 -0400
commit0365f4e08a7e717e7183aa523db1ecb66e55f3a7 (patch)
treee0584abe48882bfc3c7862ce6b2f215d4f57c1c6 /cmso-service
parent4720b950ac24eb1a9b93dba9d9bd0b7dc23f2437 (diff)
Commit 1: Define Create OPtimized API
Mulitple commits due to commit size constraint. Remove some SNIRO references Issue-ID: OPTFRA-457 Change-Id: Ia9a897d47a0f5e18deb309502d4a3ae629bea59f Signed-off-by: Jerry Flood <jflood@att.com>
Diffstat (limited to 'cmso-service')
-rw-r--r--cmso-service/pom.xml24
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java4
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispacherService.java5
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java4
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java76
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerResponse.java4
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminTool.java13
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java16
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizerCallbackImpl.java (renamed from cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSCallbackImpl.java)529
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOService.java6
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java8
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOptimizerCallback.java14
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheck.java15
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java13
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/test/loopback/SchedulerTestLoopbackServiceImpl.java10
15 files changed, 383 insertions, 358 deletions
diff --git a/cmso-service/pom.xml b/cmso-service/pom.xml
index a68744b..d64709e 100644
--- a/cmso-service/pom.xml
+++ b/cmso-service/pom.xml
@@ -56,7 +56,7 @@
<pact.version>3.3.9</pact.version>
<spring.version>5.0.10.RELEASE</spring.version>
<spring.boot.version>2.1.3.RELEASE</spring.boot.version>
- <springfox.swagger2.version>2.9.2</springfox.swagger2.version>
+ <swagger.core.version>2.0.0</swagger.core.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
@@ -65,7 +65,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
<mariadb.version>2.2.1</mariadb.version>
- <swagger.directory>${basedir}/src/main/resources/swagger-ui/dist</swagger.directory>
+ <swagger.directory>${basedir}/src/main/resources/META-INF/resources/swagger/</swagger.directory>
<aaf.version>2.1.4</aaf.version>
<!-- Sonar -->
@@ -230,15 +230,23 @@
<!--Swagger Dependencies -->
<dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger2</artifactId>
- <version>${springfox.swagger2.version}</version>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-jaxrs2</artifactId>
+ <version>${swagger.core.version}</version>
</dependency>
<dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger-ui</artifactId>
- <version>${springfox.swagger2.version}</version>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-jaxrs2-servlet-initializer</artifactId>
+ <version>${swagger.core.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-jersey2-jaxrs</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+
+
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java b/cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java
index 9b10d51..9189326 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java
@@ -42,7 +42,7 @@ import org.glassfish.jersey.servlet.ServletProperties;
import org.onap.optf.cmso.dispatcher.rs.DispatcherServiceImpl;
import org.onap.optf.cmso.filters.CMSOContainerFilters;
import org.onap.optf.cmso.service.rs.AdminToolImpl;
-import org.onap.optf.cmso.service.rs.CMSCallbackImpl;
+import org.onap.optf.cmso.service.rs.CMSOOptimizerCallbackImpl;
import org.onap.optf.cmso.service.rs.CMSOServiceImpl;
import org.onap.optf.cmso.service.rs.HealthCheckImpl;
import org.onap.optf.cmso.test.loopback.SchedulerTestLoopbackServiceImpl;
@@ -76,7 +76,7 @@ public class JerseyConfiguration extends ResourceConfig {
@Autowired
public JerseyConfiguration( /* LogRequestFilter lrf */ ) {
register(CMSOServiceImpl.class);
- register(CMSCallbackImpl.class);
+ register(CMSOOptimizerCallbackImpl.class);
register(SchedulerTestLoopbackServiceImpl.class);
register(TicketMgtLoopbackServiceImpl.class);
register(HealthCheckImpl.class);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispacherService.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispacherService.java
index d0ff299..adc3260 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispacherService.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispacherService.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,6 +40,7 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java
index 3aab301..67a69cb 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/rs/DispatcherServiceImpl.java
@@ -58,7 +58,7 @@ public class DispatcherServiceImpl implements DispacherService {
DispatchJob dispatchJob;
@Autowired
- CMSOptimizerClient sniroClient;
+ CMSOptimizerClient optimizerClient;
@Autowired
TmStatusClient tmStatusClient;
@@ -85,7 +85,7 @@ public class DispatcherServiceImpl implements DispacherService {
public Response dispatchOptimizer(Integer id, UriInfo uri, HttpServletRequest request) {
debug.debug("dispatchOptimizer entered {}", id);
try {
- sniroClient.scheduleSniroOptimization(id);
+ optimizerClient.scheduleOptimization(id);
} catch (Exception e) {
errors.error(LogMessages.UNEXPECTED_EXCEPTION, e.getMessage());
debug.error(e.getMessage(), e);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java
index 5d500d2..9feea2d 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CMSOptimizerClient.java
@@ -85,15 +85,15 @@ public class CMSOptimizerClient {
@Autowired
PropertiesManagement pm;
- public boolean scheduleSniroOptimization(Integer id) {
+ public boolean scheduleOptimization(Integer id) {
Map<String, String> mdcSave = Mdc.save();
try {
- String snirourl = env.getProperty("cmso.optimizer.url");
- String snirocallbackurl = env.getProperty("cmso.optimizer.callbackurl");
+ String optimizerurl = env.getProperty("cmso.optimizer.url");
+ String optimizercallbackurl = env.getProperty("cmso.optimizer.callbackurl");
String username = env.getProperty("mechid.user");
- Integer maxAttempts = env.getProperty("cmso.sniro.maxAttempts", Integer.class, 20);
+ Integer maxAttempts = env.getProperty("cmso.optimizer.maxAttempts", Integer.class, 20);
- // Ensure that only one cmso is requsting this call to SNIRO
+ // Ensure that only one cmso is requsting this call to optimizer
Schedule schedule = scheduleDAO.lockOne(id);
if (!schedule.getStatus().equals(CMSStatusEnum.PendingSchedule.toString()))
return false;
@@ -116,7 +116,7 @@ public class CMSOptimizerClient {
if (info == null) {
return true;
}
- buildRequest(cmReq, info, schedule, snirocallbackurl);
+ buildRequest(cmReq, info, schedule, optimizercallbackurl);
} catch (Exception e) {
Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
@@ -126,34 +126,34 @@ public class CMSOptimizerClient {
}
// This service will call SNIO for each PendingOptimiztion
- // If the request is successfully scheduled in SNIRO, status will be
+ // If the request is successfully scheduled in optimizer, status will be
// updated to OptimizationInProgress.
Client client = ClientBuilder.newClient();
client.register(new BasicAuthenticatorFilter(username, password));
client.register(new CMSOClientFilters());
- WebTarget sniroTarget = client.target(snirourl);
- Invocation.Builder invocationBuilder = sniroTarget.request(MediaType.APPLICATION_JSON);
+ WebTarget optimizerTarget = client.target(optimizerurl);
+ Invocation.Builder invocationBuilder = optimizerTarget.request(MediaType.APPLICATION_JSON);
try {
//
// First, push OptimizationInProgress to the DB (flush()) assuming a 202 status,
- // in case the SNIRO callback is received prior to the
+ // in case the optimizer callback is received prior to the
// commit of this transaction.
- // SNIRO Callback will throw an error if it receives a response in the incorrect
+ // optimizer Callback will throw an error if it receives a response in the incorrect
// state.
//
schedule.setOptimizerTransactionId(cmReq.getRequestInfo().getTransactionId());
schedule.setOptimizerDateTimeMillis(System.currentTimeMillis());
schedule.setStatus(CMSStatusEnum.OptimizationInProgress.toString());
updateScheduleStatus(schedule);
- debug.debug("SNIRO url / user: " + snirourl + " / " + username);
- debug.debug("SNIRO Request: " + new ObjectMapper().writeValueAsString(cmReq));
- Observation.report(LogMessages.OPTIMIZER_REQUEST, "Begin", schedule.getScheduleId(), snirourl);
+ debug.debug("optimizer url / user: " + optimizerurl + " / " + username);
+ debug.debug("optimizer Request: " + new ObjectMapper().writeValueAsString(cmReq));
+ Observation.report(LogMessages.OPTIMIZER_REQUEST, "Begin", schedule.getScheduleId(), optimizerurl);
Response response = invocationBuilder.post(Entity.json(cmReq));
- Observation.report(LogMessages.OPTIMIZER_REQUEST, "End", schedule.getScheduleId(), snirourl);
+ Observation.report(LogMessages.OPTIMIZER_REQUEST, "End", schedule.getScheduleId(), optimizerurl);
switch (response.getStatus()) {
case 202:
debug.debug("Successfully scheduled optimization: " + schedule.getScheduleId());
- // Scheduled with SNIRO
+ // Scheduled with optimizer
break;
case 400: // Bad request
{
@@ -162,7 +162,7 @@ public class CMSOptimizerClient {
String message = response.readEntity(String.class);
schedule.setOptimizerMessage(message);
schedule.setStatus(CMSStatusEnum.ScheduleFailed.toString());
- // Need to understand the cause of this error. May be teh same as SNIRO
+ // Need to understand the cause of this error. May be teh same as optimizer
// down.
int tries = schedule.getOptimizerAttemptsToSchedule();
tries++;
@@ -195,24 +195,24 @@ public class CMSOptimizerClient {
return true;
} catch (ResponseProcessingException e) {
schedule.setOptimizerDateTimeMillis(System.currentTimeMillis());
- schedule.setOptimizerStatus("Failed to parse SNIRO response");
+ schedule.setOptimizerStatus("Failed to parse optimizer response");
schedule.setStatus(CMSStatusEnum.ScheduleFailed.toString());
- // Need to understand the cause of this error. May be teh same as SNIRO down.
+ // Need to understand the cause of this error. May be teh same as optimizer down.
int tries = schedule.getOptimizerAttemptsToSchedule();
tries++;
schedule.setOptimizerAttemptsToSchedule(tries);
updateScheduleStatus(schedule);
- // Getting invalid response from SNIRO.
+ // Getting invalid response from optimizer.
// May be data related.
Observation.report(LogMessages.OPTIMIZER_EXCEPTION, e, e.getMessage());
return false;
} catch (ProcessingException e) {
- // Don't track number of retries on IO error (SNIRO is down)
+ // Don't track number of retries on IO error (optimizer is down)
schedule.setOptimizerDateTimeMillis(System.currentTimeMillis());
schedule.setStatus(CMSStatusEnum.PendingSchedule.toString());
updateScheduleStatus(schedule);
- /// Cannot connect to SNIRO
+ /// Cannot connect to optimizer
Observation.report(LogMessages.OPTIMIZER_EXCEPTION, e, e.getMessage());
// Wait until next cycle
return false;
@@ -226,15 +226,15 @@ public class CMSOptimizerClient {
return false;
}
- private void buildRequest(CMOptimizerRequest cmReq, CMSInfo info, Schedule schedule, String snirocallbackurl) {
+ private void buildRequest(CMOptimizerRequest cmReq, CMSInfo info, Schedule schedule, String optimizercallbackurl) {
- // TODO: Need to get SNIRO to accept ChangeManagementSchedulingInfo
- // This is to support 1707 SNIRO interface
+ // TODO: Need to get optimizer to accept ChangeManagementSchedulingInfo
+ // This is to support 1707 optimizer interface
CMRequestInfo reqInfo = cmReq.getRequestInfo();
CMSchedulingInfo schInfo = cmReq.getSchedulingInfo();
UUID uuid = UUID.randomUUID();
- reqInfo.setCallbackUrl(snirocallbackurl);
+ reqInfo.setCallbackUrl(optimizercallbackurl);
reqInfo.setOptimizer(new String[] {"scheduling"});
reqInfo.setTransactionId(schedule.getOptimizerTransactionId());
reqInfo.setRequestId("CM-" + uuid.toString());
@@ -283,7 +283,7 @@ public class CMSOptimizerClient {
// Perhaps We create ChangeManagementSchedulingInfoV1, ...V2, etc.
// ANd try them one after another....
Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, "Unable to parse message. Format changed?");
- schedule.setOptimizerStatus("Failed to parse SNIRO request");
+ schedule.setOptimizerStatus("Failed to parse optimizer request");
schedule.setOptimizerDateTimeMillis(System.currentTimeMillis());
schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
scheduleDAO.save(schedule);
@@ -300,12 +300,12 @@ public class CMSOptimizerClient {
public HealthCheckComponent healthCheck() {
Map<String, String> mdcSave = Mdc.save();
HealthCheckComponent hcc = new HealthCheckComponent();
- hcc.setName("SNIRO Interface");
- String snirourl = env.getProperty("cmso.optimizer.url");
- String snirocallbackurl = env.getProperty("cmso.optimizer.callbackurl");
+ hcc.setName("OPtimizer Interface");
+ String optimizerurl = env.getProperty("cmso.optimizer.url");
+ String optimizercallbackurl = env.getProperty("cmso.optimizer.callbackurl");
String username = env.getProperty("mechid.user");
String password = pm.getProperty("mechid.pass", "");
- hcc.setUrl(snirourl);
+ hcc.setUrl(optimizerurl);
try {
UUID uuid = UUID.randomUUID();
// Build a bogus request should fail policy validation
@@ -335,22 +335,22 @@ public class CMSOptimizerClient {
client.register(new BasicAuthenticatorFilter(username, password));
client.register(new CMSOClientFilters());
- WebTarget sniroTarget = client.target(snirourl);
- Invocation.Builder invocationBuilder = sniroTarget.request(MediaType.APPLICATION_JSON);
- debug.debug("SNIRO url / user: " + snirourl + " / " + username);
- Observation.report(LogMessages.OPTIMIZER_REQUEST, "Begin", "healthcheck", snirourl);
+ WebTarget optimizerTarget = client.target(optimizerurl);
+ Invocation.Builder invocationBuilder = optimizerTarget.request(MediaType.APPLICATION_JSON);
+ debug.debug("Optimizer url / user: " + optimizerurl + " / " + username);
+ Observation.report(LogMessages.OPTIMIZER_REQUEST, "Begin", "healthcheck", optimizerurl);
Response response = invocationBuilder.post(Entity.json(cmReq));
- Observation.report(LogMessages.OPTIMIZER_REQUEST, "End", "healthcheck", snirourl);
+ Observation.report(LogMessages.OPTIMIZER_REQUEST, "End", "healthcheck", optimizerurl);
String message = response.getStatus() + ":" + response.readEntity(String.class);
switch (response.getStatus()) {
case 202:
- debug.debug("Successful SNIRO healthcheck");
+ debug.debug("Successful optimizer healthcheck");
hcc.setHealthy(true);
break;
case 400:
// Expecting policy not found.
if (message.contains("Cannot fetch policy")) {
- debug.debug("Successful SNIRO healthcheck");
+ debug.debug("Successful optimizer healthcheck");
hcc.setHealthy(true);
hcc.setStatus("OK");
} else {
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerResponse.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerResponse.java
index a50025b..6dd7bdf 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerResponse.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerResponse.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminTool.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminTool.java
index 801986c..10eedf8 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminTool.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminTool.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,23 +31,21 @@
package org.onap.optf.cmso.service.rs;
-import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
+
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-@Api
+@Api("CMSO Administration")
@Path("/{apiVersion}")
@Produces({MediaType.APPLICATION_JSON})
public interface AdminTool {
@@ -60,7 +58,6 @@ public interface AdminTool {
@ApiResponses(
value = {@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 400, message = "Request failed")})
public Response exec(@ApiParam(value = "v1|v2") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
- @ApiParam(value = "Identifier", allowMultiple = true) @PathParam("id") String id, @Context UriInfo uri,
- @Context HttpServletRequest request);
+ @ApiParam(value = "Identifier", allowMultiple = true) @PathParam("id") String id);
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java
index b878d31..8ec4f4f 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/AdminToolImpl.java
@@ -31,32 +31,38 @@
package org.onap.optf.cmso.service.rs;
-import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
-import org.onap.observations.Mdc;
import org.onap.optf.cmso.common.PropertiesManagement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
+
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@Controller
public class AdminToolImpl implements AdminTool {
private static EELFLogger log = EELFManager.getInstance().getLogger(AdminToolImpl.class);
- private static EELFLogger audit = EELFManager.getInstance().getAuditLogger();
+
+ @Context
+ UriInfo uri;
+
+ @Context
+ HttpServletRequest request;
+
@Autowired
PropertiesManagement pm;
@Override
- public Response exec(String apiVersion, String id, UriInfo uri, HttpServletRequest request) {
+ public Response exec(String apiVersion, String id) {
log.info("AdminTool.exec entered");
if (id.length() < 4)
return Response.ok("").build();
- String encrypted = pm.getEncryptedValue(id);
+ String encrypted = PropertiesManagement.getEncryptedValue(id);
Response response = Response.ok(encrypted).build();
return response;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSCallbackImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizerCallbackImpl.java
index 5d11225..679dd02 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSCallbackImpl.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOOptimizerCallbackImpl.java
@@ -1,260 +1,269 @@
-/*
- * Copyright © 2017-2019 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed 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,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.onap.optf.cmso.service.rs;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
-import javax.transaction.Transactional;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.UriInfo;
-import org.joda.time.DateTime;
-import org.joda.time.format.DateTimeFormat;
-import org.joda.time.format.ISODateTimeFormat;
-import org.onap.observations.Mdc;
-import org.onap.optf.cmso.common.CMSStatusEnum;
-import org.onap.optf.cmso.common.DomainsEnum;
-import org.onap.optf.cmso.common.LogMessages;
-import org.onap.optf.cmso.common.exceptions.CMSException;
-import org.onap.optf.cmso.common.exceptions.CMSNotFoundException;
-import org.onap.optf.cmso.model.ChangeManagementGroup;
-import org.onap.optf.cmso.model.ChangeManagementSchedule;
-import org.onap.optf.cmso.model.Schedule;
-import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
-import org.onap.optf.cmso.optimizer.bean.CMOptimizerResponse;
-import org.onap.optf.cmso.optimizer.bean.CMSchedule;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@Controller
-public class CMSCallbackImpl extends BaseSchedulerServiceImpl implements CMSOptimizerCallback {
- private static EELFLogger log = EELFManager.getInstance().getLogger(CMSCallbackImpl.class);
- private static EELFLogger metrics = EELFManager.getInstance().getMetricsLogger();
- private static EELFLogger audit = EELFManager.getInstance().getAuditLogger();
- private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
- private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();
-
- @Autowired
- ChangeManagementScheduleDAO cmScheduleDAO;
-
- @Autowired
- ChangeManagementGroupDAO cmGroupDAO;
-
- @Autowired
- ChangeManagementChangeWindowDAO cmChangeWindowDAO;
-
- @Autowired
- ChangeManagementDetailDAO cmDetailsDAO;
-
- @Override
- @Transactional
- public Response sniroCallback(String apiVersion, CMOptimizerResponse sniroResponse, UriInfo uri,
- HttpServletRequest request) {
- Response response = null;
- log.info(LogMessages.PROCESS_OPTIMIZER_CALLBACK, "Received", request.getRemoteAddr(), "");
- log.info(LogMessages.OPTIMIZER_REQUEST, "Callback received", sniroResponse.getTransactionId(),
- uri.getAbsolutePath().toString());
- try {
- // Note that transaction ID and schedule ID are currently the same value.
-
- String transactionId = sniroResponse.getTransactionId();
-
- // Synchronize this with transaction that scheduled the SNIRO optimization
- // to ensure status updates are properly ordered.
- // This is necessary only in the race condition where SNIRO callback comes
- // before the SNIRO response is processed and the scheduling transaction is
- // still in flight.
- // Note that this may happen in loopback mode, but is not likely to happen with
- // real SNIRO unless SNIRO changes to be synchronous and the callback comes before
- // the response.
- // If this lock times out, the schedule will remain in 'Optimization In
- // Progress' and never complete.
- Schedule schedule = scheduleDAO.lockOneByTransactionId(transactionId);
-
- if (schedule == null) {
- throw new CMSNotFoundException(DomainsEnum.ChangeManagement.toString(),
- "(OptimizerTransactionID=" + transactionId + ")");
-
- }
- CMSStatusEnum status = CMSStatusEnum.PendingApproval.fromString(schedule.getStatus());
- debug.debug("Status at time of SNIRO callback is " + status.toString());
- switch (status) {
- // PendingSchedule may be a valid status in the cases where SNIRO async call
- // returns before
- // We have committed the OptimizationInProgress status
- // The dispatch logic ensures that we only every dispatch once.
- case OptimizationInProgress:
- processSniroResponse(sniroResponse, schedule);
- scheduleDAO.save(schedule);
- response = Response.ok().build();
- break;
- default:
- throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.OPTIMIZER_CALLBACK_STATE_ERROR,
- CMSStatusEnum.OptimizationInProgress.toString(), schedule.getStatus().toString());
- }
- } catch (CMSException e) {
- errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- response = Response.status(e.getStatus()).entity(e.getRequestError()).build();
- } catch (Exception e) {
- errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- response = Response.serverError().entity(e.getMessage()).build();
- } finally {
- }
- return response;
- }
-
- private void processSniroResponse(CMOptimizerResponse sniroResponse, Schedule schedule) {
- try {
- schedule.setOptimizerReturnDateTimeMillis(System.currentTimeMillis());
- schedule.setOptimizerStatus(sniroResponse.getRequestState());
- schedule.setOptimizerMessage(sniroResponse.getDescription());
- String scheduleId = sniroResponse.getScheduleId();
- ObjectMapper om = new ObjectMapper();
- CMSchedule[] scheduleArray = sniroResponse.getSchedule();
- if (scheduleArray != null && scheduleArray.length > 0) {
- String scheduleString = om.writeValueAsString(scheduleArray);
- schedule.setSchedule(scheduleString);
- log.debug("scheduleId={0} schedule={1}", scheduleId, scheduleString);
- for (CMSchedule sniroSchedule : sniroResponse.getSchedule()) {
- String groupId = sniroSchedule.getGroupId();
- DateTime finishTime = convertDate(sniroSchedule.getFinishTime(), "finishTime");
- DateTime latestInstanceStartTime =
- convertDate(sniroSchedule.getLatestInstanceStartTime(), "latestInstanceStartTime");
- DateTime startTime = convertDate(sniroSchedule.getStartTime(), "startTime");
- ChangeManagementGroup group = cmGroupDAO.findOneBySchedulesIDGroupID(schedule.getId(), groupId);
- if (group == null) {
- throw new CMSException(Status.PRECONDITION_FAILED,
- LogMessages.CHANGE_MANAGEMENT_GROUP_NOT_FOUND, schedule.getScheduleId(), groupId);
- }
- group.setStartTimeMillis(startTime.getMillis());
- group.setFinishTimeMillis(finishTime.getMillis());
- group.setLastInstanceStartTimeMillis(latestInstanceStartTime.getMillis());
- cmGroupDAO.save(group);
- long totalDuration =
- (group.getAdditionalDurationInSecs() + group.getNormalDurationInSecs()) * 1000l;
- Map<String, Map<String, Long>> startAndFinishTimeMap = new HashMap<String, Map<String, Long>>();
- makeMap(startTime.getMillis(), latestInstanceStartTime.getMillis(), group.getConcurrencyLimit(),
- totalDuration, sniroSchedule.getNode(), startAndFinishTimeMap);
- for (String node : sniroSchedule.getNode()) {
- processNode(schedule, group, node, startAndFinishTimeMap);
- }
- }
- schedule.setStatus(CMSStatusEnum.PendingApproval.toString());
- } else {
- debug.debug("scheduleId={0} schedule=null status={1} ", scheduleId, schedule.getOptimizerStatus());
- schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
- }
- } catch (CMSException e) {
- errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
- schedule.setOptimizerStatus(e.getStatus().toString());
- schedule.setOptimizerMessage(e.getLocalizedMessage());
- } catch (Exception e) {
- errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
- schedule.setOptimizerStatus("Exception");
- schedule.setOptimizerMessage(e.getLocalizedMessage());
- }
- }
-
- public static void makeMap(Long startTime, Long latestInstanceStartTime, int concurrencyLimit, long totalDuration,
- List<String> nodes, Map<String, Map<String, Long>> startAndFinishTimeMap) throws CMSException {
- Long nextStartTime = null;
- Long nextFinishTime = null;
- for (int nodeNumber = 0; nodeNumber < nodes.size(); nodeNumber++) {
- String node = nodes.get(nodeNumber);
- if (nodeNumber % concurrencyLimit == 0) {
- if (nodeNumber == 0)
- nextStartTime = startTime;
- else
- nextStartTime = nextStartTime + totalDuration;
- if (nextStartTime > latestInstanceStartTime) {
- throw new CMSException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_ALLOCATE_VNF_TIMESLOTS,
- startTime.toString(), latestInstanceStartTime.toString(), String.valueOf(totalDuration),
- String.valueOf(concurrencyLimit), String.valueOf(nodes.size()));
- }
- nextFinishTime = nextStartTime + totalDuration;
- }
- Map<String, Long> map = new HashMap<String, Long>();
- map.put("startTime", nextStartTime);
- map.put("finishTime", nextFinishTime);
- startAndFinishTimeMap.put(node, map);
- }
-
- }
-
- private void processNode(Schedule schedule, ChangeManagementGroup group, String node,
- Map<String, Map<String, Long>> startAndFinishTimeMap) throws CMSException {
- Map<String, Long> map = startAndFinishTimeMap.get(node);
- ChangeManagementSchedule detail = cmScheduleDAO.findOneByGroupIDAndVnfName(group.getId(), node);
- if (detail == null) {
- throw new CMSException(Status.NOT_FOUND, LogMessages.UNABLE_TO_LOCATE_SCHEDULE_DETAIL,
- schedule.getScheduleId(), group.getGroupId(), node);
- }
- detail.setStartTimeMillis(map.get("startTime"));
- detail.setFinishTimeMillis(map.get("finishTime"));
- detail.setVnfId("");
- detail.setStatus(CMSStatusEnum.PendingApproval.toString());
- cmScheduleDAO.save(detail);
- }
-
- public static DateTime convertDate(String utcDate, String attrName) throws CMSException {
- try {
- DateTime dateTime = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC().parseDateTime(utcDate);
- if (dateTime != null)
- return dateTime;
- } catch (Exception e) {
- debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- }
- throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate);
- }
-
- public static DateTime convertISODate(String utcDate, String attrName) throws CMSException {
- try {
- DateTime dateTime = ISODateTimeFormat.dateTimeParser().parseDateTime(utcDate);
- if (dateTime != null)
- return dateTime;
- } catch (Exception e) {
- debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- }
- throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate);
- }
-
-}
+/*
+ * Copyright © 2017-2019 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed 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,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.onap.optf.cmso.service.rs;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.transaction.Transactional;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
+
+import org.joda.time.DateTime;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.ISODateTimeFormat;
+import org.onap.optf.cmso.common.CMSStatusEnum;
+import org.onap.optf.cmso.common.DomainsEnum;
+import org.onap.optf.cmso.common.LogMessages;
+import org.onap.optf.cmso.common.exceptions.CMSException;
+import org.onap.optf.cmso.common.exceptions.CMSNotFoundException;
+import org.onap.optf.cmso.model.ChangeManagementGroup;
+import org.onap.optf.cmso.model.ChangeManagementSchedule;
+import org.onap.optf.cmso.model.Schedule;
+import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
+import org.onap.optf.cmso.optimizer.bean.CMOptimizerResponse;
+import org.onap.optf.cmso.optimizer.bean.CMSchedule;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Controller
+public class CMSOOptimizerCallbackImpl extends BaseSchedulerServiceImpl implements CMSOptimizerCallback {
+ private static EELFLogger log = EELFManager.getInstance().getLogger(CMSOOptimizerCallbackImpl.class);
+ private static EELFLogger metrics = EELFManager.getInstance().getMetricsLogger();
+ private static EELFLogger audit = EELFManager.getInstance().getAuditLogger();
+ private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
+ private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();
+
+ @Context
+ UriInfo uri;
+
+ @Context
+ HttpServletRequest request;
+
+
+ @Autowired
+ ChangeManagementScheduleDAO cmScheduleDAO;
+
+ @Autowired
+ ChangeManagementGroupDAO cmGroupDAO;
+
+ @Autowired
+ ChangeManagementChangeWindowDAO cmChangeWindowDAO;
+
+ @Autowired
+ ChangeManagementDetailDAO cmDetailsDAO;
+
+ @Override
+ @Transactional
+ public Response sniroCallback(String apiVersion, CMOptimizerResponse sniroResponse) {
+ Response response = null;
+ log.info(LogMessages.PROCESS_OPTIMIZER_CALLBACK, "Received", request.getRemoteAddr(), "");
+ log.info(LogMessages.OPTIMIZER_REQUEST, "Callback received", sniroResponse.getTransactionId(),
+ uri.getAbsolutePath().toString());
+ try {
+ // Note that transaction ID and schedule ID are currently the same value.
+
+ String transactionId = sniroResponse.getTransactionId();
+
+ // Synchronize this with transaction that scheduled the SNIRO optimization
+ // to ensure status updates are properly ordered.
+ // This is necessary only in the race condition where SNIRO callback comes
+ // before the SNIRO response is processed and the scheduling transaction is
+ // still in flight.
+ // Note that this may happen in loopback mode, but is not likely to happen with
+ // real SNIRO unless SNIRO changes to be synchronous and the callback comes before
+ // the response.
+ // If this lock times out, the schedule will remain in 'Optimization In
+ // Progress' and never complete.
+ Schedule schedule = scheduleDAO.lockOneByTransactionId(transactionId);
+
+ if (schedule == null) {
+ throw new CMSNotFoundException(DomainsEnum.ChangeManagement.toString(),
+ "(OptimizerTransactionID=" + transactionId + ")");
+
+ }
+ CMSStatusEnum status = CMSStatusEnum.PendingApproval.fromString(schedule.getStatus());
+ debug.debug("Status at time of SNIRO callback is " + status.toString());
+ switch (status) {
+ // PendingSchedule may be a valid status in the cases where SNIRO async call
+ // returns before
+ // We have committed the OptimizationInProgress status
+ // The dispatch logic ensures that we only every dispatch once.
+ case OptimizationInProgress:
+ processSniroResponse(sniroResponse, schedule);
+ scheduleDAO.save(schedule);
+ response = Response.ok().build();
+ break;
+ default:
+ throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.OPTIMIZER_CALLBACK_STATE_ERROR,
+ CMSStatusEnum.OptimizationInProgress.toString(), schedule.getStatus().toString());
+ }
+ } catch (CMSException e) {
+ errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ response = Response.status(e.getStatus()).entity(e.getRequestError()).build();
+ } catch (Exception e) {
+ errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ response = Response.serverError().entity(e.getMessage()).build();
+ } finally {
+ }
+ return response;
+ }
+
+ private void processSniroResponse(CMOptimizerResponse sniroResponse, Schedule schedule) {
+ try {
+ schedule.setOptimizerReturnDateTimeMillis(System.currentTimeMillis());
+ schedule.setOptimizerStatus(sniroResponse.getRequestState());
+ schedule.setOptimizerMessage(sniroResponse.getDescription());
+ String scheduleId = sniroResponse.getScheduleId();
+ ObjectMapper om = new ObjectMapper();
+ CMSchedule[] scheduleArray = sniroResponse.getSchedule();
+ if (scheduleArray != null && scheduleArray.length > 0) {
+ String scheduleString = om.writeValueAsString(scheduleArray);
+ schedule.setSchedule(scheduleString);
+ log.debug("scheduleId={0} schedule={1}", scheduleId, scheduleString);
+ for (CMSchedule sniroSchedule : sniroResponse.getSchedule()) {
+ String groupId = sniroSchedule.getGroupId();
+ DateTime finishTime = convertDate(sniroSchedule.getFinishTime(), "finishTime");
+ DateTime latestInstanceStartTime =
+ convertDate(sniroSchedule.getLatestInstanceStartTime(), "latestInstanceStartTime");
+ DateTime startTime = convertDate(sniroSchedule.getStartTime(), "startTime");
+ ChangeManagementGroup group = cmGroupDAO.findOneBySchedulesIDGroupID(schedule.getId(), groupId);
+ if (group == null) {
+ throw new CMSException(Status.PRECONDITION_FAILED,
+ LogMessages.CHANGE_MANAGEMENT_GROUP_NOT_FOUND, schedule.getScheduleId(), groupId);
+ }
+ group.setStartTimeMillis(startTime.getMillis());
+ group.setFinishTimeMillis(finishTime.getMillis());
+ group.setLastInstanceStartTimeMillis(latestInstanceStartTime.getMillis());
+ cmGroupDAO.save(group);
+ long totalDuration =
+ (group.getAdditionalDurationInSecs() + group.getNormalDurationInSecs()) * 1000l;
+ Map<String, Map<String, Long>> startAndFinishTimeMap = new HashMap<String, Map<String, Long>>();
+ makeMap(startTime.getMillis(), latestInstanceStartTime.getMillis(), group.getConcurrencyLimit(),
+ totalDuration, sniroSchedule.getNode(), startAndFinishTimeMap);
+ for (String node : sniroSchedule.getNode()) {
+ processNode(schedule, group, node, startAndFinishTimeMap);
+ }
+ }
+ schedule.setStatus(CMSStatusEnum.PendingApproval.toString());
+ } else {
+ debug.debug("scheduleId={0} schedule=null status={1} ", scheduleId, schedule.getOptimizerStatus());
+ schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
+ }
+ } catch (CMSException e) {
+ errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
+ schedule.setOptimizerStatus(e.getStatus().toString());
+ schedule.setOptimizerMessage(e.getLocalizedMessage());
+ } catch (Exception e) {
+ errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString());
+ schedule.setOptimizerStatus("Exception");
+ schedule.setOptimizerMessage(e.getLocalizedMessage());
+ }
+ }
+
+ public static void makeMap(Long startTime, Long latestInstanceStartTime, int concurrencyLimit, long totalDuration,
+ List<String> nodes, Map<String, Map<String, Long>> startAndFinishTimeMap) throws CMSException {
+ Long nextStartTime = null;
+ Long nextFinishTime = null;
+ for (int nodeNumber = 0; nodeNumber < nodes.size(); nodeNumber++) {
+ String node = nodes.get(nodeNumber);
+ if (nodeNumber % concurrencyLimit == 0) {
+ if (nodeNumber == 0)
+ nextStartTime = startTime;
+ else
+ nextStartTime = nextStartTime + totalDuration;
+ if (nextStartTime > latestInstanceStartTime) {
+ throw new CMSException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_ALLOCATE_VNF_TIMESLOTS,
+ startTime.toString(), latestInstanceStartTime.toString(), String.valueOf(totalDuration),
+ String.valueOf(concurrencyLimit), String.valueOf(nodes.size()));
+ }
+ nextFinishTime = nextStartTime + totalDuration;
+ }
+ Map<String, Long> map = new HashMap<String, Long>();
+ map.put("startTime", nextStartTime);
+ map.put("finishTime", nextFinishTime);
+ startAndFinishTimeMap.put(node, map);
+ }
+
+ }
+
+ private void processNode(Schedule schedule, ChangeManagementGroup group, String node,
+ Map<String, Map<String, Long>> startAndFinishTimeMap) throws CMSException {
+ Map<String, Long> map = startAndFinishTimeMap.get(node);
+ ChangeManagementSchedule detail = cmScheduleDAO.findOneByGroupIDAndVnfName(group.getId(), node);
+ if (detail == null) {
+ throw new CMSException(Status.NOT_FOUND, LogMessages.UNABLE_TO_LOCATE_SCHEDULE_DETAIL,
+ schedule.getScheduleId(), group.getGroupId(), node);
+ }
+ detail.setStartTimeMillis(map.get("startTime"));
+ detail.setFinishTimeMillis(map.get("finishTime"));
+ detail.setVnfId("");
+ detail.setStatus(CMSStatusEnum.PendingApproval.toString());
+ cmScheduleDAO.save(detail);
+ }
+
+ public static DateTime convertDate(String utcDate, String attrName) throws CMSException {
+ try {
+ DateTime dateTime = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC().parseDateTime(utcDate);
+ if (dateTime != null)
+ return dateTime;
+ } catch (Exception e) {
+ debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ }
+ throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate);
+ }
+
+ public static DateTime convertISODate(String utcDate, String attrName) throws CMSException {
+ try {
+ DateTime dateTime = ISODateTimeFormat.dateTimeParser().parseDateTime(utcDate);
+ if (dateTime != null)
+ return dateTime;
+ } catch (Exception e) {
+ debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ }
+ throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate);
+ }
+
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOService.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOService.java
index 97bb78e..6e99b0d 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOService.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOService.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@ import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-@Api
+@Api("CMSO Schedule API")
@Path("/{apiVersion}")
@Produces({MediaType.APPLICATION_JSON})
public interface CMSOService {
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java
index c3d61da..d65dd25 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOServiceImpl.java
@@ -261,8 +261,8 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer
if (cw.getEndTime() == null || cw.getEndTime().equals(""))
throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE,
"endTime");
- DateTime start = CMSCallbackImpl.convertISODate(cw.getStartTime(), "startTime");
- DateTime end = CMSCallbackImpl.convertISODate(cw.getEndTime(), "endTime");
+ DateTime start = CMSOOptimizerCallbackImpl.convertISODate(cw.getStartTime(), "startTime");
+ DateTime end = CMSOOptimizerCallbackImpl.convertISODate(cw.getEndTime(), "endTime");
if (!end.isAfter(start))
throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_CHANGE_WINDOW,
cw.getStartTime(), cw.getEndTime());
@@ -312,8 +312,8 @@ public class CMSOServiceImpl extends BaseSchedulerServiceImpl implements CMSOSer
for (ChangeWindowMessage cw : vnfDetail.getChangeWindow()) {
ChangeManagementChangeWindow cmcw = new ChangeManagementChangeWindow();
cmcw.setChangeManagementGroupsId(cmg.getId());
- DateTime start = CMSCallbackImpl.convertISODate(cw.getStartTime(), "startTime");
- DateTime end = CMSCallbackImpl.convertISODate(cw.getEndTime(), "startTime");
+ DateTime start = CMSOOptimizerCallbackImpl.convertISODate(cw.getStartTime(), "startTime");
+ DateTime end = CMSOOptimizerCallbackImpl.convertISODate(cw.getEndTime(), "startTime");
cmcw.setStartTimeMillis(start.getMillis());
cmcw.setFinishTimeMillis(end.getMillis());
cmChangeWindowDAO.save(cmcw);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOptimizerCallback.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOptimizerCallback.java
index 99b4970..cc2785e 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOptimizerCallback.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CMSOptimizerCallback.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,24 +31,23 @@
package org.onap.optf.cmso.service.rs;
-import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
+
import org.onap.optf.cmso.optimizer.bean.CMOptimizerResponse;
+
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-@Api
+@Api("CMSO Optimized Schedule API")
@Path("/{apiVersion}")
@Produces({MediaType.APPLICATION_JSON})
public interface CMSOptimizerCallback {
@@ -62,7 +61,6 @@ public interface CMSOptimizerCallback {
@ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)})
public Response sniroCallback(
@ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
- @ApiParam(value = "Return schedules > lastScheduleId") CMOptimizerResponse reponse, @Context UriInfo uri,
- @Context HttpServletRequest request);
+ @ApiParam(value = "Return schedules > lastScheduleId") CMOptimizerResponse reponse);
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheck.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheck.java
index edc2c96..fb69e31 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheck.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheck.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,25 +31,24 @@
package org.onap.optf.cmso.service.rs;
-import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
+
import org.onap.optf.cmso.service.rs.models.HealthCheckMessage;
+
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-@Api
+@Api("CMSO Administration")
@Path("/{apiVersion}")
@Produces({MediaType.APPLICATION_JSON})
public interface HealthCheck {
@@ -63,7 +62,7 @@ public interface HealthCheck {
@ApiResponse(code = 400, message = "Not healthy", response = HealthCheckMessage.class)})
public Response healthCheck(@ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
@DefaultValue(value = "true") @ApiParam(value = "Check Interfaces",
- allowMultiple = true) @QueryParam("checkInterfaces") Boolean checkInterfaces,
- @Context UriInfo uri, @Context HttpServletRequest request);
+ allowMultiple = true) @QueryParam("checkInterfaces") Boolean checkInterfaces
+ );
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java
index 0877a6b..8e6b09e 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java
@@ -34,6 +34,7 @@ package org.onap.optf.cmso.service.rs;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@@ -55,11 +56,17 @@ import com.att.eelf.configuration.EELFManager;
public class HealthCheckImpl implements HealthCheck {
private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
+ @Context
+ UriInfo uri;
+
+ @Context
+ HttpServletRequest request;
+
@Autowired
TmClient tmClient;
@Autowired
- CMSOptimizerClient sniroClient;
+ CMSOptimizerClient optimizerClient;
@Autowired
ApprovalTypeDAO approvalTypeDAO;
@@ -71,7 +78,7 @@ public class HealthCheckImpl implements HealthCheck {
MsoStatusClient msoStatusClient;
@Override
- public Response healthCheck(String apiVersion, Boolean checkInterfaces, UriInfo uri, HttpServletRequest request) {
+ public Response healthCheck(String apiVersion, Boolean checkInterfaces) {
debug.debug("Entered healthcheck");
Response response = null;
HealthCheckMessage hc = new HealthCheckMessage();
@@ -80,7 +87,7 @@ public class HealthCheckImpl implements HealthCheck {
if (checkInterfaces) {
addToHealthCheckMessage(hc, tmClient.healthCheck());
addToHealthCheckMessage(hc, msoStatusClient.healthCheck());
- addToHealthCheckMessage(hc, sniroClient.healthCheck());
+ addToHealthCheckMessage(hc, optimizerClient.healthCheck());
}
addToHealthCheckMessage(hc, this.healthCheck());
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/test/loopback/SchedulerTestLoopbackServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/test/loopback/SchedulerTestLoopbackServiceImpl.java
index b240b61..b2ff6d4 100644
--- a/cmso-service/src/main/java/org/onap/optf/cmso/test/loopback/SchedulerTestLoopbackServiceImpl.java
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/test/loopback/SchedulerTestLoopbackServiceImpl.java
@@ -1,6 +1,6 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -59,7 +59,7 @@ import org.onap.optf.cmso.optimizer.bean.CMRequestInfo;
import org.onap.optf.cmso.optimizer.bean.CMSchedule;
import org.onap.optf.cmso.optimizer.bean.CMSchedulingInfo;
import org.onap.optf.cmso.optimizer.bean.CMVnfDetails;
-import org.onap.optf.cmso.service.rs.CMSCallbackImpl;
+import org.onap.optf.cmso.service.rs.CMSOOptimizerCallbackImpl;
import org.onap.optf.cmso.wf.bean.WfCmResponse200;
import org.onap.optf.cmso.wf.bean.WfMsoRequestReferences;
import org.onap.optf.cmso.wf.bean.WfMsoResponse;
@@ -101,11 +101,11 @@ public class SchedulerTestLoopbackServiceImpl implements SchedulerTestLoopbackSe
nodes.add(sr.getNode());
}
- DateTime startTime = CMSCallbackImpl.convertISODate(si.getStartTime(), "startTime");
+ DateTime startTime = CMSOOptimizerCallbackImpl.convertISODate(si.getStartTime(), "startTime");
// Ignore the finish time for now in the calc. Just accept what they
// gave
- DateTime finishTime = CMSCallbackImpl.convertISODate(si.getEndTime(), "endTime");
+ DateTime finishTime = CMSOOptimizerCallbackImpl.convertISODate(si.getEndTime(), "endTime");
DateTimeFormatter sniroFmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC();
int add = si.getAdditionalDurationInSecs();