aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerry Flood <jflood@att.com>2019-03-19 12:07:42 -0400
committerJerry Flood <jflood@att.com>2019-03-19 12:34:29 -0400
commitca6b4dad4d74ce7a46ec7bf1b0c54a3947f3e970 (patch)
tree0375c7cf9ca3fa510fd90ec9cdd3e011791a240d
parent536e4cef3b2fd8b0d0c845157ecde717e37c57da (diff)
Commit 3: Define Create Optimized API
Mulitple commits due to commit size constraint. Remove robot from until until upgraded to Python 3. Issue-ID: OPTFRA-457 Change-Id: I1ebb555eab0fa0bf14d3c959ae042ddd200de985 Signed-off-by: Jerry Flood <jflood@att.com>
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/CMSOOptimizedScheduleService.java74
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/CMSOOptimizedScheduleServiceImpl.java122
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/OptimizedScheduleMessage.java132
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/PolicyInfo.java82
-rw-r--r--cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/SchedulingData.java132
-rw-r--r--pom.xml1
6 files changed, 542 insertions, 1 deletions
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/CMSOOptimizedScheduleService.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/CMSOOptimizedScheduleService.java
new file mode 100644
index 0000000..c0806d7
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/CMSOOptimizedScheduleService.java
@@ -0,0 +1,74 @@
+/*
+ * 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 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.common.CMSRequestError;
+import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage;
+
+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("CMSO Optimized Schedule API")
+@Path("/{apiVersion}")
+@Produces({MediaType.APPLICATION_JSON})
+public interface CMSOOptimizedScheduleService {
+
+ // ******************************************************************
+ @POST
+ @Path("/schedules/optimized/{scheduleId}")
+ @Produces({MediaType.APPLICATION_JSON})
+ @ApiOperation(value = "", notes = "Creates a request for an optimized schedule")
+ @ApiResponses(
+ value = {@ApiResponse(code = 202, message = "Schedule request accepted for optimization."),
+ @ApiResponse(code = 409, message = "Schedule request already exists for this schedule id.",
+ response = CMSRequestError.class),
+ @ApiResponse(code = 500, message = "Unexpected Runtime error")})
+ public Response createScheduleRequest(
+ @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion,
+ @ApiParam(
+ value = "Schedule id to uniquely identify the schedule request being created.") @PathParam("scheduleId") String scheduleId,
+ @ApiParam(
+ value = "Data for creating a schedule request for the given schedule id") OptimizedScheduleMessage scheduleMessage);
+
+
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/CMSOOptimizedScheduleServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/CMSOOptimizedScheduleServiceImpl.java
new file mode 100644
index 0000000..aa397ae
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/CMSOOptimizedScheduleServiceImpl.java
@@ -0,0 +1,122 @@
+/*
+ * 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 javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+import org.onap.observations.Observation;
+import org.onap.optf.cmso.common.LogMessages;
+import org.onap.optf.cmso.common.exceptions.CMSException;
+import org.onap.optf.cmso.eventq.CMSQueueJob;
+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.model.dao.ScheduleDAO;
+import org.onap.optf.cmso.model.dao.ScheduleQueryDAO;
+import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage;
+import org.onap.optf.cmso.ticketmgt.TmClient;
+import org.onap.optf.cmso.ticketmgt.bean.BuildCreateRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Controller;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+@Controller
+public class CMSOOptimizedScheduleServiceImpl implements CMSOOptimizedScheduleService {
+ private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
+
+ @Autowired
+ CMSQueueJob qJob;
+
+ @Autowired
+ Environment env;
+
+ @Autowired
+ ChangeManagementScheduleDAO cmScheduleDAO;
+
+ @Autowired
+ ChangeManagementGroupDAO cmGroupDAO;
+
+ @Autowired
+ ChangeManagementChangeWindowDAO cmChangeWindowDAO;
+
+ @Autowired
+ ChangeManagementDetailDAO cmDetailsDAO;
+
+ @Autowired
+ ScheduleQueryDAO scheduleQueryDAO;
+
+ @Autowired
+ ScheduleDAO scheduleDAO;
+
+ @Autowired
+ TmClient tmClient;
+
+ @Autowired
+ BuildCreateRequest buildCreateRequest;
+
+
+ @Context
+ HttpServletRequest request;
+
+ @Override
+ @Transactional
+ public Response createScheduleRequest(String apiVersion, String scheduleId, OptimizedScheduleMessage scheduleMessage)
+ {
+ Observation.report(LogMessages.CREATE_SCHEDULE_REQUEST, "Received", request.getRemoteAddr(), scheduleId,
+ scheduleMessage.toString());
+ Response response = null;
+ try {
+ response = Response.accepted().build();
+// } catch (CMSException e) {
+// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+// Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage());
+// response = Response.status(e.getStatus()).entity(e.getRequestError()).build();
+ } catch (Exception e) {
+ Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ response = Response.serverError().build();
+ }
+ Observation.report(LogMessages.CREATE_SCHEDULE_REQUEST, "Returned", request.getRemoteAddr(), scheduleId,
+ response.getStatusInfo().toString());
+ return response;
+ }
+
+
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/OptimizedScheduleMessage.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/OptimizedScheduleMessage.java
new file mode 100644
index 0000000..797379c
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/OptimizedScheduleMessage.java
@@ -0,0 +1,132 @@
+/*
+ * 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.models.v2;
+
+import java.io.Serializable;
+import java.util.List;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * The persistent class for the approval_types database table.
+ *
+ */
+@ApiModel(value = "Optimized Schedule Request", description = "Request to schedule VNF change management workflow(s).")
+public abstract class OptimizedScheduleMessage implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static EELFLogger log = EELFManager.getInstance().getLogger(OptimizedScheduleMessage.class);
+
+ // public abstract void setSchedulingInfo(Object schedulingInfo);
+
+ @ApiModelProperty(value = "Schedule domain : ChangeManagement")
+ private String domain;
+
+ @ApiModelProperty(value = "Schedule id that must be unique within the domain. Use of UUID is highly recommended.")
+ private String scheduleId;
+
+ @ApiModelProperty(value = "User provided name of the schedule (deaults to scheduleId")
+ private String scheduleName;
+
+ @ApiModelProperty(value = "ATTUID of the user requesting the schedule.")
+ private String userId;
+
+ @ApiModelProperty(value = "Implementation specific name value pairs.")
+ private List<NameValue> commonData;
+
+ @ApiModelProperty(value = "Scheduling data.")
+ private SchedulingData schedulingData;
+
+ public String getDomain() {
+ return domain;
+ }
+
+ public void setDomain(String domain) {
+ this.domain = domain;
+ }
+
+ public String getScheduleId() {
+ return scheduleId;
+ }
+
+ public void setScheduleId(String scheduleId) {
+ this.scheduleId = scheduleId;
+ }
+
+ public String getScheduleName() {
+ return scheduleName;
+ }
+
+ public void setScheduleName(String scheduleName) {
+ this.scheduleName = scheduleName;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public List<NameValue> getCommonData() {
+ return commonData;
+ }
+
+ public void setCommonData(List<NameValue> commonData) {
+ this.commonData = commonData;
+ }
+
+ public SchedulingData getSchedulingData() {
+ return schedulingData;
+ }
+
+ public void setSchedulingData(SchedulingData schedulingData) {
+ this.schedulingData = schedulingData;
+ }
+
+ public String toString() {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ log.debug("Error in toString()", e);
+ }
+ return "";
+ }
+
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/PolicyInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/PolicyInfo.java
new file mode 100644
index 0000000..c6a291c
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/PolicyInfo.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ *
+ * Copyright © 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.
+ *
+ *
+ * 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.models.v2;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel(value = "Supported Policy Information", description = "Policy Information returned from get policies API.")
+public class PolicyInfo implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static EELFLogger log = EELFManager.getInstance().getLogger(PolicyInfo.class);
+
+ @ApiModelProperty(value = "Policy name")
+ private String policyName;
+
+ @ApiModelProperty(value = "Named values to modify/override policy attributes.")
+ public List<NameValue> policyModifiers = new ArrayList<>();
+
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+
+ public List<NameValue> getPolicyModifiers() {
+ return policyModifiers;
+ }
+
+ public void setPolicyModifiers(List<NameValue> policyModifiers) {
+ this.policyModifiers = policyModifiers;
+ }
+
+ public String toString() {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ log.debug("Error in toString()", e);
+ }
+ return "";
+ }
+}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/SchedulingData.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/SchedulingData.java
new file mode 100644
index 0000000..e17f1d2
--- /dev/null
+++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/v2/SchedulingData.java
@@ -0,0 +1,132 @@
+/*
+ * 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.models.v2;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * The persistent class for the approval_types database table.
+ *
+ */
+@ApiModel(value = "Change Management Scheduling Info", description = "Details of schedule being requested")
+public class SchedulingData implements Serializable {
+ private static EELFLogger log = EELFManager.getInstance().getLogger(SchedulingData.class);
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "Expected duration (in seconds) of a successful execution of a single VNF change.")
+ private Integer normalDurationInSeconds;
+
+ @ApiModelProperty(value = "Additional duration (in seconds) to be added to support backout of an unsuccessful VNF change.")
+ private Integer additionalDurationInSeconds;
+
+ @ApiModelProperty(value = "Maximum number of VNF changes to schedule concurrently")
+ private Integer concurrencyLimit;
+
+ @ApiModelProperty(value = "Lists of desired change windows to schedule the elements.")
+ private List<ChangeWindow> changeWindows = new ArrayList<>();
+
+ @ApiModelProperty(value = "List of the policies to control optimization.")
+ private List<PolicyInfo> policies = new ArrayList<>();
+
+ @ApiModelProperty(value = "Lists of the VNFs to be changed and the desired change windows")
+ private List<ElementInfo> elements;
+
+ public String toString() {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ log.debug("Error in toString()", e);
+ }
+ return "";
+ }
+
+ public Integer getNormalDurationInSeconds() {
+ return normalDurationInSeconds;
+ }
+
+ public void setNormalDurationInSeconds(Integer normalDurationInSeconds) {
+ this.normalDurationInSeconds = normalDurationInSeconds;
+ }
+
+ public Integer getAdditionalDurationInSeconds() {
+ return additionalDurationInSeconds;
+ }
+
+ public void setAdditionalDurationInSeconds(Integer additionalDurationInSeconds) {
+ this.additionalDurationInSeconds = additionalDurationInSeconds;
+ }
+
+ public Integer getConcurrencyLimit() {
+ return concurrencyLimit;
+ }
+
+ public void setConcurrencyLimit(Integer concurrencyLimit) {
+ this.concurrencyLimit = concurrencyLimit;
+ }
+
+ public List<ChangeWindow> getChangeWindows() {
+ return changeWindows;
+ }
+
+ public void setChangeWindows(List<ChangeWindow> changeWindows) {
+ this.changeWindows = changeWindows;
+ }
+
+ public List<PolicyInfo> getPolicies() {
+ return policies;
+ }
+
+ public void setPolicies(List<PolicyInfo> policies) {
+ this.policies = policies;
+ }
+
+ public List<ElementInfo> getElements() {
+ return elements;
+ }
+
+ public void setElements(List<ElementInfo> elements) {
+ this.elements = elements;
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index 51bdd6d..e8e6f14 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,7 +64,6 @@
<modules>
<module>cmso-service</module>
<module>cmso-database</module>
- <module>cmso-robot</module>
</modules>
<build>