1 /*
2 // Copyright (c) 2018-2019 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 #pragma once
17 
18 #include "../lib/account_service.hpp"
19 #include "../lib/bios.hpp"
20 #include "../lib/certificate_service.hpp"
21 #include "../lib/chassis.hpp"
22 #include "../lib/ethernet.hpp"
23 #include "../lib/event_service.hpp"
24 #include "../lib/log_services.hpp"
25 #include "../lib/managers.hpp"
26 #include "../lib/memory.hpp"
27 #include "../lib/message_registries.hpp"
28 #include "../lib/metric_report.hpp"
29 #include "../lib/metric_report_definition.hpp"
30 #include "../lib/network_protocol.hpp"
31 #include "../lib/pcie.hpp"
32 #include "../lib/power.hpp"
33 #include "../lib/processor.hpp"
34 #include "../lib/redfish_sessions.hpp"
35 #include "../lib/roles.hpp"
36 #include "../lib/sensors.hpp"
37 #include "../lib/service_root.hpp"
38 #include "../lib/storage.hpp"
39 #include "../lib/systems.hpp"
40 #include "../lib/task.hpp"
41 #include "../lib/telemetry_service.hpp"
42 #include "../lib/thermal.hpp"
43 #include "../lib/update_service.hpp"
44 #ifdef BMCWEB_ENABLE_VM_NBDPROXY
45 #include "../lib/virtual_media.hpp"
46 #endif // BMCWEB_ENABLE_VM_NBDPROXY
47 #include "../lib/hypervisor_system.hpp"
48 
49 namespace redfish
50 {
51 /*
52  * @brief Top level class installing and providing Redfish services
53  */
54 class RedfishService
55 {
56   public:
57     /*
58      * @brief Redfish service constructor
59      *
60      * Loads Redfish configuration and installs schema resources
61      *
62      * @param[in] app   Crow app on which Redfish will initialize
63      */
64     RedfishService(App& app)
65     {
66         nodes.emplace_back(std::make_unique<AccountService>(app));
67         nodes.emplace_back(std::make_unique<AccountsCollection>(app));
68         nodes.emplace_back(std::make_unique<ManagerAccount>(app));
69         nodes.emplace_back(std::make_unique<SessionCollection>(app));
70         nodes.emplace_back(std::make_unique<Roles>(app));
71         nodes.emplace_back(std::make_unique<RoleCollection>(app));
72         nodes.emplace_back(std::make_unique<ServiceRoot>(app));
73         nodes.emplace_back(std::make_unique<NetworkProtocol>(app));
74         nodes.emplace_back(std::make_unique<SessionService>(app));
75         nodes.emplace_back(std::make_unique<EthernetCollection>(app));
76         nodes.emplace_back(std::make_unique<EthernetInterface>(app));
77         nodes.emplace_back(std::make_unique<Thermal>(app));
78         nodes.emplace_back(std::make_unique<ManagerCollection>(app));
79         nodes.emplace_back(std::make_unique<Manager>(app));
80         nodes.emplace_back(std::make_unique<ManagerResetAction>(app));
81         nodes.emplace_back(std::make_unique<ManagerResetActionInfo>(app));
82         nodes.emplace_back(std::make_unique<ManagerResetToDefaultsAction>(app));
83         nodes.emplace_back(std::make_unique<Power>(app));
84         nodes.emplace_back(std::make_unique<ChassisCollection>(app));
85         nodes.emplace_back(std::make_unique<Chassis>(app));
86         nodes.emplace_back(std::make_unique<ChassisResetAction>(app));
87         nodes.emplace_back(std::make_unique<ChassisResetActionInfo>(app));
88         nodes.emplace_back(std::make_unique<UpdateService>(app));
89         nodes.emplace_back(std::make_unique<StorageCollection>(app));
90         nodes.emplace_back(std::make_unique<Storage>(app));
91         nodes.emplace_back(std::make_unique<Drive>(app));
92 #ifdef BMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE
93         nodes.emplace_back(
94             std::make_unique<UpdateServiceActionsSimpleUpdate>(app));
95 #endif
96         nodes.emplace_back(std::make_unique<SoftwareInventoryCollection>(app));
97         nodes.emplace_back(std::make_unique<SoftwareInventory>(app));
98         nodes.emplace_back(
99             std::make_unique<VlanNetworkInterfaceCollection>(app));
100         nodes.emplace_back(std::make_unique<VlanNetworkInterface>(app));
101 
102         nodes.emplace_back(std::make_unique<SystemLogServiceCollection>(app));
103         nodes.emplace_back(std::make_unique<EventLogService>(app));
104 
105         nodes.emplace_back(std::make_unique<PostCodesLogService>(app));
106         nodes.emplace_back(std::make_unique<PostCodesClear>(app));
107         nodes.emplace_back(std::make_unique<PostCodesEntry>(app));
108         nodes.emplace_back(std::make_unique<PostCodesEntryCollection>(app));
109 
110 #ifdef BMCWEB_ENABLE_REDFISH_DUMP_LOG
111         nodes.emplace_back(std::make_unique<SystemDumpService>(app));
112         nodes.emplace_back(std::make_unique<SystemDumpEntryCollection>(app));
113         nodes.emplace_back(std::make_unique<SystemDumpEntry>(app));
114         nodes.emplace_back(std::make_unique<SystemDumpCreate>(app));
115         nodes.emplace_back(std::make_unique<SystemDumpClear>(app));
116 
117         nodes.emplace_back(std::make_unique<BMCDumpService>(app));
118         nodes.emplace_back(std::make_unique<BMCDumpEntryCollection>(app));
119         nodes.emplace_back(std::make_unique<BMCDumpEntry>(app));
120         nodes.emplace_back(std::make_unique<BMCDumpCreate>(app));
121         nodes.emplace_back(std::make_unique<BMCDumpClear>(app));
122 #endif
123 
124 #ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
125         nodes.emplace_back(
126             std::make_unique<JournalEventLogEntryCollection>(app));
127         nodes.emplace_back(std::make_unique<JournalEventLogEntry>(app));
128         nodes.emplace_back(std::make_unique<JournalEventLogClear>(app));
129 #endif
130 
131         nodes.emplace_back(std::make_unique<BMCLogServiceCollection>(app));
132 #ifdef BMCWEB_ENABLE_REDFISH_BMC_JOURNAL
133         nodes.emplace_back(std::make_unique<BMCJournalLogService>(app));
134         nodes.emplace_back(std::make_unique<BMCJournalLogEntryCollection>(app));
135         nodes.emplace_back(std::make_unique<BMCJournalLogEntry>(app));
136 #endif
137 
138 #ifdef BMCWEB_ENABLE_REDFISH_CPU_LOG
139         nodes.emplace_back(std::make_unique<CrashdumpService>(app));
140         nodes.emplace_back(std::make_unique<CrashdumpEntryCollection>(app));
141         nodes.emplace_back(std::make_unique<CrashdumpEntry>(app));
142         nodes.emplace_back(std::make_unique<CrashdumpFile>(app));
143         nodes.emplace_back(std::make_unique<CrashdumpClear>(app));
144         nodes.emplace_back(std::make_unique<CrashdumpCollect>(app));
145 #endif // BMCWEB_ENABLE_REDFISH_CPU_LOG
146 
147         nodes.emplace_back(std::make_unique<ProcessorCollection>(app));
148         nodes.emplace_back(std::make_unique<Processor>(app));
149         nodes.emplace_back(std::make_unique<OperatingConfigCollection>(app));
150         nodes.emplace_back(std::make_unique<OperatingConfig>(app));
151         nodes.emplace_back(std::make_unique<MemoryCollection>(app));
152         nodes.emplace_back(std::make_unique<Memory>(app));
153 
154         nodes.emplace_back(std::make_unique<SystemsCollection>(app));
155         nodes.emplace_back(std::make_unique<Systems>(app));
156         nodes.emplace_back(std::make_unique<SystemActionsReset>(app));
157         nodes.emplace_back(std::make_unique<SystemResetActionInfo>(app));
158         nodes.emplace_back(std::make_unique<BiosService>(app));
159         nodes.emplace_back(std::make_unique<BiosReset>(app));
160 #ifdef BMCWEB_ENABLE_VM_NBDPROXY
161         nodes.emplace_back(std::make_unique<VirtualMedia>(app));
162         nodes.emplace_back(std::make_unique<VirtualMediaCollection>(app));
163         nodes.emplace_back(
164             std::make_unique<VirtualMediaActionInsertMedia>(app));
165         nodes.emplace_back(std::make_unique<VirtualMediaActionEjectMedia>(app));
166 #endif // BMCWEB_ENABLE_VM_NBDPROXY
167 #ifdef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
168         nodes.emplace_back(std::make_unique<DBusLogServiceActionsClear>(app));
169         nodes.emplace_back(std::make_unique<DBusEventLogEntryCollection>(app));
170         nodes.emplace_back(std::make_unique<DBusEventLogEntry>(app));
171         nodes.emplace_back(std::make_unique<DBusEventLogEntryDownload>(app));
172 #endif
173 
174         nodes.emplace_back(
175             std::make_unique<MessageRegistryFileCollection>(app));
176         nodes.emplace_back(std::make_unique<MessageRegistryFile>(app));
177         nodes.emplace_back(std::make_unique<MessageRegistry>(app));
178         nodes.emplace_back(std::make_unique<CertificateService>(app));
179         nodes.emplace_back(
180             std::make_unique<CertificateActionsReplaceCertificate>(app));
181         nodes.emplace_back(std::make_unique<CertificateLocations>(app));
182         nodes.emplace_back(std::make_unique<HTTPSCertificateCollection>(app));
183         nodes.emplace_back(std::make_unique<HTTPSCertificate>(app));
184         nodes.emplace_back(std::make_unique<LDAPCertificateCollection>(app));
185         nodes.emplace_back(std::make_unique<LDAPCertificate>(app));
186         nodes.emplace_back(std::make_unique<CertificateActionGenerateCSR>(app));
187         nodes.emplace_back(
188             std::make_unique<TrustStoreCertificateCollection>(app));
189         nodes.emplace_back(std::make_unique<TrustStoreCertificate>(app));
190         nodes.emplace_back(std::make_unique<SystemPCIeFunctionCollection>(app));
191         nodes.emplace_back(std::make_unique<SystemPCIeFunction>(app));
192         nodes.emplace_back(std::make_unique<SystemPCIeDeviceCollection>(app));
193         nodes.emplace_back(std::make_unique<SystemPCIeDevice>(app));
194 
195         nodes.emplace_back(std::make_unique<SensorCollection>(app));
196         nodes.emplace_back(std::make_unique<Sensor>(app));
197 
198         nodes.emplace_back(std::make_unique<TaskMonitor>(app));
199         nodes.emplace_back(std::make_unique<TaskService>(app));
200         nodes.emplace_back(std::make_unique<TaskCollection>(app));
201         nodes.emplace_back(std::make_unique<Task>(app));
202         nodes.emplace_back(std::make_unique<EventService>(app));
203         nodes.emplace_back(std::make_unique<EventDestinationCollection>(app));
204         nodes.emplace_back(std::make_unique<EventDestination>(app));
205         nodes.emplace_back(std::make_unique<SubmitTestEvent>(app));
206 
207         nodes.emplace_back(
208             std::make_unique<HypervisorInterfaceCollection>(app));
209         nodes.emplace_back(std::make_unique<HypervisorInterface>(app));
210         nodes.emplace_back(std::make_unique<HypervisorSystem>(app));
211         nodes.emplace_back(std::make_unique<HypervisorActionsReset>(app));
212         nodes.emplace_back(std::make_unique<HypervisorResetActionInfo>(app));
213 
214         nodes.emplace_back(std::make_unique<TelemetryService>(app));
215         nodes.emplace_back(
216             std::make_unique<MetricReportDefinitionCollection>(app));
217         nodes.emplace_back(std::make_unique<MetricReportDefinition>(app));
218         nodes.emplace_back(std::make_unique<MetricReportCollection>(app));
219         nodes.emplace_back(std::make_unique<MetricReport>(app));
220 
221         for (const auto& node : nodes)
222         {
223             node->initPrivileges();
224         }
225     }
226 
227   private:
228     std::vector<std::unique_ptr<Node>> nodes;
229 };
230 
231 } // namespace redfish
232