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