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 #include "webserver_common.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(CrowApp& 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<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<UpdateService>(app));
84         nodes.emplace_back(std::make_unique<StorageCollection>(app));
85         nodes.emplace_back(std::make_unique<Storage>(app));
86         nodes.emplace_back(std::make_unique<Drive>(app));
87 #ifdef BMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE
88         nodes.emplace_back(
89             std::make_unique<UpdateServiceActionsSimpleUpdate>(app));
90 #endif
91         nodes.emplace_back(std::make_unique<SoftwareInventoryCollection>(app));
92         nodes.emplace_back(std::make_unique<SoftwareInventory>(app));
93         nodes.emplace_back(
94             std::make_unique<VlanNetworkInterfaceCollection>(app));
95         nodes.emplace_back(std::make_unique<VlanNetworkInterface>(app));
96 
97         nodes.emplace_back(std::make_unique<SystemLogServiceCollection>(app));
98         nodes.emplace_back(std::make_unique<EventLogService>(app));
99 
100         nodes.emplace_back(std::make_unique<PostCodesLogService>(app));
101         nodes.emplace_back(std::make_unique<PostCodesClear>(app));
102         nodes.emplace_back(std::make_unique<PostCodesEntry>(app));
103         nodes.emplace_back(std::make_unique<PostCodesEntryCollection>(app));
104 
105 #ifdef BMCWEB_ENABLE_REDFISH_SYSTEMDUMP_LOG
106         nodes.emplace_back(std::make_unique<SystemDumpService>(app));
107         nodes.emplace_back(std::make_unique<SystemDumpEntryCollection>(app));
108         nodes.emplace_back(std::make_unique<SystemDumpEntry>(app));
109         nodes.emplace_back(std::make_unique<SystemDumpEntryDownload>(app));
110         nodes.emplace_back(std::make_unique<SystemDumpClear>(app));
111 #endif
112 
113 #ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
114         nodes.emplace_back(
115             std::make_unique<JournalEventLogEntryCollection>(app));
116         nodes.emplace_back(std::make_unique<JournalEventLogEntry>(app));
117         nodes.emplace_back(std::make_unique<JournalEventLogClear>(app));
118 #endif
119 
120         nodes.emplace_back(std::make_unique<BMCLogServiceCollection>(app));
121 #ifdef BMCWEB_ENABLE_REDFISH_BMC_JOURNAL
122         nodes.emplace_back(std::make_unique<BMCJournalLogService>(app));
123         nodes.emplace_back(std::make_unique<BMCJournalLogEntryCollection>(app));
124         nodes.emplace_back(std::make_unique<BMCJournalLogEntry>(app));
125 #endif
126 
127 #ifdef BMCWEB_ENABLE_REDFISH_CPU_LOG
128         nodes.emplace_back(std::make_unique<CrashdumpService>(app));
129         nodes.emplace_back(std::make_unique<CrashdumpEntryCollection>(app));
130         nodes.emplace_back(std::make_unique<CrashdumpEntry>(app));
131         nodes.emplace_back(std::make_unique<CrashdumpFile>(app));
132         nodes.emplace_back(std::make_unique<CrashdumpClear>(app));
133         nodes.emplace_back(std::make_unique<OnDemandCrashdump>(app));
134 #ifdef BMCWEB_ENABLE_REDFISH_RAW_PECI
135         nodes.emplace_back(std::make_unique<SendRawPECI>(app));
136 #endif // BMCWEB_ENABLE_REDFISH_RAW_PECI
137 #endif // BMCWEB_ENABLE_REDFISH_CPU_LOG
138 
139         nodes.emplace_back(std::make_unique<ProcessorCollection>(app));
140         nodes.emplace_back(std::make_unique<Processor>(app));
141         nodes.emplace_back(std::make_unique<MemoryCollection>(app));
142         nodes.emplace_back(std::make_unique<Memory>(app));
143 
144         nodes.emplace_back(std::make_unique<SystemsCollection>(app));
145         nodes.emplace_back(std::make_unique<Systems>(app));
146         nodes.emplace_back(std::make_unique<SystemActionsReset>(app));
147         nodes.emplace_back(std::make_unique<BiosService>(app));
148         nodes.emplace_back(std::make_unique<BiosReset>(app));
149 #ifdef BMCWEB_ENABLE_VM_NBDPROXY
150         nodes.emplace_back(std::make_unique<VirtualMedia>(app));
151         nodes.emplace_back(std::make_unique<VirtualMediaCollection>(app));
152         nodes.emplace_back(
153             std::make_unique<VirtualMediaActionInsertMedia>(app));
154         nodes.emplace_back(std::make_unique<VirtualMediaActionEjectMedia>(app));
155 #endif // BMCWEB_ENABLE_VM_NBDPROXY
156 #ifdef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
157         nodes.emplace_back(std::make_unique<DBusLogServiceActionsClear>(app));
158         nodes.emplace_back(std::make_unique<DBusEventLogEntryCollection>(app));
159         nodes.emplace_back(std::make_unique<DBusEventLogEntry>(app));
160 #endif
161 
162         nodes.emplace_back(
163             std::make_unique<MessageRegistryFileCollection>(app));
164         nodes.emplace_back(std::make_unique<MessageRegistryFile>(app));
165         nodes.emplace_back(std::make_unique<MessageRegistry>(app));
166         nodes.emplace_back(std::make_unique<CertificateService>(app));
167         nodes.emplace_back(
168             std::make_unique<CertificateActionsReplaceCertificate>(app));
169         nodes.emplace_back(std::make_unique<CertificateLocations>(app));
170         nodes.emplace_back(std::make_unique<HTTPSCertificateCollection>(app));
171         nodes.emplace_back(std::make_unique<HTTPSCertificate>(app));
172         nodes.emplace_back(std::make_unique<LDAPCertificateCollection>(app));
173         nodes.emplace_back(std::make_unique<LDAPCertificate>(app));
174         nodes.emplace_back(std::make_unique<CertificateActionGenerateCSR>(app));
175         nodes.emplace_back(
176             std::make_unique<TrustStoreCertificateCollection>(app));
177         nodes.emplace_back(std::make_unique<TrustStoreCertificate>(app));
178         nodes.emplace_back(std::make_unique<SystemPCIeFunctionCollection>(app));
179         nodes.emplace_back(std::make_unique<SystemPCIeFunction>(app));
180         nodes.emplace_back(std::make_unique<SystemPCIeDeviceCollection>(app));
181         nodes.emplace_back(std::make_unique<SystemPCIeDevice>(app));
182 
183         nodes.emplace_back(std::make_unique<SensorCollection>(app));
184         nodes.emplace_back(std::make_unique<Sensor>(app));
185 
186         nodes.emplace_back(std::make_unique<TaskMonitor>(app));
187         nodes.emplace_back(std::make_unique<TaskService>(app));
188         nodes.emplace_back(std::make_unique<TaskCollection>(app));
189         nodes.emplace_back(std::make_unique<Task>(app));
190         nodes.emplace_back(std::make_unique<EventService>(app));
191         nodes.emplace_back(std::make_unique<EventDestinationCollection>(app));
192         nodes.emplace_back(std::make_unique<EventDestination>(app));
193         nodes.emplace_back(std::make_unique<SubmitTestEvent>(app));
194 
195         nodes.emplace_back(
196             std::make_unique<HypervisorInterfaceCollection>(app));
197         nodes.emplace_back(std::make_unique<HypervisorInterface>(app));
198         nodes.emplace_back(std::make_unique<HypervisorSystem>(app));
199 
200         for (const auto& node : nodes)
201         {
202             node->initPrivileges();
203         }
204     }
205 
206   private:
207     std::vector<std::unique_ptr<Node>> nodes;
208 };
209 
210 } // namespace redfish
211