added get wlan configs, made use of it in coretk, updated node context to allow wlan config during runtime

This commit is contained in:
Blake Harnden 2019-12-13 11:48:36 -08:00
parent b993fadedb
commit 9b16f272b8
5 changed files with 56 additions and 5 deletions

View file

@ -239,15 +239,17 @@ class CoreClient:
node_id, config.model, config.config, interface
)
# get wlan configurations
response = self.client.get_wlan_configs(self.session_id)
for _id in response.configs:
mapped_config = response.configs[_id]
self.wlan_configs[_id] = mapped_config.config
# save and retrieve data, needed for session nodes
for node in session.nodes:
# get node service config and file config
# get wlan configs for wlan nodes
if node.type == core_pb2.NodeType.WIRELESS_LAN:
response = self.client.get_wlan_config(self.session_id, node.id)
self.wlan_configs[node.id] = response.config
# retrieve service configurations data for default nodes
elif node.type == core_pb2.NodeType.DEFAULT:
if node.type == core_pb2.NodeType.DEFAULT:
for service in node.services:
response = self.client.get_node_service(
self.session_id, node.id, service

View file

@ -173,6 +173,8 @@ class CanvasNode:
context.add_command(label="Configure", command=self.show_config)
if NodeUtils.is_container_node(self.core_node.type):
context.add_command(label="Services", state=tk.DISABLED)
if is_wlan:
context.add_command(label="WLAN Config", command=self.show_wlan_config)
if is_wlan and self.core_node.id in self.app.core.mobility_players:
context.add_command(
label="Mobility Player", command=self.show_mobility_player

View file

@ -827,6 +827,18 @@ class CoreGrpcClient:
)
return self.stub.ServiceAction(request)
def get_wlan_configs(self, session_id):
"""
Get all wlan configurations.
:param int session_id: session id
:return: response with a dict of node ids to wlan configurations
:rtype: core_pb2.GetWlanConfigsResponse
:raises grpc.RpcError: when session doesn't exist
"""
request = core_pb2.GetWlanConfigsRequest(session_id=session_id)
return self.stub.GetWlanConfigs(request)
def get_wlan_config(self, session_id, node_id):
"""
Get wlan configuration for a node.

View file

@ -1236,6 +1236,31 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
return core_pb2.ServiceActionResponse(result=result)
def GetWlanConfigs(self, request, context):
"""
Retrieve all wireless-lan configurations.
:param core.api.grpc.core_pb2.GetWlanConfigsRequest request: request
:param context: core.api.grpc.core_pb2.GetWlanConfigResponse
:return: all wlan configurations
:rtype: core.api.grpc.core_pb2.GetWlanConfigsResponse
"""
logging.debug("get wlan configs: %s", request)
session = self.get_session(request.session_id, context)
response = core_pb2.GetWlanConfigsResponse()
for node_id in session.mobility.node_configurations:
model_config = session.mobility.node_configurations[node_id]
if node_id == -1:
continue
for model_name in model_config:
if model_name != BasicRangeModel.name:
continue
current_config = session.mobility.get_model_config(node_id, model_name)
config = get_config_options(current_config, BasicRangeModel)
mapped_config = core_pb2.MappedConfig(config=config)
response.configs[node_id].CopyFrom(mapped_config)
return response
def GetWlanConfig(self, request, context):
"""
Retrieve wireless-lan configuration of a node

View file

@ -101,6 +101,8 @@ service CoreApi {
}
// wlan rpc
rpc GetWlanConfigs (GetWlanConfigsRequest) returns (GetWlanConfigsResponse) {
}
rpc GetWlanConfig (GetWlanConfigRequest) returns (GetWlanConfigResponse) {
}
rpc SetWlanConfig (SetWlanConfigRequest) returns (SetWlanConfigResponse) {
@ -585,6 +587,14 @@ message ServiceActionResponse {
bool result = 1;
}
message GetWlanConfigsRequest {
int32 session_id = 1;
}
message GetWlanConfigsResponse {
map<int32, MappedConfig> configs = 1;
}
message GetWlanConfigRequest {
int32 session_id = 1;
int32 node_id = 2;