2 * ============LICENSE_START==========================================
3 * Copyright (c) 2019 PANTHEON.tech s.r.o.
4 * ===================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
11 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
12 * OF ANY KIND, either express or implied. See the License for the specific language governing permissions and
13 * limitations under the License.
14 * ============LICENSE_END============================================
17 package org.onap.ccsdk.sli.plugins.lighty;
19 import io.lighty.core.controller.api.AbstractLightyModule;
20 import org.onap.ccsdk.sli.core.lighty.common.CcsdkLightyUtils;
21 import org.onap.ccsdk.sli.plugins.prop.lighty.PropertiesNodeModule;
22 import org.onap.ccsdk.sli.plugins.prop.lighty.RestApiCallNodeModule;
23 import org.onap.ccsdk.sli.plugins.restconf.lighty.RestconfClientModule;
24 import org.onap.ccsdk.sli.plugins.sshapicall.lighty.SshApiCallModule;
25 import org.onap.ccsdk.sli.plugins.template.lighty.TemplateNodeModule;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
30 * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that groups all other LightyModules
31 * from the ccsdk-sli-plugins repository so they can be all treated as one component (for example started/stopped at once).
32 * For more information about the lighty.io visit the website https://lighty.io.
34 public class CcsdkPluginsLightyModule extends AbstractLightyModule {
36 private static final Logger LOG = LoggerFactory.getLogger(CcsdkPluginsLightyModule.class);
38 private PropertiesNodeModule propertiesNodeModule;
39 private RestApiCallNodeModule restApiCallNodeModule;
40 private RestconfClientModule restconfClientModule;
41 private SshApiCallModule sshApiCallModule;
42 private TemplateNodeModule templateNodeModule;
44 protected boolean initProcedure() {
45 LOG.debug("Initializing CCSDK Plugins Lighty module...");
47 this.propertiesNodeModule = new PropertiesNodeModule();
48 if (!CcsdkLightyUtils.startLightyModule(propertiesNodeModule)) {
49 LOG.error("Unable to start PropertiesNodeModule in CCSDK Plugins Lighty module!");
53 this.restApiCallNodeModule = new RestApiCallNodeModule();
54 if (!CcsdkLightyUtils.startLightyModule(restApiCallNodeModule)) {
55 LOG.error("Unable to start RestApiCallNodeModule in CCSDK Plugins Lighty module!");
59 this.restconfClientModule = new RestconfClientModule(restApiCallNodeModule.getPropertiesNode());
60 if (!CcsdkLightyUtils.startLightyModule(restconfClientModule)) {
61 LOG.error("Unable to start RestconfClientModule in CCSDK Plugins Lighty module!");
65 this.sshApiCallModule = new SshApiCallModule();
66 if (!CcsdkLightyUtils.startLightyModule(sshApiCallModule)) {
67 LOG.error("Unable to start SshApiCallModule in CCSDK Plugins Lighty module!");
71 this.templateNodeModule = new TemplateNodeModule();
72 if (!CcsdkLightyUtils.startLightyModule(templateNodeModule)) {
73 LOG.error("Unable to start TemplateNodeModule in CCSDK Plugins Lighty module!");
77 LOG.debug("CCSDK Plugins Lighty module was initialized successfully");
81 protected boolean stopProcedure() {
82 LOG.debug("Stopping CCSDK Plugins Lighty module...");
84 boolean stopSuccessful = true;
86 if (!CcsdkLightyUtils.stopLightyModule(templateNodeModule)) {
87 stopSuccessful = false;
90 if (!CcsdkLightyUtils.stopLightyModule(sshApiCallModule)) {
91 stopSuccessful = false;
94 if (!CcsdkLightyUtils.stopLightyModule(restconfClientModule)) {
95 stopSuccessful = false;
98 if (!CcsdkLightyUtils.stopLightyModule(restApiCallNodeModule)) {
99 stopSuccessful = false;
102 if (!CcsdkLightyUtils.stopLightyModule(propertiesNodeModule)) {
103 stopSuccessful = false;
106 if (stopSuccessful) {
107 LOG.debug("CCSDK Plugins Lighty module was stopped successfully");
109 LOG.error("CCSDK Plugins Lighty module was not stopped successfully!");
111 return stopSuccessful;
114 public PropertiesNodeModule getPropertiesNodeModule() {
115 return propertiesNodeModule;
118 public RestApiCallNodeModule getRestApiCallNodeModule() {
119 return restApiCallNodeModule;
122 public RestconfClientModule getRestconfClientModule() {
123 return restconfClientModule;
126 public SshApiCallModule getSshApiCallModule() {
127 return sshApiCallModule;
130 public TemplateNodeModule getTemplateNodeModule() {
131 return templateNodeModule;