Martin Cosyns | 0efdc87 | 2021-09-27 16:24:30 +0000 | [diff] [blame] | 1 | # Copyright 2020-present Open Networking Foundation |
| 2 | # Original copyright 2020-present ADTRAN, Inc. |
| 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 | from concurrent import futures |
| 15 | import grpc |
| 16 | |
| 17 | import dmi.hw_events_mgmt_service_pb2 |
| 18 | import dmi.hw_events_mgmt_service_pb2_grpc |
| 19 | import dmi.hw_management_service_pb2 |
| 20 | import dmi.hw_management_service_pb2_grpc |
| 21 | import dmi.hw_metrics_mgmt_service_pb2 |
| 22 | import dmi.hw_metrics_mgmt_service_pb2_grpc |
| 23 | import dmi.sw_management_service_pb2 |
| 24 | import dmi.sw_management_service_pb2_grpc |
| 25 | import dmi.commons_pb2 |
| 26 | import dmi.sw_image_pb2 |
| 27 | |
| 28 | |
| 29 | class DmiEventsManagementServiceServicer(dmi.hw_events_mgmt_service_pb2_grpc.NativeEventsManagementServiceServicer): |
| 30 | |
| 31 | def ListEvents(self, request, context): |
| 32 | return dmi.hw_events_mgmt_service_pb2.ListEventsResponse(status=dmi.commons_pb2.OK_STATUS) |
| 33 | |
| 34 | def UpdateEventsConfiguration(self, request, context): |
| 35 | return dmi.hw_events_mgmt_service_pb2.EventsConfigurationResponse(status=dmi.commons_pb2.OK_STATUS) |
| 36 | |
| 37 | def StreamEvents(self, request, context): |
| 38 | for _ in range(0, 1): |
| 39 | yield dmi.hw_events_mgmt_service_pb2.Event(event_id=dmi.hw_events_mgmt_service_pb2.EVENT_NAME_UNDEFINED) |
| 40 | |
| 41 | |
| 42 | class DmiHwManagementServiceServicer(dmi.hw_management_service_pb2_grpc.NativeHWManagementServiceServicer): |
| 43 | |
| 44 | def StartManagingDevice(self, request, context): |
| 45 | for _ in range(0, 1): |
| 46 | yield dmi.hw_management_service_pb2.StartManagingDeviceResponse(status=dmi.commons_pb2.OK_STATUS) |
| 47 | |
| 48 | def StopManagingDevice(self, request, context): |
| 49 | return dmi.hw_management_service_pb2.StopManagingDeviceResponse(status=dmi.commons_pb2.OK_STATUS) |
| 50 | |
| 51 | def GetManagedDevices(self, request, context): |
| 52 | return dmi.hw_management_service_pb2.ManagedDevicesResponse() |
| 53 | |
| 54 | def GetPhysicalInventory(self, request, context): |
| 55 | for _ in range(0, 1): |
| 56 | yield dmi.hw_management_service_pb2.PhysicalInventoryResponse(status=dmi.commons_pb2.OK_STATUS) |
| 57 | |
| 58 | def GetHWComponentInfo(self, request, context): |
| 59 | for _ in range(0, 1): |
| 60 | yield dmi.hw_management_service_pb2.HWComponentInfoGetResponse(status=dmi.commons_pb2.OK_STATUS) |
| 61 | |
| 62 | def SetHWComponentInfo(self, request, context): |
| 63 | return dmi.hw_management_service_pb2.HWComponentInfoSetResponse(status=dmi.commons_pb2.OK_STATUS) |
| 64 | |
| 65 | def SetLoggingEndpoint(self, request, context): |
| 66 | return dmi.hw_management_service_pb2.SetRemoteEndpointResponse(status=dmi.commons_pb2.OK_STATUS) |
| 67 | |
| 68 | def GetLoggingEndpoint(self, request, context): |
| 69 | return dmi.hw_management_service_pb2.GetLoggingEndpointResponse(status=dmi.commons_pb2.OK_STATUS) |
| 70 | |
| 71 | def SetMsgBusEndpoint(self, request, context): |
| 72 | return dmi.hw_management_service_pb2.SetRemoteEndpointResponse(status=dmi.commons_pb2.OK_STATUS) |
| 73 | |
| 74 | def GetMsgBusEndpoint(self, request, context): |
| 75 | return dmi.hw_management_service_pb2.GetMsgBusEndpointResponse(status=dmi.commons_pb2.OK_STATUS) |
| 76 | |
| 77 | def GetLoggableEntities(self, request, context): |
| 78 | return dmi.hw_management_service_pb2.GetLogLevelResponse(status=dmi.commons_pb2.OK_STATUS) |
| 79 | |
| 80 | def SetLogLevel(self, request, context): |
| 81 | return dmi.hw_management_service_pb2.SetLogLevelResponse() |
| 82 | |
| 83 | def GetLogLevel(self, request, context): |
| 84 | return dmi.hw_management_service_pb2.GetLogLevelResponse(status=dmi.commons_pb2.OK_STATUS) |
| 85 | |
| 86 | def HeartbeatCheck(self, request, context): |
| 87 | return dmi.hw_management_service_pb2.Heartbeat(heartbeat_signature=0) |
| 88 | |
| 89 | def RebootDevice(self, request, context): |
| 90 | return dmi.hw_management_service_pb2.RebootDeviceResponse(status=dmi.commons_pb2.OK_STATUS) |
| 91 | |
| 92 | |
| 93 | class DmiMetricsManagementServiceServicer(dmi.hw_metrics_mgmt_service_pb2_grpc.NativeMetricsManagementServiceServicer): |
| 94 | |
| 95 | def ListMetrics(self, request, context): |
| 96 | return dmi.hw_metrics_mgmt_service_pb2.ListMetricsResponse(status=dmi.commons_pb2.OK_STATUS) |
| 97 | |
| 98 | def UpdateMetricsConfiguration(self, request, context): |
| 99 | return dmi.hw_metrics_mgmt_service_pb2.MetricsConfigurationResponse(status=dmi.commons_pb2.OK_STATUS) |
| 100 | |
| 101 | def GetMetric(self, request, context): |
| 102 | return dmi.hw_metrics_mgmt_service_pb2.GetMetricResponse(status=dmi.commons_pb2.OK_STATUS) |
| 103 | |
| 104 | def StreamMetrics(self, request, context): |
| 105 | for _ in range(0, 1): |
| 106 | yield dmi.hw_metrics_mgmt_service_pb2.Metric(metric_id=dmi.hw_metrics_mgmt_service_pb2.METRIC_NAME_UNDEFINED) |
| 107 | |
| 108 | |
| 109 | class DmiSoftwareManagementServiceServicer(dmi.sw_management_service_pb2_grpc.NativeSoftwareManagementServiceServicer): |
| 110 | |
| 111 | def GetSoftwareVersion(self, request, context): |
| 112 | return dmi.sw_management_service_pb2.GetSoftwareVersionInformationResponse(status=dmi.commons_pb2.OK_STATUS) |
| 113 | |
| 114 | def DownloadImage(self, request, context): |
| 115 | for _ in range(0, 1): |
| 116 | yield dmi.sw_image_pb2.ImageStatus(status=dmi.commons_pb2.OK_STATUS) |
| 117 | |
| 118 | def ActivateImage(self, request, context): |
| 119 | for _ in range(0, 1): |
| 120 | yield dmi.sw_image_pb2.ImageStatus(status=dmi.commons_pb2.OK_STATUS) |
| 121 | |
| 122 | def RevertToStandbyImage(self, request, context): |
| 123 | for _ in range(0, 1): |
| 124 | yield dmi.sw_image_pb2.ImageStatus(status=dmi.commons_pb2.OK_STATUS) |
| 125 | |
| 126 | def UpdateStartupConfiguration(self, request, context): |
| 127 | for _ in range(0, 1): |
| 128 | yield dmi.sw_management_service_pb2.ConfigResponse(status=dmi.commons_pb2.OK_STATUS) |
| 129 | |
| 130 | def GetStartupConfigurationInfo(self, request, context): |
| 131 | return dmi.sw_management_service_pb2.StartupConfigInfoResponse(status=dmi.commons_pb2.OK_STATUS) |
| 132 | |
| 133 | |
| 134 | def serve(): |
| 135 | server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) |
| 136 | |
| 137 | dmi.hw_events_mgmt_service_pb2_grpc.add_NativeEventsManagementServiceServicer_to_server(DmiEventsManagementServiceServicer(), server) |
| 138 | dmi.hw_management_service_pb2_grpc.add_NativeHWManagementServiceServicer_to_server(DmiHwManagementServiceServicer(), server) |
| 139 | dmi.hw_metrics_mgmt_service_pb2_grpc.add_NativeMetricsManagementServiceServicer_to_server(DmiMetricsManagementServiceServicer(), server) |
| 140 | dmi.sw_management_service_pb2_grpc.add_NativeSoftwareManagementServiceServicer_to_server(DmiSoftwareManagementServiceServicer(), server) |
| 141 | |
| 142 | server.add_insecure_port('127.0.01:50051') |
| 143 | server.start() |
| 144 | server.wait_for_termination() |
| 145 | |
| 146 | |
| 147 | if __name__ == '__main__': |
| 148 | serve() |