diff options
author | Jerry Flood <jflood@att.com> | 2019-04-23 16:16:34 -0400 |
---|---|---|
committer | Jerry Flood <jflood@att.com> | 2019-04-24 06:37:15 -0400 |
commit | cb8d238bf57c2723fac484a0f7c1dc77428a65c0 (patch) | |
tree | 42f9736406df7acbfde6449d3cc1960157cc05ee /cmso-service/src/main/java/org/onap | |
parent | 990a5833020c8b01f059c7e5f6405c0076eeed05 (diff) |
Remove dead code, add robot tests
Issue-ID: OPTFRA-474
Change-Id: I409f3c16d287419357d07487032ceee8eda8cf94
Signed-off-by: Jerry Flood <jflood@att.com>
Diffstat (limited to 'cmso-service/src/main/java/org/onap')
12 files changed, 63 insertions, 961 deletions
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/CmsoEnvironmentPostProcessor.java b/cmso-service/src/main/java/org/onap/optf/cmso/CmsoEnvironmentPostProcessor.java deleted file mode 100644 index 8b4c44a..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/CmsoEnvironmentPostProcessor.java +++ /dev/null @@ -1,47 +0,0 @@ -/*
- * ============LICENSE_START=======================================================================================
- * Copyright (c) 2019 AT&T Intellectual Property.
- * ===================================================================
- * 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.
- * ============LICENSE_END=========================================================================================
- *
- ******************************************************************************/
-
-package org.onap.optf.cmso;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.onap.optf.cmso.common.PropertiesManagement;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.env.EnvironmentPostProcessor;
-import org.springframework.core.env.ConfigurableEnvironment;
-import org.springframework.core.env.MapPropertySource;
-import org.springframework.core.env.MutablePropertySources;
-
-public class CmsoEnvironmentPostProcessor implements EnvironmentPostProcessor {
- // TODO tested in ONAP springboot and this is called before all of the properties files have been
- // loaded...
- // perhaps there is a post post processor? Until this works. DB password will be in the clear in the
- // proeprties files.
- @Override
- public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
- String pwd = environment.getProperty("cmso.database.password");
- if (pwd != null) {
- pwd = PropertiesManagement.getDecryptedValue(pwd);
- Map<String, Object> map = new HashMap<>();
- map.put("spring.datasource.password", pwd);
- MapPropertySource propertySource = new MapPropertySource("abc", map);
- MutablePropertySources proeprtySources = environment.getPropertySources();
- proeprtySources.addLast(propertySource);
- }
- }
-
-}
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 2ba5fa3..eb4160a 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 @@ -47,7 +47,6 @@ 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.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;
@@ -84,7 +83,6 @@ public class JerseyConfiguration extends ResourceConfig { @Autowired
public JerseyConfiguration( /* LogRequestFilter lrf */ ) {
register(CmsoServiceImpl.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/optimizer/bean/CmsoOptimizerRequest.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerRequest.java deleted file mode 100644 index 05ab753..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerRequest.java +++ /dev/null @@ -1,74 +0,0 @@ -/*
- * 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.
- * 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.optimizer.bean;
-
-public class CmsoOptimizerRequest {
-
- /*
- *
- * { "schedulingInfo": { "scheduleId": "CM-<__SCHEDULE ID__>", "startTime":
- * "2017-02-15T00:00:00+05:00", "endTime": "2017-02-18T23:59:00+05:00",
- * "normalDurationInSecs": 60, "additionalDurationInSecs": 0, // for backout
- * "concurrencyLimit": 10, "policyId": ["SNIRO.TimeLimitAndVerticalTopology"],
- * "vnfDetails": [{ “node�?: "satmo415vbc", “groupId�?: “group1�?//optional }, {
- * “node�?: "satmo415vbc", “groupId�?: “group1�?//optional }] }, "requestInfo": {
- * “transactionId�?: �?__TRANSACTIONID__�?, //logging "requestId":
- * "CM-<__SCHEDULE ID__>", "sourceId": "cm-portal", “optimizer�?: [“scheduling�?],
- * "callbackUrl": "http://callbackurl.onap.org:8080/callback" } }
- *
- */
-
- private CmsoSchedulingInfo schedulingInfo;
- private CmsoRequestInfo requestInfo;
-
- public CmsoOptimizerRequest() {
- schedulingInfo = new CmsoSchedulingInfo();
- requestInfo = new CmsoRequestInfo();
- }
-
- public CmsoSchedulingInfo getSchedulingInfo() {
- return schedulingInfo;
- }
-
- public void setSchedulingInfo(CmsoSchedulingInfo schedulingInfo) {
- this.schedulingInfo = schedulingInfo;
- }
-
- public CmsoRequestInfo getRequestInfo() {
- return requestInfo;
- }
-
- public void setRequestInfo(CmsoRequestInfo requestInfo) {
- this.requestInfo = requestInfo;
- }
-
-}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerResponse.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerResponse.java deleted file mode 100644 index 1660866..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerResponse.java +++ /dev/null @@ -1,124 +0,0 @@ -/*
- * 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.
- * 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.optimizer.bean;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-
-@ApiModel(value = "Response from schedule optimizer",
- description = "Asynchronous response to schedule oprimizer request.")
-public class CmsoOptimizerResponse {
-
- /*
- *
- * { "transactionId": "dummy-transaction-id",
- * "scheduleId":"CM-<__SCHEDULE ID__>", "requestState": "complete", "status":
- * "Optimal", // diagnostic code "description": "Optimal solution found", //
- * diagnostic code "schedule": [ { "groupId": "grp06", "startTime":
- * "2016-10-01T00:30:00+05:00", // starting time for this group (In 1707,
- * seconds will always be zero but there is no reason to hardcode that decision)
- * "finishTime": "2016-10-01T00:40:00+05:00", // endtime for this group
- * (including failover) "latestInstanceStartTime": "2016-10-01T00:38:00Z", //
- * latest time when an instance of this group can be started "node": [ "up01",
- * "up03", "up09" ] // list of instances for this group. } ] }
- *
- */
-
- @ApiModelProperty(value = "Unique id of optimization request.")
- private String transactionId;
-
- @ApiModelProperty(value = "Schedule id for which the optimization request was executed.")
- private String scheduleId;
-
- @ApiModelProperty(value = "State of the request as reported by the optimizer.")
- private String requestState;
-
- @ApiModelProperty(value = "Status of the request.")
- private String status;
-
- @ApiModelProperty(value = "Description of the request status.")
- private String description;
-
- @ApiModelProperty(value = "List of schedules returned, one per group. Only 1 group supported at this time.")
- private CmsoSchedule[] schedule;
-
- public CmsoOptimizerResponse() {}
-
- public String getTransactionId() {
- return transactionId;
- }
-
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
- }
-
- public String getScheduleId() {
- return scheduleId;
- }
-
- public void setScheduleId(String scheduleId) {
- this.scheduleId = scheduleId;
- }
-
- public String getRequestState() {
- return requestState;
- }
-
- public void setRequestState(String requestState) {
- this.requestState = requestState;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public CmsoSchedule[] getSchedule() {
- return schedule;
- }
-
- public void setSchedule(CmsoSchedule[] schedule) {
- this.schedule = schedule;
- }
-
-}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoRequestInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoRequestInfo.java deleted file mode 100644 index dd74db2..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoRequestInfo.java +++ /dev/null @@ -1,83 +0,0 @@ -/*
- * 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.
- * 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.optimizer.bean;
-
-public class CmsoRequestInfo {
- private String transactionId;
- private String requestId;
- private String sourceId;
- private String[] optimizer;
- private String callbackUrl;
-
- public CmsoRequestInfo() {}
-
- public String getTransactionId() {
- return transactionId;
- }
-
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
- }
-
- public String getRequestId() {
- return requestId;
- }
-
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
-
- public String getSourceId() {
- return sourceId;
- }
-
- public void setSourceId(String sourceId) {
- this.sourceId = sourceId;
- }
-
- public String[] getOptimizer() {
- return optimizer;
- }
-
- public void setOptimizer(String[] optimizer) {
- this.optimizer = optimizer;
- }
-
- public String getCallbackUrl() {
- return callbackUrl;
- }
-
- public void setCallbackUrl(String callbackUrl) {
- this.callbackUrl = callbackUrl;
- }
-
-}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedule.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedule.java deleted file mode 100644 index 0d56fbd..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedule.java +++ /dev/null @@ -1,88 +0,0 @@ -/*
- * 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.
- * 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.optimizer.bean;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class CmsoSchedule {
- private String groupId;
- private String startTime;
- private String finishTime;
- private String latestInstanceStartTime;
- private List<String> node;
-
- public CmsoSchedule() {
- node = new ArrayList<String>();
- }
-
- public String getGroupId() {
- return groupId;
- }
-
- public void setGroupId(String groupId) {
- this.groupId = groupId;
- }
-
- public String getStartTime() {
- return startTime;
- }
-
- public void setStartTime(String startTime) {
- this.startTime = startTime;
- }
-
- public String getFinishTime() {
- return finishTime;
- }
-
- public void setFinishTime(String finishTime) {
- this.finishTime = finishTime;
- }
-
- public String getLatestInstanceStartTime() {
- return latestInstanceStartTime;
- }
-
- public void setLatestInstanceStartTime(String latestInstanceStartTime) {
- this.latestInstanceStartTime = latestInstanceStartTime;
- }
-
- public List<String> getNode() {
- return node;
- }
-
- public void setNode(List<String> node) {
- this.node = node;
- }
-
-}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedulingInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedulingInfo.java deleted file mode 100644 index 840cbb7..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedulingInfo.java +++ /dev/null @@ -1,110 +0,0 @@ -/*
- * 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.
- * 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.optimizer.bean;
-
-public class CmsoSchedulingInfo {
- private String scheduleId;
- private String startTime;
- private String endTime;
- private int normalDurationInSecs;
- private int additionalDurationInSecs;
- private int concurrencyLimit;
- private String[] policyId;
- private CmsoVnfDetails[] vnfDetails;
-
- public CmsoSchedulingInfo() {}
-
- public String getScheduleId() {
- return scheduleId;
- }
-
- public void setScheduleId(String scheduleId) {
- this.scheduleId = scheduleId;
- }
-
- public String getStartTime() {
- return startTime;
- }
-
- public void setStartTime(String startTime) {
- this.startTime = startTime;
- }
-
- public String getEndTime() {
- return endTime;
- }
-
- public void setEndTime(String endTime) {
- this.endTime = endTime;
- }
-
- public int getNormalDurationInSecs() {
- return normalDurationInSecs;
- }
-
- public void setNormalDurationInSecs(int normalDurationInSecs) {
- this.normalDurationInSecs = normalDurationInSecs;
- }
-
- public int getAdditionalDurationInSecs() {
- return additionalDurationInSecs;
- }
-
- public void setAdditionalDurationInSecs(int additionalDurationInSecs) {
- this.additionalDurationInSecs = additionalDurationInSecs;
- }
-
- public int getConcurrencyLimit() {
- return concurrencyLimit;
- }
-
- public void setConcurrencyLimit(int concurrencyLimit) {
- this.concurrencyLimit = concurrencyLimit;
- }
-
- public String[] getPolicyId() {
- return policyId;
- }
-
- public void setPolicyId(String[] policyId) {
- this.policyId = policyId;
- }
-
- public CmsoVnfDetails[] getVnfDetails() {
- return vnfDetails;
- }
-
- public void setVnfDetails(CmsoVnfDetails[] vnfDetails) {
- this.vnfDetails = vnfDetails;
- }
-
-}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoVnfDetails.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoVnfDetails.java deleted file mode 100644 index 4ee6053..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoVnfDetails.java +++ /dev/null @@ -1,60 +0,0 @@ -/*
- * 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.
- * 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.optimizer.bean;
-
-public class CmsoVnfDetails {
- private String node;
- private String groupId;
-
- public CmsoVnfDetails() {}
-
- public CmsoVnfDetails(String groupId) {
- this.groupId = groupId;
- }
-
- public String getNode() {
- return node;
- }
-
- public void setNode(String node) {
- this.node = node;
- }
-
- public String getGroupId() {
- return groupId;
- }
-
- public void setGroupId(String groupId) {
- this.groupId = groupId;
- }
-
-}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallback.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallback.java deleted file mode 100644 index b6b81e6..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallback.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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. - * 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 io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -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.MediaType; -import javax.ws.rs.core.Response; -import org.onap.optf.cmso.optimizer.bean.CmsoOptimizerResponse; - -@Api("CMSO Optimized Schedule API") -@Path("/{apiVersion}") -@Produces({MediaType.APPLICATION_JSON}) -public interface CmsoOptimizerCallback { - - // ****************************************************************** - @POST - @Path("/optimizerCallback") - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "", notes = "Processes optimizer results callback to a Pending Optimization schedule.") - @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"), - @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") CmsoOptimizerResponse reponse); - -} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallbackImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallbackImpl.java deleted file mode 100644 index ffe00c5..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallbackImpl.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * 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 com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.ObjectMapper; -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.CmsoStatusEnum; -import org.onap.optf.cmso.common.DomainsEnum; -import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CmsoException; -import org.onap.optf.cmso.common.exceptions.CmsoNotFoundException; -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.CmsoOptimizerResponse; -import org.onap.optf.cmso.optimizer.bean.CmsoSchedule; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; - -/** - * The Class CmsoOptimizerCallbackImpl. - */ -@Controller -public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implements CmsoOptimizerCallback { - private static EELFLogger log = EELFManager.getInstance().getLogger(CmsoOptimizerCallbackImpl.class); - 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 cmDetailsDaoO; - - /** - * Sniro callback. - * - * @param apiVersion the api version - * @param sniroResponse the sniro response - * @return the response - */ - @Override - @Transactional - public Response sniroCallback(String apiVersion, CmsoOptimizerResponse 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 CmsoNotFoundException(DomainsEnum.ChangeManagement.toString(), - "(OptimizerTransactionID=" + transactionId + ")"); - - } - CmsoStatusEnum status = CmsoStatusEnum.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 CmsoException(Status.PRECONDITION_FAILED, LogMessages.OPTIMIZER_CALLBACK_STATE_ERROR, - CmsoStatusEnum.OptimizationInProgress.toString(), schedule.getStatus().toString()); - } - } catch (CmsoException 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(); - } - return response; - } - - private void processSniroResponse(CmsoOptimizerResponse sniroResponse, Schedule schedule) { - try { - schedule.setOptimizerReturnDateTimeMillis(System.currentTimeMillis()); - schedule.setOptimizerStatus(sniroResponse.getRequestState()); - schedule.setOptimizerMessage(sniroResponse.getDescription()); - String scheduleId = sniroResponse.getScheduleId(); - ObjectMapper om = new ObjectMapper(); - CmsoSchedule[] 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 (CmsoSchedule sniroSchedule : sniroResponse.getSchedule()) { - String groupId = sniroSchedule.getGroupId(); - DateTime finishTime = convertDate(sniroSchedule.getFinishTime(), "finishTime"); - DateTime startTime = convertDate(sniroSchedule.getStartTime(), "startTime"); - ChangeManagementGroup group = cmGroupDao.findOneBySchedulesIdGroupId(schedule.getUuid(), groupId); - if (group == null) { - throw new CmsoException(Status.PRECONDITION_FAILED, - LogMessages.CHANGE_MANAGEMENT_GROUP_NOT_FOUND, schedule.getScheduleId(), groupId); - } - group.setStartTimeMillis(startTime.getMillis()); - group.setFinishTimeMillis(finishTime.getMillis()); - DateTime latestInstanceStartTime = - convertDate(sniroSchedule.getLatestInstanceStartTime(), "latestInstanceStartTime"); - 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(CmsoStatusEnum.PendingApproval.toString()); - } else { - debug.debug("scheduleId={0} schedule=null status={1} ", scheduleId, schedule.getOptimizerStatus()); - schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); - } - } catch (CmsoException e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); - schedule.setOptimizerStatus(e.getStatus().toString()); - schedule.setOptimizerMessage(e.getLocalizedMessage()); - } catch (Exception e) { - errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); - schedule.setOptimizerStatus("Exception"); - schedule.setOptimizerMessage(e.getLocalizedMessage()); - } - } - - /** - * Make map. - * - * @param startTime the start time - * @param latestInstanceStartTime the latest instance start time - * @param concurrencyLimit the concurrency limit - * @param totalDuration the total duration - * @param nodeList the node list - * @param startAndFinishTimeMap the start and finish time map - * @throws CmsoException the CMS exception - */ - public static void makeMap(Long startTime, Long latestInstanceStartTime, int concurrencyLimit, long totalDuration, - List<String> nodeList, Map<String, Map<String, Long>> startAndFinishTimeMap) throws CmsoException { - Long nextStartTime = null; - Long nextFinishTime = null; - for (int nodeNumber = 0; nodeNumber < nodeList.size(); nodeNumber++) { - if (nodeNumber % concurrencyLimit == 0) { - if (nodeNumber == 0) { - nextStartTime = startTime; - } - else { - nextStartTime = nextStartTime + totalDuration; - } - if (nextStartTime > latestInstanceStartTime) { - throw new CmsoException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_ALLOCATE_VNF_TIMESLOTS, - startTime.toString(), latestInstanceStartTime.toString(), String.valueOf(totalDuration), - String.valueOf(concurrencyLimit), String.valueOf(nodeList.size())); - } - nextFinishTime = nextStartTime + totalDuration; - } - Map<String, Long> map = new HashMap<String, Long>(); - map.put("startTime", nextStartTime); - map.put("finishTime", nextFinishTime); - String node = nodeList.get(nodeNumber); - startAndFinishTimeMap.put(node, map); - } - - } - - private void processNode(Schedule schedule, ChangeManagementGroup group, String node, - Map<String, Map<String, Long>> startAndFinishTimeMap) throws CmsoException { - Map<String, Long> map = startAndFinishTimeMap.get(node); - ChangeManagementSchedule detail = cmScheduleDao.findOneByGroupUuidAndVnfName(group.getUuid(), node); - if (detail == null) { - throw new CmsoException(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(CmsoStatusEnum.PendingApproval.toString()); - cmScheduleDao.save(detail); - } - - /** - * Convert date. - * - * @param utcDate the utc date - * @param attrName the attr name - * @return the date time - * @throws CmsoException the CMS exception - */ - public static DateTime convertDate(String utcDate, String attrName) throws CmsoException { - 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 CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate); - } - - /** - * Convert ISO date. - * - * @param utcDate the utc date - * @param attrName the attr name - * @return the date time - * @throws CmsoException the CMS exception - */ - public static DateTime convertIsoDate(String utcDate, String attrName) throws CmsoException { - 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 CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate); - } - -} 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 b9d0b60..8a1633a 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 @@ -46,6 +46,7 @@ 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.ISODateTimeFormat; import org.onap.observations.Observation; import org.onap.optf.cmso.common.DomainsEnum; import org.onap.optf.cmso.common.LogMessages; @@ -244,8 +245,8 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { if (vdm.getChangeWindow() != null) { for (ChangeWindowMessage cwm : vdm.getChangeWindow()) { ChangeWindow cw = new ChangeWindow(); - DateTime start = CmsoOptimizerCallbackImpl.convertIsoDate(cwm.getStartTime(), "startTime"); - DateTime end = CmsoOptimizerCallbackImpl.convertIsoDate(cwm.getEndTime(), "endTime"); + DateTime start = convertIsoDate(cwm.getStartTime(), "startTime"); + DateTime end = convertIsoDate(cwm.getEndTime(), "endTime"); cw.setStartTime(start.toDate()); cw.setEndTime(end.toDate()); windows.add(cw); @@ -457,4 +458,24 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { } return msg; } + /** + * Convert ISO date. + * + * @param utcDate the utc date + * @param attrName the attr name + * @return the date time + * @throws CmsoException the CMS exception + */ + public static DateTime convertIsoDate(String utcDate, String attrName) throws CmsoException { + 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 CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate); + } + } 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 9be348a..a834878 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 @@ -42,6 +42,7 @@ import org.joda.time.DateTime; import org.onap.observations.Observation;
import org.onap.optf.cmso.common.LogMessages;
import org.onap.optf.cmso.common.PropertiesManagement;
+import org.onap.optf.cmso.common.exceptions.CmsoException;
import org.onap.optf.cmso.optimizer.model.OptimizerElementInfo;
import org.onap.optf.cmso.optimizer.model.OptimizerRequest;
import org.onap.optf.cmso.optimizer.model.OptimizerResponse;
@@ -49,7 +50,6 @@ import org.onap.optf.cmso.optimizer.model.OptimizerScheduleInfo; import org.onap.optf.cmso.optimizer.model.ScheduledElement;
import org.onap.optf.cmso.optimizer.model.ScheduledElement.ScheduleType;
import org.onap.optf.cmso.optimizer.model.UnScheduledElement;
-import org.onap.optf.cmso.service.rs.CmsoOptimizerCallbackImpl;
import org.onap.optf.cmso.service.rs.models.v2.ChangeWindow;
import org.onap.optf.cmso.wf.bean.WfCmResponse200;
import org.onap.optf.cmso.wf.bean.WfMsoRequestReferences;
@@ -129,13 +129,12 @@ public class SchedulerTestLoopbackServiceImpl implements SchedulerTestLoopbackSe serialized = (serialized * totalDuration);
}
DateTime latestInstanceStartTime = startTime.plus(serialized);
- DateTime finishTime = latestInstanceStartTime.plus(totalDuration);
// Reformat request into a response setting the groups start finish
// time based upon
Map<String, Map<String, Long>> startAndFinishTimeMap = new HashMap<String, Map<String, Long>>();
try {
- CmsoOptimizerCallbackImpl.makeMap(startTime.getMillis(), latestInstanceStartTime.getMillis(),
+ makeMap(startTime.getMillis(), latestInstanceStartTime.getMillis(),
concurrencyLimit, totalDuration, nodeList, startAndFinishTimeMap);
for (String node : nodes.keySet()) {
Map<String, Long> map = startAndFinishTimeMap.get(node);
@@ -197,5 +196,43 @@ public class SchedulerTestLoopbackServiceImpl implements SchedulerTestLoopbackSe return Response.ok().entity(response).build();
}
+ /**
+ * Make map.
+ *
+ * @param startTime the start time
+ * @param latestInstanceStartTime the latest instance start time
+ * @param concurrencyLimit the concurrency limit
+ * @param totalDuration the total duration
+ * @param nodeList the node list
+ * @param startAndFinishTimeMap the start and finish time map
+ * @throws CmsoException the CMS exception
+ */
+ public static void makeMap(Long startTime, Long latestInstanceStartTime, int concurrencyLimit, long totalDuration,
+ List<String> nodeList, Map<String, Map<String, Long>> startAndFinishTimeMap) throws CmsoException {
+ Long nextStartTime = null;
+ Long nextFinishTime = null;
+ for (int nodeNumber = 0; nodeNumber < nodeList.size(); nodeNumber++) {
+ if (nodeNumber % concurrencyLimit == 0) {
+ if (nodeNumber == 0) {
+ nextStartTime = startTime;
+ }
+ else {
+ nextStartTime = nextStartTime + totalDuration;
+ }
+ if (nextStartTime > latestInstanceStartTime) {
+ throw new CmsoException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_ALLOCATE_VNF_TIMESLOTS,
+ startTime.toString(), latestInstanceStartTime.toString(), String.valueOf(totalDuration),
+ String.valueOf(concurrencyLimit), String.valueOf(nodeList.size()));
+ }
+ nextFinishTime = nextStartTime + totalDuration;
+ }
+ Map<String, Long> map = new HashMap<String, Long>();
+ map.put("startTime", nextStartTime);
+ map.put("finishTime", nextFinishTime);
+ String node = nodeList.get(nodeNumber);
+ startAndFinishTimeMap.put(node, map);
+ }
+
+ }
}
|