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/network_protocol.hpp"
29 #include "../lib/pcie.hpp"
30 #include "../lib/power.hpp"
31 #include "../lib/processor.hpp"
32 #include "../lib/redfish_sessions.hpp"
33 #include "../lib/roles.hpp"
34 #include "../lib/sensors.hpp"
35 #include "../lib/service_root.hpp"
36 #include "../lib/storage.hpp"
37 #include "../lib/systems.hpp"
38 #include "../lib/task.hpp"
39 #include "../lib/thermal.hpp"
40 #include "../lib/update_service.hpp"
41 #ifdef BMCWEB_ENABLE_VM_NBDPROXY
42 #include "../lib/virtual_media.hpp"
43 #endif // BMCWEB_ENABLE_VM_NBDPROXY
44 #include "../lib/hypervisor_ethernet.hpp"
45 
46 namespace redfish
47 {
48 /*
49  * @brief Top level class installing and providing Redfish services
50  */
51 class RedfishService
52 {
53   public:
54     /*
55      * @brief Redfish service constructor
56      *
57      * Loads Redfish configuration and installs schema resources
58      *
59      * @param[in] app   Crow app on which Redfish will initialize
60      */
61     RedfishService(App& app)
62     {
63         nodes.emplace_back(std::make_unique<AccountService>(app));
64         nodes.emplace_back(std::make_unique<AccountsCollection>(app));
65         nodes.emplace_back(std::make_unique<ManagerAccount>(app));
66         nodes.emplace_back(std::make_unique<SessionCollection>(app));
67         nodes.emplace_back(std::make_unique<Roles>(app));
68         nodes.emplace_back(std::make_unique<RoleCollection>(app));
69         nodes.emplace_back(std::make_unique<ServiceRoot>(app));
70         nodes.emplace_back(std::make_unique<NetworkProtocol>(app));
71         nodes.emplace_back(std::make_unique<SessionService>(app));
72         nodes.emplace_back(std::make_unique<EthernetCollection>(app));
73         nodes.emplace_back(std::make_unique<EthernetInterface>(app));
74         nodes.emplace_back(std::make_unique<Thermal>(app));
75         nodes.emplace_back(std::make_unique<ManagerCollection>(app));
76         nodes.emplace_back(std::make_unique<Manager>(app));
77         nodes.emplace_back(std::make_unique<ManagerResetAction>(app));
78         nodes.emplace_back(std::make_unique<ManagerResetActionInfo>(app));
79         nodes.emplace_back(std::make_unique<ManagerResetToDefaultsAction>(app));
80         nodes.emplace_back(std::make_unique<Power>(app));
81         nodes.emplace_back(std::make_unique<ChassisCollection>(app));
82         nodes.emplace_back(std::make_unique<Chassis>(app));
83         nodes.emplace_back(std::make_unique<ChassisResetAction>(app));
84         nodes.emplace_back(std::make_unique<ChassisResetActionInfo>(app));
85         nodes.emplace_back(std::make_unique<UpdateService>(app));
86         nodes.emplace_back(std::make_unique<StorageCollection>(app));
87         nodes.emplace_back(std::make_unique<Storage>(app));
88         nodes.emplace_back(std::make_unique<Drive>(app));
89 #ifdef BMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE
90         nodes.emplace_back(
91             std::make_unique<UpdateServiceActionsSimpleUpdate>(app));
92 #endif
93         nodes.emplace_back(std::make_unique<SoftwareInventoryCollection>(app));
94         nodes.emplace_back(std::make_unique<SoftwareInventory>(app));
95         nodes.emplace_back(
96             std::make_unique<VlanNetworkInterfaceCollection>(app));
97         nodes.emplace_back(std::make_unique<VlanNetworkInterface>(app));
98 
99         nodes.emplace_back(std::make_unique<SystemLogServiceCollection>(app));
100         nodes.emplace_back(std::make_unique<EventLogService>(app));
101 
102         nodes.emplace_back(std::make_unique<PostCodesLogService>(app));
103         nodes.emplace_back(std::make_unique<PostCodesClear>(app));
104         nodes.emplace_back(std::make_unique<PostCodesEntry>(app));
105         nodes.emplace_back(std::make_unique<PostCodesEntryCollection>(app));
106 
107 #ifdef BMCWEB_ENABLE_REDFISH_DUMP_LOG
108         nodes.emplace_back(std::make_unique<SystemDumpService>(app));
109         nodes.emplace_back(std::make_unique<SystemDumpEntryCollection>(app));
110         nodes.emplace_back(std::make_unique<SystemDumpEntry>(app));
111         nodes.emplace_back(std::make_unique<SystemDumpCreate>(app));
112         nodes.emplace_back(std::make_unique<SystemDumpClear>(app));
113 
114         nodes.emplace_back(std::make_unique<BMCDumpService>(app));
115         nodes.emplace_back(std::make_unique<BMCDumpEntryCollection>(app));
116         nodes.emplace_back(std::make_unique<BMCDumpEntry>(app));
117         nodes.emplace_back(std::make_unique<BMCDumpCreate>(app));
118         nodes.emplace_back(std::make_unique<BMCDumpClear>(app));
119 #endif
120 
121 #ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
122         nodes.emplace_back(
123             std::make_unique<JournalEventLogEntryCollection>(app));
124         nodes.emplace_back(std::make_unique<JournalEventLogEntry>(app));
125         nodes.emplace_back(std::make_unique<JournalEventLogClear>(app));
126 #endif
127 
128         nodes.emplace_back(std::make_unique<BMCLogServiceCollection>(app));
129 #ifdef BMCWEB_ENABLE_REDFISH_BMC_JOURNAL
130         nodes.emplace_back(std::make_unique<BMCJournalLogService>(app));
131         nodes.emplace_back(std::make_unique<BMCJournalLogEntryCollection>(app));
132         nodes.emplace_back(std::make_unique<BMCJournalLogEntry>(app));
133 #endif
134 
135 #ifdef BMCWEB_ENABLE_REDFISH_CPU_LOG
136         nodes.emplace_back(std::make_unique<CrashdumpService>(app));
137         nodes.emplace_back(std::make_unique<CrashdumpEntryCollection>(app));
138         nodes.emplace_back(std::make_unique<CrashdumpEntry>(app));
139         nodes.emplace_back(std::make_unique<CrashdumpFile>(app));
140         nodes.emplace_back(std::make_unique<CrashdumpClear>(app));
141         nodes.emplace_back(std::make_unique<OnDemandCrashdump>(app));
142         nodes.emplace_back(std::make_unique<TelemetryCrashdump>(app));
143 #ifdef BMCWEB_ENABLE_REDFISH_RAW_PECI
144         nodes.emplace_back(std::make_unique<SendRawPECI>(app));
145 #endif // BMCWEB_ENABLE_REDFISH_RAW_PECI
146 #endif // BMCWEB_ENABLE_REDFISH_CPU_LOG
147 
148         nodes.emplace_back(std::make_unique<ProcessorCollection>(app));
149         nodes.emplace_back(std::make_unique<Processor>(app));
150         nodes.emplace_back(std::make_unique<OperatingConfigCollection>(app));
151         nodes.emplace_back(std::make_unique<OperatingConfig>(app));
152         nodes.emplace_back(std::make_unique<MemoryCollection>(app));
153         nodes.emplace_back(std::make_unique<Memory>(app));
154 
155         nodes.emplace_back(std::make_unique<SystemsCollection>(app));
156         nodes.emplace_back(std::make_unique<Systems>(app));
157         nodes.emplace_back(std::make_unique<SystemActionsReset>(app));
158         nodes.emplace_back(std::make_unique<SystemResetActionInfo>(app));
159         nodes.emplace_back(std::make_unique<BiosService>(app));
160         nodes.emplace_back(std::make_unique<BiosReset>(app));
161 #ifdef BMCWEB_ENABLE_VM_NBDPROXY
162         nodes.emplace_back(std::make_unique<VirtualMedia>(app));
163         nodes.emplace_back(std::make_unique<VirtualMediaCollection>(app));
164         nodes.emplace_back(
165             std::make_unique<VirtualMediaActionInsertMedia>(app));
166         nodes.emplace_back(std::make_unique<VirtualMediaActionEjectMedia>(app));
167 #endif // BMCWEB_ENABLE_VM_NBDPROXY
168 #ifdef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
169         nodes.emplace_back(std::make_unique<DBusLogServiceActionsClear>(app));
170         nodes.emplace_back(std::make_unique<DBusEventLogEntryCollection>(app));
171         nodes.emplace_back(std::make_unique<DBusEventLogEntry>(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 
212         for (const auto& node : nodes)
213         {
214             node->initPrivileges();
215         }
216     }
217 
218   private:
219     std::vector<std::unique_ptr<Node>> nodes;
220 };
221 
222 } // namespace redfish
223