From fe8c1df09a3c74321831b40f6f953016d746aa61 Mon Sep 17 00:00:00 2001 From: Jerry Flood Date: Thu, 28 Mar 2019 15:41:57 -0400 Subject: Merge missing optimizer classes Implement policy model. Issue-ID: OPTFRA-458 Change-Id: Ibb7f8535af910dff3ab9ce671b62fb826899058c Signed-off-by: Jerry Flood --- cmso-optimizer/etc/config/optimizer.properties | 2 + cmso-optimizer/pom.xml | 5 +- .../optf/cmso/optimizer/common/LogMessages.java | 1 + .../service/rs/models/OptimizerRequest.java | 160 +++++++++++++++++++++ .../service/rs/models/OptimizerResponse.java | 110 ++++++++++++++ .../service/rs/models/OptimizerScheduleInfo.java | 82 +++++++++++ .../optimizer/service/rs/models/PolicyInfo.java | 88 ++++++++++++ .../service/rs/models/ReferencedElementInfo.java | 100 +++++++++++++ .../service/rs/models/ScheduledElement.java | 127 ++++++++++++++++ .../service/rs/models/UnScheduledElement.java | 103 +++++++++++++ .../src/main/resources/META-INF/spring.factories | 1 + .../src/main/resources/aaf/AAFUserRoles.properties | 1 + .../src/main/resources/aaf/org.onap.oof.cred.props | 11 ++ .../src/main/resources/aaf/org.onap.oof.keyfile | 27 ++++ .../main/resources/aaf/org.onap.oof.location.props | 8 ++ .../src/main/resources/aaf/org.onap.oof.props | 14 ++ .../src/main/resources/aaf/permissions.properties | 2 + .../src/main/resources/application.properties | 49 +++++++ cmso-optimizer/src/main/resources/banner.txt | 10 ++ .../src/main/resources/logmessages.properties | 1 + .../optf/cmso/topology/common/LogMessages.java | 2 +- .../cmso/topology/service/rs/HealthCheckImpl.java | 4 +- .../topology/service/rs/TopologyInterfaceImpl.java | 44 ++++-- .../service/rs/models/TopologyResponse.java | 13 +- .../src/main/resources/logmessages.properties | 4 +- 25 files changed, 948 insertions(+), 21 deletions(-) create mode 100644 cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerRequest.java create mode 100644 cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerResponse.java create mode 100644 cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerScheduleInfo.java create mode 100644 cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/PolicyInfo.java create mode 100644 cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ReferencedElementInfo.java create mode 100644 cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ScheduledElement.java create mode 100644 cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/UnScheduledElement.java create mode 100644 cmso-optimizer/src/main/resources/META-INF/spring.factories create mode 100644 cmso-optimizer/src/main/resources/aaf/AAFUserRoles.properties create mode 100644 cmso-optimizer/src/main/resources/aaf/org.onap.oof.cred.props create mode 100644 cmso-optimizer/src/main/resources/aaf/org.onap.oof.keyfile create mode 100644 cmso-optimizer/src/main/resources/aaf/org.onap.oof.location.props create mode 100644 cmso-optimizer/src/main/resources/aaf/org.onap.oof.props create mode 100644 cmso-optimizer/src/main/resources/aaf/permissions.properties create mode 100644 cmso-optimizer/src/main/resources/application.properties create mode 100644 cmso-optimizer/src/main/resources/banner.txt diff --git a/cmso-optimizer/etc/config/optimizer.properties b/cmso-optimizer/etc/config/optimizer.properties index 7dc75f5..8b8c6a1 100644 --- a/cmso-optimizer/etc/config/optimizer.properties +++ b/cmso-optimizer/etc/config/optimizer.properties @@ -45,3 +45,5 @@ logging.level.org.hibernate=TRACE cmso.topology.create.request.url=http://127.0.0.1:7998/topology/v1/current + +cmso.local.policy.folder=data/policies \ No newline at end of file diff --git a/cmso-optimizer/pom.xml b/cmso-optimizer/pom.xml index afa75f2..8db7eb2 100644 --- a/cmso-optimizer/pom.xml +++ b/cmso-optimizer/pom.xml @@ -239,8 +239,9 @@ - joda-time - joda-time + org.scala-saddle + google-rfc-2445 + 20110304 org.apache.commons diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/LogMessages.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/LogMessages.java index ce1c389..b61b02a 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/LogMessages.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/LogMessages.java @@ -72,6 +72,7 @@ public enum LogMessages implements ObservationInterface { TOPOLOGY_REQUEST("Topology request {0} for {1} URL: {1}", Status.OK, Level.INFO), OPTIMIZER_REQUEST("OPtimizer request {0} for {1} Command: {1}", Status.OK, Level.INFO), TICKETS_REQUEST("Tickets request {0} for {1} URL: {1}", Status.OK, Level.INFO), + UNSUPPORTED_PERIODIC_TIME("Unsupported periodic time from policy: {0}", Status.INTERNAL_SERVER_ERROR, Level.ERROR), ; private final String defaultId; diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerRequest.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerRequest.java new file mode 100644 index 0000000..0961de5 --- /dev/null +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerRequest.java @@ -0,0 +1,160 @@ +/* + * 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.service.rs.models; + +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; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +@ApiModel(value = "Optimizer Request", + description = "Request to provide an \"conflict free\" schedule for passed elements.") +public class OptimizerRequest implements Serializable { + private static final long serialVersionUID = 1L; + private static EELFLogger log = EELFManager.getInstance().getLogger(OptimizerRequest.class); + + @ApiModelProperty(value = "Unique Id of the request") + private String requestId; + + @ApiModelProperty(value = "Concurrency limit for this request") + private Integer concurrencyLimit; + + @ApiModelProperty(value = "Expected duration of normal change") + private Integer normalDuration; + + @ApiModelProperty(value = "Additional duration for failed change") + private Integer additionalDuration; + + @ApiModelProperty(value = "Implementation specific name value pairs.") + private List commonData; + + @ApiModelProperty(value = "Lists of desired change windows to schedule the elements.") + private List changeWindows = new ArrayList<>(); + + @ApiModelProperty(value = "List of the elements to schedule.") + private List elements = new ArrayList<>(); + + @ApiModelProperty(value = "List of the policies to control optimization.") + private List policies = new ArrayList<>(); + + public String getRequestId() { + return requestId; + } + + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + + public List getPolicies() { + return policies; + } + + + public void setPolicies(List policies) { + this.policies = policies; + } + + + public List getCommonData() { + return commonData; + } + + + public void setCommonData(List commonData) { + this.commonData = commonData; + } + + + public List getElements() { + return elements; + } + + + public void setElements(List elements) { + this.elements = elements; + } + + + public List getChangeWindows() { + return changeWindows; + } + + + public void setChangeWindows(List changeWindows) { + this.changeWindows = changeWindows; + } + + + public Integer getConcurrencyLimit() { + return concurrencyLimit; + } + + + public void setConcurrencyLimit(Integer concurrencyLimit) { + this.concurrencyLimit = concurrencyLimit; + } + + + public Integer getNormalDuration() { + return normalDuration; + } + + + public void setNormalDuration(Integer normalDuration) { + this.normalDuration = normalDuration; + } + + + public Integer getAdditionalDuration() { + return additionalDuration; + } + + + public void setAdditionalDuration(Integer additionalDuration) { + this.additionalDuration = additionalDuration; + } + + + @Override + 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-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerResponse.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerResponse.java new file mode 100644 index 0000000..2f8e705 --- /dev/null +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerResponse.java @@ -0,0 +1,110 @@ +/* + * 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.service.rs.models; + +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; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +@ApiModel(value = "Optimizer Response", description = "Response to optimizer request for the requested elements.") +public class OptimizerResponse implements Serializable { + private static final long serialVersionUID = 1L; + private static EELFLogger log = EELFManager.getInstance().getLogger(OptimizerResponse.class); + + public enum OptimizeScheduleStatus { + CREATED, PENDING_TOPOLOGY, PENDING_TICKETS, PENDING_OPTIMIZER, COMPLETED, FAILED, DELETED, + } + + @ApiModelProperty(value = "Unique Id of the request") + private String requestId; + + @ApiModelProperty(value = "Status of the optimization") + private OptimizeScheduleStatus status; + + @ApiModelProperty(value = "Message for failed optimization") + private String errorMessage; + + + @ApiModelProperty(value = "List of schedules returned by the optimizer.") + private List schedules = new ArrayList<>(); + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + + public List getSchedules() { + return schedules; + } + + public void setSchedules(List schedules) { + this.schedules = schedules; + } + + public OptimizeScheduleStatus getStatus() { + return status; + } + + public void setStatus(OptimizeScheduleStatus status) { + this.status = status; + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + /** + * To string. + * + * @return the string + */ + @Override + 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-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerScheduleInfo.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerScheduleInfo.java new file mode 100644 index 0000000..37bb404 --- /dev/null +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/OptimizerScheduleInfo.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.optimizer.service.rs.models; + +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; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +@ApiModel(value = "Optimizer Schedule Info", description = "Schedule Information returned from optimizer request.") +public class OptimizerScheduleInfo implements Serializable { + private static final long serialVersionUID = 1L; + private static EELFLogger log = EELFManager.getInstance().getLogger(OptimizerScheduleInfo.class); + + @ApiModelProperty(value = "Lists of elements with start times.") + private List scheduledElements = new ArrayList<>(); + + @ApiModelProperty(value = "Lists of elements that were not able to be scheduled.") + private List unScheduledElements = new ArrayList<>(); + + + public List getScheduledElements() { + return scheduledElements; + } + + + public void setScheduledElements(List scheduledElements) { + this.scheduledElements = scheduledElements; + } + + + public List getUnScheduledElements() { + return unScheduledElements; + } + + + public void setUnScheduledElements(List unScheduledElements) { + this.unScheduledElements = unScheduledElements; + } + + + @Override + 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-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/PolicyInfo.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/PolicyInfo.java new file mode 100644 index 0000000..524571a --- /dev/null +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/PolicyInfo.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * + * 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.optimizer.service.rs.models; + +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; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +@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 = "Policy description") + private String policyDescription; + + @ApiModelProperty(value = "Named values to modify/override policy attributes.") + public List policyModifiers = new ArrayList<>(); + + public String getPolicyName() { + return policyName; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + public String getPolicyDescription() { + return policyDescription; + } + + public void setPolicyDescription(String policyDescription) { + this.policyDescription = policyDescription; + } + + public List getPolicyModifiers() { + return policyModifiers; + } + + public void setPolicyModifiers(List policyModifiers) { + this.policyModifiers = policyModifiers; + } + + @Override + 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-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ReferencedElementInfo.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ReferencedElementInfo.java new file mode 100644 index 0000000..97210b1 --- /dev/null +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ReferencedElementInfo.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * + * 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.optimizer.service.rs.models; + +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; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +@ApiModel(value = "Topology Related Element", description = "Element Information returned from TopologyRequuest.") +public class ReferencedElementInfo implements Serializable { + private static final long serialVersionUID = 1L; + private static EELFLogger log = EELFManager.getInstance().getLogger(ReferencedElementInfo.class); + + @ApiModelProperty(value = "Element identifier") + private String elementId; + + @ApiModelProperty(value = "Location information for the element.") + private ElementLocation elementLocation; + + @ApiModelProperty(value = "Related elements only. Element ids of the element(s) ") + private List referencingElements; + + @ApiModelProperty(value = "Implementation specific element data.") + public List elementData = new ArrayList<>(); + + public String getElementId() { + return elementId; + } + + public void setElementId(String elementId) { + this.elementId = elementId; + } + + public ElementLocation getElementLocation() { + return elementLocation; + } + + public void setElementLocation(ElementLocation elementLocation) { + this.elementLocation = elementLocation; + } + + + public List getRelatedElements() { + return referencingElements; + } + + public void setRelatedElements(List relatedElements) { + this.referencingElements = relatedElements; + } + + public List getElementData() { + return elementData; + } + + public void setElementData(List elementData) { + this.elementData = elementData; + } + + @Override + 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-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ScheduledElement.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ScheduledElement.java new file mode 100644 index 0000000..b3561dd --- /dev/null +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ScheduledElement.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * + * 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.optimizer.service.rs.models; + +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; +import java.io.Serializable; +import java.util.Date; +import org.springframework.format.annotation.DateTimeFormat; + +@ApiModel(value = "Scheduled Element", description = "Scheduled element returned by the optimizer.") +public class ScheduledElement implements Serializable { + private static final long serialVersionUID = 1L; + private static EELFLogger log = EELFManager.getInstance().getLogger(ScheduledElement.class); + + public enum ScheduleType { + UNKNOWN, GROUP_DISPATCH, INDIVIDUAL, + } + + @ApiModelProperty(value = "Element identifier") + private String elementId; + + @ApiModelProperty(value = "Group identifier") + private String groupId; + + private ScheduleType scheduleType = ScheduleType.UNKNOWN; + + @ApiModelProperty(value = "Earliest time for which changes may begin.") + @DateTimeFormat(pattern = "yyyy-MM-dd'T'hh:mm:ss'Z'") + private Date startTime; + + @ApiModelProperty(value = "Latest time by which all changes must be completed.") + @DateTimeFormat(pattern = "yyyy-MM-dd'T'hh:mm:ss'Z'") + private Date endTime; + + @ApiModelProperty(value = "Expected duration of change in seconds.") + private Long durationSeconds; + + public String getElementId() { + return elementId; + } + + public void setElementId(String elementId) { + this.elementId = elementId; + } + + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public ScheduleType getScheduleType() { + return scheduleType; + } + + public void setScheduleType(ScheduleType scheduleType) { + this.scheduleType = scheduleType; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public Long getDurationSeconds() { + return durationSeconds; + } + + public void setDurationSeconds(Long durationSeconds) { + this.durationSeconds = durationSeconds; + } + + @Override + 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-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/UnScheduledElement.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/UnScheduledElement.java new file mode 100644 index 0000000..775c760 --- /dev/null +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/UnScheduledElement.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * + * 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.optimizer.service.rs.models; + +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; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +@ApiModel(value = "Unscheduled Element", description = "Scheduled element returned by the optimizer.") +public class UnScheduledElement implements Serializable { + private static final long serialVersionUID = 1L; + private static EELFLogger log = EELFManager.getInstance().getLogger(UnScheduledElement.class); + + public enum NotScheduledReason { + ConcurrencyConstraint, AvailabilityConstraint, Other, + } + + @ApiModelProperty(value = "Element identifier") + private String elementId; + + @ApiModelProperty(value = "Group identifier") + private String groupId; + + @ApiModelProperty(value = "List of reasons not able to schedule this element.") + private List notScheduledReaons = new ArrayList<>(); + + @ApiModelProperty(value = "List of messages not able to schedule this element.") + private List notScheduledMessages = new ArrayList<>(); + + public String getElementId() { + return elementId; + } + + public void setElementId(String elementId) { + this.elementId = elementId; + } + + public List getNotScheduledReaons() { + return notScheduledReaons; + } + + public void setNotScheduledReaons(List notScheduledReaons) { + this.notScheduledReaons = notScheduledReaons; + } + + public List getNotScheduledMessages() { + return notScheduledMessages; + } + + public void setNotScheduledMessages(List notScheduledMessages) { + this.notScheduledMessages = notScheduledMessages; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + @Override + 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-optimizer/src/main/resources/META-INF/spring.factories b/cmso-optimizer/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..c0b4a01 --- /dev/null +++ b/cmso-optimizer/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.env.EnvironmentPostProcessor=org.onap.optf.cmso.CmsoEnvironmentPostProcessor \ No newline at end of file diff --git a/cmso-optimizer/src/main/resources/aaf/AAFUserRoles.properties b/cmso-optimizer/src/main/resources/aaf/AAFUserRoles.properties new file mode 100644 index 0000000..e7fc221 --- /dev/null +++ b/cmso-optimizer/src/main/resources/aaf/AAFUserRoles.properties @@ -0,0 +1 @@ +/**=org.onap.oof.access|*|get ALL \ No newline at end of file diff --git a/cmso-optimizer/src/main/resources/aaf/org.onap.oof.cred.props b/cmso-optimizer/src/main/resources/aaf/org.onap.oof.cred.props new file mode 100644 index 0000000..21945b8 --- /dev/null +++ b/cmso-optimizer/src/main/resources/aaf/org.onap.oof.cred.props @@ -0,0 +1,11 @@ +############################################################ +# Properties Generated by AT&T Certificate Manager +# by root +# on 2019-02-15T21:01:19.868+0000 +# @copyright 2016, AT&T +############################################################ +aaf_id=oof@oof.onap.org +aaf_password=demo123456! +cadi_keyfile=src/main/resources/aaf/org.onap.oof.keyfile +cadi_truststore=src/main/resources/aaf/truststoreONAPall.jks +#cadi_truststore_password=enc:erNqS33_5xn_bwcaroba7NvYfPLpPUYxqzw3rdwGTY7jbnygOTyQ-R6dpSC_3iPOomp-rqZkHgMGImiUk9DFPr diff --git a/cmso-optimizer/src/main/resources/aaf/org.onap.oof.keyfile b/cmso-optimizer/src/main/resources/aaf/org.onap.oof.keyfile new file mode 100644 index 0000000..f85a567 --- /dev/null +++ b/cmso-optimizer/src/main/resources/aaf/org.onap.oof.keyfile @@ -0,0 +1,27 @@ +liD-IR8Y1MHqPDTUqq3AaTtqnWn5jCpfIRBlyi6xY4A0fbQz8ZPlTZPHkshRt0dHdST3R7TIvTyQ +JpTCeBNBu2df3vBbUzsN0rIpPG9TGjzmE7cRu4V4kfefSqsIj-S7OTAaWaWpwGWJYLLCB2sQALkS +f68VWdupUEw3g9jqCU1QzjKOnLGvhlp6Qrc1xG4Z5Ar8WERw-C3DqTWUKANoEvjWkvH2rAywzj93 +pmspvd5fQfH1rp1ACNvnPrRb_oYNfwPrNpE7Sb4LvM1muoiKMDF64IDO0TkxhjHZ9wpJgVsnowby +qmokqf39dMRRk3S1IEpOiBGyLS_885JDj_XJKYRQsjvkTzjpFJ7wE2-HDZEVWCITvtS9-Xorm5TI +3iU4rjMDew5fkBnjoKuSOS7Lksva4ouZOCiUkDos1jAJ5XMDEQm4BcPHtcW6PpC602-qRcgnNjjP +wOPdF7hCm27ZTai3lAtNGByR7oBr9r5Uma-soORFvg8drV8Rgh0lax-poFVhoEH7RhKPIzYpSco9 +jnpURzi_epTjAhjjup-erTv2GAIllKsSEHZLbfsFWlNUZTOx58PSB0jBN5m_8HxTyNm0zsm0Cb7U +KsjPduQ5ZblsfRIJwqpOBXoof7WerKReMZSOdgjZUNueiuEImVH9_SYOdKZhkluSi4yfEtme7CCP +kZ2JhdiT5km3SeonalhU2MUsx60krxyQ1mnjI4jS9QagUME4mujdvM_L7mtjcPZVSfXUn49whakE +J-NQV6q2iZgN2IxsT_uCnlZYwnE5i-IbQkQAEu13m6ETsMmf0cwPnKaSwRhb8G48EkJhTL-GP9Z0 +-EsIKT7lQt7kfX-mmNoEirTg9gQAaN3uxLmdHvXpeJdlETnnaLYYJJ3h-SL0e_5Yz2SpdsEwZ3Bk +PtR-QvlYKDhG1nhPOna65ctCzn81PZOUP3lsO6MSTOK6D6Taxfh1TYEBAvzCP0BfFBodw4lSglFP +I5IfdiJmomTGARa36nC_O5YzH_jBWLQrgd2gxI5H5bB-5zqzu79SGX9o2_LRVY_LVV0BmI3xSYOI +vziYYC1XyTY6blfdiOM5a5KjraErxSTEFZVFrsx4OQ_dLA0woVtixawrIy1rgfQr49U1oIRe8BgN +j3eis_UQAbPbmdbEe1qtXnvi6T7trHskzt6K-vTgo5ITJkr-F2Sds_QgNdaFBGuES6X5RwRGlbHT +Tl_M8Ja_1K-RMNKJRssoRTKstpwnrhk9IcoSwYcLykbDLgeC0mhSMHOOuWv1RGRaZdzObc5YA1eB +idQmzy5xAHzNxPHHrB-fpjFJRYv_QZY9qZcGvP58d6bHO0upxbj-BBt9zfc7Qt0JLU6EAdYbW5TI +2v4JImikrx6KvtoK8vcjJMTDAanTVB31J65tat0rq9wYKxUdjBJLzkT3psYs_DRtYQc0i02YTD7t +dWya0-3p1Yrt0em3XGb8JAh2PA3BsQKmvKAOc054wf_B8n8saxSFw1WQL30vU5c4-Z_p53HfaUYd +Qg7DZskzgwBRy48sLJNCrn81RtxXfQP1XtPEZs-AAlTUslHoUdoQ1cwrYEgkNT1cjk6sLI_oKSK- +dDICBnlYLrZRBS3sH8K38WaIh1WRY6vbGVDs1tUectUpng_-Khavd0Crw7D_CE6T7Rnfcn0pnTV- +HW1PIXejFsONQn-2c3a9HZ-v6Hg4JL6UWm-qgBPC5118ymO0LfmrviAFAC6Wt3WFiNzrvx9Jggus +lE0qvLVfkQVZXAy-hSPHlYZmtxk5voVsf60qPoDN2-NdpWz62M9PrXd_A03YGxzt0G6J4VXExRES +xqLeGNGB496AfX_vEub97sR8xcbbUXsyt12uVnygifGyND60coikaKrMktv2OLOLEl8AudLp0ZNA +oOoYJZqfUnQqaLt0dNmNa5OtzYjf7f6bYX0V8XLTHlFqZ6QzqYGFMPNhDYjqtet6d--Q8t7_5S5C +RfXP8Wh8CjbEh2_rsr9rvy1nhM_Cptxc0BFXcS5Dt_R4vjd2G4B_LEC4Hy1s_rZThzUVxRCl \ No newline at end of file diff --git a/cmso-optimizer/src/main/resources/aaf/org.onap.oof.location.props b/cmso-optimizer/src/main/resources/aaf/org.onap.oof.location.props new file mode 100644 index 0000000..d4a48df --- /dev/null +++ b/cmso-optimizer/src/main/resources/aaf/org.onap.oof.location.props @@ -0,0 +1,8 @@ +############################################################ +# Properties Generated by AT&T Certificate Manager +# by root +# on 2019-02-15T21:01:19.861+0000 +# @copyright 2016, AT&T +############################################################ +cadi_latitude=0.00 +cadi_longitude=0.00 diff --git a/cmso-optimizer/src/main/resources/aaf/org.onap.oof.props b/cmso-optimizer/src/main/resources/aaf/org.onap.oof.props new file mode 100644 index 0000000..766c354 --- /dev/null +++ b/cmso-optimizer/src/main/resources/aaf/org.onap.oof.props @@ -0,0 +1,14 @@ +############################################################ +# Properties Generated by AT&T Certificate Manager +# by root +# on 2019-02-15T21:01:19.866+0000 +# @copyright 2016, AT&T +############################################################ +aaf_id=oof@oof.onap.org +aaf_locate_url=https://aaf-onap-test.osaaf.org:8095 +aaf_url=https://AAF_LOCATE_URL/AAF_NS.service:2.1 +cadi_etc_dir=etc/config +cadi_latitude=0.00 +cadi_longitude=0.00 +cadi_prop_files=src/main/resources/aaf/org.onap.oof.location.props;src/main/resources/aaf/org.onap.oof.cred.props +cm_url=https://AAF_LOCATE_URL/AAF_NS.cm:2.1 diff --git a/cmso-optimizer/src/main/resources/aaf/permissions.properties b/cmso-optimizer/src/main/resources/aaf/permissions.properties new file mode 100644 index 0000000..85d3e3c --- /dev/null +++ b/cmso-optimizer/src/main/resources/aaf/permissions.properties @@ -0,0 +1,2 @@ +permission.type=org.onap.oof +permission.instance=* \ No newline at end of file diff --git a/cmso-optimizer/src/main/resources/application.properties b/cmso-optimizer/src/main/resources/application.properties new file mode 100644 index 0000000..a22df14 --- /dev/null +++ b/cmso-optimizer/src/main/resources/application.properties @@ -0,0 +1,49 @@ +#------------------------------------------------------------------------------- +# ============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================================================= +# +#------------------------------------------------------------------------------- + +info.build.artifact=@project.artifactId@ +info.build.name=@project.name@ +info.build.description=@project.description@ +info.build.version=@project.version@ + +spring.jersey.type=filter +spring.mvc.urls=swagger,docs,prometheus +server.servlet.context-path=/optimizer +spring.main.allow-bean-definition-overriding=true + +#This property is used to set the Tomcat connector attributes.developers can define multiple attributes separated by comma +#tomcat.connector.attributes=allowTrace-true + +#The max number of active threads in this pool +server.tomcat.max-threads=200 + +#The minimum number of threads always kept alive +server.tomcat.min-spare-threads=25 + +# External API port +server.port=7997 + +kubernetes.namespace=org.onap.optf.cmso + + +com.att.eelf.logging.file=logback.xml +com.att.eelf.logging.path= + +logging.config= +spring.profiles.active=proprietary-auth diff --git a/cmso-optimizer/src/main/resources/banner.txt b/cmso-optimizer/src/main/resources/banner.txt new file mode 100644 index 0000000..ecb0dd9 --- /dev/null +++ b/cmso-optimizer/src/main/resources/banner.txt @@ -0,0 +1,10 @@ +#----------------------------------------------------------- + ____ ____ ____________ ________ ________ ____ + / __ \/ __ \/_ __/ ____/ / ____/ |/ / ___// __ \ + / / / / /_/ / / / / /_ / / / /|_/ /\__ \/ / / / + / /_/ / ____/ / / / __/ / /___/ / / /___/ / /_/ / + \____/_/ /_/ /_/ \____/_/ /_//____/\____/ + +${archetype.name}-Version:${archetype.version} + +#----------------------------------------------------------- \ No newline at end of file diff --git a/cmso-optimizer/src/main/resources/logmessages.properties b/cmso-optimizer/src/main/resources/logmessages.properties index 9961749..2c7a32c 100644 --- a/cmso-optimizer/src/main/resources/logmessages.properties +++ b/cmso-optimizer/src/main/resources/logmessages.properties @@ -25,3 +25,4 @@ DUPLICATE_REQUEST_ID DUPLICATE_REQUEST_ID|Request id {0} already exists|No resol TOPOLOGY_REQUEST TOPOLOGY_REQUEST|Topology request {0} for {1} URL: {1}|No resolution needed|No action is required OPTIMIZER_REQUEST OPTIMIZER_REQUEST|OPtimizer request {0} for {1} Command: {1}|No resolution needed|No action is required TICKETS_REQUEST TICKETS_REQUEST|Tickets request {0} for {1} URL: {1}|No resolution needed|No action is required +UNSUPPORTED_PERIODIC_TIME UNSUPPORTED_PERIODIC_TIME|Unsupported periodic time from policy: {0}|No resolution needed|No action is required diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/LogMessages.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/LogMessages.java index fd15b25..4ce4776 100644 --- a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/LogMessages.java +++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/LogMessages.java @@ -43,7 +43,7 @@ public enum LogMessages implements ObservationInterface { CREATE_TICKET("Create Ticket {0} : {1}: {2} : {3}", Status.OK, Level.INFO), CANCEL_TICKET("Cancel ticket {0} : {1}: {2} : {3}", Status.OK, Level.INFO), UPDATE_TICKET("Update ticket {0} : {1}: {2} : {3}", Status.OK, Level.INFO), - GET_ACTIVE_TICKETS("Get active tickets {0} : {1}: {2} : {3}", Status.OK, Level.INFO), + GET_CURRENT_TOPOLOGY("Get active tickets {0} : {1}: {2} : {3}", Status.OK, Level.INFO), SEARCH_TICKETS("Search tickets {0} : {1}: {2} : {3}", Status.OK, Level.INFO), TICKET_NOT_FOUND("Ticket not found id={0}", Status.NOT_FOUND, Level.INFO), diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/HealthCheckImpl.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/HealthCheckImpl.java index c1dfe81..a1bacb9 100644 --- a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/HealthCheckImpl.java +++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/HealthCheckImpl.java @@ -60,7 +60,7 @@ public class HealthCheckImpl implements HealthCheck { HealthCheckMessage hc = new HealthCheckMessage(); hc.setHealthy(true); - addToHealthCheckMessage(hc, this.healthCheckDb()); + //addToHealthCheckMessage(hc, this.healthCheckDb()); if (hc.getHealthy()) { response = Response.ok().entity(hc).build(); @@ -87,7 +87,7 @@ public class HealthCheckImpl implements HealthCheck { */ private HealthCheckComponent healthCheckDb() { HealthCheckComponent hcc = new HealthCheckComponent(); - hcc.setName("Ticket Management Database"); + hcc.setName("Database"); String url = env.getProperty("spring.datasource.url"); hcc.setUrl(url); try { diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/TopologyInterfaceImpl.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/TopologyInterfaceImpl.java index 6ed401f..c824d20 100644 --- a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/TopologyInterfaceImpl.java +++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/TopologyInterfaceImpl.java @@ -1,23 +1,23 @@ /* * 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 @@ -28,12 +28,16 @@ package org.onap.optf.cmso.topology.service.rs; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; +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; import org.onap.observations.Observation; import org.onap.optf.cmso.topology.common.LogMessages; +import org.onap.optf.cmso.topology.service.rs.models.ElementCriteria; +import org.onap.optf.cmso.topology.service.rs.models.ElementInfo; +import org.onap.optf.cmso.topology.service.rs.models.ElementLocation; import org.onap.optf.cmso.topology.service.rs.models.TopologyRequest; import org.onap.optf.cmso.topology.service.rs.models.TopologyResponse; import org.onap.optf.cmso.topology.service.rs.models.TopologyResponse.TopologyRequestStatus; @@ -60,12 +64,26 @@ public class TopologyInterfaceImpl implements TopologyInterface { public Response retrieveCurrentTopology(String apiVersion, TopologyRequest topologyRequest) { // TODO Auto-generated method stub String id = topologyRequest.getRequestId(); - Observation.report(LogMessages.GET_ACTIVE_TICKETS, "Received", request.getRemoteAddr(), id, ""); + Observation.report(LogMessages.GET_CURRENT_TOPOLOGY, "Received", request.getRemoteAddr(), id, ""); Response response = null; try { + // Only implementing synchronous responses for Dublin TopologyResponse atr = new TopologyResponse(); atr.setRequestId(topologyRequest.getRequestId()); atr.setStatus(TopologyRequestStatus.COMPLETED); + List elements = topologyRequest.getElements(); + // At a minimum, return the requested elements + for (ElementCriteria criteria : elements) + { + ElementInfo element = new ElementInfo(); + element.setElementId(criteria.getElementId()); + ElementLocation loc = new ElementLocation(); + loc.setLat(new Float(-0.00)); + loc.setLon(new Float(0.00)); + element.setElementLocation(loc); + atr.getElements().add(element); + } + response = Response.ok(atr).build(); // } catch (CMSException e) { // TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); @@ -76,7 +94,7 @@ public class TopologyInterfaceImpl implements TopologyInterface { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); response = Response.serverError().build(); } - Observation.report(LogMessages.GET_ACTIVE_TICKETS, "Returned", request.getRemoteAddr(), id, + Observation.report(LogMessages.GET_CURRENT_TOPOLOGY, "Returned", request.getRemoteAddr(), id, response.getStatusInfo().toString()); return response; } @@ -85,7 +103,7 @@ public class TopologyInterfaceImpl implements TopologyInterface { @Override public Response getTopologyRequest(String apiVersion, String id) { // TODO Auto-generated method stub - Observation.report(LogMessages.GET_ACTIVE_TICKETS, "Received", request.getRemoteAddr(), id, ""); + Observation.report(LogMessages.GET_CURRENT_TOPOLOGY, "Received", request.getRemoteAddr(), id, ""); Response response = null; try { TopologyResponse atr = new TopologyResponse(); @@ -101,7 +119,7 @@ public class TopologyInterfaceImpl implements TopologyInterface { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); response = Response.serverError().build(); } - Observation.report(LogMessages.GET_ACTIVE_TICKETS, "Returned", request.getRemoteAddr(), id, + Observation.report(LogMessages.GET_CURRENT_TOPOLOGY, "Returned", request.getRemoteAddr(), id, response.getStatusInfo().toString()); return response; } @@ -110,7 +128,7 @@ public class TopologyInterfaceImpl implements TopologyInterface { @Override public Response deleteTopologyRequest(String apiVersion, String id) { // TODO Auto-generated method stub - Observation.report(LogMessages.GET_ACTIVE_TICKETS, "Received", request.getRemoteAddr(), id, ""); + Observation.report(LogMessages.GET_CURRENT_TOPOLOGY, "Received", request.getRemoteAddr(), id, ""); Response response = null; try { response = Response.noContent().build(); @@ -123,7 +141,7 @@ public class TopologyInterfaceImpl implements TopologyInterface { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); response = Response.serverError().build(); } - Observation.report(LogMessages.GET_ACTIVE_TICKETS, "Returned", request.getRemoteAddr(), id, + Observation.report(LogMessages.GET_CURRENT_TOPOLOGY, "Returned", request.getRemoteAddr(), id, response.getStatusInfo().toString()); return response; } diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/models/TopologyResponse.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/models/TopologyResponse.java index d22b64a..fc4f7df 100644 --- a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/models/TopologyResponse.java +++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/service/rs/models/TopologyResponse.java @@ -42,7 +42,7 @@ public class TopologyResponse implements Serializable { private static EELFLogger log = EELFManager.getInstance().getLogger(TopologyResponse.class); public enum TopologyRequestStatus { - IN_PROGRESS, COMPLETED, + IN_PROGRESS, COMPLETED, FAILED } @ApiModelProperty(value = "Unique Id of the request") @@ -58,6 +58,9 @@ public class TopologyResponse implements Serializable { + "If IN_PROGRESS is returned, the optimizer will enter asynchronous polling mode.") private TopologyRequestStatus status; + @ApiModelProperty(value = "FAILED request error message.") + private String errorMessage; + @ApiModelProperty(value = "If request is asynchronous (IN_PROGRESS), suggested interval to the next poll.") private Integer pollingSeconds; @@ -101,6 +104,14 @@ public class TopologyResponse implements Serializable { this.referencedElements = referencedElements; } + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + /** * To string. * diff --git a/cmso-topology/src/main/resources/logmessages.properties b/cmso-topology/src/main/resources/logmessages.properties index de09032..8e20de6 100644 --- a/cmso-topology/src/main/resources/logmessages.properties +++ b/cmso-topology/src/main/resources/logmessages.properties @@ -1,9 +1,9 @@ -# Generated from org.onap.optf.ticketmgt.common.LogMessages +# Generated from org.onap.optf.cmso.topology.common.LogMessages FETCH_TICKET FETCH_TICKET|Fetch ticket {0} : {1}: {2} : {3}|No resolution needed|No action is required CREATE_TICKET CREATE_TICKET|Create Ticket {0} : {1}: {2} : {3}|No resolution needed|No action is required CANCEL_TICKET CANCEL_TICKET|Cancel ticket {0} : {1}: {2} : {3}|No resolution needed|No action is required UPDATE_TICKET UPDATE_TICKET|Update ticket {0} : {1}: {2} : {3}|No resolution needed|No action is required -GET_ACTIVE_TICKETS GET_ACTIVE_TICKETS|Get active tickets {0} : {1}: {2} : {3}|No resolution needed|No action is required +GET_CURRENT_TOPOLOGY GET_CURRENT_TOPOLOGY|Get active tickets {0} : {1}: {2} : {3}|No resolution needed|No action is required SEARCH_TICKETS SEARCH_TICKETS|Search tickets {0} : {1}: {2} : {3}|No resolution needed|No action is required TICKET_NOT_FOUND TICKET_NOT_FOUND|Ticket not found id={0}|No resolution needed|No action is required INVALID_ATTRIBUTE INVALID_ATTRIBUTE|Invalid attribute {0}={1}|No resolution needed|No action is required -- cgit 1.2.3-korg