added get wlan configs, made use of it in coretk, updated node context to allow wlan config during runtime
This commit is contained in:
parent
b993fadedb
commit
9b16f272b8
5 changed files with 56 additions and 5 deletions
|
@ -239,15 +239,17 @@ class CoreClient:
|
||||||
node_id, config.model, config.config, interface
|
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
|
# save and retrieve data, needed for session nodes
|
||||||
for node in session.nodes:
|
for node in session.nodes:
|
||||||
# get node service config and file config
|
# 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
|
# 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:
|
for service in node.services:
|
||||||
response = self.client.get_node_service(
|
response = self.client.get_node_service(
|
||||||
self.session_id, node.id, service
|
self.session_id, node.id, service
|
||||||
|
|
|
@ -173,6 +173,8 @@ class CanvasNode:
|
||||||
context.add_command(label="Configure", command=self.show_config)
|
context.add_command(label="Configure", command=self.show_config)
|
||||||
if NodeUtils.is_container_node(self.core_node.type):
|
if NodeUtils.is_container_node(self.core_node.type):
|
||||||
context.add_command(label="Services", state=tk.DISABLED)
|
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:
|
if is_wlan and self.core_node.id in self.app.core.mobility_players:
|
||||||
context.add_command(
|
context.add_command(
|
||||||
label="Mobility Player", command=self.show_mobility_player
|
label="Mobility Player", command=self.show_mobility_player
|
||||||
|
|
|
@ -827,6 +827,18 @@ class CoreGrpcClient:
|
||||||
)
|
)
|
||||||
return self.stub.ServiceAction(request)
|
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):
|
def get_wlan_config(self, session_id, node_id):
|
||||||
"""
|
"""
|
||||||
Get wlan configuration for a node.
|
Get wlan configuration for a node.
|
||||||
|
|
|
@ -1236,6 +1236,31 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
||||||
|
|
||||||
return core_pb2.ServiceActionResponse(result=result)
|
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):
|
def GetWlanConfig(self, request, context):
|
||||||
"""
|
"""
|
||||||
Retrieve wireless-lan configuration of a node
|
Retrieve wireless-lan configuration of a node
|
||||||
|
|
|
@ -101,6 +101,8 @@ service CoreApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
// wlan rpc
|
// wlan rpc
|
||||||
|
rpc GetWlanConfigs (GetWlanConfigsRequest) returns (GetWlanConfigsResponse) {
|
||||||
|
}
|
||||||
rpc GetWlanConfig (GetWlanConfigRequest) returns (GetWlanConfigResponse) {
|
rpc GetWlanConfig (GetWlanConfigRequest) returns (GetWlanConfigResponse) {
|
||||||
}
|
}
|
||||||
rpc SetWlanConfig (SetWlanConfigRequest) returns (SetWlanConfigResponse) {
|
rpc SetWlanConfig (SetWlanConfigRequest) returns (SetWlanConfigResponse) {
|
||||||
|
@ -585,6 +587,14 @@ message ServiceActionResponse {
|
||||||
bool result = 1;
|
bool result = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message GetWlanConfigsRequest {
|
||||||
|
int32 session_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetWlanConfigsResponse {
|
||||||
|
map<int32, MappedConfig> configs = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message GetWlanConfigRequest {
|
message GetWlanConfigRequest {
|
||||||
int32 session_id = 1;
|
int32 session_id = 1;
|
||||||
int32 node_id = 2;
|
int32 node_id = 2;
|
||||||
|
|
Loading…
Reference in a new issue