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/cpudimm.hpp"
23 #include "../lib/ethernet.hpp"
24 #include "../lib/event_service.hpp"
25 #include "../lib/log_services.hpp"
26 #include "../lib/managers.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/redfish_sessions.hpp"
32 #include "../lib/roles.hpp"
33 #include "../lib/sensors.hpp"
34 #include "../lib/service_root.hpp"
35 #include "../lib/storage.hpp"
36 #include "../lib/systems.hpp"
37 #include "../lib/task.hpp"
38 #include "../lib/thermal.hpp"
39 #include "../lib/update_service.hpp"
40 #ifdef BMCWEB_ENABLE_VM_NBDPROXY
41 #include "../lib/virtual_media.hpp"
42 #endif // BMCWEB_ENABLE_VM_NBDPROXY
43 #include "../lib/hypervisor_ethernet.hpp"
44 
45 namespace redfish
46 {
47 /*
48  * @brief Top level class installing and providing Redfish services
49  */
50 class RedfishService
51 {
52   public:
53     /*
54      * @brief Redfish service constructor
55      *
56      * Loads Redfish configuration and installs schema resources
57      *
58      * @param[in] app   Crow app on which Redfish will initialize
59      */
60     RedfishService(App& app)
61     {
62         nodes.emplace_back(std::make_unique<AccountService>(app));
63         nodes.emplace_back(std::make_unique<AccountsCollection>(app));
64         nodes.emplace_back(std::make_unique<ManagerAccount>(app));
65         nodes.emplace_back(std::make_unique<SessionCollection>(app));
66         nodes.emplace_back(std::make_unique<Roles>(app));
67         nodes.emplace_back(std::make_unique<RoleCollection>(app));
68         nodes.emplace_back(std::make_unique<ServiceRoot>(app));
69         nodes.emplace_back(std::make_unique<NetworkProtocol>(app));
70         nodes.emplace_back(std::make_unique<SessionService>(app));
71         nodes.emplace_back(std::make_unique<EthernetCollection>(app));
72         nodes.emplace_back(std::make_unique<EthernetInterface>(app));
73         nodes.emplace_back(std::make_unique<Thermal>(app));
74         nodes.emplace_back(std::make_unique<ManagerCollection>(app));
75         nodes.emplace_back(std::make_unique<Manager>(app));
76         nodes.emplace_back(std::make_unique<ManagerResetAction>(app));
77         nodes.emplace_back(std::make_unique<ManagerResetActionInfo>(app));
78         nodes.emplace_back(std::make_unique<ManagerResetToDefaultsAction>(app));
79         nodes.emplace_back(std::make_unique<Power>(app));
80         nodes.emplace_back(std::make_unique<ChassisCollection>(app));
81         nodes.emplace_back(std::make_unique<Chassis>(app));
82         nodes.emplace_back(std::make_unique<ChassisResetAction>(app));
83         nodes.emplace_back(std::make_unique<ChassisResetActionInfo>(app));
84         nodes.emplace_back(std::make_unique<UpdateService>(app));
85         nodes.emplace_back(std::make_unique<StorageCollection>(app));
86         nodes.emplace_back(std::make_unique<Storage>(app));
87         nodes.emplace_back(std::make_unique<Drive>(app));
88 #ifdef BMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE
89         nodes.emplace_back(
90             std::make_unique<UpdateServiceActionsSimpleUpdate>(app));
91 #endif
92         nodes.emplace_back(std::make_unique<SoftwareInventoryCollection>(app));
93         nodes.emplace_back(std::make_unique<SoftwareInventory>(app));
94         nodes.emplace_back(
95             std::make_unique<VlanNetworkInterfaceCollection>(app));
96         nodes.emplace_back(std::make_unique<VlanNetworkInterface>(app));
97 
98         nodes.emplace_back(std::make_unique<SystemLogServiceCollection>(app));
99         nodes.emplace_back(std::make_unique<EventLogService>(app));
100 
101         nodes.emplace_back(std::make_unique<PostCodesLogService>(app));
102         nodes.emplace_back(std::make_unique<PostCodesClear>(app));
103         nodes.emplace_back(std::make_unique<PostCodesEntry>(app));
104         nodes.emplace_back(std::make_unique<PostCodesEntryCollection>(app));
105 
106 #ifdef BMCWEB_ENABLE_REDFISH_DUMP_LOG
107         nodes.emplace_back(std::make_unique<SystemDumpService>(app));
108         nodes.emplace_back(std::make_unique<SystemDumpEntryCollection>(app));
109         nodes.emplace_back(std::make_unique<SystemDumpEntry>(app));
110         nodes.emplace_back(std::make_unique<SystemDumpCreate>(app));
111         nodes.emplace_back(std::make_unique<SystemDumpClear>(app));
112 
113         nodes.emplace_back(std::make_unique<BMCDumpService>(app));
114         nodes.emplace_back(std::make_unique<BMCDumpEntryCollection>(app));
115         nodes.emplace_back(std::make_unique<BMCDumpEntry>(app));
116         nodes.emplace_back(std::make_unique<BMCDumpCreate>(app));
117         nodes.emplace_back(std::make_unique<BMCDumpClear>(app));
118 #endif
119 
120 #ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
121         nodes.emplace_back(
122             std::make_unique<JournalEventLogEntryCollection>(app));
123         nodes.emplace_back(std::make_unique<JournalEventLogEntry>(app));
124         nodes.emplace_back(std::make_unique<JournalEventLogClear>(app));
125 #endif
126 
127         nodes.emplace_back(std::make_unique<BMCLogServiceCollection>(app));
128 #ifdef BMCWEB_ENABLE_REDFISH_BMC_JOURNAL
129         nodes.emplace_back(std::make_unique<BMCJournalLogService>(app));
130         nodes.emplace_back(std::make_unique<BMCJournalLogEntryCollection>(app));
131         nodes.emplace_back(std::make_unique<BMCJournalLogEntry>(app));
132 #endif
133 
134 #ifdef BMCWEB_ENABLE_REDFISH_CPU_LOG
135         nodes.emplace_back(std::make_unique<CrashdumpService>(app));
136         nodes.emplace_back(std::make_unique<CrashdumpEntryCollection>(app));
137         nodes.emplace_back(std::make_unique<CrashdumpEntry>(app));
138         nodes.emplace_back(std::make_unique<CrashdumpFile>(app));
139         nodes.emplace_back(std::make_unique<CrashdumpClear>(app));
140         nodes.emplace_back(std::make_unique<OnDemandCrashdump>(app));
141         nodes.emplace_back(std::make_unique<TelemetryCrashdump>(app));
142 #ifdef BMCWEB_ENABLE_REDFISH_RAW_PECI
143         nodes.emplace_back(std::make_unique<SendRawPECI>(app));
144 #endif // BMCWEB_ENABLE_REDFISH_RAW_PECI
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<MemoryCollection>(app));
150         nodes.emplace_back(std::make_unique<Memory>(app));
151 
152         nodes.emplace_back(std::make_unique<SystemsCollection>(app));
153         nodes.emplace_back(std::make_unique<Systems>(app));
154         nodes.emplace_back(std::make_unique<SystemActionsReset>(app));
155         nodes.emplace_back(std::make_unique<SystemResetActionInfo>(app));
156         nodes.emplace_back(std::make_unique<BiosService>(app));
157         nodes.emplace_back(std::make_unique<BiosReset>(app));
158 #ifdef BMCWEB_ENABLE_VM_NBDPROXY
159         nodes.emplace_back(std::make_unique<VirtualMedia>(app));
160         nodes.emplace_back(std::make_unique<VirtualMediaCollection>(app));
161         nodes.emplace_back(
162             std::make_unique<VirtualMediaActionInsertMedia>(app));
163         nodes.emplace_back(std::make_unique<VirtualMediaActionEjectMedia>(app));
164 #endif // BMCWEB_ENABLE_VM_NBDPROXY
165 #ifdef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
166         nodes.emplace_back(std::make_unique<DBusLogServiceActionsClear>(app));
167         nodes.emplace_back(std::make_unique<DBusEventLogEntryCollection>(app));
168         nodes.emplace_back(std::make_unique<DBusEventLogEntry>(app));
169 #endif
170 
171         nodes.emplace_back(
172             std::make_unique<MessageRegistryFileCollection>(app));
173         nodes.emplace_back(std::make_unique<MessageRegistryFile>(app));
174         nodes.emplace_back(std::make_unique<MessageRegistry>(app));
175         nodes.emplace_back(std::make_unique<CertificateService>(app));
176         nodes.emplace_back(
177             std::make_unique<CertificateActionsReplaceCertificate>(app));
178         nodes.emplace_back(std::make_unique<CertificateLocations>(app));
179         nodes.emplace_back(std::make_unique<HTTPSCertificateCollection>(app));
180         nodes.emplace_back(std::make_unique<HTTPSCertificate>(app));
181         nodes.emplace_back(std::make_unique<LDAPCertificateCollection>(app));
182         nodes.emplace_back(std::make_unique<LDAPCertificate>(app));
183         nodes.emplace_back(std::make_unique<CertificateActionGenerateCSR>(app));
184         nodes.emplace_back(
185             std::make_unique<TrustStoreCertificateCollection>(app));
186         nodes.emplace_back(std::make_unique<TrustStoreCertificate>(app));
187         nodes.emplace_back(std::make_unique<SystemPCIeFunctionCollection>(app));
188         nodes.emplace_back(std::make_unique<SystemPCIeFunction>(app));
189         nodes.emplace_back(std::make_unique<SystemPCIeDeviceCollection>(app));
190         nodes.emplace_back(std::make_unique<SystemPCIeDevice>(app));
191 
192         nodes.emplace_back(std::make_unique<SensorCollection>(app));
193         nodes.emplace_back(std::make_unique<Sensor>(app));
194 
195         nodes.emplace_back(std::make_unique<TaskMonitor>(app));
196         nodes.emplace_back(std::make_unique<TaskService>(app));
197         nodes.emplace_back(std::make_unique<TaskCollection>(app));
198         nodes.emplace_back(std::make_unique<Task>(app));
199         nodes.emplace_back(std::make_unique<EventService>(app));
200         nodes.emplace_back(std::make_unique<EventDestinationCollection>(app));
201         nodes.emplace_back(std::make_unique<EventDestination>(app));
202         nodes.emplace_back(std::make_unique<SubmitTestEvent>(app));
203 
204         nodes.emplace_back(
205             std::make_unique<HypervisorInterfaceCollection>(app));
206         nodes.emplace_back(std::make_unique<HypervisorInterface>(app));
207         nodes.emplace_back(std::make_unique<HypervisorSystem>(app));
208 
209         for (const auto& node : nodes)
210         {
211             node->initPrivileges();
212         }
213     }
214 
215   private:
216     std::vector<std::unique_ptr<Node>> nodes;
217 };
218 
219 } // namespace redfish
220