1 /*************************************************************************
3 * Copyright 2020 highstreet technologies GmbH and others
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 ***************************************************************************/
20 #include "web_cut_through.h"
21 #include "utils/log_utils.h"
22 #include "utils/sys_utils.h"
23 #include "utils/rand_utils.h"
24 #include "utils/http_client.h"
25 #include "utils/nts_utils.h"
29 #include "core/session.h"
30 #include "core/framework.h"
32 #define SYSTEM_NAME_SCHEMA_XPATH "/ietf-system:system/onap-system:name"
33 #define SYSTEM_WEB_UI_SCHEMA_XPATH "/ietf-system:system/onap-system:web-ui"
36 int web_cut_through_feature_start(sr_session_ctx_t *current_session) {
37 assert(current_session);
42 //update ietf-system details
43 rc = sr_set_item_str(current_session, SYSTEM_NAME_SCHEMA_XPATH, framework_environment.hostname, 0, 0);
45 log_error("sr_set_item_str failed");
46 return NTS_ERR_FAILED;
49 controller_details_t *controller_details = controller_details_get(current_session);
50 if(controller_details == 0) {
51 log_error("controller_details_get failed");
52 return NTS_ERR_FAILED;
56 asprintf(&web_ui, "%s/odlux/index.html#/about", controller_details->base_url);
57 controller_details_free(controller_details);
60 log_error("asprintf failed");
61 return NTS_ERR_FAILED;
64 rc = sr_set_item_str(current_session, SYSTEM_WEB_UI_SCHEMA_XPATH, web_ui, 0, 0);
67 log_error("sr_set_item_str failed");
68 return NTS_ERR_FAILED;
71 rc = sr_apply_changes(current_session, 0, 0);
73 log_error("could not apply changes on datastore");
74 return NTS_ERR_FAILED;