Zdravko Bozakov | 7401ff2 | 2019-05-28 22:45:12 +0200 | [diff] [blame^] | 1 | // Copyright (c) 2018 Open Networking Foundation |
| 2 | // |
| 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 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | syntax = "proto3"; |
| 16 | package bbsim.api.v1; |
| 17 | |
| 18 | import "google/api/annotations.proto"; |
| 19 | import "protoc-gen-swagger/options/annotations.proto"; |
| 20 | |
| 21 | option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = { |
| 22 | info: { |
| 23 | title: "BBSim API"; |
| 24 | version: "1.0"; |
| 25 | }; |
| 26 | schemes: HTTP; |
| 27 | consumes: "application/json"; |
| 28 | produces: "application/json"; |
| 29 | responses: { |
| 30 | key: "404"; |
| 31 | value: { |
| 32 | description: "Returned when the resource does not exist."; |
| 33 | schema: { |
| 34 | json_schema: { |
| 35 | type: STRING; |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | }; |
| 41 | |
| 42 | // OLT information |
| 43 | message OLTInfo { |
| 44 | int64 olt_id = 1; |
| 45 | string olt_serial = 2; |
| 46 | string olt_ip = 3; |
| 47 | string olt_state = 4; |
| 48 | string olt_vendor = 5; |
| 49 | } |
| 50 | |
| 51 | // ONU information |
| 52 | message ONUInfo { |
| 53 | uint32 onu_id = 1; |
| 54 | uint32 pon_port_id = 2; |
| 55 | // ONU serial number |
| 56 | string onu_serial = 3; |
| 57 | // ONU oper state |
| 58 | string oper_state = 4; |
| 59 | // ONU internal state |
| 60 | string onu_state = 5; |
| 61 | } |
| 62 | |
| 63 | // Bulk ONU operations |
| 64 | message ONUs { |
| 65 | repeated ONUInfo onus = 1; |
| 66 | } |
| 67 | |
| 68 | message ONURequest { |
| 69 | ONUInfo onu = 1; |
| 70 | ONUs onus_batch = 2; |
| 71 | } |
| 72 | |
| 73 | // Port information |
| 74 | message PortInfo { |
| 75 | string port_type = 1; |
| 76 | uint32 port_id = 2; |
| 77 | int32 pon_port_max_onus = 3; |
| 78 | uint32 pon_port_active_onus = 4; |
| 79 | string port_state = 5; |
| 80 | string alarm_state = 6; |
| 81 | } |
| 82 | |
| 83 | // Bulk port information |
| 84 | message Ports { |
| 85 | repeated PortInfo ports = 1; |
| 86 | } |
| 87 | |
| 88 | // BBSim status |
| 89 | message OLTStatusResponse { |
| 90 | OLTInfo olt = 1; |
| 91 | repeated PortInfo ports = 2; |
| 92 | } |
| 93 | |
| 94 | // BBSim response message |
| 95 | message BBSimResponse { |
| 96 | string status_msg = 1; |
| 97 | } |
| 98 | |
| 99 | // ONU alarm request |
| 100 | message ONUAlarmRequest { |
| 101 | // ONU serial number |
| 102 | string onu_serial = 1; |
| 103 | // Alarm types are: |
| 104 | // "signaldegrade" |
| 105 | // "lossofomcichannel" |
| 106 | // "lossofploam" |
| 107 | string alarm_type = 2; |
| 108 | // "on"/"off" indicates raised or cleared alarm |
| 109 | string status = 3; } |
| 110 | |
| 111 | // OLT alarm request |
| 112 | message OLTAlarmRequest { |
| 113 | uint32 port_id = 1; |
| 114 | string port_type = 2; |
| 115 | string status = 3; |
| 116 | } |
| 117 | |
| 118 | // Device action |
| 119 | message DeviceAction { |
| 120 | string device_type = 1; // ONU or OLT |
| 121 | string device_serial_number = 2; // Device serial number |
| 122 | string device_action = 3; // soft or hard reboot |
| 123 | } |
| 124 | |
| 125 | message Empty {} |
| 126 | |
| 127 | service BBSimService { |
| 128 | |
| 129 | // Get current status of OLT |
| 130 | rpc OLTStatus(Empty) returns (OLTStatusResponse) { |
| 131 | option (google.api.http) = { |
| 132 | get : "/v1/olt" |
| 133 | additional_bindings {get : "/v1/olt/status"} |
| 134 | }; |
| 135 | } |
| 136 | |
| 137 | // Get status of a PON/NNI port |
| 138 | rpc PortStatus(PortInfo) returns (Ports) { |
| 139 | option (google.api.http) = { |
| 140 | get : "/v1/olt/ports/{port_type}" |
| 141 | }; |
| 142 | } |
| 143 | |
| 144 | // Get status of all or specific ONUs |
| 145 | rpc ONUStatus(ONURequest) returns (ONUs) { |
| 146 | option (google.api.http) = { |
| 147 | get : "/v1/olt/onus" |
| 148 | additional_bindings { get : "/v1/olt/ports/{onu.pon_port_id}/onus" } |
| 149 | additional_bindings { get : "/v1/olt/onus/{onu.onu_serial}" } |
| 150 | }; |
| 151 | } |
| 152 | |
| 153 | // Single/bulk activate ONU(s) for specific PON port(s) |
| 154 | rpc ONUActivate(ONURequest) returns (BBSimResponse) { |
| 155 | option (google.api.http) = { |
| 156 | post : "/v1/olt/onus" |
| 157 | body: "onus_batch" |
| 158 | additional_bindings { post : "/v1/olt/ports/{onu.pon_port_id}/onus" } |
| 159 | additional_bindings { post : "/v1/olt/ports/{onu.pon_port_id}/onus/{onu.onu_serial}" } |
| 160 | }; |
| 161 | } |
| 162 | |
| 163 | // Deactivate ONU(s) for specific PON port(s) specified by |
| 164 | // a given onu_serial, onu_id, or pon_port_id |
| 165 | rpc ONUDeactivate(ONURequest) returns (BBSimResponse) { |
| 166 | option (google.api.http) = { |
| 167 | delete : "/v1/olt/onus" |
| 168 | body: "onus_batch" |
| 169 | additional_bindings { delete: "/v1/olt/onus/{onu.onu_serial}" } |
| 170 | additional_bindings { delete: "/v1/olt/ports/{onu.pon_port_id}/onus" } |
| 171 | additional_bindings { delete: "/v1/olt/ports/{onu.pon_port_id}/onus/{onu.onu_id}" } |
| 172 | }; |
| 173 | } |
| 174 | |
| 175 | // Generate ONU related alarms |
| 176 | rpc GenerateONUAlarm(ONUAlarmRequest) returns (BBSimResponse) { |
| 177 | option (google.api.http) = { |
| 178 | post : "/v1/olt/onus/{onu_serial}/alarms/{alarm_type}/{status}" |
| 179 | }; |
| 180 | } |
| 181 | |
| 182 | // Generate OLT related alarms |
| 183 | rpc GenerateOLTAlarm(OLTAlarmRequest) returns (BBSimResponse) { |
| 184 | option (google.api.http) = { |
| 185 | post : "/v1/olt/ports/{port_type}/{port_id}/alarms/los/{status}" |
| 186 | }; |
| 187 | } |
| 188 | |
| 189 | // Perform actions on OLT/ONU devices (e.g. reboot) |
| 190 | rpc PerformDeviceAction(DeviceAction) returns (BBSimResponse) { |
| 191 | option (google.api.http) = { |
| 192 | patch: "/v1/{device_type}/reboot" |
| 193 | additional_bindings { patch : "/v1/olt/{device_type}/{device_serial_number}/reboot/{device_action}"} |
| 194 | }; |
| 195 | } |
| 196 | } |