Beerappa S M | 7af96e5 | 2021-04-20 18:57:54 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2021-present Open Networking Foundation |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at |
| 6 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | * Unless required by applicable law or agreed to in writing, software |
| 8 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | * See the License for the specific language governing permissions and |
| 11 | * limitations under the License. |
| 12 | */ |
| 13 | |
| 14 | #ifndef DMI_HW_MGMT_H_ |
| 15 | #include "dmi_hw_mgmt.h" |
| 16 | #endif |
| 17 | |
| 18 | #include "dmi_sw_mgmt.h" |
| 19 | #include "dmi_events_mgmt.h" |
| 20 | #include "dmi_metrics_mgmt.h" |
| 21 | |
| 22 | #define GRPC_ADDRESS "0.0.0.0:9292" |
| 23 | |
| 24 | using namespace std; |
| 25 | |
| 26 | void RunGrpcServer() { |
| 27 | const char* address = GRPC_ADDRESS; |
| 28 | HWMgmtService &HWMgmtSrv = HWMgmtService::getHWInstance(); |
| 29 | SWMgmtService &SWMgmtSrv = SWMgmtService::getSWInstance(); |
| 30 | HWEventsMgmtService &EventMgmtSrv = HWEventsMgmtService::getHwEventMgmtInstance(); |
| 31 | HWMetricsMgmtService &MetricMgmtSrv = HWMetricsMgmtService::getHwMetricMgmtInstance(); |
| 32 | |
| 33 | ServerBuilder builder; |
| 34 | |
| 35 | builder.AddListeningPort(address, grpc::InsecureServerCredentials()); |
| 36 | builder.RegisterService(&HWMgmtSrv); |
| 37 | builder.RegisterService(&SWMgmtSrv); |
| 38 | builder.RegisterService(&EventMgmtSrv); |
| 39 | builder.RegisterService(&MetricMgmtSrv); |
| 40 | |
| 41 | std::unique_ptr<Server> server(builder.BuildAndStart()); |
| 42 | std::cout << "opendm-agent GRPC server listening on port: " << address << std::endl; |
| 43 | |
| 44 | server->Wait(); |
| 45 | } |