grpc added get wlan and set wlan config
This commit is contained in:
parent
5d72b6af26
commit
9c973249e8
3 changed files with 66 additions and 0 deletions
|
@ -252,6 +252,19 @@ class CoreApiClient(object):
|
|||
request.service = service
|
||||
return self.stub.GetNodeService(request)
|
||||
|
||||
def get_wlan_config(self, session, _id):
|
||||
request = core_pb2.GetWlanConfigRequest()
|
||||
request.session = session
|
||||
request.id = _id
|
||||
return self.stub.GetWlanConfig(request)
|
||||
|
||||
def set_wlan_config(self, session, _id, config):
|
||||
request = core_pb2.SetWlanConfigRequest()
|
||||
request.session = session
|
||||
request.id = _id
|
||||
request.config.update(config)
|
||||
return self.stub.SetWlanConfig(request)
|
||||
|
||||
def get_emane_config(self, session):
|
||||
request = core_pb2.GetEmaneConfigRequest()
|
||||
request.session = session
|
||||
|
|
|
@ -13,6 +13,7 @@ import grpc
|
|||
import core_pb2
|
||||
import core_pb2_grpc
|
||||
from core.misc import nodeutils
|
||||
from core.mobility import BasicRangeModel
|
||||
from core.service import ServiceManager
|
||||
|
||||
_ONE_DAY_IN_SECONDS = 60 * 60 * 24
|
||||
|
@ -590,6 +591,33 @@ class CoreApiServer(core_pb2_grpc.CoreApiServicer):
|
|||
response.service.meta = service.meta
|
||||
return response
|
||||
|
||||
def GetWlanConfig(self, request, context):
|
||||
session = self.coreemu.sessions.get(request.session)
|
||||
if not session:
|
||||
raise Exception("no session found")
|
||||
node = session.get_object(request.id)
|
||||
if not node:
|
||||
raise Exception("no node found")
|
||||
|
||||
config = session.mobility.get_model_config(node.objid, BasicRangeModel.name)
|
||||
groups = get_config_groups(config, BasicRangeModel)
|
||||
response = core_pb2.GetWlanConfigResponse()
|
||||
response.groups.extend(groups)
|
||||
return response
|
||||
|
||||
def SetWlanConfig(self, request, context):
|
||||
session = self.coreemu.sessions.get(request.session)
|
||||
if not session:
|
||||
raise Exception("no session found")
|
||||
node = session.get_object(request.id)
|
||||
if not node:
|
||||
raise Exception("no node found")
|
||||
|
||||
session.mobility.set_model_config(node.objid, BasicRangeModel.name, request.config)
|
||||
response = core_pb2.SetWlanConfigResponse()
|
||||
response.result = True
|
||||
return response
|
||||
|
||||
def GetEmaneConfig(self, request, context):
|
||||
session = self.coreemu.sessions.get(request.session)
|
||||
if not session:
|
||||
|
|
|
@ -57,6 +57,12 @@ service CoreApi {
|
|||
rpc GetNodeService (GetNodeServiceRequest) returns (GetNodeServiceResponse) {
|
||||
}
|
||||
|
||||
// wlan rpc
|
||||
rpc GetWlanConfig (GetWlanConfigRequest) returns (GetWlanConfigResponse) {
|
||||
}
|
||||
rpc SetWlanConfig (SetWlanConfigRequest) returns (SetWlanConfigResponse) {
|
||||
}
|
||||
|
||||
// emane rpc
|
||||
rpc GetEmaneConfig (GetEmaneConfigRequest) returns (GetEmaneConfigResponse) {
|
||||
}
|
||||
|
@ -290,6 +296,25 @@ message GetNodeServiceResponse {
|
|||
NodeServiceData service = 1;
|
||||
}
|
||||
|
||||
message GetWlanConfigRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
}
|
||||
|
||||
message GetWlanConfigResponse {
|
||||
repeated ConfigGroup groups = 1;
|
||||
}
|
||||
|
||||
message SetWlanConfigRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
map<string, string> config = 3;
|
||||
}
|
||||
|
||||
message SetWlanConfigResponse {
|
||||
bool result = 1;
|
||||
}
|
||||
|
||||
message GetEmaneConfigRequest {
|
||||
int32 session = 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue