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.adaptors.lighty;
19 import io.lighty.core.controller.api.AbstractLightyModule;
20 import org.onap.ccsdk.sli.adaptors.aai.lighty.AaaServiceModule;
21 import org.onap.ccsdk.sli.adaptors.ansible.lighty.AnsibleAdapterModule;
22 import org.onap.ccsdk.sli.adaptors.netbox.lighty.NetboxClientModule;
23 import org.onap.ccsdk.sli.adaptors.resource.lighty.ResourceModule;
24 import org.onap.ccsdk.sli.adaptors.resource.mdsal.lighty.MdsalResourceModule;
25 import org.onap.ccsdk.sli.adaptors.resource.sql.lighty.SqlModule;
26 import org.onap.ccsdk.sli.adaptors.saltstack.lighty.SaltstackAdapterModule;
27 import org.onap.ccsdk.sli.core.dblib.DbLibService;
28 import org.onap.ccsdk.sli.core.lighty.common.CcsdkLightyUtils;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
33 * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that groups all other LightyModules
34 * from the ccsdk-sli-adaptors repository so they can be all treated as one component (for example started/stopped
36 * For more information about the lighty.io visit the website https://lighty.io.
38 public class CcsdkAdaptorsLightyModule extends AbstractLightyModule {
40 private static final Logger LOG = LoggerFactory.getLogger(CcsdkAdaptorsLightyModule.class);
42 private DbLibService dbLibService;
44 private AaaServiceModule aaaServiceModule;
45 private AnsibleAdapterModule ansibleAdapterModule;
46 private MdsalResourceModule mdsalResourceModule;
47 private NetboxClientModule netboxClientModule;
48 private ResourceModule resourceModule;
49 private SaltstackAdapterModule saltstackAdapterModule;
50 private SqlModule sqlModule;
52 public CcsdkAdaptorsLightyModule(DbLibService dbLibService) {
53 this.dbLibService = dbLibService;
57 protected boolean initProcedure() {
58 LOG.debug("Initializing CCSDK Adaptors Lighty module...");
60 this.aaaServiceModule = new AaaServiceModule();
61 if (!CcsdkLightyUtils.startLightyModule(aaaServiceModule)) {
62 LOG.error("Unable to start AaaServiceModule in CCSDK Adaptors Lighty module!");
66 this.ansibleAdapterModule = new AnsibleAdapterModule();
67 if (!CcsdkLightyUtils.startLightyModule(ansibleAdapterModule)) {
68 LOG.error("Unable to start AnsibleAdapterModule in CCSDK Adaptors Lighty module!");
72 this.mdsalResourceModule = new MdsalResourceModule();
73 if (!CcsdkLightyUtils.startLightyModule(mdsalResourceModule)) {
74 LOG.error("Unable to start MdsalResourceModule in CCSDK Adaptors Lighty module!");
78 this.netboxClientModule = new NetboxClientModule(dbLibService);
79 if (!CcsdkLightyUtils.startLightyModule(netboxClientModule)) {
80 LOG.error("Unable to start NetboxClientModule in CCSDK Adaptors Lighty module!");
84 this.resourceModule = new ResourceModule(dbLibService);
85 if (!CcsdkLightyUtils.startLightyModule(resourceModule)) {
86 LOG.error("Unable to start ResourceModule in CCSDK Adaptors Lighty module!");
90 this.saltstackAdapterModule = new SaltstackAdapterModule();
91 if (!CcsdkLightyUtils.startLightyModule(saltstackAdapterModule)) {
92 LOG.error("Unable to start SaltstackAdapterModule in CCSDK Adaptors Lighty module!");
96 this.sqlModule = new SqlModule(dbLibService);
97 if (!CcsdkLightyUtils.startLightyModule(sqlModule)) {
98 LOG.error("Unable to start SqlModule in CCSDK Adaptors Lighty module!");
102 LOG.debug("CCSDK Adaptors Lighty module was initialized successfully");
107 protected boolean stopProcedure() {
108 LOG.debug("Stopping CCSDK Adaptors Lighty module...");
110 boolean stopSuccessful = true;
112 if (!CcsdkLightyUtils.stopLightyModule(sqlModule)) {
113 stopSuccessful = false;
116 if (!CcsdkLightyUtils.stopLightyModule(saltstackAdapterModule)) {
117 stopSuccessful = false;
120 if (!CcsdkLightyUtils.stopLightyModule(resourceModule)) {
121 stopSuccessful = false;
124 if (!CcsdkLightyUtils.stopLightyModule(netboxClientModule)) {
125 stopSuccessful = false;
128 if (!CcsdkLightyUtils.stopLightyModule(mdsalResourceModule)) {
129 stopSuccessful = false;
132 if (!CcsdkLightyUtils.stopLightyModule(ansibleAdapterModule)) {
133 stopSuccessful = false;
136 if (!CcsdkLightyUtils.stopLightyModule(aaaServiceModule)) {
137 stopSuccessful = false;
140 if (stopSuccessful) {
141 LOG.debug("CCSDK Adaptors Lighty module was stopped successfully");
143 LOG.error("CCSDK Adaptors Lighty module was not stopped successfully!");
145 return stopSuccessful;
148 public AaaServiceModule getAaaServiceModule() {
149 return aaaServiceModule;
152 public AnsibleAdapterModule getAnsibleAdapterModule() {
153 return ansibleAdapterModule;
156 public MdsalResourceModule getMdsalResourceModule() {
157 return mdsalResourceModule;
160 public NetboxClientModule getNetboxClientModule() {
161 return netboxClientModule;
164 public ResourceModule getResourceModule() {
165 return resourceModule;
168 public SaltstackAdapterModule getSaltstackAdapterModule() {
169 return saltstackAdapterModule;
172 public SqlModule getSqlModule() {