+++ /dev/null
-/*
- * 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;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.onap.optf.cmso.optimizer.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<String, Object>();
- map.put("spring.datasource.password", pwd);
- MapPropertySource propertySource = new MapPropertySource("abc", map);
- MutablePropertySources proeprtySources = environment.getPropertySources();
- proeprtySources.addLast(propertySource);
- }
- }
-
-}
+++ /dev/null
-org.springframework.boot.env.EnvironmentPostProcessor=org.onap.optf.cmso.optimizer.CmsoEnvironmentPostProcessor
\ No newline at end of file
GLOBAL_OPTIMIZER_USER = "oof@oof.onap.org"
GLOBAL_OPTIMIZER_PASSWORD = "demo123456!"
+GLOBAL_TICKET_MGT_URL = "http://127.0.0.1:7999"
+GLOBAL_TICKET_MGT_USER = "oof@oof.onap.org"
+GLOBAL_TICKET_MGT_PASSWORD = "demo123456!"
+
+GLOBAL_TOPOLOGY_URL = "http://127.0.0.1:7998"
+GLOBAL_TOPOLOGY_USER = "oof@oof.onap.org"
+GLOBAL_TOPOLOGY_PASSWORD = "demo123456!"
+
GLOBAL_CALLBACK_USERID = "onap-user"
GLOBAL_CALLBACK_PASSWORD = "onap-user"
Get Optimizer
[Documentation] Runs a scheduler GET request
- [Arguments] ${alias} ${resource}
+ [Arguments] ${alias} ${resource} ${accept}=application/json
${data_path}= Catenate ${OPTIMIZER_PATH}/${resource}
${url}= Catenate ${GLOBAL_OPTIMIZER_URL}
${uuid}= Generate UUID
${proxies}= Create Dictionary no=pass
${session}= Create Session ${alias} ${url}
${auth_string}= B64 Encode ${GLOBAL_OPTIMIZER_USER}:${GLOBAL_OPTIMIZER_PASSWORD}
- ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} Authorization=Basic ${auth_string}
+ ${headers}= Create Dictionary Accept=${accept} Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} Authorization=Basic ${auth_string}
${resp}= Get Request ${alias} ${data_path} headers=${headers}
Log Received response from scheduler ${resp.json()}
[Return] ${resp}
+
+Get Optimizer Plain Text
+ [Documentation] Runs a scheduler GET request
+ [Arguments] ${alias} ${resource} ${accept}=text/plain
+ ${data_path}= Catenate ${OPTIMIZER_PATH}/${resource}
+ ${url}= Catenate ${GLOBAL_OPTIMIZER_URL}
+ ${uuid}= Generate UUID
+ ${proxies}= Create Dictionary no=pass
+ ${session}= Create Session ${alias} ${url}
+ ${auth_string}= B64 Encode ${GLOBAL_OPTIMIZER_USER}:${GLOBAL_OPTIMIZER_PASSWORD}
+ ${headers}= Create Dictionary Accept=${accept} Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} Authorization=Basic ${auth_string}
+ ${resp}= Get Request ${alias} ${data_path} headers=${headers}
+ Log Received response from scheduler ${resp.text}
+ [Return] ${resp}
${valid}= Split String ${valid_status_codes}
Validate Status ${resp} ${valid}
[Return] ${resp}
+
+Get Scheduler Plain Text
+ [Documentation] Runs a scheduler GET request
+ [Arguments] ${alias} ${data_path}
+ ${url}= Catenate ${GLOBAL_SCHEDULER_URL}
+ ${uuid}= Generate UUID
+ ${proxies}= Create Dictionary no=pass
+ ${session}= Create Session ${alias} ${url}
+ ${auth_string}= B64 Encode ${GLOBAL_SCHEDULER_USER}:${GLOBAL_SCHEDULER_PASSWORD}
+ ${headers}= Create Dictionary Accept=text/plain Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} Authorization=Basic ${auth_string}
+ ${resp}= Get Request ${alias} ${data_path} headers=${headers}
+ Log Received response from scheduler ${resp.text}
+ [Return] ${resp}
--- /dev/null
+*** Settings ***
+Documentation The private interface for interacting with Openstack. It handles low level stuff like managing the authtoken and Openstack required fields
+
+Library Collections
+Library RequestsLibrary
+Library UUID
+Library HTTPUtils
+Library String
+Resource misc.robot
+*** Variables ***
+*** Variables ***
+${TICKET_MGT_PATH} /ticketmgt/v1
+#**************** Test Case Variables ******************
+
+*** Keywords ***
+
+
+Post Ticket Mgt
+ [Documentation] Runs a scheduler POST request
+ [Arguments] ${alias} ${resource} ${data}={}
+ ${data_path}= Catenate ${TICKET_MGT_PATH}/${resource}
+ ${url}= Catenate ${GLOBAL_TICKET_MGT_URL}
+ ${uuid}= Generate UUID
+ ${proxies}= Create Dictionary no=pass
+ ${session}= Create Session ${alias} ${url}
+ ${auth_string}= B64 Encode ${GLOBAL_TICKET_MGT_USER}:${GLOBAL_TICKET_MGT_PASSWORD}
+ ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} Authorization=Basic ${auth_string}
+ ${resp}= Post Request ${alias} ${data_path} headers=${headers} data=${data}
+ Log Received response from scheduler ${resp.text}
+ [Return] ${resp}
+
+Delete Ticket Mgt
+ [Documentation] Runs a scheduler DELETE request (this may need to be changed for 1802 US change Delete schedule to Cancel Schedule)
+ [Arguments] ${alias} ${resource}
+ ${data_path}= Catenate ${TICKET_MGT_PATH}/${resource}
+ ${url}= Catenate ${GLOBAL_TICKET_MGT_URL}
+ ${uuid}= Generate UUID
+ ${proxies}= Create Dictionary no=pass
+ ${session}= Create Session ${alias} ${url}
+ ${auth_string}= B64 Encode ${GLOBAL_TICKET_MGT_USER}:${GLOBAL_TICKET_MGT_PASSWORD}
+ ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} Authorization=Basic ${auth_string}
+ ${resp}= Delete Request ${alias} ${data_path} headers=${headers}
+ Log Received response from scheduler ${resp.text}
+ [Return] ${resp}
+
+Get Ticket Mgt
+ [Documentation] Runs a scheduler GET request
+ [Arguments] ${alias} ${resource}
+ ${data_path}= Catenate ${TICKET_MGT_PATH}/${resource}
+ ${url}= Catenate ${GLOBAL_TICKET_MGT_URL}
+ ${uuid}= Generate UUID
+ ${proxies}= Create Dictionary no=pass
+ ${session}= Create Session ${alias} ${url}
+ ${auth_string}= B64 Encode ${GLOBAL_TICKET_MGT_USER}:${GLOBAL_TICKET_MGT_PASSWORD}
+ ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} Authorization=Basic ${auth_string}
+ ${resp}= Get Request ${alias} ${data_path} headers=${headers}
+ Log Received response from scheduler ${resp.json()}
+ [Return] ${resp}
+
+Get Ticket Mgt Plain Text
+ [Documentation] Runs a scheduler GET request
+ [Arguments] ${alias} ${resource}
+ ${data_path}= Catenate ${TICKET_MGT_PATH}/${resource}
+ ${url}= Catenate ${GLOBAL_TICKET_MGT_URL}
+ ${uuid}= Generate UUID
+ ${proxies}= Create Dictionary no=pass
+ ${session}= Create Session ${alias} ${url}
+ ${auth_string}= B64 Encode ${GLOBAL_TICKET_MGT_USER}:${GLOBAL_TICKET_MGT_PASSWORD}
+ ${headers}= Create Dictionary Accept=text/plain Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} Authorization=Basic ${auth_string}
+ ${resp}= Get Request ${alias} ${data_path} headers=${headers}
+ Log Received response from scheduler ${resp.text}
+ [Return] ${resp}
--- /dev/null
+*** Settings ***
+Documentation The private interface for interacting with Openstack. It handles low level stuff like managing the authtoken and Openstack required fields
+
+Library Collections
+Library RequestsLibrary
+Library UUID
+Library HTTPUtils
+Library String
+Resource misc.robot
+*** Variables ***
+*** Variables ***
+${TOPOLOGY_PATH} /topology/v1
+#**************** Test Case Variables ******************
+
+*** Keywords ***
+
+
+Post Topology
+ [Documentation] Runs a scheduler POST request
+ [Arguments] ${alias} ${resource} ${data}={}
+ ${data_path}= Catenate ${TOPOLOGY_PATH}/${resource}
+ ${url}= Catenate ${GLOBAL_TOPOLOGY_URL}
+ ${uuid}= Generate UUID
+ ${proxies}= Create Dictionary no=pass
+ ${session}= Create Session ${alias} ${url}
+ ${auth_string}= B64 Encode ${GLOBAL_TOPOLOGY_USER}:${GLOBAL_TOPOLOGY_PASSWORD}
+ ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} Authorization=Basic ${auth_string}
+ ${resp}= Post Request ${alias} ${data_path} headers=${headers} data=${data}
+ Log Received response from scheduler ${resp.text}
+ [Return] ${resp}
+
+Delete Topology
+ [Documentation] Runs a scheduler DELETE request (this may need to be changed for 1802 US change Delete schedule to Cancel Schedule)
+ [Arguments] ${alias} ${resource}
+ ${data_path}= Catenate ${TOPOLOGY_PATH}/${resource}
+ ${url}= Catenate ${GLOBAL_TOPOLOGY_URL}
+ ${uuid}= Generate UUID
+ ${proxies}= Create Dictionary no=pass
+ ${session}= Create Session ${alias} ${url}
+ ${auth_string}= B64 Encode ${GLOBAL_TOPOLOGY_USER}:${GLOBAL_TOPOLOGY_PASSWORD}
+ ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} Authorization=Basic ${auth_string}
+ ${resp}= Delete Request ${alias} ${data_path} headers=${headers}
+ Log Received response from scheduler ${resp.text}
+ [Return] ${resp}
+
+Get Topology
+ [Documentation] Runs a scheduler GET request
+ [Arguments] ${alias} ${resource}
+ ${data_path}= Catenate ${TOPOLOGY_PATH}/${resource}
+ ${url}= Catenate ${GLOBAL_TOPOLOGY_URL}
+ ${uuid}= Generate UUID
+ ${proxies}= Create Dictionary no=pass
+ ${session}= Create Session ${alias} ${url}
+ ${auth_string}= B64 Encode ${GLOBAL_TOPOLOGY_USER}:${GLOBAL_TOPOLOGY_PASSWORD}
+ ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} Authorization=Basic ${auth_string}
+ ${resp}= Get Request ${alias} ${data_path} headers=${headers}
+ Log Received response from scheduler ${resp.json()}
+ [Return] ${resp}
+
+Get Topology Plain Text
+ [Documentation] Runs a scheduler GET request
+ [Arguments] ${alias} ${resource}
+ ${data_path}= Catenate ${TOPOLOGY_PATH}/${resource}
+ ${url}= Catenate ${GLOBAL_TOPOLOGY_URL}
+ ${uuid}= Generate UUID
+ ${proxies}= Create Dictionary no=pass
+ ${session}= Create Session ${alias} ${url}
+ ${auth_string}= B64 Encode ${GLOBAL_TOPOLOGY_USER}:${GLOBAL_TOPOLOGY_PASSWORD}
+ ${headers}= Create Dictionary Accept=text/plain Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} Authorization=Basic ${auth_string}
+ ${resp}= Get Request ${alias} ${data_path} headers=${headers}
+ Log Received response from scheduler ${resp.text}
+ [Return] ${resp}
Library StringTemplater
Library UUID
+Library Collections
-Resource ../resources/test_templates/change_management.robot
-Resource ../resources/test_templates/check_logs.robot
+Resource ../resources/optimizer_common.robot
+Resource ../resources/scheduler_common.robot
+Resource ../resources/ticketmgt_common.robot
+Resource ../resources/topology_common.robot
# Test Setup
# Test Teardown
${uuid_list_file}= robot/assets/get_schedule_UUIDs.txt
${template_folder}= robot/assets/templates/changemanagement
*** Test Cases ***
-Get Schedule
- Get Schedule Test Template ${uuid_list_file}
+Test CMSO Optimizer Admin
+ [Tags] ete
+ ${response}= Get Optimizer Plain Text alias admin/password
+ Should Contain ${response.text} kECFDaLusYNHTN6Q4DmsYw==
-Post Existing Immediate Schedule
- Change Management Already Exists Immediate Template OneVnfImmediateReplaceVNFInfra.json.template ${template_folder}
+Test CMSO Service Admin
+ [Tags] ete
+ ${response}= Get Scheduler Plain Text alias /cmso/v1/admin/password
+ Should Contain ${response.text} kECFDaLusYNHTN6Q4DmsYw==
+Test CMSO Ticket Mgt Admin
+ [Tags] ete
+ ${response}= Get Ticket Mgt Plain Text alias admin/password
+ Should Contain ${response.text} kECFDaLusYNHTN6Q4DmsYw==
+
+Test CMSO Topology Admin
+ [Tags] ete
+ ${response}= Get Topology Plain Text alias admin/password
+ Should Contain ${response.text} kECFDaLusYNHTN6Q4DmsYw==
+
+Test CMSO Optimizer Health
+ [Tags] ete
+ ${response}= Get Optimizer alias health
+ Dictionary Should Contain Item ${response.json()} healthy True
+
+Test CMSO Service Health
+ [Tags] ete
+ ${response}= Get Scheduler alias /cmso/v1/health
+ Dictionary Should Contain Item ${response.json()} healthy True
+
+
+Test CMSO Ticket Mgt Health
+ [Tags] ete
+ ${response}= Get Ticket Mgt alias health
+ Dictionary Should Contain Item ${response.json()} healthy True
+
+
+Test CMSO Topology Health
+ [Tags] ete
+ ${response}= Get Topology alias health
+ Dictionary Should Contain Item ${response.json()} healthy True
+
+++ /dev/null
-/*\r
- * ============LICENSE_START=======================================================================================\r
- * Copyright (c) 2019 AT&T Intellectual Property.\r
- * ===================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance\r
- * with the License. You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\r
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS\r
- * OF ANY KIND, either express or implied. See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================================================\r
- *\r
- ******************************************************************************/\r
-\r
-package org.onap.optf.cmso;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import org.onap.optf.cmso.common.PropertiesManagement;\r
-import org.springframework.boot.SpringApplication;\r
-import org.springframework.boot.env.EnvironmentPostProcessor;\r
-import org.springframework.core.env.ConfigurableEnvironment;\r
-import org.springframework.core.env.MapPropertySource;\r
-import org.springframework.core.env.MutablePropertySources;\r
-\r
-public class CmsoEnvironmentPostProcessor implements EnvironmentPostProcessor {\r
- // TODO tested in ONAP springboot and this is called before all of the properties files have been\r
- // loaded...\r
- // perhaps there is a post post processor? Until this works. DB password will be in the clear in the\r
- // proeprties files.\r
- @Override\r
- public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {\r
- String pwd = environment.getProperty("cmso.database.password");\r
- if (pwd != null) {\r
- pwd = PropertiesManagement.getDecryptedValue(pwd);\r
- Map<String, Object> map = new HashMap<>();\r
- map.put("spring.datasource.password", pwd);\r
- MapPropertySource propertySource = new MapPropertySource("abc", map);\r
- MutablePropertySources proeprtySources = environment.getPropertySources();\r
- proeprtySources.addLast(propertySource);\r
- }\r
- }\r
-\r
-}\r
import org.onap.optf.cmso.dispatcher.rs.DispatcherServiceImpl;\r
import org.onap.optf.cmso.filters.CmsoContainerFilters;\r
import org.onap.optf.cmso.service.rs.AdminToolImpl;\r
-import org.onap.optf.cmso.service.rs.CmsoOptimizerCallbackImpl;\r
import org.onap.optf.cmso.service.rs.CmsoServiceImpl;\r
import org.onap.optf.cmso.service.rs.HealthCheckImpl;\r
import org.onap.optf.cmso.test.loopback.SchedulerTestLoopbackServiceImpl;\r
@Autowired\r
public JerseyConfiguration( /* LogRequestFilter lrf */ ) {\r
register(CmsoServiceImpl.class);\r
- register(CmsoOptimizerCallbackImpl.class);\r
register(SchedulerTestLoopbackServiceImpl.class);\r
register(TicketMgtLoopbackServiceImpl.class);\r
register(HealthCheckImpl.class);\r
+++ /dev/null
-/*\r
- * Copyright � 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright � 2018 IBM.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * \r
- * \r
- * Unless otherwise specified, all documentation contained herein is licensed\r
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
- * you may not use this documentation except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * https://creativecommons.org/licenses/by/4.0/\r
- * \r
- * Unless required by applicable law or agreed to in writing, documentation\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
-*/\r
-\r
-package org.onap.optf.cmso.optimizer.bean;\r
-\r
-public class CmsoOptimizerRequest {\r
-\r
- /*\r
- * \r
- * { "schedulingInfo": { "scheduleId": "CM-<__SCHEDULE ID__>", "startTime":\r
- * "2017-02-15T00:00:00+05:00", "endTime": "2017-02-18T23:59:00+05:00",\r
- * "normalDurationInSecs": 60, "additionalDurationInSecs": 0, // for backout\r
- * "concurrencyLimit": 10, "policyId": ["SNIRO.TimeLimitAndVerticalTopology"],\r
- * "vnfDetails": [{ “node�?: "satmo415vbc", “groupId�?: “group1�?//optional }, {\r
- * “node�?: "satmo415vbc", “groupId�?: “group1�?//optional }] }, "requestInfo": {\r
- * “transactionId�?: �?__TRANSACTIONID__�?, //logging "requestId":\r
- * "CM-<__SCHEDULE ID__>", "sourceId": "cm-portal", “optimizer�?: [“scheduling�?],\r
- * "callbackUrl": "http://callbackurl.onap.org:8080/callback" } }\r
- * \r
- */\r
-\r
- private CmsoSchedulingInfo schedulingInfo;\r
- private CmsoRequestInfo requestInfo;\r
-\r
- public CmsoOptimizerRequest() {\r
- schedulingInfo = new CmsoSchedulingInfo();\r
- requestInfo = new CmsoRequestInfo();\r
- }\r
-\r
- public CmsoSchedulingInfo getSchedulingInfo() {\r
- return schedulingInfo;\r
- }\r
-\r
- public void setSchedulingInfo(CmsoSchedulingInfo schedulingInfo) {\r
- this.schedulingInfo = schedulingInfo;\r
- }\r
-\r
- public CmsoRequestInfo getRequestInfo() {\r
- return requestInfo;\r
- }\r
-\r
- public void setRequestInfo(CmsoRequestInfo requestInfo) {\r
- this.requestInfo = requestInfo;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * \r
- * \r
- * Unless otherwise specified, all documentation contained herein is licensed\r
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
- * you may not use this documentation except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * https://creativecommons.org/licenses/by/4.0/\r
- * \r
- * Unless required by applicable law or agreed to in writing, documentation\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
-*/\r
-\r
-package org.onap.optf.cmso.optimizer.bean;\r
-\r
-import io.swagger.annotations.ApiModel;\r
-import io.swagger.annotations.ApiModelProperty;\r
-\r
-@ApiModel(value = "Response from schedule optimizer",\r
- description = "Asynchronous response to schedule oprimizer request.")\r
-public class CmsoOptimizerResponse {\r
-\r
- /*\r
- * \r
- * { "transactionId": "dummy-transaction-id",\r
- * "scheduleId":"CM-<__SCHEDULE ID__>", "requestState": "complete", "status":\r
- * "Optimal", // diagnostic code "description": "Optimal solution found", //\r
- * diagnostic code "schedule": [ { "groupId": "grp06", "startTime":\r
- * "2016-10-01T00:30:00+05:00", // starting time for this group (In 1707,\r
- * seconds will always be zero but there is no reason to hardcode that decision)\r
- * "finishTime": "2016-10-01T00:40:00+05:00", // endtime for this group\r
- * (including failover) "latestInstanceStartTime": "2016-10-01T00:38:00Z", //\r
- * latest time when an instance of this group can be started "node": [ "up01",\r
- * "up03", "up09" ] // list of instances for this group. } ] }\r
- * \r
- */\r
-\r
- @ApiModelProperty(value = "Unique id of optimization request.")\r
- private String transactionId;\r
-\r
- @ApiModelProperty(value = "Schedule id for which the optimization request was executed.")\r
- private String scheduleId;\r
-\r
- @ApiModelProperty(value = "State of the request as reported by the optimizer.")\r
- private String requestState;\r
-\r
- @ApiModelProperty(value = "Status of the request.")\r
- private String status;\r
-\r
- @ApiModelProperty(value = "Description of the request status.")\r
- private String description;\r
-\r
- @ApiModelProperty(value = "List of schedules returned, one per group. Only 1 group supported at this time.")\r
- private CmsoSchedule[] schedule;\r
-\r
- public CmsoOptimizerResponse() {}\r
-\r
- public String getTransactionId() {\r
- return transactionId;\r
- }\r
-\r
- public void setTransactionId(String transactionId) {\r
- this.transactionId = transactionId;\r
- }\r
-\r
- public String getScheduleId() {\r
- return scheduleId;\r
- }\r
-\r
- public void setScheduleId(String scheduleId) {\r
- this.scheduleId = scheduleId;\r
- }\r
-\r
- public String getRequestState() {\r
- return requestState;\r
- }\r
-\r
- public void setRequestState(String requestState) {\r
- this.requestState = requestState;\r
- }\r
-\r
- public String getDescription() {\r
- return description;\r
- }\r
-\r
- public void setDescription(String description) {\r
- this.description = description;\r
- }\r
-\r
- public String getStatus() {\r
- return status;\r
- }\r
-\r
- public void setStatus(String status) {\r
- this.status = status;\r
- }\r
-\r
- public CmsoSchedule[] getSchedule() {\r
- return schedule;\r
- }\r
-\r
- public void setSchedule(CmsoSchedule[] schedule) {\r
- this.schedule = schedule;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright � 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright � 2018 IBM.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * \r
- * \r
- * Unless otherwise specified, all documentation contained herein is licensed\r
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
- * you may not use this documentation except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * https://creativecommons.org/licenses/by/4.0/\r
- * \r
- * Unless required by applicable law or agreed to in writing, documentation\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
-*/\r
-\r
-package org.onap.optf.cmso.optimizer.bean;\r
-\r
-public class CmsoRequestInfo {\r
- private String transactionId;\r
- private String requestId;\r
- private String sourceId;\r
- private String[] optimizer;\r
- private String callbackUrl;\r
-\r
- public CmsoRequestInfo() {}\r
-\r
- public String getTransactionId() {\r
- return transactionId;\r
- }\r
-\r
- public void setTransactionId(String transactionId) {\r
- this.transactionId = transactionId;\r
- }\r
-\r
- public String getRequestId() {\r
- return requestId;\r
- }\r
-\r
- public void setRequestId(String requestId) {\r
- this.requestId = requestId;\r
- }\r
-\r
- public String getSourceId() {\r
- return sourceId;\r
- }\r
-\r
- public void setSourceId(String sourceId) {\r
- this.sourceId = sourceId;\r
- }\r
-\r
- public String[] getOptimizer() {\r
- return optimizer;\r
- }\r
-\r
- public void setOptimizer(String[] optimizer) {\r
- this.optimizer = optimizer;\r
- }\r
-\r
- public String getCallbackUrl() {\r
- return callbackUrl;\r
- }\r
-\r
- public void setCallbackUrl(String callbackUrl) {\r
- this.callbackUrl = callbackUrl;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright � 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright � 2018 IBM.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * \r
- * \r
- * Unless otherwise specified, all documentation contained herein is licensed\r
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
- * you may not use this documentation except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * https://creativecommons.org/licenses/by/4.0/\r
- * \r
- * Unless required by applicable law or agreed to in writing, documentation\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
-*/\r
-\r
-package org.onap.optf.cmso.optimizer.bean;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-public class CmsoSchedule {\r
- private String groupId;\r
- private String startTime;\r
- private String finishTime;\r
- private String latestInstanceStartTime;\r
- private List<String> node;\r
-\r
- public CmsoSchedule() {\r
- node = new ArrayList<String>();\r
- }\r
-\r
- public String getGroupId() {\r
- return groupId;\r
- }\r
-\r
- public void setGroupId(String groupId) {\r
- this.groupId = groupId;\r
- }\r
-\r
- public String getStartTime() {\r
- return startTime;\r
- }\r
-\r
- public void setStartTime(String startTime) {\r
- this.startTime = startTime;\r
- }\r
-\r
- public String getFinishTime() {\r
- return finishTime;\r
- }\r
-\r
- public void setFinishTime(String finishTime) {\r
- this.finishTime = finishTime;\r
- }\r
-\r
- public String getLatestInstanceStartTime() {\r
- return latestInstanceStartTime;\r
- }\r
-\r
- public void setLatestInstanceStartTime(String latestInstanceStartTime) {\r
- this.latestInstanceStartTime = latestInstanceStartTime;\r
- }\r
-\r
- public List<String> getNode() {\r
- return node;\r
- }\r
-\r
- public void setNode(List<String> node) {\r
- this.node = node;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright � 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright � 2018 IBM.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * \r
- * \r
- * Unless otherwise specified, all documentation contained herein is licensed\r
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
- * you may not use this documentation except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * https://creativecommons.org/licenses/by/4.0/\r
- * \r
- * Unless required by applicable law or agreed to in writing, documentation\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
-*/\r
-\r
-package org.onap.optf.cmso.optimizer.bean;\r
-\r
-public class CmsoSchedulingInfo {\r
- private String scheduleId;\r
- private String startTime;\r
- private String endTime;\r
- private int normalDurationInSecs;\r
- private int additionalDurationInSecs;\r
- private int concurrencyLimit;\r
- private String[] policyId;\r
- private CmsoVnfDetails[] vnfDetails;\r
-\r
- public CmsoSchedulingInfo() {}\r
-\r
- public String getScheduleId() {\r
- return scheduleId;\r
- }\r
-\r
- public void setScheduleId(String scheduleId) {\r
- this.scheduleId = scheduleId;\r
- }\r
-\r
- public String getStartTime() {\r
- return startTime;\r
- }\r
-\r
- public void setStartTime(String startTime) {\r
- this.startTime = startTime;\r
- }\r
-\r
- public String getEndTime() {\r
- return endTime;\r
- }\r
-\r
- public void setEndTime(String endTime) {\r
- this.endTime = endTime;\r
- }\r
-\r
- public int getNormalDurationInSecs() {\r
- return normalDurationInSecs;\r
- }\r
-\r
- public void setNormalDurationInSecs(int normalDurationInSecs) {\r
- this.normalDurationInSecs = normalDurationInSecs;\r
- }\r
-\r
- public int getAdditionalDurationInSecs() {\r
- return additionalDurationInSecs;\r
- }\r
-\r
- public void setAdditionalDurationInSecs(int additionalDurationInSecs) {\r
- this.additionalDurationInSecs = additionalDurationInSecs;\r
- }\r
-\r
- public int getConcurrencyLimit() {\r
- return concurrencyLimit;\r
- }\r
-\r
- public void setConcurrencyLimit(int concurrencyLimit) {\r
- this.concurrencyLimit = concurrencyLimit;\r
- }\r
-\r
- public String[] getPolicyId() {\r
- return policyId;\r
- }\r
-\r
- public void setPolicyId(String[] policyId) {\r
- this.policyId = policyId;\r
- }\r
-\r
- public CmsoVnfDetails[] getVnfDetails() {\r
- return vnfDetails;\r
- }\r
-\r
- public void setVnfDetails(CmsoVnfDetails[] vnfDetails) {\r
- this.vnfDetails = vnfDetails;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright � 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright � 2018 IBM.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * \r
- * \r
- * Unless otherwise specified, all documentation contained herein is licensed\r
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
- * you may not use this documentation except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * https://creativecommons.org/licenses/by/4.0/\r
- * \r
- * Unless required by applicable law or agreed to in writing, documentation\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
-*/\r
-\r
-package org.onap.optf.cmso.optimizer.bean;\r
-\r
-public class CmsoVnfDetails {\r
- private String node;\r
- private String groupId;\r
-\r
- public CmsoVnfDetails() {}\r
-\r
- public CmsoVnfDetails(String groupId) {\r
- this.groupId = groupId;\r
- }\r
-\r
- public String getNode() {\r
- return node;\r
- }\r
-\r
- public void setNode(String node) {\r
- this.node = node;\r
- }\r
-\r
- public String getGroupId() {\r
- return groupId;\r
- }\r
-\r
- public void setGroupId(String groupId) {\r
- this.groupId = groupId;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*
- * 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);
-
-}
+++ /dev/null
-/*
- * 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);
- }
-
-}
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;
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);
}
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);
+ }
+
}
import org.onap.observations.Observation;\r
import org.onap.optf.cmso.common.LogMessages;\r
import org.onap.optf.cmso.common.PropertiesManagement;\r
+import org.onap.optf.cmso.common.exceptions.CmsoException;\r
import org.onap.optf.cmso.optimizer.model.OptimizerElementInfo;\r
import org.onap.optf.cmso.optimizer.model.OptimizerRequest;\r
import org.onap.optf.cmso.optimizer.model.OptimizerResponse;\r
import org.onap.optf.cmso.optimizer.model.ScheduledElement;\r
import org.onap.optf.cmso.optimizer.model.ScheduledElement.ScheduleType;\r
import org.onap.optf.cmso.optimizer.model.UnScheduledElement;\r
-import org.onap.optf.cmso.service.rs.CmsoOptimizerCallbackImpl;\r
import org.onap.optf.cmso.service.rs.models.v2.ChangeWindow;\r
import org.onap.optf.cmso.wf.bean.WfCmResponse200;\r
import org.onap.optf.cmso.wf.bean.WfMsoRequestReferences;\r
serialized = (serialized * totalDuration);\r
}\r
DateTime latestInstanceStartTime = startTime.plus(serialized);\r
- DateTime finishTime = latestInstanceStartTime.plus(totalDuration);\r
// Reformat request into a response setting the groups start finish\r
// time based upon\r
\r
Map<String, Map<String, Long>> startAndFinishTimeMap = new HashMap<String, Map<String, Long>>();\r
try {\r
- CmsoOptimizerCallbackImpl.makeMap(startTime.getMillis(), latestInstanceStartTime.getMillis(),\r
+ makeMap(startTime.getMillis(), latestInstanceStartTime.getMillis(),\r
concurrencyLimit, totalDuration, nodeList, startAndFinishTimeMap);\r
for (String node : nodes.keySet()) {\r
Map<String, Long> map = startAndFinishTimeMap.get(node);\r
return Response.ok().entity(response).build();\r
}\r
\r
+ /**\r
+ * Make map.\r
+ *\r
+ * @param startTime the start time\r
+ * @param latestInstanceStartTime the latest instance start time\r
+ * @param concurrencyLimit the concurrency limit\r
+ * @param totalDuration the total duration\r
+ * @param nodeList the node list\r
+ * @param startAndFinishTimeMap the start and finish time map\r
+ * @throws CmsoException the CMS exception\r
+ */\r
+ public static void makeMap(Long startTime, Long latestInstanceStartTime, int concurrencyLimit, long totalDuration,\r
+ List<String> nodeList, Map<String, Map<String, Long>> startAndFinishTimeMap) throws CmsoException {\r
+ Long nextStartTime = null;\r
+ Long nextFinishTime = null;\r
+ for (int nodeNumber = 0; nodeNumber < nodeList.size(); nodeNumber++) {\r
+ if (nodeNumber % concurrencyLimit == 0) {\r
+ if (nodeNumber == 0) {\r
+ nextStartTime = startTime;\r
+ }\r
+ else {\r
+ nextStartTime = nextStartTime + totalDuration;\r
+ }\r
+ if (nextStartTime > latestInstanceStartTime) {\r
+ throw new CmsoException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_ALLOCATE_VNF_TIMESLOTS,\r
+ startTime.toString(), latestInstanceStartTime.toString(), String.valueOf(totalDuration),\r
+ String.valueOf(concurrencyLimit), String.valueOf(nodeList.size()));\r
+ }\r
+ nextFinishTime = nextStartTime + totalDuration;\r
+ }\r
+ Map<String, Long> map = new HashMap<String, Long>();\r
+ map.put("startTime", nextStartTime);\r
+ map.put("finishTime", nextFinishTime);\r
+ String node = nodeList.get(nodeNumber);\r
+ startAndFinishTimeMap.put(node, map);\r
+ }\r
+\r
+ }\r
\r
}\r
+++ /dev/null
-org.springframework.boot.env.EnvironmentPostProcessor=org.onap.optf.cmso.CmsoEnvironmentPostProcessor
\ No newline at end of file
+++ /dev/null
-/*
- * 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;
-
-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<String, Object>();
- map.put("spring.datasource.password", pwd);
- MapPropertySource propertySource = new MapPropertySource("abc", map);
- MutablePropertySources proeprtySources = environment.getPropertySources();
- proeprtySources.addLast(propertySource);
- }
- }
-
-}
+++ /dev/null
-org.springframework.boot.env.EnvironmentPostProcessor=org.onap.optf.cmso.CmsoEnvironmentPostProcessor
\ No newline at end of file
+++ /dev/null
-/*
- * 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;
-
-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<String, Object>();
- map.put("spring.datasource.password", pwd);
- MapPropertySource propertySource = new MapPropertySource("abc", map);
- MutablePropertySources proeprtySources = environment.getPropertySources();
- proeprtySources.addLast(propertySource);
- }
- }
-
-}
+++ /dev/null
-org.springframework.boot.env.EnvironmentPostProcessor=org.onap.optf.cmso.CmsoEnvironmentPostProcessor
\ No newline at end of file