grpc - add rpc to get local non-core interfaces

This commit is contained in:
Blake Harnden 2019-07-12 13:02:15 -07:00
parent a97d93ef4c
commit bcd2584eb8
2 changed files with 19 additions and 0 deletions

View file

@ -960,3 +960,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
logging.exception("error opening session file")
self.coreemu.delete_session(session.id)
context.abort(grpc.StatusCode.INVALID_ARGUMENT, "invalid xml file")
def GetInterfaces(self, request, context):
interfaces = []
for interface in os.listdir("/sys/class/net"):
if interface.startswith("b.") or interface.startswith("veth") or interface == "lo":
continue
interfaces.append(interface)
return core_pb2.GetInterfacesResponse(interfaces=interfaces)

View file

@ -115,6 +115,10 @@ service CoreApi {
}
rpc OpenXml (OpenXmlRequest) returns (OpenXmlResponse) {
}
// utilities
rpc GetInterfaces (GetInterfacesRequest) returns (GetInterfacesResponse) {
}
}
// rpc request/response messages
@ -622,6 +626,13 @@ message OpenXmlResponse {
int32 session_id = 2;
}
message GetInterfacesRequest {
}
message GetInterfacesResponse {
repeated string interfaces = 1;
}
// data structures for messages below
message MessageType {
enum Enum {