From f4ddf310a8c64c0e377de7efd08153ec81a80362 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Thu, 16 Jan 2020 11:00:57 -0800 Subject: [PATCH] removed rtype and param typing from doc strings to help avoid maintaining duplicate information provided by type hints --- daemon/core/api/grpc/client.py | 354 +++++++++++--------------- daemon/core/api/grpc/events.py | 23 +- daemon/core/api/grpc/grpcutils.py | 55 ++-- daemon/core/api/grpc/server.py | 268 ++++++++----------- daemon/core/config.py | 82 +++--- daemon/core/emane/commeffect.py | 2 +- daemon/core/emane/emanemanager.py | 17 +- daemon/core/emane/emanemanifest.py | 23 +- daemon/core/emane/emanemodel.py | 18 +- daemon/core/emulator/coreemu.py | 16 +- daemon/core/emulator/distributed.py | 45 ++-- daemon/core/emulator/emudata.py | 62 +++-- daemon/core/emulator/session.py | 223 ++++++++-------- daemon/core/emulator/sessionconfig.py | 7 +- daemon/core/gui/graph/graph.py | 2 +- daemon/core/gui/toolbar.py | 6 +- daemon/core/location/corelocation.py | 9 +- daemon/core/location/event.py | 8 +- daemon/core/location/mobility.py | 101 ++++---- daemon/core/nodes/base.py | 247 ++++++++---------- daemon/core/nodes/client.py | 16 +- daemon/core/nodes/docker.py | 39 ++- daemon/core/nodes/interface.py | 99 ++++--- daemon/core/nodes/lxd.py | 37 ++- daemon/core/nodes/netclient.py | 101 ++++---- daemon/core/nodes/network.py | 140 +++++----- daemon/core/nodes/physical.py | 66 +++-- daemon/core/plugins/sdt.py | 39 ++- daemon/core/services/__init__.py | 3 +- daemon/core/services/coreservices.py | 144 +++++------ daemon/core/utils.py | 77 +++--- daemon/core/xml/emanexml.py | 119 ++++----- 32 files changed, 1091 insertions(+), 1357 deletions(-) diff --git a/daemon/core/api/grpc/client.py b/daemon/core/api/grpc/client.py index a2641e87..07e9d8ef 100644 --- a/daemon/core/api/grpc/client.py +++ b/daemon/core/api/grpc/client.py @@ -23,8 +23,8 @@ class InterfaceHelper: """ Creates an InterfaceHelper object. - :param str ip4_prefix: ip4 prefix to use for generation - :param str ip6_prefix: ip6 prefix to use for generation + :param ip4_prefix: ip4 prefix to use for generation + :param ip6_prefix: ip6 prefix to use for generation :raises ValueError: when both ip4 and ip6 prefixes have not been provided """ if not ip4_prefix and not ip6_prefix: @@ -41,9 +41,8 @@ class InterfaceHelper: """ Convenience method to return the IP4 address for a node. - :param int node_id: node id to get IP4 address for + :param node_id: node id to get IP4 address for :return: IP4 address or None - :rtype: str """ if not self.ip4: raise ValueError("ip4 prefixes have not been set") @@ -53,9 +52,8 @@ class InterfaceHelper: """ Convenience method to return the IP6 address for a node. - :param int node_id: node id to get IP6 address for + :param node_id: node id to get IP6 address for :return: IP4 address or None - :rtype: str """ if not self.ip6: raise ValueError("ip6 prefixes have not been set") @@ -68,13 +66,12 @@ class InterfaceHelper: Creates interface data for linking nodes, using the nodes unique id for generation, along with a random mac address, unless provided. - :param int node_id: node id to create interface for - :param int interface_id: interface id for interface - :param str name: name to set for interface, default is eth{id} - :param str mac: mac address to use for this interface, default is random + :param node_id: node id to create interface for + :param interface_id: interface id for interface + :param name: name to set for interface, default is eth{id} + :param mac: mac address to use for this interface, default is random generation :return: new interface data for the provided node - :rtype: core_pb2.Interface """ # generate ip4 data ip4 = None @@ -145,7 +142,7 @@ class CoreGrpcClient: """ Creates a CoreGrpcClient instance. - :param str address: grpc server address to connect to + :param address: grpc server address to connect to """ self.address = address self.stub = None @@ -170,20 +167,19 @@ class CoreGrpcClient: """ Start a session. - :param int session_id: id of session - :param list nodes: list of nodes to create - :param list links: list of links to create - :param core_pb2.SessionLocation location: location to set - :param list[core_pb2.Hook] hooks: session hooks to set - :param dict emane_config: emane configuration to set - :param list emane_model_configs: node emane model configurations - :param list wlan_configs: node wlan configurations - :param list mobility_configs: node mobility configurations - :param list service_configs: node service configurations - :param list service_file_configs: node service file configurations - :param list asymmetric_links: asymmetric links to edit + :param session_id: id of session + :param nodes: list of nodes to create + :param links: list of links to create + :param location: location to set + :param hooks: session hooks to set + :param emane_config: emane configuration to set + :param emane_model_configs: node emane model configurations + :param wlan_configs: node wlan configurations + :param mobility_configs: node mobility configurations + :param service_configs: node service configurations + :param service_file_configs: node service file configurations + :param asymmetric_links: asymmetric links to edit :return: start session response - :rtype: core_pb2.StartSessionResponse """ request = core_pb2.StartSessionRequest( session_id=session_id, @@ -205,9 +201,8 @@ class CoreGrpcClient: """ Stop a running session. - :param int session_id: id of session + :param session_id: id of session :return: stop session response - :rtype: core_pb2.StopSessionResponse """ request = core_pb2.StopSessionRequest(session_id=session_id) return self.stub.StopSession(request) @@ -216,10 +211,9 @@ class CoreGrpcClient: """ Create a session. - :param int session_id: id for session, default is None and one will be created + :param session_id: id for session, default is None and one will be created for you :return: response with created session id - :rtype: core_pb2.CreateSessionResponse """ request = core_pb2.CreateSessionRequest(session_id=session_id) return self.stub.CreateSession(request) @@ -228,9 +222,8 @@ class CoreGrpcClient: """ Delete a session. - :param int session_id: id of session + :param session_id: id of session :return: response with result of deletion success or failure - :rtype: core_pb2.DeleteSessionResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.DeleteSessionRequest(session_id=session_id) @@ -242,7 +235,6 @@ class CoreGrpcClient: :return: response with a list of currently known session, their state and number of nodes - :rtype: core_pb2.GetSessionsResponse """ return self.stub.GetSessions(core_pb2.GetSessionsRequest()) @@ -250,9 +242,8 @@ class CoreGrpcClient: """ Retrieve a session. - :param int session_id: id of session + :param session_id: id of session :return: response with sessions state, nodes, and links - :rtype: core_pb2.GetSessionResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.GetSessionRequest(session_id=session_id) @@ -264,9 +255,8 @@ class CoreGrpcClient: """ Retrieve session options as a dict with id mapping. - :param int session_id: id of session + :param session_id: id of session :return: response with a list of configuration groups - :rtype: core_pb2.GetSessionOptionsResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.GetSessionOptionsRequest(session_id=session_id) @@ -278,10 +268,9 @@ class CoreGrpcClient: """ Set options for a session. - :param int session_id: id of session - :param dict[str, str] config: configuration values to set + :param session_id: id of session + :param config: configuration values to set :return: response with result of success or failure - :rtype: core_pb2.SetSessionOptionsResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.SetSessionOptionsRequest( @@ -295,9 +284,8 @@ class CoreGrpcClient: """ Retrieve session metadata as a dict with id mapping. - :param int session_id: id of session + :param session_id: id of session :return: response with metadata dict - :rtype: core_pb2.GetSessionMetadataResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.GetSessionMetadataRequest(session_id=session_id) @@ -309,10 +297,9 @@ class CoreGrpcClient: """ Set metadata for a session. - :param int session_id: id of session - :param dict[str, str] config: configuration values to set + :param session_id: id of session + :param config: configuration values to set :return: response with result of success or failure - :rtype: core_pb2.SetSessionMetadataResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.SetSessionMetadataRequest( @@ -326,9 +313,8 @@ class CoreGrpcClient: """ Get session location. - :param int session_id: id of session + :param session_id: id of session :return: response with session position reference and scale - :rtype: core_pb2.GetSessionLocationResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.GetSessionLocationRequest(session_id=session_id) @@ -348,16 +334,15 @@ class CoreGrpcClient: """ Set session location. - :param int session_id: id of session - :param float x: x position - :param float y: y position - :param float z: z position - :param float lat: latitude position - :param float lon: longitude position - :param float alt: altitude position - :param float scale: geo scale + :param session_id: id of session + :param x: x position + :param y: y position + :param z: z position + :param lat: latitude position + :param lon: longitude position + :param alt: altitude position + :param scale: geo scale :return: response with result of success or failure - :rtype: core_pb2.SetSessionLocationResponse :raises grpc.RpcError: when session doesn't exist """ location = core_pb2.SessionLocation( @@ -374,10 +359,9 @@ class CoreGrpcClient: """ Set session state. - :param int session_id: id of session - :param core_pb2.SessionState state: session state to transition to + :param session_id: id of session + :param state: session state to transition to :return: response with result of success or failure - :rtype: core_pb2.SetSessionStateResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.SetSessionStateRequest(session_id=session_id, state=state) @@ -389,11 +373,10 @@ class CoreGrpcClient: """ Add distributed session server. - :param int session_id: id of session - :param str name: name of server to add - :param str host: host address to connect to + :param session_id: id of session + :param name: name of server to add + :param host: host address to connect to :return: response with result of success or failure - :rtype: core_pb2.AddSessionServerResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.AddSessionServerRequest( @@ -410,9 +393,9 @@ class CoreGrpcClient: """ Listen for session events. - :param int session_id: id of session + :param session_id: id of session :param handler: handler for received events - :param list events: events to listen to, defaults to all + :param events: events to listen to, defaults to all :return: stream processing events, can be used to cancel stream :raises grpc.RpcError: when session doesn't exist """ @@ -428,7 +411,7 @@ class CoreGrpcClient: """ Listen for throughput events with information for interfaces and bridges. - :param int session_id: session id + :param session_id: session id :param handler: handler for every event :return: stream processing events, can be used to cancel stream :raises grpc.RpcError: when session doesn't exist @@ -444,10 +427,9 @@ class CoreGrpcClient: """ Add node to session. - :param int session_id: session id - :param core_pb2.Node node: node to add + :param session_id: session id + :param node: node to add :return: response with node id - :rtype: core_pb2.AddNodeResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.AddNodeRequest(session_id=session_id, node=node) @@ -457,10 +439,9 @@ class CoreGrpcClient: """ Get node details. - :param int session_id: session id - :param int node_id: node id + :param session_id: session id + :param node_id: node id :return: response with node details - :rtype: core_pb2.GetNodeResponse :raises grpc.RpcError: when session or node doesn't exist """ request = core_pb2.GetNodeRequest(session_id=session_id, node_id=node_id) @@ -477,13 +458,12 @@ class CoreGrpcClient: """ Edit a node, currently only changes position. - :param int session_id: session id - :param int node_id: node id - :param core_pb2.Position position: position to set node to - :param str icon: path to icon for gui to use for node - :param str source: application source editing node + :param session_id: session id + :param node_id: node id + :param position: position to set node to + :param icon: path to icon for gui to use for node + :param source: application source editing node :return: response with result of success or failure - :rtype: core_pb2.EditNodeResponse :raises grpc.RpcError: when session or node doesn't exist """ request = core_pb2.EditNodeRequest( @@ -499,10 +479,9 @@ class CoreGrpcClient: """ Delete node from session. - :param int session_id: session id - :param int node_id: node id + :param session_id: session id + :param node_id: node id :return: response with result of success or failure - :rtype: core_pb2.DeleteNodeResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.DeleteNodeRequest(session_id=session_id, node_id=node_id) @@ -514,11 +493,10 @@ class CoreGrpcClient: """ Send command to a node and get the output. - :param int session_id: session id - :param int node_id: node id - :param str command: command to run on node + :param session_id: session id + :param node_id: node id + :param command: command to run on node :return: response with command combined stdout/stderr - :rtype: core_pb2.NodeCommandResponse :raises grpc.RpcError: when session or node doesn't exist """ request = core_pb2.NodeCommandRequest( @@ -532,10 +510,9 @@ class CoreGrpcClient: """ Retrieve terminal command string for launching a local terminal. - :param int session_id: session id - :param int node_id: node id + :param session_id: session id + :param node_id: node id :return: response with a node terminal command - :rtype: core_pb2.GetNodeTerminalResponse :raises grpc.RpcError: when session or node doesn't exist """ request = core_pb2.GetNodeTerminalRequest( @@ -549,10 +526,9 @@ class CoreGrpcClient: """ Get current links for a node. - :param int session_id: session id - :param int node_id: node id + :param session_id: session id + :param node_id: node id :return: response with a list of links - :rtype: core_pb2.GetNodeLinksResponse :raises grpc.RpcError: when session or node doesn't exist """ request = core_pb2.GetNodeLinksRequest(session_id=session_id, node_id=node_id) @@ -570,14 +546,13 @@ class CoreGrpcClient: """ Add a link between nodes. - :param int session_id: session id - :param int node_one_id: node one id - :param int node_two_id: node two id - :param core_pb2.Interface interface_one: node one interface data - :param core_pb2.Interface interface_two: node two interface data - :param core_pb2.LinkOptions options: options for link (jitter, bandwidth, etc) + :param session_id: session id + :param node_one_id: node one id + :param node_two_id: node two id + :param interface_one: node one interface data + :param interface_two: node two interface data + :param options: options for link (jitter, bandwidth, etc) :return: response with result of success or failure - :rtype: core_pb2.AddLinkResponse :raises grpc.RpcError: when session or one of the nodes don't exist """ link = core_pb2.Link( @@ -603,14 +578,13 @@ class CoreGrpcClient: """ Edit a link between nodes. - :param int session_id: session id - :param int node_one_id: node one id - :param int node_two_id: node two id - :param core_pb2.LinkOptions options: options for link (jitter, bandwidth, etc) - :param int interface_one_id: node one interface id - :param int interface_two_id: node two interface id + :param session_id: session id + :param node_one_id: node one id + :param node_two_id: node two id + :param options: options for link (jitter, bandwidth, etc) + :param interface_one_id: node one interface id + :param interface_two_id: node two interface id :return: response with result of success or failure - :rtype: core_pb2.EditLinkResponse :raises grpc.RpcError: when session or one of the nodes don't exist """ request = core_pb2.EditLinkRequest( @@ -634,13 +608,12 @@ class CoreGrpcClient: """ Delete a link between nodes. - :param int session_id: session id - :param int node_one_id: node one id - :param int node_two_id: node two id - :param int interface_one_id: node one interface id - :param int interface_two_id: node two interface id + :param session_id: session id + :param node_one_id: node one id + :param node_two_id: node two id + :param interface_one_id: node one interface id + :param interface_two_id: node two interface id :return: response with result of success or failure - :rtype: core_pb2.DeleteLinkResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.DeleteLinkRequest( @@ -656,9 +629,8 @@ class CoreGrpcClient: """ Get all hook scripts. - :param int session_id: session id + :param session_id: session id :return: response with a list of hooks - :rtype: core_pb2.GetHooksResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.GetHooksRequest(session_id=session_id) @@ -674,12 +646,11 @@ class CoreGrpcClient: """ Add hook scripts. - :param int session_id: session id - :param core_pb2.SessionState state: state to trigger hook - :param str file_name: name of file for hook script - :param bytes file_data: hook script contents + :param session_id: session id + :param state: state to trigger hook + :param file_name: name of file for hook script + :param file_data: hook script contents :return: response with result of success or failure - :rtype: core_pb2.AddHookResponse :raises grpc.RpcError: when session doesn't exist """ hook = core_pb2.Hook(state=state, file=file_name, data=file_data) @@ -692,9 +663,8 @@ class CoreGrpcClient: """ Get all mobility configurations. - :param int session_id: session id + :param session_id: session id :return: response with a dict of node ids to mobility configurations - :rtype: core_pb2.GetMobilityConfigsResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.GetMobilityConfigsRequest(session_id=session_id) @@ -706,10 +676,9 @@ class CoreGrpcClient: """ Get mobility configuration for a node. - :param int session_id: session id - :param int node_id: node id + :param session_id: session id + :param node_id: node id :return: response with a list of configuration groups - :rtype: core_pb2.GetMobilityConfigResponse :raises grpc.RpcError: when session or node doesn't exist """ request = core_pb2.GetMobilityConfigRequest( @@ -723,11 +692,10 @@ class CoreGrpcClient: """ Set mobility configuration for a node. - :param int session_id: session id - :param int node_id: node id - :param dict[str, str] config: mobility configuration + :param session_id: session id + :param node_id: node id + :param config: mobility configuration :return: response with result of success or failure - :rtype: core_pb2.SetMobilityConfigResponse :raises grpc.RpcError: when session or node doesn't exist """ mobility_config = core_pb2.MobilityConfig(node_id=node_id, config=config) @@ -742,11 +710,10 @@ class CoreGrpcClient: """ Send a mobility action for a node. - :param int session_id: session id - :param int node_id: node id - :param core_pb2.ServiceAction action: action to take + :param session_id: session id + :param node_id: node id + :param action: action to take :return: response with result of success or failure - :rtype: core_pb2.MobilityActionResponse :raises grpc.RpcError: when session or node doesn't exist """ request = core_pb2.MobilityActionRequest( @@ -759,7 +726,6 @@ class CoreGrpcClient: Get all currently loaded services. :return: response with a list of services - :rtype: core_pb2.GetServicesResponse """ request = core_pb2.GetServicesRequest() return self.stub.GetServices(request) @@ -770,9 +736,8 @@ class CoreGrpcClient: """ Get default services for different default node models. - :param int session_id: session id + :param session_id: session id :return: response with a dict of node model to a list of services - :rtype: core_pb2.GetServiceDefaultsResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.GetServiceDefaultsRequest(session_id=session_id) @@ -784,10 +749,9 @@ class CoreGrpcClient: """ Set default services for node models. - :param int session_id: session id - :param dict service_defaults: node models to lists of services + :param session_id: session id + :param service_defaults: node models to lists of services :return: response with result of success or failure - :rtype: core_pb2.SetServiceDefaultsResponse :raises grpc.RpcError: when session doesn't exist """ defaults = [] @@ -806,9 +770,8 @@ class CoreGrpcClient: """ Get service data for a node. - :param int session_id: session id + :param session_id: session id :return: response with all node service configs - :rtype: core_pb2.GetNodeServiceConfigsResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.GetNodeServiceConfigsRequest(session_id=session_id) @@ -820,11 +783,10 @@ class CoreGrpcClient: """ Get service data for a node. - :param int session_id: session id - :param int node_id: node id - :param str service: service name + :param session_id: session id + :param node_id: node id + :param service: service name :return: response with node service data - :rtype: core_pb2.GetNodeServiceResponse :raises grpc.RpcError: when session or node doesn't exist """ request = core_pb2.GetNodeServiceRequest( @@ -838,12 +800,11 @@ class CoreGrpcClient: """ Get a service file for a node. - :param int session_id: session id - :param int node_id: node id - :param str service: service name - :param str file_name: file name to get data for + :param session_id: session id + :param node_id: node id + :param service: service name + :param file_name: file name to get data for :return: response with file data - :rtype: core_pb2.GetNodeServiceFileResponse :raises grpc.RpcError: when session or node doesn't exist """ request = core_pb2.GetNodeServiceFileRequest( @@ -863,14 +824,13 @@ class CoreGrpcClient: """ Set service data for a node. - :param int session_id: session id - :param int node_id: node id - :param str service: service name - :param list startup: startup commands - :param list validate: validation commands - :param list shutdown: shutdown commands + :param session_id: session id + :param node_id: node id + :param service: service name + :param startup: startup commands + :param validate: validation commands + :param shutdown: shutdown commands :return: response with result of success or failure - :rtype: core_pb2.SetNodeServiceResponse :raises grpc.RpcError: when session or node doesn't exist """ config = core_pb2.ServiceConfig( @@ -889,13 +849,12 @@ class CoreGrpcClient: """ Set a service file for a node. - :param int session_id: session id - :param int node_id: node id - :param str service: service name - :param str file_name: file name to save - :param bytes data: data to save for file + :param session_id: session id + :param node_id: node id + :param service: service name + :param file_name: file name to save + :param data: data to save for file :return: response with result of success or failure - :rtype: core_pb2.SetNodeServiceFileResponse :raises grpc.RpcError: when session or node doesn't exist """ config = core_pb2.ServiceFileConfig( @@ -916,13 +875,12 @@ class CoreGrpcClient: """ Send an action to a service for a node. - :param int session_id: session id - :param int node_id: node id - :param str service: service name - :param core_pb2.ServiceAction action: action for service (start, stop, restart, + :param session_id: session id + :param node_id: node id + :param service: service name + :param action: action for service (start, stop, restart, validate) :return: response with result of success or failure - :rtype: core_pb2.ServiceActionResponse :raises grpc.RpcError: when session or node doesn't exist """ request = core_pb2.ServiceActionRequest( @@ -934,9 +892,8 @@ class CoreGrpcClient: """ Get all wlan configurations. - :param int session_id: session id + :param 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) @@ -948,10 +905,9 @@ class CoreGrpcClient: """ Get wlan configuration for a node. - :param int session_id: session id - :param int node_id: node id + :param session_id: session id + :param node_id: node id :return: response with a list of configuration groups - :rtype: core_pb2.GetWlanConfigResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.GetWlanConfigRequest(session_id=session_id, node_id=node_id) @@ -963,11 +919,10 @@ class CoreGrpcClient: """ Set wlan configuration for a node. - :param int session_id: session id - :param int node_id: node id - :param dict[str, str] config: wlan configuration + :param session_id: session id + :param node_id: node id + :param config: wlan configuration :return: response with result of success or failure - :rtype: core_pb2.SetWlanConfigResponse :raises grpc.RpcError: when session doesn't exist """ wlan_config = core_pb2.WlanConfig(node_id=node_id, config=config) @@ -980,9 +935,8 @@ class CoreGrpcClient: """ Get session emane configuration. - :param int session_id: session id + :param session_id: session id :return: response with a list of configuration groups - :rtype: core_pb2.GetEmaneConfigResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.GetEmaneConfigRequest(session_id=session_id) @@ -994,10 +948,9 @@ class CoreGrpcClient: """ Set session emane configuration. - :param int session_id: session id - :param dict[str, str] config: emane configuration + :param session_id: session id + :param config: emane configuration :return: response with result of success or failure - :rtype: core_pb2.SetEmaneConfigResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.SetEmaneConfigRequest(session_id=session_id, config=config) @@ -1007,9 +960,8 @@ class CoreGrpcClient: """ Get session emane models. - :param int session_id: session id + :param session_id: session id :return: response with a list of emane models - :rtype: core_pb2.GetEmaneModelsResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.GetEmaneModelsRequest(session_id=session_id) @@ -1021,12 +973,11 @@ class CoreGrpcClient: """ Get emane model configuration for a node or a node's interface. - :param int session_id: session id - :param int node_id: node id - :param str model: emane model name - :param int interface_id: node interface id + :param session_id: session id + :param node_id: node id + :param model: emane model name + :param interface_id: node interface id :return: response with a list of configuration groups - :rtype: core_pb2.GetEmaneModelConfigResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.GetEmaneModelConfigRequest( @@ -1045,13 +996,12 @@ class CoreGrpcClient: """ Set emane model configuration for a node or a node's interface. - :param int session_id: session id - :param int node_id: node id - :param str model: emane model name - :param dict[str, str] config: emane model configuration - :param int interface_id: node interface id + :param session_id: session id + :param node_id: node id + :param model: emane model name + :param config: emane model configuration + :param interface_id: node interface id :return: response with result of success or failure - :rtype: core_pb2.SetEmaneModelConfigResponse :raises grpc.RpcError: when session doesn't exist """ model_config = core_pb2.EmaneModelConfig( @@ -1068,9 +1018,8 @@ class CoreGrpcClient: """ Get all emane model configurations for a session. - :param int session_id: session id + :param session_id: session id :return: response with a dictionary of node/interface ids to configurations - :rtype: core_pb2.GetEmaneModelConfigsResponse :raises grpc.RpcError: when session doesn't exist """ request = core_pb2.GetEmaneModelConfigsRequest(session_id=session_id) @@ -1080,8 +1029,8 @@ class CoreGrpcClient: """ Save the current scenario to an XML file. - :param int session_id: session id - :param str file_path: local path to save scenario XML file to + :param session_id: session id + :param file_path: local path to save scenario XML file to :return: nothing """ request = core_pb2.SaveXmlRequest(session_id=session_id) @@ -1093,10 +1042,9 @@ class CoreGrpcClient: """ Load a local scenario XML file to open as a new session. - :param str file_path: path of scenario XML file - :param bool start: True to start session, False otherwise + :param file_path: path of scenario XML file + :param start: True to start session, False otherwise :return: response with opened session id - :rtype: core_pb2.OpenXmlResponse """ with open(file_path, "r") as xml_file: data = xml_file.read() @@ -1109,10 +1057,10 @@ class CoreGrpcClient: """ Helps broadcast wireless link/unlink between EMANE nodes. - :param int session_id: session id - :param int nem_one: - :param int nem_two: - :param bool linked: True to link, False to unlink + :param session_id: session id + :param nem_one: + :param nem_two: + :param linked: True to link, False to unlink :return: core_pb2.EmaneLinkResponse """ request = core_pb2.EmaneLinkRequest( diff --git a/daemon/core/api/grpc/events.py b/daemon/core/api/grpc/events.py index 2eebd8ae..172cec82 100644 --- a/daemon/core/api/grpc/events.py +++ b/daemon/core/api/grpc/events.py @@ -19,9 +19,8 @@ def handle_node_event(event: NodeData) -> core_pb2.NodeEvent: """ Handle node event when there is a node event - :param core.emulator.data.NodeData event: node data + :param event: node data :return: node event that contains node id, name, model, position, and services - :rtype: core.api.grpc.core_pb2.NodeEvent """ position = core_pb2.Position(x=event.x_position, y=event.y_position) services = event.services or "" @@ -40,9 +39,8 @@ def handle_link_event(event: LinkData) -> core_pb2.LinkEvent: """ Handle link event when there is a link event - :param core.emulator.data.LinkData event: link data + :param event: link data :return: link event that has message type and link information - :rtype: core.api.grpc.core_pb2.LinkEvent """ interface_one = None if event.interface1_id is not None: @@ -96,9 +94,8 @@ def handle_session_event(event: EventData) -> core_pb2.SessionEvent: """ Handle session event when there is a session event - :param core.emulator.data.EventData event: event data + :param event: event data :return: session event - :rtype: core.api.grpc.core_pb2.SessionEvent """ event_time = event.time if event_time is not None: @@ -116,9 +113,8 @@ def handle_config_event(event: ConfigData) -> core_pb2.ConfigEvent: """ Handle configuration event when there is configuration event - :param core.emulator.data.ConfigData event: configuration data + :param event: configuration data :return: configuration event - :rtype: core.api.grpc.core_pb2.ConfigEvent """ return core_pb2.ConfigEvent( message_type=event.message_type, @@ -141,9 +137,8 @@ def handle_exception_event(event: ExceptionData) -> core_pb2.ExceptionEvent: """ Handle exception event when there is exception event - :param core.emulator.data.ExceptionData event: exception data + :param event: exception data :return: exception event - :rtype: core.api.grpc.core_pb2.ExceptionEvent """ return core_pb2.ExceptionEvent( node_id=event.node, @@ -159,9 +154,8 @@ def handle_file_event(event: FileData) -> core_pb2.FileEvent: """ Handle file event - :param core.emulator.data.FileData event: file data + :param event: file data :return: file event - :rtype: core.api.grpc.core_pb2.FileEvent """ return core_pb2.FileEvent( message_type=event.message_type, @@ -187,8 +181,8 @@ class EventStreamer: """ Create a EventStreamer instance. - :param core.emulator.session.Session session: session to process events for - :param set event_types: types of events to process + :param session: session to process events for + :param event_types: types of events to process """ self.session = session self.event_types = event_types @@ -219,7 +213,6 @@ class EventStreamer: Process the next event in the queue. :return: grpc event, or None when invalid event or queue timeout - :rtype: core.api.grpc.core_pb2.Event """ event = core_pb2.Event(session_id=self.session.id) try: diff --git a/daemon/core/api/grpc/grpcutils.py b/daemon/core/api/grpc/grpcutils.py index 89a1d298..d54cba27 100644 --- a/daemon/core/api/grpc/grpcutils.py +++ b/daemon/core/api/grpc/grpcutils.py @@ -19,9 +19,8 @@ def add_node_data(node_proto: core_pb2.Node) -> Tuple[NodeTypes, int, NodeOption """ Convert node protobuf message to data for creating a node. - :param core_pb2.Node node_proto: node proto message + :param node_proto: node proto message :return: node type, id, and options - :rtype: tuple """ _id = node_proto.id _type = node_proto.type @@ -49,9 +48,8 @@ def link_interface(interface_proto: core_pb2.Interface) -> InterfaceData: """ Create interface data from interface proto. - :param core_pb2.Interface interface_proto: interface proto + :param interface_proto: interface proto :return: interface data - :rtype: InterfaceData """ interface = None if interface_proto: @@ -79,9 +77,8 @@ def add_link_data( """ Convert link proto to link interfaces and options data. - :param core_pb2.Link link_proto: link proto + :param link_proto: link proto :return: link interfaces and options - :rtype: tuple """ interface_one = link_interface(link_proto.interface_one) interface_two = link_interface(link_proto.interface_two) @@ -115,10 +112,9 @@ def create_nodes( """ Create nodes using a thread pool and wait for completion. - :param core.emulator.session.Session session: session to create nodes in - :param list[core_pb2.Node] node_protos: node proto messages + :param session: session to create nodes in + :param node_protos: node proto messages :return: results and exceptions for created nodes - :rtype: tuple """ funcs = [] for node_proto in node_protos: @@ -138,10 +134,9 @@ def create_links( """ Create links using a thread pool and wait for completion. - :param core.emulator.session.Session session: session to create nodes in - :param list[core_pb2.Link] link_protos: link proto messages + :param session: session to create nodes in + :param link_protos: link proto messages :return: results and exceptions for created links - :rtype: tuple """ funcs = [] for link_proto in link_protos: @@ -163,10 +158,9 @@ def edit_links( """ Edit links using a thread pool and wait for completion. - :param core.emulator.session.Session session: session to create nodes in - :param list[core_pb2.Link] link_protos: link proto messages + :param session: session to create nodes in + :param link_protos: link proto messages :return: results and exceptions for created links - :rtype: tuple """ funcs = [] for link_proto in link_protos: @@ -188,7 +182,6 @@ def convert_value(value: Any) -> str: :param value: value :return: string conversion of the value - :rtype: str """ if value is not None: value = str(value) @@ -201,10 +194,9 @@ def get_config_options( """ Retrieve configuration options in a form that is used by the grpc server. - :param dict config: configuration - :param core.config.ConfigurableOptions configurable_options: configurable options + :param config: configuration + :param configurable_options: configurable options :return: mapping of configuration ids to configuration options - :rtype: dict[str,core.api.grpc.core_pb2.ConfigOption] """ results = {} for configuration in configurable_options.configurations(): @@ -230,8 +222,8 @@ def get_links(session: Session, node: NodeBase): """ Retrieve a list of links for grpc to use - :param core.emulator.Session session: node's section - :param core.nodes.base.NodeBase node: node to get links from + :param session: node's section + :param node: node to get links from :return: [core.api.grpc.core_pb2.Link] """ links = [] @@ -245,10 +237,9 @@ def get_emane_model_id(node_id: int, interface_id: int) -> int: """ Get EMANE model id - :param int node_id: node id - :param int interface_id: interface id + :param node_id: node id + :param interface_id: interface id :return: EMANE model id - :rtype: int """ if interface_id >= 0: return node_id * 1000 + interface_id @@ -262,7 +253,6 @@ def parse_emane_model_id(_id: int) -> Tuple[int, int]: :param _id: id to parse :return: node id and interface id - :rtype: tuple """ interface = -1 node_id = _id @@ -276,10 +266,9 @@ def convert_link(session: Session, link_data: LinkData) -> core_pb2.Link: """ Convert link_data into core protobuf Link - :param core.emulator.session.Session session: - :param core.emulator.data.LinkData link_data: + :param session: + :param link_data: :return: core protobuf Link - :rtype: core.api.grpc.core_pb2.Link """ interface_one = None if link_data.interface1_id is not None: @@ -344,7 +333,6 @@ def get_net_stats() -> Dict[str, Dict]: Retrieve status about the current interfaces in the system :return: send and receive status of the interfaces in the system - :rtype: dict """ with open("/proc/net/dev", "r") as f: data = f.readlines()[2:] @@ -365,8 +353,8 @@ def session_location(session: Session, location: core_pb2.SessionLocation) -> No """ Set session location based on location proto. - :param core.emulator.session.Session session: session for location - :param core_pb2.SessionLocation location: location to set + :param session: session for location + :param location: location to set :return: nothing """ session.location.refxyz = (location.x, location.y, location.z) @@ -378,8 +366,8 @@ def service_configuration(session: Session, config: core_pb2.ServiceConfig) -> N """ Convenience method for setting a node service configuration. - :param core.emulator.session.Session session: session for service configuration - :param core_pb2.ServiceConfig config: service configuration + :param session: session for service configuration + :param config: service configuration :return: """ session.services.set_service(config.node_id, config.service) @@ -395,7 +383,6 @@ def get_service_configuration(service: Type[CoreService]) -> core_pb2.NodeServic :param service: service to get proto data for :return: service proto data - :rtype: core.api.grpc.core_pb2.NodeServiceData """ return core_pb2.NodeServiceData( executables=service.executables, diff --git a/daemon/core/api/grpc/server.py b/daemon/core/api/grpc/server.py index 06fde7e8..3d24b981 100644 --- a/daemon/core/api/grpc/server.py +++ b/daemon/core/api/grpc/server.py @@ -38,7 +38,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Create CoreGrpcServer instance - :param core.emulator.coreemu.CoreEmu coreemu: coreemu object + :param coreemu: coreemu object """ def __init__(self, coreemu: CoreEmu) -> None: @@ -75,11 +75,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve session given the session id - :param int session_id: session id - :param grpc.ServicerContext context: + :param session_id: session id + :param context: :return: session object that satisfies, if session not found then raise an exception - :rtype: core.emulator.session.Session """ session = self.coreemu.sessions.get(session_id) if not session: @@ -92,11 +91,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve node given session and node id - :param core.emulator.session.Session session: session that has the node - :param int node_id: node id - :param grpc.ServicerContext context: + :param session: session that has the node + :param node_id: node id + :param context: :return: node object that satisfies. If node not found then raise an exception. - :rtype: core.nodes.base.CoreNode """ try: return session.get_node(node_id) @@ -109,10 +107,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Start a session. - :param core.api.grpc.core_pb2.StartSessionRequest request: start session request + :param request: start session request :param context: grcp context :return: start session response - :rtype: core.api.grpc.core_pb2.StartSessionResponse """ logging.debug("start session: %s", request) session = self.get_session(request.session_id, context) @@ -198,10 +195,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Stop a running session. - :param core.api.grpc.core_pb2.StopSessionRequest request: stop session request + :param request: stop session request :param context: grcp context :return: stop session response - :rtype: core.api.grpc.core_pb2.StopSessionResponse """ logging.debug("stop session: %s", request) session = self.get_session(request.session_id, context) @@ -217,10 +213,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Create a session - :param core.api.grpc.core_pb2.CreateSessionRequest request: create-session request - :param grpc.ServicerContext context: + :param request: create-session request + :param context: :return: a create-session response - :rtype: core.api.grpc.core_pb2.CreateSessionResponse """ logging.debug("create session: %s", request) session = self.coreemu.create_session(request.session_id) @@ -237,10 +232,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Delete the session - :param core.api.grpc.core_pb2.DeleteSessionRequest request: delete-session request - :param grpc.ServicerContext context: context object + :param request: delete-session request + :param context: context object :return: a delete-session response - :rtype: core.api.grpc.core_pb2.DeleteSessionResponse """ logging.debug("delete session: %s", request) result = self.coreemu.delete_session(request.session_id) @@ -252,10 +246,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Delete the session - :param core.api.grpc.core_pb2.GetSessionRequest request: get-session request - :param grpc.ServicerContext context: context object + :param request: get-session request + :param context: context object :return: a delete-session response - :rtype: core.api.grpc.core_pb2.DeleteSessionResponse """ logging.debug("get sessions: %s", request) sessions = [] @@ -276,10 +269,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve a requested session location - :param core.api.grpc.core_pb2.GetSessionLocationRequest request: get-session-location request - :param grpc.ServicerContext context: context object + :param request: get-session-location request + :param context: context object :return: a get-session-location response - :rtype: core.api.grpc.core_pb2.GetSessionLocationResponse """ logging.debug("get session location: %s", request) session = self.get_session(request.session_id, context) @@ -297,10 +289,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Set session location - :param core.api.grpc.core_pb2.SetSessionLocationRequest request: set-session-location request - :param grpc.ServicerContext context: context object + :param request: set-session-location request + :param context: context object :return: a set-session-location-response - :rtype: core.api.grpc.core_pb2.SetSessionLocationResponse """ logging.debug("set session location: %s", request) session = self.get_session(request.session_id, context) @@ -313,10 +304,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Set session state - :param core.api.grpc.core_pb2.SetSessionStateRequest request: set-session-state request - :param grpc.ServicerContext context:context object + :param request: set-session-state request + :param context:context object :return: set-session-state response - :rtype: core.api.grpc.core_pb2.SetSessionStateResponse """ logging.debug("set session state: %s", request) session = self.get_session(request.session_id, context) @@ -348,11 +338,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve session options. - :param core.api.grpc.core_pb2.GetSessionOptions request: + :param request: get-session-options request - :param grpc.ServicerContext context: context object + :param context: context object :return: get-session-options response about all session's options - :rtype: core.api.grpc.core_pb2.GetSessionOptions """ logging.debug("get session options: %s", request) session = self.get_session(request.session_id, context) @@ -368,10 +357,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Update a session's configuration - :param core.api.grpc.core_pb2.SetSessionOptions request: set-session-options request - :param grpc.ServicerContext context: context object + :param request: set-session-options request + :param context: context object :return: set-session-options response - :rtype: core.api.grpc.core_pb2.SetSessionOptionsResponse """ logging.debug("set session options: %s", request) session = self.get_session(request.session_id, context) @@ -385,11 +373,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve session metadata. - :param core.api.grpc.core_pb2.GetSessionMetadata request: get session metadata + :param request: get session metadata request - :param grpc.ServicerContext context: context object + :param context: context object :return: get session metadata response - :rtype: core.api.grpc.core_pb2.GetSessionMetadata """ logging.debug("get session metadata: %s", request) session = self.get_session(request.session_id, context) @@ -401,10 +388,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Update a session's metadata. - :param core.api.grpc.core_pb2.SetSessionMetadata request: set metadata request - :param grpc.ServicerContext context: context object + :param request: set metadata request + :param context: context object :return: set metadata response - :rtype: core.api.grpc.core_pb2.SetSessionMetadataResponse """ logging.debug("set session metadata: %s", request) session = self.get_session(request.session_id, context) @@ -417,10 +403,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve requested session - :param core.api.grpc.core_pb2.GetSessionRequest request: get-session request - :param grpc.ServicerContext context: context object + :param request: get-session request + :param context: context object :return: get-session response - :rtype: core.api.grpc.core_bp2.GetSessionResponse """ logging.debug("get session: %s", request) session = self.get_session(request.session_id, context) @@ -473,11 +458,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Add distributed server to a session. - :param core.api.grpc.core_pb2.AddSessionServerRequest request: get-session + :param request: get-session request - :param grpc.ServicerContext context: context object + :param context: context object :return: add session server response - :rtype: core.api.grpc.core_bp2.AddSessionServerResponse """ session = self.get_session(request.session_id, context) session.distributed.add_server(request.name, request.host) @@ -504,8 +488,8 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Calculate average throughput after every certain amount of delay time - :param core.api.grpc.core_pb2.ThroughputsRequest request: throughputs request - :param grpc.SrevicerContext context: context object + :param request: throughputs request + :param context: context object :return: nothing """ session = self.get_session(request.session_id, context) @@ -574,10 +558,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Add node to requested session - :param core.api.grpc.core_pb2.AddNodeRequest request: add-node request - :param grpc.ServicerContext context: context object + :param request: add-node request + :param context: context object :return: add-node response - :rtype: core.api.grpc.core_pb2.AddNodeResponse """ logging.debug("add node: %s", request) session = self.get_session(request.session_id, context) @@ -591,10 +574,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve node - :param core.api.grpc.core_pb2.GetNodeRequest request: get-node request - :param grpc.ServicerContext context: context object + :param request: get-node request + :param context: context object :return: get-node response - :rtype: core.api.grpc.core_pb2.GetNodeResponse """ logging.debug("get node: %s", request) session = self.get_session(request.session_id, context) @@ -648,10 +630,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Edit node - :param core.api.grpc.core_bp2.EditNodeRequest request: edit-node request - :param grpc.ServicerContext context: context object + :param request: edit-node request + :param context: context object :return: edit-node response - :rtype: core.api.grpc.core_pb2.EditNodeResponse """ logging.debug("edit node: %s", request) session = self.get_session(request.session_id, context) @@ -683,8 +664,8 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Delete node - :param core.api.grpc.core_pb2.DeleteNodeRequest request: delete-node request - :param grpc.ServicerContext context: context object + :param request: delete-node request + :param context: context object :return: core.api.grpc.core_pb2.DeleteNodeResponse """ logging.debug("delete node: %s", request) @@ -698,8 +679,8 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Run command on a node - :param core.api.grpc.core_pb2.NodeCommandRequest request: node-command request - :param grpc.ServicerContext context: context object + :param request: node-command request + :param context: context object :return: core.api.grpc.core_pb2.NodeCommandResponse """ logging.debug("sending node command: %s", request) @@ -717,10 +698,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve terminal command string of a node - :param core.api.grpc.core_pb2.GetNodeTerminalRequest request: get-node-terminal request - :param grpc.ServicerContext context: context object + :param request: get-node-terminal request + :param context: context object :return: get-node-terminal response - :rtype: core.api.grpc.core_bp2.GetNodeTerminalResponse """ logging.debug("getting node terminal: %s", request) session = self.get_session(request.session_id, context) @@ -734,10 +714,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve all links form a requested node - :param core.api.grpc.core_pb2.GetNodeLinksRequest request: get-node-links request - :param grpc.ServicerContext context: context object + :param request: get-node-links request + :param context: context object :return: get-node-links response - :rtype: core.api.grpc.core_pb2.GetNodeLinksResponse """ logging.debug("get node links: %s", request) session = self.get_session(request.session_id, context) @@ -751,10 +730,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Add link to a session - :param core.api.grpc.core_pb2.AddLinkRequest request: add-link request - :param grpc.ServicerContext context: context object + :param request: add-link request + :param context: context object :return: add-link response - :rtype: core.api.grpc.AddLinkResponse """ logging.debug("add link: %s", request) # validate session and nodes @@ -776,10 +754,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Edit a link - :param core.api.grpc.core_pb2.EditLinkRequest request: edit-link request - :param grpc.ServicerContext context: context object + :param request: edit-link request + :param context: context object :return: edit-link response - :rtype: core.api.grpc.core_pb2.EditLinkResponse """ logging.debug("edit link: %s", request) session = self.get_session(request.session_id, context) @@ -811,10 +788,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Delete a link - :param core.api.grpc.core_pb2.DeleteLinkRequest request: delete-link request - :param grpc.ServicerContext context: context object + :param request: delete-link request + :param context: context object :return: delete-link response - :rtype: core.api.grpc.core_pb2.DeleteLinkResponse """ logging.debug("delete link: %s", request) session = self.get_session(request.session_id, context) @@ -833,10 +809,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve all hooks from a session - :param core.api.grpc.core_pb2.GetHooksRequest request: get-hook request - :param grpc.ServicerContext context: context object + :param request: get-hook request + :param context: context object :return: get-hooks response about all the hooks in all session states - :rtype: core.api.grpc.core_pb2.GetHooksResponse """ logging.debug("get hooks: %s", request) session = self.get_session(request.session_id, context) @@ -854,10 +829,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Add hook to a session - :param core.api.grpc.core_pb2.AddHookRequest request: add-hook request - :param grpc.ServicerContext context: context object + :param request: add-hook request + :param context: context object :return: add-hook response - :rtype: core.api.grpc.core_pb2.AddHookResponse """ logging.debug("add hook: %s", request) session = self.get_session(request.session_id, context) @@ -871,11 +845,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve all mobility configurations from a session - :param core.api.grpc.core_pb2.GetMobilityConfigsRequest request: + :param request: get-mobility-configurations request - :param grpc.ServicerContext context: context object + :param context: context object :return: get-mobility-configurations response that has a list of configurations - :rtype: core.api.grpc.core_pb2.GetMobilityConfigsResponse """ logging.debug("get mobility configs: %s", request) session = self.get_session(request.session_id, context) @@ -899,11 +872,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve mobility configuration of a node - :param core.api.grpc.core_pb2.GetMobilityConfigRequest request: + :param request: get-mobility-configuration request - :param grpc.ServicerContext context: context object + :param context: context object :return: get-mobility-configuration response - :rtype: core.api.grpc.core_pb2.GetMobilityConfigResponse """ logging.debug("get mobility config: %s", request) session = self.get_session(request.session_id, context) @@ -919,11 +891,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Set mobility configuration of a node - :param core.api.grpc.core_pb2.SetMobilityConfigRequest request: + :param request: set-mobility-configuration request - :param grpc.ServicerContext context: context object + :param context: context object :return: set-mobility-configuration response - "rtype" core.api.grpc.SetMobilityConfigResponse """ logging.debug("set mobility config: %s", request) session = self.get_session(request.session_id, context) @@ -939,11 +910,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Take mobility action whether to start, pause, stop or none of those - :param core.api.grpc.core_pb2.MobilityActionRequest request: mobility-action + :param request: mobility-action request - :param grpc.ServicerContext context: context object + :param context: context object :return: mobility-action response - :rtype: core.api.grpc.core_pb2.MobilityActionResponse """ logging.debug("mobility action: %s", request) session = self.get_session(request.session_id, context) @@ -965,10 +935,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve all the services that are running - :param core.api.grpc.core_pb2.GetServicesRequest request: get-service request - :param grpc.ServicerContext context: context object + :param request: get-service request + :param context: context object :return: get-services response - :rtype: core.api.grpc.core_pb2.GetServicesResponse """ logging.debug("get services: %s", request) services = [] @@ -984,11 +953,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve all the default services of all node types in a session - :param core.api.grpc.core_pb2.GetServiceDefaultsRequest request: + :param request: get-default-service request - :param grpc.ServicerContext context: context object + :param context: context object :return: get-service-defaults response about all the available default services - :rtype: core.api.grpc.core_pb2.GetServiceDefaultsResponse """ logging.debug("get service defaults: %s", request) session = self.get_session(request.session_id, context) @@ -1006,11 +974,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): ) -> core_pb2.SetServiceDefaultsResponse: """ Set new default services to the session after whipping out the old ones - :param core.api.grpc.core_pb2.SetServiceDefaults request: set-service-defaults + :param request: set-service-defaults request - :param grpc.ServicerContext context: context object + :param context: context object :return: set-service-defaults response - :rtype: core.api.grpc.core_pb2 SetServiceDefaultsResponse """ logging.debug("set service defaults: %s", request) session = self.get_session(request.session_id, context) @@ -1027,11 +994,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve all node service configurations. - :param core.api.grpc.core_pb2.GetNodeServiceConfigsRequest request: + :param request: get-node-service request - :param grpc.ServicerContext context: context object + :param context: context object :return: all node service configs response - :rtype: core.api.grpc.core_pb2.GetNodeServiceConfigsResponse """ logging.debug("get node service configs: %s", request) session = self.get_session(request.session_id, context) @@ -1055,11 +1021,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve a requested service from a node - :param core.api.grpc.core_pb2.GetNodeServiceRequest request: get-node-service + :param request: get-node-service request - :param grpc.ServicerContext context: context object + :param context: context object :return: get-node-service response about the requested service - :rtype: core.api.grpc.core_pb2.GetNodeServiceResponse """ logging.debug("get node service: %s", request) session = self.get_session(request.session_id, context) @@ -1075,11 +1040,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve a requested service file from a node - :param core.api.grpc.core_pb2.GetNodeServiceFileRequest request: + :param request: get-node-service request - :param grpc.ServicerContext context: context object + :param context: context object :return: get-node-service response about the requested service - :rtype: core.api.grpc.core_pb2.GetNodeServiceFileResponse """ logging.debug("get node service file: %s", request) session = self.get_session(request.session_id, context) @@ -1095,11 +1059,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Set a node service for a node - :param core.api.grpc.core_pb2.SetNodeServiceRequest request: set-node-service + :param request: set-node-service request that has info to set a node service - :param grpc.ServicerContext context: context object + :param context: context object :return: set-node-service response - :rtype: core.api.grpc.core_pb2.SetNodeServiceResponse """ logging.debug("set node service: %s", request) session = self.get_session(request.session_id, context) @@ -1113,11 +1076,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Store the customized service file in the service config - :param core.api.grpc.core_pb2.SetNodeServiceFileRequest request: + :param request: set-node-service-file request - :param grpc.ServicerContext context: context object + :param context: context object :return: set-node-service-file response - :rtype: core.api.grpc.core_pb2.SetNodeServiceFileResponse """ logging.debug("set node service file: %s", request) session = self.get_session(request.session_id, context) @@ -1134,10 +1096,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): Take action whether to start, stop, restart, validate the service or none of the above. - :param core.api.grpc.core_pb2.ServiceActionRequest request: service-action request - :param grpcServicerContext context: context object + :param request: service-action request + :param context: context object :return: service-action response about status of action - :rtype: core.api.grpc.core_pb2.ServiceActionResponse """ logging.debug("service action: %s", request) session = self.get_session(request.session_id, context) @@ -1175,10 +1136,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve all wireless-lan configurations. - :param core.api.grpc.core_pb2.GetWlanConfigsRequest request: request + :param 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) @@ -1202,10 +1162,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve wireless-lan configuration of a node - :param core.api.grpc.core_pb2.GetWlanConfigRequest request: get-wlan-configuration request + :param request: get-wlan-configuration request :param context: core.api.grpc.core_pb2.GetWlanConfigResponse :return: get-wlan-configuration response about the wlan configuration of a node - :rtype: core.api.grpc.core_pb2.GetWlanConfigResponse """ logging.debug("get wlan config: %s", request) session = self.get_session(request.session_id, context) @@ -1221,10 +1180,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Set configuration data for a model - :param core.api.grpc.core_pb2.SetWlanConfigRequest request: set-wlan-configuration request - :param grpc.ServicerContext context: context object + :param request: set-wlan-configuration request + :param context: context object :return: set-wlan-configuration response - :rtype: core.api.grpc.core_pb2.SetWlanConfigResponse """ logging.debug("set wlan config: %s", request) session = self.get_session(request.session_id, context) @@ -1243,10 +1201,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve EMANE configuration of a session - :param core.api.grpc.core_pb2.GetEmanConfigRequest request: get-EMANE-configuration request - :param grpc.ServicerContext context: context object + :param request: get-EMANE-configuration request + :param context: context object :return: get-EMANE-configuration response - :rtype: core.api.grpc.core_pb2.GetEmaneConfigResponse """ logging.debug("get emane config: %s", request) session = self.get_session(request.session_id, context) @@ -1260,10 +1217,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Set EMANE configuration of a session - :param core.api.grpc.core_pb2.SetEmaneConfigRequest request: set-EMANE-configuration request - :param grpc.ServicerContext context: context object + :param request: set-EMANE-configuration request + :param context: context object :return: set-EMANE-configuration response - :rtype: core.api.grpc.core_pb2.SetEmaneConfigResponse """ logging.debug("set emane config: %s", request) session = self.get_session(request.session_id, context) @@ -1277,10 +1233,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve all the EMANE models in the session - :param core.api.grpc.core_pb2.GetEmaneModelRequest request: get-emane-model request - :param grpc.ServicerContext context: context object + :param request: get-emane-model request + :param context: context object :return: get-EMANE-models response that has all the models - :rtype: core.api.grpc.core_pb2.GetEmaneModelsResponse """ logging.debug("get emane models: %s", request) session = self.get_session(request.session_id, context) @@ -1297,11 +1252,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve EMANE model configuration of a node - :param core.api.grpc.core_pb2.GetEmaneModelConfigRequest request: + :param request: get-EMANE-model-configuration request - :param grpc.ServicerContext context: context object + :param context: context object :return: get-EMANE-model-configuration response - :rtype: core.api.grpc.core_pb2.GetEmaneModelConfigResponse """ logging.debug("get emane model config: %s", request) session = self.get_session(request.session_id, context) @@ -1317,11 +1271,10 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Set EMANE model configuration of a node - :param core.api.grpc.core_pb2.SetEmaneModelConfigRequest request: + :param request: set-EMANE-model-configuration request - :param grpc.ServicerContext context: context object + :param context: context object :return: set-EMANE-model-configuration response - :rtype: core.api.grpc.core_pb2.SetEmaneModelConfigResponse """ logging.debug("set emane model config: %s", request) session = self.get_session(request.session_id, context) @@ -1336,12 +1289,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve all EMANE model configurations of a session - :param core.api.grpc.core_pb2.GetEmaneModelConfigsRequest request: + :param request: get-EMANE-model-configurations request - :param grpc.ServicerContext context: context object + :param context: context object :return: get-EMANE-model-configurations response that has all the EMANE configurations - :rtype: core.api.grpc.core_pb2.GetEmaneModelConfigsResponse """ logging.debug("get emane model configs: %s", request) session = self.get_session(request.session_id, context) @@ -1372,10 +1324,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Export the session nto the EmulationScript XML format - :param core.api.grpc.core_pb2.SaveXmlRequest request: save xml request - :param grpc SrvicerContext context: context object + :param request: save xml request + :param context: context object :return: save-xml response - :rtype: core.api.grpc.core_pb2.SaveXmlResponse """ logging.debug("save xml: %s", request) session = self.get_session(request.session_id, context) @@ -1394,10 +1345,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Import a session from the EmulationScript XML format - :param core.api.grpc.OpenXmlRequest request: open-xml request - :param grpc.ServicerContext context: context object + :param request: open-xml request + :param context: context object :return: Open-XML response or raise an exception if invalid XML file - :rtype: core.api.grpc.core_pb2.OpenXMLResponse """ logging.debug("open xml: %s", request) session = self.coreemu.create_session() @@ -1424,10 +1374,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Retrieve all the interfaces of the system including bridges, virtual ethernet, and loopback - :param core.api.grpc.core_pb2.GetInterfacesRequest request: get-interfaces request - :param grpc.ServicerContext context: context object + :param request: get-interfaces request + :param context: context object :return: get-interfaces response that has all the system's interfaces - :rtype: core.api.grpc.core_pb2.GetInterfacesResponse """ interfaces = [] for interface in os.listdir("/sys/class/net"): @@ -1446,10 +1395,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ Helps broadcast wireless link/unlink between EMANE nodes. - :param core.api.grpc.core_pb2.EmaneLinkRequest request: get-interfaces request - :param grpc.ServicerContext context: context object + :param request: get-interfaces request + :param context: context object :return: emane link response with success status - :rtype: core.api.grpc.core_pb2.EmaneLinkResponse """ logging.debug("emane link: %s", request) session = self.get_session(request.session_id, context) diff --git a/daemon/core/config.py b/daemon/core/config.py index b117ce54..9075f560 100644 --- a/daemon/core/config.py +++ b/daemon/core/config.py @@ -24,9 +24,9 @@ class ConfigGroup: """ Creates a ConfigGroup object. - :param str name: configuration group display name - :param int start: configurations start index for this group - :param int stop: configurations stop index for this group + :param name: configuration group display name + :param start: configurations start index for this group + :param stop: configurations stop index for this group """ self.name = name self.start = start @@ -49,11 +49,11 @@ class Configuration: """ Creates a Configuration object. - :param str _id: unique name for configuration - :param core.enumerations.ConfigDataTypes _type: configuration data type - :param str label: configuration label for display - :param str default: default value for configuration - :param list options: list options if this is a configuration with a combobox + :param _id: unique name for configuration + :param _type: configuration data type + :param label: configuration label for display + :param default: default value for configuration + :param options: list options if this is a configuration with a combobox """ self.id = _id self.type = _type @@ -84,7 +84,6 @@ class ConfigurableOptions: Provides the configurations for this class. :return: configurations - :rtype: list[Configuration] """ return cls.options @@ -94,7 +93,6 @@ class ConfigurableOptions: Defines how configurations are grouped. :return: configuration group definition - :rtype: list[ConfigGroup] """ return [ConfigGroup("Options", 1, len(cls.configurations()))] @@ -104,7 +102,6 @@ class ConfigurableOptions: Provides an ordered mapping of configuration keys to default values. :return: ordered configuration mapping default values - :rtype: OrderedDict """ return OrderedDict( [(config.id, config.default) for config in cls.configurations()] @@ -121,9 +118,8 @@ class ConfigShim: """ Converts a TLV key/value string into an ordered mapping. - :param str key_values: + :param key_values: :return: ordered mapping of key/value pairs - :rtype: OrderedDict """ key_values = key_values.split("|") values = OrderedDict() @@ -137,9 +133,8 @@ class ConfigShim: """ Converts configuration groups to a TLV formatted string. - :param list[ConfigGroup] config_groups: configuration groups to format + :param config_groups: configuration groups to format :return: TLV configuration group string - :rtype: str """ group_strings = [] for config_group in config_groups: @@ -163,13 +158,12 @@ class ConfigShim: by the class, but node number, conf type flags, and values must be passed in. - :param int flags: message flags - :param int node_id: node id - :param int type_flags: type flags - :param ConfigurableOptions configurable_options: options to create config data for - :param dict config: configuration values for options + :param flags: message flags + :param node_id: node id + :param type_flags: type flags + :param configurable_options: options to create config data for + :param config: configuration values for options :return: configuration data object - :rtype: ConfigData """ key_values = None captions = None @@ -232,7 +226,6 @@ class ConfigurableManager: Retrieves the ids of all node configurations known by this manager. :return: list of node ids - :rtype: list """ return [x for x in self.node_configurations if x != self._default_node] @@ -240,7 +233,7 @@ class ConfigurableManager: """ Clears all configurations or configuration for a specific node. - :param int node_id: node id to clear configurations for, default is None and clears all configurations + :param node_id: node id to clear configurations for, default is None and clears all configurations :return: nothing """ if not node_id: @@ -258,10 +251,10 @@ class ConfigurableManager: """ Set a specific configuration value for a node and configuration type. - :param str _id: configuration key - :param str value: configuration value - :param int node_id: node id to store configuration for - :param str config_type: configuration type to store configuration for + :param _id: configuration key + :param value: configuration value + :param node_id: node id to store configuration for + :param config_type: configuration type to store configuration for :return: nothing """ node_configs = self.node_configurations.setdefault(node_id, OrderedDict()) @@ -277,9 +270,9 @@ class ConfigurableManager: """ Set configurations for a node and configuration type. - :param dict config: configurations to set - :param int node_id: node id to store configuration for - :param str config_type: configuration type to store configuration for + :param config: configurations to set + :param node_id: node id to store configuration for + :param config_type: configuration type to store configuration for :return: nothing """ logging.debug( @@ -298,12 +291,11 @@ class ConfigurableManager: """ Retrieves a specific configuration for a node and configuration type. - :param str _id: specific configuration to retrieve - :param int node_id: node id to store configuration for - :param str config_type: configuration type to store configuration for + :param _id: specific configuration to retrieve + :param node_id: node id to store configuration for + :param config_type: configuration type to store configuration for :param default: default value to return when value is not found :return: configuration value - :rtype str """ result = default node_type_configs = self.get_configs(node_id, config_type) @@ -317,10 +309,9 @@ class ConfigurableManager: """ Retrieve configurations for a node and configuration type. - :param int node_id: node id to store configuration for - :param str config_type: configuration type to store configuration for + :param node_id: node id to store configuration for + :param config_type: configuration type to store configuration for :return: configurations - :rtype: dict """ result = None node_configs = self.node_configurations.get(node_id) @@ -332,9 +323,8 @@ class ConfigurableManager: """ Retrieve all current configuration types for a node. - :param int node_id: node id to retrieve configurations for + :param node_id: node id to retrieve configurations for :return: all configuration types for a node - :rtype: dict """ return self.node_configurations.get(node_id) @@ -358,9 +348,9 @@ class ModelManager(ConfigurableManager): """ Set configuration data for a model. - :param int node_id: node id to set model configuration for - :param str model_name: model to set configuration for - :param dict config: configuration data to set for model + :param node_id: node id to set model configuration for + :param model_name: model to set configuration for + :param config: configuration data to set for model :return: nothing """ # get model class to configure @@ -386,10 +376,9 @@ class ModelManager(ConfigurableManager): """ Retrieve configuration data for a model. - :param int node_id: node id to set model configuration for - :param str model_name: model to set configuration for + :param node_id: node id to set model configuration for + :param model_name: model to set configuration for :return: current model configuration for node - :rtype: dict """ # get model class to configure model_class = self.models.get(model_name) @@ -415,7 +404,7 @@ class ModelManager(ConfigurableManager): :param node: node to set model for :param model_class: model class to set for node - :param dict config: model configuration, None for default configuration + :param config: model configuration, None for default configuration :return: nothing """ logging.debug( @@ -434,7 +423,6 @@ class ModelManager(ConfigurableManager): :param node: network node to get models for :return: list of model and values tuples for the network node - :rtype: list """ all_configs = self.get_all_configs(node.id) if not all_configs: diff --git a/daemon/core/emane/commeffect.py b/daemon/core/emane/commeffect.py index c7224068..635291e0 100644 --- a/daemon/core/emane/commeffect.py +++ b/daemon/core/emane/commeffect.py @@ -68,7 +68,7 @@ class EmaneCommEffectModel(emanemodel.EmaneModel): that file also. Otherwise the WLAN-wide nXXemane_commeffectnem.xml, nXXemane_commeffectshim.xml are used. - :param dict config: emane model configuration for the node and interface + :param config: emane model configuration for the node and interface :param interface: interface for the emane node :return: nothing """ diff --git a/daemon/core/emane/emanemanager.py b/daemon/core/emane/emanemanager.py index 8561c68e..4acc512b 100644 --- a/daemon/core/emane/emanemanager.py +++ b/daemon/core/emane/emanemanager.py @@ -69,7 +69,7 @@ class EmaneManager(ModelManager): """ Creates a Emane instance. - :param core.session.Session session: session this manager is tied to + :param session: session this manager is tied to :return: nothing """ super().__init__() @@ -100,12 +100,11 @@ class EmaneManager(ModelManager): """ Retrieve interface configuration or node configuration if not provided. - :param int node_id: node id + :param node_id: node id :param interface: node interface - :param str model_name: model to get configuration for + :param model_name: model to get configuration for :return: node/interface model configuration - :rtype: dict - """ +""" # use the network-wide config values or interface(NEM)-specific values? if interface is None: return self.get_configs(node_id=node_id, config_type=model_name) @@ -231,7 +230,7 @@ class EmaneManager(ModelManager): """ Add EMANE network object to this manager. - :param core.emane.nodes.EmaneNet emane_net: emane node to add + :param emane_net: emane node to add :return: nothing """ with self._emane_node_lock: @@ -259,8 +258,7 @@ class EmaneManager(ModelManager): :return: SUCCESS, NOT_NEEDED, NOT_READY in order to delay session instantiation - :rtype: int - """ +""" logging.debug("emane setup") # TODO: drive this from the session object @@ -318,8 +316,7 @@ class EmaneManager(ModelManager): :return: SUCCESS, NOT_NEEDED, NOT_READY in order to delay session instantiation - :rtype: int - """ +""" self.reset() r = self.setup() diff --git a/daemon/core/emane/emanemanifest.py b/daemon/core/emane/emanemanifest.py index 0fc5facc..5a51dedb 100644 --- a/daemon/core/emane/emanemanifest.py +++ b/daemon/core/emane/emanemanifest.py @@ -18,7 +18,7 @@ def _type_value(config_type: str) -> ConfigDataTypes: """ Convert emane configuration type to core configuration value. - :param str config_type: emane configuration type + :param config_type: emane configuration type :return: core config type """ config_type = config_type.upper() @@ -33,11 +33,10 @@ def _get_possible(config_type: str, config_regex: str) -> List[str]: """ Retrieve possible config value options based on emane regexes. - :param str config_type: emane configuration type - :param str config_regex: emane configuration regex + :param config_type: emane configuration type + :param config_regex: emane configuration regex :return: a string listing comma delimited values, if needed, empty string otherwise - :rtype: list - """ +""" if config_type == "bool": return ["On", "Off"] @@ -52,11 +51,10 @@ def _get_default(config_type_name: str, config_value: List[str]) -> str: """ Convert default configuration values to one used by core. - :param str config_type_name: emane configuration type name - :param list config_value: emane configuration value list + :param config_type_name: emane configuration type name + :param config_value: emane configuration value list :return: default core config value - :rtype: str - """ +""" config_default = "" @@ -77,11 +75,10 @@ def parse(manifest_path: str, defaults: Dict[str, str]) -> List[Configuration]: """ Parses a valid emane manifest file and converts the provided configuration values into ones used by core. - :param str manifest_path: absolute manifest file path - :param dict defaults: used to override default values for configurations + :param manifest_path: absolute manifest file path + :param defaults: used to override default values for configurations :return: list of core configuration values - :rtype: list - """ +""" # no results when emane bindings are not present if not manifest: diff --git a/daemon/core/emane/emanemodel.py b/daemon/core/emane/emanemodel.py index 4e5dbbfa..5ac85c9d 100644 --- a/daemon/core/emane/emanemodel.py +++ b/daemon/core/emane/emanemodel.py @@ -52,7 +52,7 @@ class EmaneModel(WirelessModel): Called after being loaded within the EmaneManager. Provides configured emane_prefix for parsing xml files. - :param str emane_prefix: configured emane prefix path + :param emane_prefix: configured emane prefix path :return: nothing """ manifest_path = "share/emane/manifest" @@ -70,8 +70,7 @@ class EmaneModel(WirelessModel): Returns the combination all all configurations (mac, phy, and external). :return: all configurations - :rtype: list[Configuration] - """ +""" return cls.mac_config + cls.phy_config + cls.external_config @classmethod @@ -80,8 +79,7 @@ class EmaneModel(WirelessModel): Returns the defined configuration groups. :return: list of configuration groups. - :rtype: list[ConfigGroup] - """ +""" mac_len = len(cls.mac_config) phy_len = len(cls.phy_config) + mac_len config_len = len(cls.configurations()) @@ -98,7 +96,7 @@ class EmaneModel(WirelessModel): Builds xml files for this emane model. Creates a nem.xml file that points to both mac.xml and phy.xml definitions. - :param dict config: emane model configuration for the node and interface + :param config: emane model configuration for the node and interface :param interface: interface for the emane node :return: nothing """ @@ -145,8 +143,8 @@ class EmaneModel(WirelessModel): emane location events to be generated for the nodes in the moved list, making EmaneModels compatible with Ns2ScriptedMobility. - :param bool moved: were nodes moved - :param list moved_netifs: interfaces that were moved + :param moved: were nodes moved + :param moved_netifs: interfaces that were moved :return: nothing """ try: @@ -168,13 +166,13 @@ class EmaneModel(WirelessModel): """ Invoked when a Link Message is received. Default is unimplemented. - :param core.nodes.interface.Veth netif: interface one + :param netif: interface one :param bw: bandwidth to set to :param delay: packet delay to set to :param loss: packet loss to set to :param duplicate: duplicate percentage to set to :param jitter: jitter to set to - :param core.netns.vif.Veth netif2: interface two + :param netif2: interface two :return: nothing """ logging.warning( diff --git a/daemon/core/emulator/coreemu.py b/daemon/core/emulator/coreemu.py index ed51e076..23ef81da 100644 --- a/daemon/core/emulator/coreemu.py +++ b/daemon/core/emulator/coreemu.py @@ -14,7 +14,7 @@ def signal_handler(signal_number: int, _) -> None: """ Handle signals and force an exit with cleanup. - :param int signal_number: signal number + :param signal_number: signal number :param _: ignored :return: nothing """ @@ -38,7 +38,7 @@ class CoreEmu: """ Create a CoreEmu object. - :param dict config: configuration options + :param config: configuration options """ # set umask 0 os.umask(0) @@ -88,11 +88,10 @@ class CoreEmu: """ Create a new CORE session. - :param int _id: session id for new session - :param class _cls: Session class to use + :param _id: session id for new session + :param _cls: Session class to use :return: created session - :rtype: EmuSession - """ +""" if not _id: _id = 1 while _id in self.sessions: @@ -106,10 +105,9 @@ class CoreEmu: """ Shutdown and delete a CORE session. - :param int _id: session id to delete + :param _id: session id to delete :return: True if deleted, False otherwise - :rtype: bool - """ +""" logging.info("deleting session: %s", _id) session = self.sessions.pop(_id, None) result = False diff --git a/daemon/core/emulator/distributed.py b/daemon/core/emulator/distributed.py index 105b767f..d332b170 100644 --- a/daemon/core/emulator/distributed.py +++ b/daemon/core/emulator/distributed.py @@ -34,8 +34,8 @@ class DistributedServer: """ Create a DistributedServer instance. - :param str name: convenience name to associate with host - :param str host: host to connect to + :param name: convenience name to associate with host + :param host: host to connect to """ self.name = name self.host = host @@ -48,14 +48,13 @@ class DistributedServer: """ Run command remotely using server connection. - :param str cmd: command to run - :param dict env: environment for remote command, default is None - :param str cwd: directory to run command in, defaults to None, which is the + :param cmd: command to run + :param env: environment for remote command, default is None + :param cwd: directory to run command in, defaults to None, which is the user's home directory - :param bool wait: True to wait for status, False to background process + :param wait: True to wait for status, False to background process :return: stdout when success - :rtype: str - :raises CoreCommandError: when a non-zero exit status occurs +:raises CoreCommandError: when a non-zero exit status occurs """ replace_env = env is not None @@ -83,8 +82,8 @@ class DistributedServer: """ Push file to remote server. - :param str source: source file to push - :param str destination: destination file location + :param source: source file to push + :param destination: destination file location :return: nothing """ with self.lock: @@ -95,8 +94,8 @@ class DistributedServer: Remote push file contents to a remote server, using a temp file as an intermediate step. - :param str destination: file destination for data - :param str data: data to store in remote file + :param destination: file destination for data + :param data: data to store in remote file :return: nothing """ with self.lock: @@ -129,8 +128,8 @@ class DistributedController: """ Add distributed server configuration. - :param str name: distributed server name - :param str host: distributed server host address + :param name: distributed server name + :param host: distributed server host address :return: nothing """ server = DistributedServer(name, host) @@ -197,12 +196,11 @@ class DistributedController: Create gre tunnel using a pair of gre taps between the local and remote server. - :param core.nodes.network.CoreNetwork node: node to create gre tunnel for - :param core.emulator.distributed.DistributedServer server: server to create + :param node: node to create gre tunnel for + :param server: server to create tunnel for :return: local and remote gre taps created for tunnel - :rtype: tuple - """ +""" host = server.host key = self.tunnel_key(node.id, netaddr.IPAddress(host).value) tunnel = self.tunnels.get(key) @@ -236,11 +234,10 @@ class DistributedController: The hash(n1num), hash(n2num) values are used, so node numbers may be None or string values (used for e.g. "ctrlnet"). - :param int n1_id: node one id - :param int n2_id: node two id + :param n1_id: node one id + :param n2_id: node two id :return: tunnel key for the node pair - :rtype: int - """ +""" logging.debug("creating tunnel key for: %s, %s", n1_id, n2_id) key = ( (self.session.id << 16) ^ utils.hashkey(n1_id) ^ (utils.hashkey(n2_id) << 8) @@ -251,8 +248,8 @@ class DistributedController: """ Return the GreTap between two nodes if it exists. - :param int n1_id: node one id - :param int n2_id: node two id + :param n1_id: node one id + :param n2_id: node two id :return: gre tap between nodes or None """ key = self.tunnel_key(n1_id, n2_id) diff --git a/daemon/core/emulator/emudata.py b/daemon/core/emulator/emudata.py index acf105eb..f4e93940 100644 --- a/daemon/core/emulator/emudata.py +++ b/daemon/core/emulator/emudata.py @@ -32,8 +32,8 @@ def link_config( :param network: network to configure link for :param interface: interface to configure - :param core.emulator.emudata.LinkOptions link_options: data to configure link with - :param str devname: device name, default is None + :param link_options: data to configure link with + :param devname: device name, default is None :param interface_two: other interface associated, default is None :return: nothing """ @@ -64,10 +64,10 @@ class NodeOptions: """ Create a NodeOptions object. - :param str name: name of node, defaults to node class name postfix with its id - :param str model: defines services for default and physical nodes, defaults to + :param name: name of node, defaults to node class name postfix with its id + :param model: defines services for default and physical nodes, defaults to "router" - :param str image: image to use for docker nodes + :param image: image to use for docker nodes """ self.name = name self.model = model @@ -89,8 +89,8 @@ class NodeOptions: """ Convenience method for setting position. - :param float x: x position - :param float y: y position + :param x: x position + :param y: y position :return: nothing """ self.x = x @@ -100,9 +100,9 @@ class NodeOptions: """ Convenience method for setting location. - :param float lat: latitude - :param float lon: longitude - :param float alt: altitude + :param lat: latitude + :param lon: longitude + :param alt: altitude :return: nothing """ self.lat = lat @@ -119,7 +119,7 @@ class LinkOptions: """ Create a LinkOptions object. - :param core.emulator.enumerations.LinkTypes _type: type of link, defaults to + :param _type: type of link, defaults to wired """ self.type = _type @@ -158,13 +158,13 @@ class InterfaceData: """ Creates an InterfaceData object. - :param int _id: interface id - :param str name: name for interface - :param str mac: mac address - :param str ip4: ipv4 address - :param int ip4_mask: ipv4 bit mask - :param str ip6: ipv6 address - :param int ip6_mask: ipv6 bit mask + :param _id: interface id + :param name: name for interface + :param mac: mac address + :param ip4: ipv4 address + :param ip4_mask: ipv4 bit mask + :param ip6: ipv6 address + :param ip6_mask: ipv6 bit mask """ self.id = _id self.name = name @@ -217,8 +217,7 @@ class InterfaceData: Returns a list of ip4 and ip6 address when present. :return: list of addresses - :rtype: list - """ +""" ip4 = self.ip4_address() ip6 = self.ip6_address() return [i for i in [ip4, ip6] if i] @@ -233,8 +232,8 @@ class IpPrefixes: """ Creates an IpPrefixes object. - :param str ip4_prefix: ip4 prefix to use for generation - :param str ip6_prefix: ip6 prefix to use for generation + :param ip4_prefix: ip4 prefix to use for generation + :param ip6_prefix: ip6 prefix to use for generation :raises ValueError: when both ip4 and ip6 prefixes have not been provided """ if not ip4_prefix and not ip6_prefix: @@ -253,8 +252,7 @@ class IpPrefixes: :param node: node to get IP4 address for :return: IP4 address or None - :rtype: str - """ +""" if not self.ip4: raise ValueError("ip4 prefixes have not been set") return str(self.ip4[node.id]) @@ -265,8 +263,7 @@ class IpPrefixes: :param node: node to get IP6 address for :return: IP4 address or None - :rtype: str - """ +""" if not self.ip6: raise ValueError("ip6 prefixes have not been set") return str(self.ip6[node.id]) @@ -278,13 +275,12 @@ class IpPrefixes: Creates interface data for linking nodes, using the nodes unique id for generation, along with a random mac address, unless provided. - :param core.nodes.base.CoreNode node: node to create interface for - :param str name: name to set for interface, default is eth{id} - :param str mac: mac address to use for this interface, default is random + :param node: node to create interface for + :param name: name to set for interface, default is eth{id} + :param mac: mac address to use for this interface, default is random generation :return: new interface data for the provided node - :rtype: InterfaceData - """ +""" # interface id inteface_id = node.newifindex() @@ -324,8 +320,8 @@ def create_interface( Create an interface for a node on a network using provided interface data. :param node: node to create interface for - :param core.nodes.base.CoreNetworkBase network: network to associate interface with - :param core.emulator.emudata.InterfaceData interface_data: interface data + :param network: network to associate interface with + :param interface_data: interface data :return: created interface """ node.newnetif( diff --git a/daemon/core/emulator/session.py b/daemon/core/emulator/session.py index ca585c31..3d03d73a 100644 --- a/daemon/core/emulator/session.py +++ b/daemon/core/emulator/session.py @@ -90,9 +90,9 @@ class Session: """ Create a Session instance. - :param int _id: session id - :param dict config: session configuration - :param bool mkdir: flag to determine if a directory should be made + :param _id: session id + :param config: session configuration + :param mkdir: flag to determine if a directory should be made """ self.id = _id @@ -166,7 +166,7 @@ class Session: """ Retrieve the class for a given node type. - :param core.emulator.enumerations.NodeTypes _type: node type to get class for + :param _type: node type to get class for :return: node class """ node_class = NODES.get(_type) @@ -181,8 +181,7 @@ class Session: :param _class: node class to get a node type for :return: node type - :rtype: core.emulator.enumerations.NodeTypes - :raises CoreError: when node type does not exist +:raises CoreError: when node type does not exist """ node_type = NODES_TYPE.get(_class) if node_type is None: @@ -197,11 +196,10 @@ class Session: """ Convenience method for retrieving nodes within link data. - :param int node_one_id: node one id - :param int node_two_id: node two id + :param node_one_id: node one id + :param node_two_id: node two id :return: nodes, network nodes if present, and tunnel if present - :rtype: tuple - """ +""" logging.debug( "link message between node1(%s) and node2(%s)", node_one_id, node_two_id ) @@ -258,8 +256,8 @@ class Session: """ Objects to deal with when connecting/disconnecting wireless links. - :param list objects: possible objects to deal with - :param bool connect: link interfaces if True, unlink otherwise + :param objects: possible objects to deal with + :param connect: link interfaces if True, unlink otherwise :return: nothing :raises core.CoreError: when objects to link is less than 2, or no common networks are found @@ -304,13 +302,13 @@ class Session: """ Add a link between nodes. - :param int node_one_id: node one id - :param int node_two_id: node two id - :param core.emulator.emudata.InterfaceData interface_one: node one interface + :param node_one_id: node one id + :param node_two_id: node two id + :param interface_one: node one interface data, defaults to none - :param core.emulator.emudata.InterfaceData interface_two: node two interface + :param interface_two: node two interface data, defaults to none - :param core.emulator.emudata.LinkOptions link_options: data for creating link, + :param link_options: data for creating link, defaults to no options :return: nothing """ @@ -436,11 +434,11 @@ class Session: """ Delete a link between nodes. - :param int node_one_id: node one id - :param int node_two_id: node two id - :param int interface_one_id: interface id for node one - :param int interface_two_id: interface id for node two - :param core.emulator.enumerations.LinkTypes link_type: link type to delete + :param node_one_id: node one id + :param node_two_id: node two id + :param interface_one_id: interface id for node one + :param interface_two_id: interface id for node two + :param link_type: link type to delete :return: nothing :raises core.CoreError: when no common network is found for link being deleted """ @@ -542,11 +540,11 @@ class Session: """ Update link information between nodes. - :param int node_one_id: node one id - :param int node_two_id: node two id - :param int interface_one_id: interface id for node one - :param int interface_two_id: interface id for node two - :param core.emulator.emudata.LinkOptions link_options: data to update link with + :param node_one_id: node one id + :param node_two_id: node two id + :param interface_one_id: interface id for node one + :param interface_two_id: interface id for node two + :param link_options: data to update link with :return: nothing :raises core.CoreError: when updating a wireless type link, when there is a unknown link between networks @@ -654,10 +652,10 @@ class Session: """ Add a node to the session, based on the provided node data. - :param core.emulator.enumerations.NodeTypes _type: type of node to create - :param int _id: id for node, defaults to None for generated id - :param core.emulator.emudata.NodeOptions options: data to create node with - :param class _cls: optional custom class to use for a created node + :param _type: type of node to create + :param _id: id for node, defaults to None for generated id + :param options: data to create node with + :param _cls: optional custom class to use for a created node :return: created node :raises core.CoreError: when an invalid node type is given """ @@ -748,11 +746,10 @@ class Session: """ Edit node information. - :param int node_id: id of node to update - :param core.emulator.emudata.NodeOptions options: data to update node with + :param node_id: id of node to update + :param options: data to update node with :return: True if node updated, False otherwise - :rtype: nothing - :raises core.CoreError: when node to update does not exist +:raises core.CoreError: when node to update does not exist """ # get node to update node = self.get_node(node_id) @@ -769,7 +766,7 @@ class Session: Set position for a node, use lat/lon/alt if needed. :param node: node to set position for - :param core.emulator.emudata.NodeOptions options: data for node + :param options: data for node :return: nothing """ # extract location values @@ -798,7 +795,7 @@ class Session: """ Broadcast node location to all listeners. - :param core.nodes.base.NodeBase node: node to broadcast location for + :param node: node to broadcast location for :return: nothing """ node_data = NodeData( @@ -813,7 +810,7 @@ class Session: """ Start mobility for the provided node ids. - :param list[int] node_ids: nodes to start mobility for + :param node_ids: nodes to start mobility for :return: nothing """ self.mobility.startup(node_ids) @@ -835,8 +832,8 @@ class Session: """ Import a session from the EmulationScript XML format. - :param str file_name: xml file to load session from - :param bool start: instantiate session if true, false otherwise + :param file_name: xml file to load session from + :param start: instantiate session if true, false otherwise :return: nothing """ logging.info("opening xml: %s", file_name) @@ -863,7 +860,7 @@ class Session: """ Export a session to the EmulationScript XML format. - :param str file_name: file name to write session xml to + :param file_name: file name to write session xml to :return: nothing """ CoreXmlWriter(self).write(file_name) @@ -872,9 +869,9 @@ class Session: """ Store a hook from a received file message. - :param int state: when to run hook - :param str file_name: file name for hook - :param str source_name: source name + :param state: when to run hook + :param file_name: file name for hook + :param source_name: source name :param data: hook data :return: nothing """ @@ -888,10 +885,10 @@ class Session: """ Add a file to a node. - :param int node_id: node to add file to - :param str source_name: source file name - :param str file_name: file name to add - :param str data: file data + :param node_id: node to add file to + :param source_name: source file name + :param file_name: file name to add + :param data: file data :return: nothing """ @@ -930,7 +927,7 @@ class Session: """ Handle a mobility event. - :param core.emulator.data.EventData event_data: event data to handle + :param event_data: event data to handle :return: nothing """ self.mobility.handleevent(event_data) @@ -939,10 +936,10 @@ class Session: """ Set session geospatial location. - :param float lat: latitude - :param float lon: longitude - :param float alt: altitude - :param float scale: reference scale + :param lat: latitude + :param lon: longitude + :param alt: altitude + :param scale: reference scale :return: nothing """ self.location.setrefgeo(lat, lon, alt) @@ -975,7 +972,7 @@ class Session: """ Handle event data that should be provided to event handler. - :param core.data.EventData event_data: event data to send out + :param event_data: event data to send out :return: nothing """ @@ -986,7 +983,7 @@ class Session: """ Handle exception data that should be provided to exception handlers. - :param core.emulator.data.ExceptionData exception_data: exception data to send out + :param exception_data: exception data to send out :return: nothing """ @@ -997,7 +994,7 @@ class Session: """ Handle node data that should be provided to node handlers. - :param core.emulator.data.ExceptionData node_data: node data to send out + :param node_data: node data to send out :return: nothing """ @@ -1008,7 +1005,7 @@ class Session: """ Handle file data that should be provided to file handlers. - :param core.data.FileData file_data: file data to send out + :param file_data: file data to send out :return: nothing """ @@ -1019,7 +1016,7 @@ class Session: """ Handle config data that should be provided to config handlers. - :param core.emulator.data.ConfigData config_data: config data to send out + :param config_data: config data to send out :return: nothing """ @@ -1030,7 +1027,7 @@ class Session: """ Handle link data that should be provided to link handlers. - :param core.emulator.data.ExceptionData link_data: link data to send out + :param link_data: link data to send out :return: nothing """ @@ -1041,7 +1038,7 @@ class Session: """ Set the session's current state. - :param core.enumerations.EventTypes state: state to set to + :param state: state to set to :param send_event: if true, generate core API event messages :return: nothing """ @@ -1072,7 +1069,7 @@ class Session: """ Write the current state to a state file in the session dir. - :param int state: state to write to file + :param state: state to write to file :return: nothing """ try: @@ -1087,7 +1084,7 @@ class Session: Run hook scripts upon changing states. If hooks is not specified, run all hooks in the given state. - :param int state: state to run hooks for + :param state: state to run hooks for :return: nothing """ @@ -1111,10 +1108,10 @@ class Session: """ Store a hook from a received file message. - :param str hook_type: hook type - :param str file_name: file name for hook - :param str source_name: source name - :param str data: hook data + :param hook_type: hook type + :param file_name: file name for hook + :param source_name: source name + :param data: hook data :return: nothing """ logging.info( @@ -1149,7 +1146,7 @@ class Session: """ Run a hook. - :param tuple hook: hook to run + :param hook: hook to run :return: nothing """ file_name, data = hook @@ -1190,7 +1187,7 @@ class Session: """ Run state hooks. - :param int state: state to run hooks for + :param state: state to run hooks for :return: nothing """ for hook in self._state_hooks.get(state, []): @@ -1210,8 +1207,8 @@ class Session: """ Add a state hook. - :param int state: state to add hook for - :param func hook: hook callback for the state + :param state: state to add hook for + :param hook: hook callback for the state :return: nothing """ hooks = self._state_hooks.setdefault(state, []) @@ -1226,8 +1223,8 @@ class Session: """ Delete a state hook. - :param int state: state to delete hook for - :param func hook: hook to delete + :param state: state to delete hook for + :param hook: hook to delete :return: nothing """ hooks = self._state_hooks.setdefault(state, []) @@ -1237,7 +1234,7 @@ class Session: """ Runtime state hook check. - :param int state: state to check + :param state: state to check :return: nothing """ if state == EventTypes.RUNTIME_STATE.value: @@ -1255,10 +1252,9 @@ class Session: This is the current process environment with some session-specific variables. - :param bool state: flag to determine if session state should be included + :param state: flag to determine if session state should be included :return: environment variables - :rtype: dict - """ +""" env = os.environ.copy() env["SESSION"] = str(self.id) env["SESSION_SHORT"] = self.short_session_id() @@ -1301,7 +1297,7 @@ class Session: """ Set the thumbnail filename. Move files from /tmp to session dir. - :param str thumb_file: tumbnail file to set for session + :param thumb_file: tumbnail file to set for session :return: nothing """ if not os.path.exists(thumb_file): @@ -1318,7 +1314,7 @@ class Session: Set the username for this session. Update the permissions of the session dir to allow the user write access. - :param str user: user to give write permissions to for the session directory + :param user: user to give write permissions to for the session directory :return: nothing """ if user: @@ -1346,9 +1342,9 @@ class Session: """ Create an emulation node. - :param class cls: node class to create - :param list args: list of arguments for the class to create - :param dict kwargs: dictionary of arguments for the class to create + :param cls: node class to create + :param args: list of arguments for the class to create + :param kwargs: dictionary of arguments for the class to create :return: the created node instance :raises core.CoreError: when id of the node to create already exists """ @@ -1364,10 +1360,9 @@ class Session: """ Get a session node. - :param int _id: node id to retrieve + :param _id: node id to retrieve :return: node for the given id - :rtype: core.nodes.base.NodeBase - :raises core.CoreError: when node does not exist +:raises core.CoreError: when node does not exist """ if _id not in self.nodes: raise CoreError(f"unknown node id {_id}") @@ -1377,10 +1372,9 @@ class Session: """ Delete a node from the session and check if session should shutdown, if no nodes are left. - :param int _id: id of node to delete + :param _id: id of node to delete :return: True if node deleted, False otherwise - :rtype: bool - """ +""" # delete node and check for session shutdown if a node was removed logging.info("deleting node(%s)", _id) node = None @@ -1440,10 +1434,10 @@ class Session: """ Generate and broadcast an exception event. - :param core.emulator.enumerations.ExceptionLevel level: exception level - :param str source: source name - :param int node_id: node related to exception - :param str text: exception message + :param level: exception level + :param source: source name + :param node_id: node related to exception + :param text: exception message :return: nothing """ exception_data = ExceptionData( @@ -1602,7 +1596,7 @@ class Session: Boot node by adding a control interface when necessary and starting node services. - :param core.nodes.base.CoreNode node: node to boot + :param node: node to boot :return: nothing """ logging.info("booting node(%s): %s", node.name, [x.name for x in node.services]) @@ -1616,8 +1610,7 @@ class Session: request flag. :return: service boot exceptions - :rtype: list[Exception] - """ +""" with self._nodes_lock: funcs = [] start = time.monotonic() @@ -1638,8 +1631,7 @@ class Session: Retrieve control net prefixes. :return: control net prefix list - :rtype: list - """ +""" p = self.options.get_config("controlnet") p0 = self.options.get_config("controlnet0") p1 = self.options.get_config("controlnet1") @@ -1654,8 +1646,7 @@ class Session: Retrieve control net server interfaces. :return: list of control net server interfaces - :rtype: list - """ +""" d0 = self.options.get_config("controlnetif0") if d0: logging.error("controlnet0 cannot be assigned with a host interface") @@ -1668,10 +1659,9 @@ class Session: """ Retrieve control net index. - :param str dev: device to get control net index for + :param dev: device to get control net index for :return: control net index, -1 otherwise - :rtype: int - """ +""" if dev[0:4] == "ctrl" and int(dev[4]) in [0, 1, 2, 3]: index = int(dev[4]) if index == 0: @@ -1702,12 +1692,11 @@ class Session: interfaces. The conf_reqd flag, when False, causes a control network bridge to be added even if one has not been configured. - :param int net_index: network index - :param bool remove: flag to check if it should be removed - :param bool conf_required: flag to check if conf is required + :param net_index: network index + :param remove: flag to check if it should be removed + :param conf_required: flag to check if conf is required :return: control net node - :rtype: core.nodes.network.CtrlNet - """ +""" logging.debug( "add/remove control net: index(%s) remove(%s) conf_required(%s)", net_index, @@ -1791,10 +1780,10 @@ class Session: If conf_reqd is False, the control network may be built even when the user has not configured one (e.g. for EMANE.) - :param core.nodes.base.CoreNodeBase node: node to add or remove control interface - :param int net_index: network index - :param bool remove: flag to check if it should be removed - :param bool conf_required: flag to check if conf is required + :param node: node to add or remove control interface + :param net_index: network index + :param remove: flag to check if it should be removed + :param conf_required: flag to check if conf is required :return: nothing """ control_net = self.add_remove_control_net(net_index, remove, conf_required) @@ -1836,8 +1825,8 @@ class Session: """ Add the IP addresses of control interfaces to the /etc/hosts file. - :param int net_index: network index to update - :param bool remove: flag to check if it should be removed + :param net_index: network index to update + :param remove: flag to check if it should be removed :return: nothing """ if not self.options.get_config_bool("update_etc_hosts", default=False): @@ -1887,8 +1876,8 @@ class Session: start of the runtime state. :param event_time: event time - :param core.nodes.base.CoreNode node: node to add event for - :param str name: name of event + :param node: node to add event for + :param name: name of event :param data: data for event :return: nothing """ @@ -1926,9 +1915,9 @@ class Session: """ Run a scheduled event, executing commands in the data string. - :param int node_id: node id to run event - :param str name: event name - :param str data: event data + :param node_id: node id to run event + :param name: event name + :param data: event data :return: nothing """ now = self.runtime() diff --git a/daemon/core/emulator/sessionconfig.py b/daemon/core/emulator/sessionconfig.py index b403b8d6..38322efd 100644 --- a/daemon/core/emulator/sessionconfig.py +++ b/daemon/core/emulator/sessionconfig.py @@ -76,12 +76,11 @@ class SessionConfig(ConfigurableManager, ConfigurableOptions): """ Retrieves a specific configuration for a node and configuration type. - :param str _id: specific configuration to retrieve - :param int node_id: node id to store configuration for - :param str config_type: configuration type to store configuration for + :param _id: specific configuration to retrieve + :param node_id: node id to store configuration for + :param config_type: configuration type to store configuration for :param default: default value to return when value is not found :return: configuration value - :rtype str """ value = super().get_config(_id, node_id, config_type, default) if value == "": diff --git a/daemon/core/gui/graph/graph.py b/daemon/core/gui/graph/graph.py index 1a354209..2ae47b83 100644 --- a/daemon/core/gui/graph/graph.py +++ b/daemon/core/gui/graph/graph.py @@ -95,7 +95,7 @@ class CanvasGraph(tk.Canvas): """ Reset the private variables CanvasGraph object, redraw nodes given the new grpc client. - :param core.api.grpc.core_pb2.Session session: session to draw + :param session: session to draw """ # hide context self.hide_context() diff --git a/daemon/core/gui/toolbar.py b/daemon/core/gui/toolbar.py index 021c2bc1..a92f50f5 100644 --- a/daemon/core/gui/toolbar.py +++ b/daemon/core/gui/toolbar.py @@ -205,10 +205,10 @@ class Toolbar(ttk.Frame): """ Create button and put it on the frame - :param PIL.Image image: button image + :param image: button image :param func: the command that is executed when button is clicked - :param tkinter.Frame frame: frame that contains the button - :param str label: button label + :param frame: frame that contains the button + :param label: button label """ button = ttk.Button( frame, image=image, text=label, compound=tk.TOP, style=Styles.picker_button diff --git a/daemon/core/location/corelocation.py b/daemon/core/location/corelocation.py index fc803fac..b744b935 100644 --- a/daemon/core/location/corelocation.py +++ b/daemon/core/location/corelocation.py @@ -100,8 +100,7 @@ class CoreLocation: :param y: y value :param z: z value :return: lat, lon, alt values for provided coordinates - :rtype: tuple - """ +""" # shift (x,y,z) over to reference point (x,y,z) x -= self.refxyz[0] y = -(y - self.refxyz[1]) @@ -143,8 +142,7 @@ class CoreLocation: :param lon: longitude :param alt: altitude :return: converted x, y, z coordinates - :rtype: tuple - """ +""" # convert lat/lon to UTM coordinates in meters e, n, zonen, zonel = utm.from_latlon(lat, lon) _rlat, _rlon, ralt = self.refgeo @@ -251,8 +249,7 @@ class CoreLocation: :param e: easting value :param n: northing value :return: modified easting, northing, and zone values - :rtype: tuple - """ +""" zone = self.refutm[0] rlat, rlon, _ralt = self.refgeo if e > 834000 or e < 166000: diff --git a/daemon/core/location/event.py b/daemon/core/location/event.py index d553e4ee..acba5e5a 100644 --- a/daemon/core/location/event.py +++ b/daemon/core/location/event.py @@ -51,8 +51,7 @@ class Timer(threading.Thread): the timer was already running. :return: True if canceled, False otherwise - :rtype: bool - """ +""" locked = self._running.acquire(False) if locked: self.finished.set() @@ -218,13 +217,12 @@ class EventLoop: """ Add an event to the event loop. - :param float delaysec: delay in seconds for event + :param delaysec: delay in seconds for event :param func: event function :param args: event arguments :param kwds: event keyword arguments :return: created event - :rtype: Event - """ +""" with self.lock: eventnum = self.eventnum self.eventnum += 1 diff --git a/daemon/core/location/mobility.py b/daemon/core/location/mobility.py index e1917636..320b6f9e 100644 --- a/daemon/core/location/mobility.py +++ b/daemon/core/location/mobility.py @@ -42,7 +42,7 @@ class MobilityManager(ModelManager): """ Creates a MobilityManager instance. - :param core.emulator.session.Session session: session this manager is tied to + :param session: session this manager is tied to """ super().__init__() self.session = session @@ -62,7 +62,7 @@ class MobilityManager(ModelManager): Session is transitioning from instantiation to runtime state. Instantiate any mobility models that have been configured for a WLAN. - :param list node_ids: node ids to startup + :param node_ids: node ids to startup :return: nothing """ if node_ids is None: @@ -97,7 +97,7 @@ class MobilityManager(ModelManager): Handle an Event Message used to start, stop, or pause mobility scripts for a given WlanNode. - :param EventData event_data: event data to handle + :param event_data: event data to handle :return: nothing """ event_type = event_data.event_type @@ -160,7 +160,7 @@ class MobilityManager(ModelManager): Send an event message on behalf of a mobility model. This communicates the current and end (max) times to the GUI. - :param WayPointMobility model: mobility model to send event for + :param model: mobility model to send event for :return: nothing """ event_type = EventTypes.NONE.value @@ -193,8 +193,8 @@ class MobilityManager(ModelManager): Update every WlanNode. This saves range calculations if the model were to recalculate for each individual node movement. - :param list moved: moved nodes - :param list moved_netifs: moved network interfaces + :param moved: moved nodes + :param moved_netifs: moved network interfaces :return: nothing """ for node_id in self.nodes(): @@ -220,8 +220,8 @@ class WirelessModel(ConfigurableOptions): """ Create a WirelessModel instance. - :param core.session.Session session: core session we are tied to - :param int _id: object id + :param session: core session we are tied to + :param _id: object id """ self.session = session self.id = _id @@ -233,16 +233,15 @@ class WirelessModel(ConfigurableOptions): :param flags: link data flags :return: link data - :rtype: list - """ +""" return [] def update(self, moved: bool, moved_netifs: List[CoreInterface]) -> None: """ Update this wireless model. - :param bool moved: flag is it was moved - :param list moved_netifs: moved network interfaces + :param moved: flag is it was moved + :param moved_netifs: moved network interfaces :return: nothing """ raise NotImplementedError @@ -252,7 +251,7 @@ class WirelessModel(ConfigurableOptions): For run-time updates of model config. Returns True when position callback and set link parameters should be invoked. - :param dict config: configuration values to update + :param config: configuration values to update :return: nothing """ pass @@ -307,8 +306,8 @@ class BasicRangeModel(WirelessModel): """ Create a BasicRangeModel instance. - :param core.session.Session session: related core session - :param int _id: object id + :param session: related core session + :param _id: object id """ super().__init__(session, _id) self.session = session @@ -326,7 +325,7 @@ class BasicRangeModel(WirelessModel): """ Values to convert to link parameters. - :param dict config: values to convert + :param config: values to convert :return: nothing """ self.range = int(float(config["range"])) @@ -406,8 +405,8 @@ class BasicRangeModel(WirelessModel): Assumes bidirectional links, with one calculation per node pair, where one of the nodes has moved. - :param bool moved: flag is it was moved - :param list moved_netifs: moved network interfaces + :param moved: flag is it was moved + :param moved_netifs: moved network interfaces :return: nothing """ with self._netifslock: @@ -471,11 +470,10 @@ class BasicRangeModel(WirelessModel): """ Calculate the distance between two three-dimensional points. - :param tuple p1: point one - :param tuple p2: point two + :param p1: point one + :param p2: point two :return: distance petween the points - :rtype: float - """ +""" a = p1[0] - p2[0] b = p1[1] - p2[1] c = 0 @@ -487,7 +485,7 @@ class BasicRangeModel(WirelessModel): """ Configuration has changed during runtime. - :param dict config: values to update configuration + :param config: values to update configuration :return: nothing """ self.values_from_config(config) @@ -500,12 +498,11 @@ class BasicRangeModel(WirelessModel): """ Create a wireless link/unlink data message. - :param core.nodes.interface.CoreInterface interface1: interface one - :param core.nodes.interface.CoreInterface interface2: interface two + :param interface1: interface one + :param interface2: interface two :param message_type: link message type :return: link data - :rtype: LinkData - """ +""" return LinkData( message_type=message_type, node1_id=interface1.node.id, @@ -520,9 +517,9 @@ class BasicRangeModel(WirelessModel): """ Send a wireless link/unlink API message to the GUI. - :param core.nodes.interface.CoreInterface netif: interface one - :param core.nodes.interface.CoreInterface netif2: interface two - :param bool unlink: unlink or not + :param netif: interface one + :param netif2: interface two + :param unlink: unlink or not :return: nothing """ if unlink: @@ -539,8 +536,7 @@ class BasicRangeModel(WirelessModel): :param flags: link flags :return: all link data - :rtype: list - """ +""" all_links = [] with self.wlan._linked_lock: for a in self.wlan._linked: @@ -561,7 +557,7 @@ class WayPoint: Creates a WayPoint instance. :param time: waypoint time - :param int nodenum: node id + :param nodenum: node id :param coords: waypoint coordinates :param speed: waypoint speed """ @@ -599,8 +595,8 @@ class WayPointMobility(WirelessModel): """ Create a WayPointMobility instance. - :param core.emulator.session.Session session: CORE session instance - :param int _id: object id + :param session: CORE session instance + :param _id: object id :return: """ super().__init__(session=session, _id=_id) @@ -691,11 +687,10 @@ class WayPointMobility(WirelessModel): Calculate next node location and update its coordinates. Returns True if the node's position has changed. - :param core.nodes.base.CoreNode node: node to move + :param node: node to move :param dt: move factor :return: True if node was moved, False otherwise - :rtype: bool - """ +""" if node.id not in self.points: return False x1, y1, z1 = node.getposition() @@ -764,7 +759,7 @@ class WayPointMobility(WirelessModel): Waypoints are pushed to a heapq, sorted by time. :param _time: waypoint time - :param int nodenum: node id + :param nodenum: node id :param x: x position :param y: y position :param z: z position @@ -778,7 +773,7 @@ class WayPointMobility(WirelessModel): """ Record initial position in a dict. - :param int nodenum: node id + :param nodenum: node id :param x: x position :param y: y position :param z: z position @@ -791,7 +786,7 @@ class WayPointMobility(WirelessModel): """ Move items from self.queue to self.points when their time has come. - :param float now: current timestamp + :param now: current timestamp :return: nothing """ while len(self.queue): @@ -823,7 +818,7 @@ class WayPointMobility(WirelessModel): without invoking the interface poshook callback that may perform range calculation. - :param core.nodes.base.CoreNode node: node to set position for + :param node: node to set position for :param x: x position :param y: y position :param z: z position @@ -871,7 +866,7 @@ class WayPointMobility(WirelessModel): """ Stop the script and move nodes to initial positions. - :param bool move_initial: flag to check if we should move nodes to initial + :param move_initial: flag to check if we should move nodes to initial position :return: nothing """ @@ -954,8 +949,8 @@ class Ns2ScriptedMobility(WayPointMobility): """ Creates a Ns2ScriptedMobility instance. - :param core.emulator.session.Session session: CORE session instance - :param int _id: object id + :param session: CORE session instance + :param _id: object id """ super().__init__(session, _id) self._netifs = {} @@ -1061,10 +1056,9 @@ class Ns2ScriptedMobility(WayPointMobility): configs directory (~/.core/configs). This allows for sample files without absolute path names. - :param str file_name: file name to find + :param file_name: file name to find :return: absolute path to the file - :rtype: str - """ +""" if os.path.exists(file_name): return file_name @@ -1087,7 +1081,7 @@ class Ns2ScriptedMobility(WayPointMobility): """ Parse a node mapping string, given as a configuration parameter. - :param str mapstr: mapping string to parse + :param mapstr: mapping string to parse :return: nothing """ self.nodemap = {} @@ -1107,10 +1101,9 @@ class Ns2ScriptedMobility(WayPointMobility): """ Map one node number (from a script file) to another. - :param int nodenum: node id to map + :param nodenum: node id to map :return: mapped value or the node id itself - :rtype: int - """ +""" nodenum = int(nodenum) return self.nodemap.get(nodenum, nodenum) @@ -1174,7 +1167,7 @@ class Ns2ScriptedMobility(WayPointMobility): """ Stop the mobility script. - :param bool move_initial: flag to check if we should move node to initial + :param move_initial: flag to check if we should move node to initial position :return: nothing """ @@ -1185,7 +1178,7 @@ class Ns2ScriptedMobility(WayPointMobility): """ State of the mobility script. - :param str typestr: state type string + :param typestr: state type string :return: nothing """ filename = None diff --git a/daemon/core/nodes/base.py b/daemon/core/nodes/base.py index ccfc2c1c..b1c5a227 100644 --- a/daemon/core/nodes/base.py +++ b/daemon/core/nodes/base.py @@ -45,11 +45,11 @@ class NodeBase: """ Creates a NodeBase instance. - :param core.emulator.session.Session session: CORE session object - :param int _id: id - :param str name: object name - :param bool start: start value - :param core.emulator.distributed.DistributedServer server: remote server node + :param session: CORE session object + :param _id: id + :param name: object name + :param start: start value + :param server: remote server node will run on, default is None for localhost """ @@ -102,14 +102,13 @@ class NodeBase: """ Runs a command on the host system or distributed server. - :param str args: command to run - :param dict env: environment to run command with - :param str cwd: directory to run command in - :param bool wait: True to wait for status, False otherwise - :param bool shell: True to use shell, False otherwise + :param args: command to run + :param env: environment to run command with + :param cwd: directory to run command in + :param wait: True to wait for status, False otherwise + :param shell: True to use shell, False otherwise :return: combined stdout and stderr - :rtype: str - :raises CoreCommandError: when a non-zero exit status occurs +:raises CoreCommandError: when a non-zero exit status occurs """ if self.server is None: return utils.cmd(args, env, cwd, wait, shell) @@ -120,12 +119,11 @@ class NodeBase: """ Set the (x,y,z) position of the object. - :param float x: x position - :param float y: y position - :param float z: z position + :param x: x position + :param y: y position + :param z: z position :return: True if position changed, False otherwise - :rtype: bool - """ +""" return self.position.set(x=x, y=y, z=z) def getposition(self) -> Tuple[float, float, float]: @@ -133,28 +131,25 @@ class NodeBase: Return an (x,y,z) tuple representing this object's position. :return: x,y,z position tuple - :rtype: tuple - """ +""" return self.position.get() def ifname(self, ifindex: int) -> str: """ Retrieve interface name for index. - :param int ifindex: interface index + :param ifindex: interface index :return: interface name - :rtype: str - """ +""" return self._netif[ifindex].name def netifs(self, sort: bool = False) -> List[CoreInterface]: """ Retrieve network interfaces, sorted if desired. - :param bool sort: boolean used to determine if interfaces should be sorted + :param sort: boolean used to determine if interfaces should be sorted :return: network interfaces - :rtype: list[core.nodes.interfaces.CoreInterface] - """ +""" if sort: return [self._netif[x] for x in sorted(self._netif)] else: @@ -165,18 +160,16 @@ class NodeBase: Return the attached interface count. :return: number of network interfaces - :rtype: int - """ +""" return len(self._netif) def getifindex(self, netif: CoreInterface) -> int: """ Retrieve index for an interface. - :param core.nodes.interface.CoreInterface netif: interface to get index for + :param netif: interface to get index for :return: interface index if found, -1 otherwise - :rtype: int - """ +""" for ifindex in self._netif: if self._netif[ifindex] is netif: return ifindex @@ -187,8 +180,7 @@ class NodeBase: Create a new interface index. :return: interface index - :rtype: int - """ +""" while self.ifindex in self._netif: self.ifindex += 1 ifindex = self.ifindex @@ -207,13 +199,12 @@ class NodeBase: Build a data object for this node. :param message_type: purpose for the data object we are creating - :param str lat: latitude - :param str lon: longitude - :param str alt: altitude - :param str source: source of node data + :param lat: latitude + :param lon: longitude + :param alt: altitude + :param source: source of node data :return: node data object - :rtype: core.emulator.data.NodeData - """ +""" if self.apitype is None: return None @@ -257,8 +248,7 @@ class NodeBase: :param flags: message flags :return: list of link data - :rtype: list[core.data.LinkData] - """ +""" return [] @@ -278,11 +268,11 @@ class CoreNodeBase(NodeBase): """ Create a CoreNodeBase instance. - :param core.emulator.session.Session session: CORE session object - :param int _id: object id - :param str name: object name - :param bool start: boolean for starting - :param core.emulator.distributed.DistributedServer server: remote server node + :param session: CORE session object + :param _id: object id + :param name: object name + :param start: boolean for starting + :param server: remote server node will run on, default is None for localhost """ super().__init__(session, _id, name, start, server) @@ -320,8 +310,8 @@ class CoreNodeBase(NodeBase): """ Add network interface to node and set the network interface index if successful. - :param core.nodes.interface.CoreInterface netif: network interface to add - :param int ifindex: interface index + :param netif: network interface to add + :param ifindex: interface index :return: nothing """ if ifindex in self._netif: @@ -333,7 +323,7 @@ class CoreNodeBase(NodeBase): """ Delete a network interface - :param int ifindex: interface index to delete + :param ifindex: interface index to delete :return: nothing """ if ifindex not in self._netif: @@ -346,10 +336,9 @@ class CoreNodeBase(NodeBase): """ Retrieve network interface. - :param int ifindex: index of interface to retrieve + :param ifindex: index of interface to retrieve :return: network interface, or None if not found - :rtype: core.nodes.interface.CoreInterface - """ +""" if ifindex in self._netif: return self._netif[ifindex] else: @@ -359,8 +348,8 @@ class CoreNodeBase(NodeBase): """ Attach a network. - :param int ifindex: interface of index to attach - :param core.nodes.base.CoreNetworkBase net: network to attach + :param ifindex: interface of index to attach + :param net: network to attach :return: nothing """ if ifindex not in self._netif: @@ -371,7 +360,7 @@ class CoreNodeBase(NodeBase): """ Detach network interface. - :param int ifindex: interface index to detach + :param ifindex: interface index to detach :return: nothing """ if ifindex not in self._netif: @@ -403,8 +392,7 @@ class CoreNodeBase(NodeBase): :param obj: object to get common network with :param want_ctrl: flag set to determine if control network are wanted :return: tuples of common networks - :rtype: list - """ +""" common = [] for netif1 in self.netifs(): if not want_ctrl and hasattr(netif1, "control"): @@ -418,12 +406,11 @@ class CoreNodeBase(NodeBase): """ Runs a command within a node container. - :param str args: command to run - :param bool wait: True to wait for status, False otherwise - :param bool shell: True to use shell, False otherwise + :param args: command to run + :param wait: True to wait for status, False otherwise + :param shell: True to use shell, False otherwise :return: combined stdout and stderr - :rtype: str - :raises CoreCommandError: when a non-zero exit status occurs +:raises CoreCommandError: when a non-zero exit status occurs """ raise NotImplementedError @@ -431,7 +418,7 @@ class CoreNodeBase(NodeBase): """ Create a terminal command string. - :param str sh: shell to execute command in + :param sh: shell to execute command in :return: str """ raise NotImplementedError @@ -458,13 +445,13 @@ class CoreNode(CoreNodeBase): """ Create a CoreNode instance. - :param core.emulator.session.Session session: core session instance - :param int _id: object id - :param str name: object name - :param str nodedir: node directory - :param str bootsh: boot shell to use - :param bool start: start flag - :param core.emulator.distributed.DistributedServer server: remote server node + :param session: core session instance + :param _id: object id + :param name: object name + :param nodedir: node directory + :param bootsh: boot shell to use + :param start: start flag + :param server: remote server node will run on, default is None for localhost """ super().__init__(session, _id, name, start, server) @@ -490,7 +477,7 @@ class CoreNode(CoreNodeBase): Create node network client for running network commands within the nodes container. - :param bool use_ovs: True for OVS bridges, False for Linux bridges + :param use_ovs: True for OVS bridges, False for Linux bridges :return: node network client """ return get_net_client(use_ovs, self.cmd) @@ -500,8 +487,7 @@ class CoreNode(CoreNodeBase): Check if the node is alive. :return: True if node is alive, False otherwise - :rtype: bool - """ +""" try: self.host_cmd(f"kill -0 {self.pid}") except CoreCommandError: @@ -601,12 +587,11 @@ class CoreNode(CoreNodeBase): Runs a command that is used to configure and setup the network within a node. - :param str args: command to run - :param bool wait: True to wait for status, False otherwise - :param bool shell: True to use shell, False otherwise + :param args: command to run + :param wait: True to wait for status, False otherwise + :param shell: True to use shell, False otherwise :return: combined stdout and stderr - :rtype: str - :raises CoreCommandError: when a non-zero exit status occurs +:raises CoreCommandError: when a non-zero exit status occurs """ if self.server is None: return self.client.check_cmd(args, wait=wait, shell=shell) @@ -618,7 +603,7 @@ class CoreNode(CoreNodeBase): """ Create a terminal command string. - :param str sh: shell to execute command in + :param sh: shell to execute command in :return: str """ terminal = self.client.create_cmd(sh) @@ -631,7 +616,7 @@ class CoreNode(CoreNodeBase): """ Create a private directory. - :param str path: path to create + :param path: path to create :return: nothing """ if path[0] != "/": @@ -646,8 +631,8 @@ class CoreNode(CoreNodeBase): """ Create and mount a directory. - :param str source: source directory to mount - :param str target: target directory to create + :param source: source directory to mount + :param target: target directory to create :return: nothing :raises CoreCommandError: when a non-zero exit status occurs """ @@ -662,8 +647,7 @@ class CoreNode(CoreNodeBase): Retrieve a new interface index. :return: new interface index - :rtype: int - """ +""" with self.lock: return super().newifindex() @@ -671,8 +655,8 @@ class CoreNode(CoreNodeBase): """ Create a new interface. - :param int ifindex: index for the new interface - :param str ifname: name for the new interface + :param ifindex: index for the new interface + :param ifname: name for the new interface :return: nothing """ with self.lock: @@ -728,11 +712,10 @@ class CoreNode(CoreNodeBase): """ Create a new tunnel tap. - :param int ifindex: interface index - :param str ifname: interface name + :param ifindex: interface index + :param ifname: interface name :return: interface index - :rtype: int - """ +""" with self.lock: if ifindex is None: ifindex = self.newifindex() @@ -758,8 +741,8 @@ class CoreNode(CoreNodeBase): """ Set hardware addres for an interface. - :param int ifindex: index of interface to set hardware address for - :param str addr: hardware address to set + :param ifindex: index of interface to set hardware address for + :param addr: hardware address to set :return: nothing :raises CoreCommandError: when a non-zero exit status occurs """ @@ -773,8 +756,8 @@ class CoreNode(CoreNodeBase): """ Add interface address. - :param int ifindex: index of interface to add address to - :param str addr: address to add to interface + :param ifindex: index of interface to add address to + :param addr: address to add to interface :return: nothing """ addr = utils.validate_ip(addr) @@ -791,8 +774,8 @@ class CoreNode(CoreNodeBase): """ Delete address from an interface. - :param int ifindex: index of interface to delete address from - :param str addr: address to delete from interface + :param ifindex: index of interface to delete address from + :param addr: address to delete from interface :return: nothing :raises CoreCommandError: when a non-zero exit status occurs """ @@ -810,7 +793,7 @@ class CoreNode(CoreNodeBase): """ Bring an interface up. - :param int ifindex: index of interface to bring up + :param ifindex: index of interface to bring up :return: nothing """ if self.up: @@ -828,14 +811,13 @@ class CoreNode(CoreNodeBase): """ Create a new network interface. - :param core.nodes.base.CoreNetworkBase net: network to associate with - :param list addrlist: addresses to add on the interface - :param str hwaddr: hardware address to set for interface - :param int ifindex: index of interface to create - :param str ifname: name for interface + :param net: network to associate with + :param addrlist: addresses to add on the interface + :param hwaddr: hardware address to set for interface + :param ifindex: index of interface to create + :param ifname: name for interface :return: interface index - :rtype: int - """ +""" if not addrlist: addrlist = [] @@ -872,8 +854,8 @@ class CoreNode(CoreNodeBase): """ Add a file. - :param str srcname: source file name - :param str filename: file name to add + :param srcname: source file name + :param filename: file name to add :return: nothing :raises CoreCommandError: when a non-zero exit status occurs """ @@ -891,7 +873,7 @@ class CoreNode(CoreNodeBase): """ Return the name of a node"s file on the host filesystem. - :param str filename: host file name + :param filename: host file name :return: path to file """ dirname, basename = os.path.split(filename) @@ -907,9 +889,9 @@ class CoreNode(CoreNodeBase): """ Create a node file with a given mode. - :param str filename: name of file to create - :param str contents: contents of file - :param int mode: mode for file + :param filename: name of file to create + :param contents: contents of file + :param mode: mode for file :return: nothing """ hostfilename = self.hostfilename(filename) @@ -933,9 +915,9 @@ class CoreNode(CoreNodeBase): Copy a file to a node, following symlinks and preserving metadata. Change file mode if specified. - :param str filename: file name to copy file to - :param str srcfilename: file to copy - :param int mode: mode to copy to + :param filename: file name to copy file to + :param srcfilename: file to copy + :param mode: mode to copy to :return: nothing """ hostfilename = self.hostfilename(filename) @@ -969,11 +951,11 @@ class CoreNetworkBase(NodeBase): """ Create a CoreNetworkBase instance. - :param core.emulator.session.Session session: CORE session object - :param int _id: object id - :param str name: object name - :param bool start: should object start - :param core.emulator.distributed.DistributedServer server: remote server node + :param session: CORE session object + :param _id: object id + :param name: object name + :param start: should object start + :param server: remote server node will run on, default is None for localhost """ super().__init__(session, _id, name, start, server) @@ -1000,20 +982,18 @@ class CoreNetworkBase(NodeBase): """ Link network to another. - :param core.nodes.base.CoreNetworkBase net: network to link with + :param net: network to link with :return: created interface - :rtype: core.nodes.interface.Veth - """ +""" pass def getlinknetif(self, net: "CoreNetworkBase") -> CoreInterface: """ Return the interface of that links this net with another net. - :param core.nodes.base.CoreNetworkBase net: interface to get link for + :param net: interface to get link for :return: interface the provided network is linked to - :rtype: core.nodes.interface.CoreInterface - """ +""" for netif in self.netifs(): if hasattr(netif, "othernet") and netif.othernet == net: return netif @@ -1023,7 +1003,7 @@ class CoreNetworkBase(NodeBase): """ Attach network interface. - :param core.nodes.interface.CoreInterface netif: network interface to attach + :param netif: network interface to attach :return: nothing """ i = self.newifindex() @@ -1036,7 +1016,7 @@ class CoreNetworkBase(NodeBase): """ Detach network interface. - :param core.nodes.interface.CoreInterface netif: network interface to detach + :param netif: network interface to detach :return: nothing """ del self._netif[netif.netifi] @@ -1049,10 +1029,9 @@ class CoreNetworkBase(NodeBase): Build link data objects for this network. Each link object describes a link between this network and a node. - :param int flags: message type + :param flags: message type :return: list of link data - :rtype: list[core.data.LinkData] - """ +""" all_links = [] # build a link message from this network node to each node having a @@ -1159,12 +1138,11 @@ class Position: """ Returns True if the position has actually changed. - :param float x: x position - :param float y: y position - :param float z: z position + :param x: x position + :param y: y position + :param z: z position :return: True if position changed, False otherwise - :rtype: bool - """ +""" if self.x == x and self.y == y and self.z == z: return False self.x = x @@ -1177,6 +1155,5 @@ class Position: Retrieve x,y,z position. :return: x,y,z position tuple - :rtype: tuple - """ +""" return self.x, self.y, self.z diff --git a/daemon/core/nodes/client.py b/daemon/core/nodes/client.py index c2624d6b..989bee41 100644 --- a/daemon/core/nodes/client.py +++ b/daemon/core/nodes/client.py @@ -17,8 +17,8 @@ class VnodeClient: """ Create a VnodeClient instance. - :param str name: name for client - :param str ctrlchnlname: control channel name + :param name: name for client + :param ctrlchnlname: control channel name """ self.name = name self.ctrlchnlname = ctrlchnlname @@ -38,8 +38,7 @@ class VnodeClient: Check if node is connected or not. :return: True if connected, False otherwise - :rtype: bool - """ +""" return True def close(self) -> None: @@ -57,12 +56,11 @@ class VnodeClient: """ Run command and return exit status and combined stdout and stderr. - :param str args: command to run - :param bool wait: True to wait for command status, False otherwise - :param bool shell: True to use shell, False otherwise + :param args: command to run + :param wait: True to wait for command status, False otherwise + :param shell: True to use shell, False otherwise :return: combined stdout and stderr - :rtype: str - :raises core.CoreCommandError: when there is a non-zero exit status +:raises core.CoreCommandError: when there is a non-zero exit status """ self._verify_connection() args = self.create_cmd(args) diff --git a/daemon/core/nodes/docker.py b/daemon/core/nodes/docker.py index 1d7f3f02..7590dd32 100644 --- a/daemon/core/nodes/docker.py +++ b/daemon/core/nodes/docker.py @@ -88,15 +88,15 @@ class DockerNode(CoreNode): """ Create a DockerNode instance. - :param core.emulator.session.Session session: core session instance - :param int _id: object id - :param str name: object name - :param str nodedir: node directory - :param str bootsh: boot shell to use - :param bool start: start flag - :param core.emulator.distributed.DistributedServer server: remote server node + :param session: core session instance + :param _id: object id + :param name: object name + :param nodedir: node directory + :param bootsh: boot shell to use + :param start: start flag + :param server: remote server node will run on, default is None for localhost - :param str image: image to start container with + :param image: image to start container with """ if image is None: image = "ubuntu" @@ -108,7 +108,7 @@ class DockerNode(CoreNode): Create node network client for running network commands within the nodes container. - :param bool use_ovs: True for OVS bridges, False for Linux bridges + :param use_ovs: True for OVS bridges, False for Linux bridges :return:node network client """ return get_net_client(use_ovs, self.nsenter_cmd) @@ -118,8 +118,7 @@ class DockerNode(CoreNode): Check if the node is alive. :return: True if node is alive, False otherwise - :rtype: bool - """ +""" return self.client.is_alive() def startup(self) -> None: @@ -165,7 +164,7 @@ class DockerNode(CoreNode): """ Create a terminal command string. - :param str sh: shell to execute command in + :param sh: shell to execute command in :return: str """ return f"docker exec -it {self.name} bash" @@ -174,7 +173,7 @@ class DockerNode(CoreNode): """ Create a private directory. - :param str path: path to create + :param path: path to create :return: nothing """ logging.debug("creating node dir: %s", path) @@ -185,8 +184,8 @@ class DockerNode(CoreNode): """ Create and mount a directory. - :param str source: source directory to mount - :param str target: target directory to create + :param source: source directory to mount + :param target: target directory to create :return: nothing :raises CoreCommandError: when a non-zero exit status occurs """ @@ -197,9 +196,9 @@ class DockerNode(CoreNode): """ Create a node file with a given mode. - :param str filename: name of file to create + :param filename: name of file to create :param contents: contents of file - :param int mode: mode for file + :param mode: mode for file :return: nothing """ logging.debug("nodefile filename(%s) mode(%s)", filename, mode) @@ -226,9 +225,9 @@ class DockerNode(CoreNode): Copy a file to a node, following symlinks and preserving metadata. Change file mode if specified. - :param str filename: file name to copy file to - :param str srcfilename: file to copy - :param int mode: mode to copy to + :param filename: file name to copy file to + :param srcfilename: file to copy + :param mode: mode to copy to :return: nothing """ logging.info( diff --git a/daemon/core/nodes/interface.py b/daemon/core/nodes/interface.py index b583d3a8..9a8e4554 100644 --- a/daemon/core/nodes/interface.py +++ b/daemon/core/nodes/interface.py @@ -32,11 +32,11 @@ class CoreInterface: """ Creates a CoreInterface instance. - :param core.emulator.session.Session session: core session instance - :param core.nodes.base.CoreNode node: node for interface - :param str name: interface name - :param int mtu: mtu value - :param core.emulator.distributed.DistributedServer server: remote server node + :param session: core session instance + :param node: node for interface + :param name: interface name + :param mtu: mtu value + :param server: remote server node will run on, default is None for localhost """ self.session = session @@ -74,14 +74,13 @@ class CoreInterface: """ Runs a command on the host system or distributed server. - :param str args: command to run - :param dict env: environment to run command with - :param str cwd: directory to run command in - :param bool wait: True to wait for status, False otherwise - :param bool shell: True to use shell, False otherwise + :param args: command to run + :param env: environment to run command with + :param cwd: directory to run command in + :param wait: True to wait for status, False otherwise + :param shell: True to use shell, False otherwise :return: combined stdout and stderr - :rtype: str - :raises CoreCommandError: when a non-zero exit status occurs +:raises CoreCommandError: when a non-zero exit status occurs """ if self.server is None: return utils.cmd(args, env, cwd, wait, shell) @@ -108,7 +107,7 @@ class CoreInterface: """ Attach network. - :param core.nodes.base.CoreNetworkBase net: network to attach + :param net: network to attach :return: nothing """ if self.net: @@ -131,7 +130,7 @@ class CoreInterface: """ Add address. - :param str addr: address to add + :param addr: address to add :return: nothing """ addr = utils.validate_ip(addr) @@ -141,7 +140,7 @@ class CoreInterface: """ Delete address. - :param str addr: address to delete + :param addr: address to delete :return: nothing """ self.addrlist.remove(addr) @@ -150,7 +149,7 @@ class CoreInterface: """ Set hardware address. - :param str addr: hardware address to set to. + :param addr: hardware address to set to. :return: nothing """ if addr is not None: @@ -201,7 +200,7 @@ class CoreInterface: intialize it. This is for supporting separate upstream/downstream parameters when two layer-2 nodes are linked together. - :param str name: name of parameter to swap + :param name: name of parameter to swap :return: nothing """ tmp = self._params @@ -227,8 +226,7 @@ class CoreInterface: :param other: other interface :return: true if less than, false otherwise - :rtype: bool - """ +""" return id(self) < id(other) @@ -250,14 +248,14 @@ class Veth(CoreInterface): """ Creates a VEth instance. - :param core.emulator.session.Session session: core session instance - :param core.nodes.base.CoreNode node: related core node - :param str name: interface name - :param str localname: interface local name - :param int mtu: interface mtu - :param core.emulator.distributed.DistributedServer server: remote server node + :param session: core session instance + :param node: related core node + :param name: interface name + :param localname: interface local name + :param mtu: interface mtu + :param server: remote server node will run on, default is None for localhost - :param bool start: start flag + :param start: start flag :raises CoreCommandError: when there is a command exception """ # note that net arg is ignored @@ -320,14 +318,14 @@ class TunTap(CoreInterface): """ Create a TunTap instance. - :param core.emulator.session.Session session: core session instance - :param core.nodes.base.CoreNode node: related core node - :param str name: interface name - :param str localname: local interface name - :param int mtu: interface mtu - :param core.emulator.distributed.DistributedServer server: remote server node + :param session: core session instance + :param node: related core node + :param name: interface name + :param localname: local interface name + :param mtu: interface mtu + :param server: remote server node will run on, default is None for localhost - :param bool start: start flag + :param start: start flag """ super().__init__(session, node, name, mtu, server) self.localname = localname @@ -373,11 +371,10 @@ class TunTap(CoreInterface): Wait for func() to return zero with exponential backoff. :param func: function to wait for a result of zero - :param int attempts: number of attempts to wait for a zero result - :param float maxretrydelay: maximum retry delay + :param attempts: number of attempts to wait for a zero result + :param maxretrydelay: maximum retry delay :return: True if wait succeeded, False otherwise - :rtype: bool - """ +""" delay = 0.01 result = False for i in range(1, attempts + 1): @@ -405,8 +402,7 @@ class TunTap(CoreInterface): appear right away waits :return: wait for device local response - :rtype: int - """ +""" logging.debug("waiting for device local: %s", self.localname) def localdevexists(): @@ -500,17 +496,17 @@ class GreTap(CoreInterface): """ Creates a GreTap instance. - :param core.nodes.base.CoreNode node: related core node - :param str name: interface name - :param core.emulator.session.Session session: core session instance - :param int mtu: interface mtu - :param str remoteip: remote address - :param int _id: object id - :param str localip: local address - :param int ttl: ttl value - :param int key: gre tap key - :param bool start: start flag - :param core.emulator.distributed.DistributedServer server: remote server node + :param node: related core node + :param name: interface name + :param session: core session instance + :param mtu: interface mtu + :param remoteip: remote address + :param _id: object id + :param localip: local address + :param ttl: ttl value + :param key: gre tap key + :param start: start flag + :param server: remote server node will run on, default is None for localhost :raises CoreCommandError: when there is a command exception """ @@ -564,6 +560,5 @@ class GreTap(CoreInterface): :param flags: link flags :return: link data - :rtype: list[core.emulator.data.LinkData] - """ +""" return [] diff --git a/daemon/core/nodes/lxd.py b/daemon/core/nodes/lxd.py index 20e2bc43..357c6b56 100644 --- a/daemon/core/nodes/lxd.py +++ b/daemon/core/nodes/lxd.py @@ -82,15 +82,15 @@ class LxcNode(CoreNode): """ Create a LxcNode instance. - :param core.emulator.session.Session session: core session instance - :param int _id: object id - :param str name: object name - :param str nodedir: node directory - :param str bootsh: boot shell to use - :param bool start: start flag - :param core.emulator.distributed.DistributedServer server: remote server node + :param session: core session instance + :param _id: object id + :param name: object name + :param nodedir: node directory + :param bootsh: boot shell to use + :param start: start flag + :param server: remote server node will run on, default is None for localhost - :param str image: image to start container with + :param image: image to start container with """ if image is None: image = "ubuntu" @@ -102,8 +102,7 @@ class LxcNode(CoreNode): Check if the node is alive. :return: True if node is alive, False otherwise - :rtype: bool - """ +""" return self.client.is_alive() def startup(self) -> None: @@ -139,7 +138,7 @@ class LxcNode(CoreNode): """ Create a terminal command string. - :param str sh: shell to execute command in + :param sh: shell to execute command in :return: str """ return f"lxc exec {self.name} -- {sh}" @@ -148,7 +147,7 @@ class LxcNode(CoreNode): """ Create a private directory. - :param str path: path to create + :param path: path to create :return: nothing """ logging.info("creating node dir: %s", path) @@ -159,8 +158,8 @@ class LxcNode(CoreNode): """ Create and mount a directory. - :param str source: source directory to mount - :param str target: target directory to create + :param source: source directory to mount + :param target: target directory to create :return: nothing :raises CoreCommandError: when a non-zero exit status occurs """ @@ -171,9 +170,9 @@ class LxcNode(CoreNode): """ Create a node file with a given mode. - :param str filename: name of file to create + :param filename: name of file to create :param contents: contents of file - :param int mode: mode for file + :param mode: mode for file :return: nothing """ logging.debug("nodefile filename(%s) mode(%s)", filename, mode) @@ -199,9 +198,9 @@ class LxcNode(CoreNode): Copy a file to a node, following symlinks and preserving metadata. Change file mode if specified. - :param str filename: file name to copy file to - :param str srcfilename: file to copy - :param int mode: mode to copy to + :param filename: file name to copy file to + :param srcfilename: file to copy + :param mode: mode to copy to :return: nothing """ logging.info( diff --git a/daemon/core/nodes/netclient.py b/daemon/core/nodes/netclient.py index c5de1c8e..9ad72d57 100644 --- a/daemon/core/nodes/netclient.py +++ b/daemon/core/nodes/netclient.py @@ -24,7 +24,7 @@ class LinuxNetClient: """ Set network hostname. - :param str name: name for hostname + :param name: name for hostname :return: nothing """ self.run(f"hostname {name}") @@ -33,8 +33,8 @@ class LinuxNetClient: """ Create a new route for a device. - :param str route: route to create - :param str device: device to add route to + :param route: route to create + :param device: device to add route to :return: nothing """ self.run(f"{IP_BIN} route add {route} dev {device}") @@ -43,7 +43,7 @@ class LinuxNetClient: """ Bring a device up. - :param str device: device to bring up + :param device: device to bring up :return: nothing """ self.run(f"{IP_BIN} link set {device} up") @@ -52,7 +52,7 @@ class LinuxNetClient: """ Bring a device down. - :param str device: device to bring down + :param device: device to bring down :return: nothing """ self.run(f"{IP_BIN} link set {device} down") @@ -61,8 +61,8 @@ class LinuxNetClient: """ Set a device name. - :param str device: device to set name for - :param str name: name to set + :param device: device to set name for + :param name: name to set :return: nothing """ self.run(f"{IP_BIN} link set {device} name {name}") @@ -71,38 +71,35 @@ class LinuxNetClient: """ Show information for a device. - :param str device: device to get information for + :param device: device to get information for :return: device information - :rtype: str - """ +""" return self.run(f"{IP_BIN} link show {device}") def get_mac(self, device: str) -> str: """ Retrieve MAC address for a given device. - :param str device: device to get mac for + :param device: device to get mac for :return: MAC address - :rtype: str - """ +""" return self.run(f"cat /sys/class/net/{device}/address") def get_ifindex(self, device: str) -> str: """ Retrieve ifindex for a given device. - :param str device: device to get ifindex for + :param device: device to get ifindex for :return: ifindex - :rtype: str - """ +""" return self.run(f"cat /sys/class/net/{device}/ifindex") def device_ns(self, device: str, namespace: str) -> None: """ Set netns for a device. - :param str device: device to setns for - :param str namespace: namespace to set device to + :param device: device to setns for + :param namespace: namespace to set device to :return: nothing """ self.run(f"{IP_BIN} link set {device} netns {namespace}") @@ -111,7 +108,7 @@ class LinuxNetClient: """ Flush device addresses. - :param str device: device to flush + :param device: device to flush :return: nothing """ self.run( @@ -123,8 +120,8 @@ class LinuxNetClient: """ Set MAC address for a device. - :param str device: device to set mac for - :param str mac: mac to set + :param device: device to set mac for + :param mac: mac to set :return: nothing """ self.run(f"{IP_BIN} link set dev {device} address {mac}") @@ -133,7 +130,7 @@ class LinuxNetClient: """ Delete device. - :param str device: device to delete + :param device: device to delete :return: nothing """ self.run(f"{IP_BIN} link delete {device}") @@ -142,7 +139,7 @@ class LinuxNetClient: """ Remove traffic control settings for a device. - :param str device: device to remove tc + :param device: device to remove tc :return: nothing """ self.run(f"{TC_BIN} qdisc delete dev {device} root") @@ -151,7 +148,7 @@ class LinuxNetClient: """ Turns interface checksums off. - :param str interface_name: interface to update + :param interface_name: interface to update :return: nothing """ self.run(f"{ETHTOOL_BIN} -K {interface_name} rx off tx off") @@ -160,9 +157,9 @@ class LinuxNetClient: """ Create address for a device. - :param str device: device to add address to - :param str address: address to add - :param str broadcast: broadcast address to use, default is None + :param device: device to add address to + :param address: address to add + :param broadcast: broadcast address to use, default is None :return: nothing """ if broadcast is not None: @@ -176,8 +173,8 @@ class LinuxNetClient: """ Delete an address from a device. - :param str device: targeted device - :param str address: address to remove + :param device: targeted device + :param address: address to remove :return: nothing """ self.run(f"{IP_BIN} address delete {address} dev {device}") @@ -186,8 +183,8 @@ class LinuxNetClient: """ Create a veth pair. - :param str name: veth name - :param str peer: peer name + :param name: veth name + :param peer: peer name :return: nothing """ self.run(f"{IP_BIN} link add name {name} type veth peer name {peer}") @@ -198,11 +195,11 @@ class LinuxNetClient: """ Create a GRE tap on a device. - :param str device: device to add tap to - :param str address: address to add tap for - :param str local: local address to tie to - :param int ttl: time to live value - :param int key: key for tap + :param device: device to add tap to + :param address: address to add tap for + :param local: local address to tie to + :param ttl: time to live value + :param key: key for tap :return: nothing """ cmd = f"{IP_BIN} link add {device} type gretap remote {address}" @@ -218,7 +215,7 @@ class LinuxNetClient: """ Create a Linux bridge and bring it up. - :param str name: bridge name + :param name: bridge name :return: nothing """ self.run(f"{IP_BIN} link add name {name} type bridge") @@ -231,7 +228,7 @@ class LinuxNetClient: """ Bring down and delete a Linux bridge. - :param str name: bridge name + :param name: bridge name :return: nothing """ self.device_down(name) @@ -241,8 +238,8 @@ class LinuxNetClient: """ Create an interface associated with a Linux bridge. - :param str bridge_name: bridge name - :param str interface_name: interface name + :param bridge_name: bridge name + :param interface_name: interface name :return: nothing """ self.run(f"{IP_BIN} link set dev {interface_name} master {bridge_name}") @@ -252,8 +249,8 @@ class LinuxNetClient: """ Delete an interface associated with a Linux bridge. - :param str bridge_name: bridge name - :param str interface_name: interface name + :param bridge_name: bridge name + :param interface_name: interface name :return: nothing """ self.run(f"{IP_BIN} link set dev {interface_name} nomaster") @@ -282,7 +279,7 @@ class LinuxNetClient: """ Disable mac learning for a Linux bridge. - :param str name: bridge name + :param name: bridge name :return: nothing """ self.run(f"{IP_BIN} link set {name} type bridge ageing_time 0") @@ -297,7 +294,7 @@ class OvsNetClient(LinuxNetClient): """ Create a OVS bridge and bring it up. - :param str name: bridge name + :param name: bridge name :return: nothing """ self.run(f"{OVS_BIN} add-br {name}") @@ -310,7 +307,7 @@ class OvsNetClient(LinuxNetClient): """ Bring down and delete a OVS bridge. - :param str name: bridge name + :param name: bridge name :return: nothing """ self.device_down(name) @@ -320,8 +317,8 @@ class OvsNetClient(LinuxNetClient): """ Create an interface associated with a network bridge. - :param str bridge_name: bridge name - :param str interface_name: interface name + :param bridge_name: bridge name + :param interface_name: interface name :return: nothing """ self.run(f"{OVS_BIN} add-port {bridge_name} {interface_name}") @@ -331,8 +328,8 @@ class OvsNetClient(LinuxNetClient): """ Delete an interface associated with a OVS bridge. - :param str bridge_name: bridge name - :param str interface_name: interface name + :param bridge_name: bridge name + :param interface_name: interface name :return: nothing """ self.run(f"{OVS_BIN} del-port {bridge_name} {interface_name}") @@ -356,7 +353,7 @@ class OvsNetClient(LinuxNetClient): """ Disable mac learning for a OVS bridge. - :param str name: bridge name + :param name: bridge name :return: nothing """ self.run(f"{OVS_BIN} set bridge {name} other_config:mac-aging-time=0") @@ -366,8 +363,8 @@ def get_net_client(use_ovs: bool, run: Callable[..., str]) -> LinuxNetClient: """ Retrieve desired net client for running network commands. - :param bool use_ovs: True for OVS bridges, False for Linux bridges - :param func run: function used to run net client commands + :param use_ovs: True for OVS bridges, False for Linux bridges + :param run: function used to run net client commands :return: net client class """ if use_ovs: diff --git a/daemon/core/nodes/network.py b/daemon/core/nodes/network.py index c7c36a1e..20c1ad16 100644 --- a/daemon/core/nodes/network.py +++ b/daemon/core/nodes/network.py @@ -100,10 +100,9 @@ class EbtablesQueue: """ Helper for building ebtables atomic file command list. - :param str cmd: ebtable command + :param cmd: ebtable command :return: ebtable atomic command - :rtype: str - """ +""" return f"{EBTABLES_BIN} --atomic-file {self.atomic_file} {cmd}" def lastupdate(self, wlan: "CoreNetwork") -> float: @@ -112,8 +111,7 @@ class EbtablesQueue: :param wlan: wlan entity :return: elpased time - :rtype: float - """ +""" try: elapsed = time.monotonic() - self.last_update_time[wlan] except KeyError: @@ -243,8 +241,8 @@ def ebtablescmds(call: Callable[..., str], cmds: List[str]) -> None: """ Run ebtable commands. - :param func call: function to call commands - :param list cmds: commands to call + :param call: function to call commands + :param cmds: commands to call :return: nothing """ with ebtables_lock: @@ -271,11 +269,11 @@ class CoreNetwork(CoreNetworkBase): """ Creates a LxBrNet instance. - :param core.session.Session session: core session instance - :param int _id: object id - :param str name: object name - :param bool start: start flag - :param core.emulator.distributed.DistributedServer server: remote server node + :param session: core session instance + :param _id: object id + :param name: object name + :param start: start flag + :param server: remote server node will run on, default is None for localhost :param policy: network policy """ @@ -305,14 +303,13 @@ class CoreNetwork(CoreNetworkBase): Runs a command that is used to configure and setup the network on the host system and all configured distributed servers. - :param str args: command to run - :param dict env: environment to run command with - :param str cwd: directory to run command in - :param bool wait: True to wait for status, False otherwise - :param bool shell: True to use shell, False otherwise + :param args: command to run + :param env: environment to run command with + :param cwd: directory to run command in + :param wait: True to wait for status, False otherwise + :param shell: True to use shell, False otherwise :return: combined stdout and stderr - :rtype: str - :raises CoreCommandError: when a non-zero exit status occurs +:raises CoreCommandError: when a non-zero exit status occurs """ logging.debug("network node(%s) cmd", self.name) output = utils.cmd(args, env, cwd, wait, shell) @@ -365,7 +362,7 @@ class CoreNetwork(CoreNetworkBase): """ Attach a network interface. - :param core.nodes.interface.CoreInterface netif: network interface to attach + :param netif: network interface to attach :return: nothing """ if self.up: @@ -376,7 +373,7 @@ class CoreNetwork(CoreNetworkBase): """ Detach a network interface. - :param core.nodes.interface.Veth netif: network interface to detach + :param netif: network interface to detach :return: nothing """ if self.up: @@ -387,11 +384,10 @@ class CoreNetwork(CoreNetworkBase): """ Determine if the provided network interfaces are linked. - :param core.nodes.interface.CoreInterface netif1: interface one - :param core.nodes.interface.CoreInterface netif2: interface two + :param netif1: interface one + :param netif2: interface two :return: True if interfaces are linked, False otherwise - :rtype: bool - """ +""" # check if the network interfaces are attached to this network if self._netif[netif1.netifi] != netif1: raise ValueError(f"inconsistency for netif {netif1.name}") @@ -417,8 +413,8 @@ class CoreNetwork(CoreNetworkBase): Unlink two interfaces, resulting in adding or removing ebtables filtering rules. - :param core.nodes.interface.CoreInterface netif1: interface one - :param core.nodes.interface.CoreInterface netif2: interface two + :param netif1: interface one + :param netif2: interface two :return: nothing """ with self._linked_lock: @@ -433,8 +429,8 @@ class CoreNetwork(CoreNetworkBase): Link two interfaces together, resulting in adding or removing ebtables filtering rules. - :param core.nodes.interface.CoreInterface netif1: interface one - :param core.nodes.interface.CoreInterface netif2: interface two + :param netif1: interface one + :param netif2: interface two :return: nothing """ with self._linked_lock: @@ -458,13 +454,13 @@ class CoreNetwork(CoreNetworkBase): """ Configure link parameters by applying tc queuing disciplines on the interface. - :param core.nodes.interface.CoreInterface netif: interface one + :param netif: interface one :param bw: bandwidth to set to :param delay: packet delay to set to :param loss: packet loss to set to :param duplicate: duplicate percentage to set to :param jitter: jitter to set to - :param core.netns.vif.Veth netif2: interface two + :param netif2: interface two :param devname: device name :return: nothing """ @@ -546,10 +542,9 @@ class CoreNetwork(CoreNetworkBase): Link this bridge with another by creating a veth pair and installing each device into each bridge. - :param core.nodes.base.CoreNetworkBase net: network to link with + :param net: network to link with :return: created interface - :rtype: core.nodes.interface.CoreInterface - """ +""" sessionid = self.session.short_session_id() try: _id = f"{self.id:x}" @@ -587,10 +582,9 @@ class CoreNetwork(CoreNetworkBase): Return the interface of that links this net with another net (that were linked using linknet()). - :param core.nodes.base.CoreNetworkBase net: interface to get link for + :param net: interface to get link for :return: interface the provided network is linked to - :rtype: core.nodes.interface.CoreInterface - """ +""" for netif in self.netifs(): if hasattr(netif, "othernet") and netif.othernet == net: return netif @@ -600,7 +594,7 @@ class CoreNetwork(CoreNetworkBase): """ Set addresses on the bridge. - :param list[str] addrlist: address list + :param addrlist: address list :return: nothing """ if not self.up: @@ -632,16 +626,16 @@ class GreTapBridge(CoreNetwork): """ Create a GreTapBridge instance. - :param core.emulator.session.Session session: core session instance - :param str remoteip: remote address - :param int _id: object id - :param str name: object name + :param session: core session instance + :param remoteip: remote address + :param _id: object id + :param name: object name :param policy: network policy - :param str localip: local address + :param localip: local address :param ttl: ttl value :param key: gre tap key - :param bool start: start flag - :param core.emulator.distributed.DistributedServer server: remote server node + :param start: start flag + :param server: remote server node will run on, default is None for localhost """ CoreNetwork.__init__(self, session, _id, name, False, server, policy) @@ -696,7 +690,7 @@ class GreTapBridge(CoreNetwork): The 1st address in the provided list is remoteip, 2nd optionally specifies localip. - :param list addrlist: address list + :param addrlist: address list :return: nothing """ if self.gretap: @@ -756,16 +750,16 @@ class CtrlNet(CoreNetwork): """ Creates a CtrlNet instance. - :param core.emulator.session.Session session: core session instance - :param int _id: node id - :param str name: node namee + :param session: core session instance + :param _id: node id + :param name: node namee :param prefix: control network ipv4 prefix :param hostid: host id - :param bool start: start flag - :param core.emulator.distributed.DistributedServer server: remote server node + :param start: start flag + :param server: remote server node will run on, default is None for localhost - :param str assign_address: assigned address - :param str updown_script: updown script + :param assign_address: assigned address + :param updown_script: updown script :param serverintf: server interface :return: """ @@ -780,7 +774,7 @@ class CtrlNet(CoreNetwork): """ Add addresses used for created control networks, - :param int index: starting address index + :param index: starting address index :return: nothing """ use_ovs = self.session.options.get_config("ovs") == "True" @@ -861,8 +855,7 @@ class CtrlNet(CoreNetwork): :param flags: message flags :return: list of link data - :rtype: list[core.data.LinkData] - """ +""" return [] @@ -877,7 +870,7 @@ class PtpNet(CoreNetwork): """ Attach a network interface, but limit attachment to two interfaces. - :param core.nodes.interface.CoreInterface netif: network interface + :param netif: network interface :return: nothing """ if len(self._netif) >= 2: @@ -899,13 +892,12 @@ class PtpNet(CoreNetwork): built using a link message instead. :param message_type: purpose for the data object we are creating - :param float lat: latitude - :param float lon: longitude - :param float alt: altitude - :param str source: source of node data + :param lat: latitude + :param lon: longitude + :param alt: altitude + :param source: source of node data :return: node data object - :rtype: core.emulator.data.NodeData - """ +""" return None def all_link_data(self, flags: int) -> List[LinkData]: @@ -915,8 +907,7 @@ class PtpNet(CoreNetwork): :param flags: message flags :return: list of link data - :rtype: list[core.emulator.data.LinkData] - """ +""" all_links = [] @@ -1057,11 +1048,11 @@ class WlanNode(CoreNetwork): """ Create a WlanNode instance. - :param core.session.Session session: core session instance - :param int _id: node id - :param str name: node name - :param bool start: start flag - :param core.emulator.distributed.DistributedServer server: remote server node + :param session: core session instance + :param _id: node id + :param name: node name + :param start: start flag + :param server: remote server node will run on, default is None for localhost :param policy: wlan policy """ @@ -1083,7 +1074,7 @@ class WlanNode(CoreNetwork): """ Attach a network interface. - :param core.nodes.interface.CoreInterface netif: network interface + :param netif: network interface :return: nothing """ super().attach(netif) @@ -1099,8 +1090,8 @@ class WlanNode(CoreNetwork): """ Sets the mobility and wireless model. - :param core.location.mobility.WirelessModel.cls model: wireless model to set to - :param dict config: configuration for model being set + :param model: wireless model to set to + :param config: configuration for model being set :return: nothing """ logging.debug("node(%s) setting model: %s", self.name, model.name) @@ -1139,8 +1130,7 @@ class WlanNode(CoreNetwork): :param flags: message flags :return: list of link data - :rtype: list[core.emulator.data.LinkData] - """ +""" all_links = super().all_link_data(flags) if self.model: all_links.extend(self.model.all_link_data(flags)) diff --git a/daemon/core/nodes/physical.py b/daemon/core/nodes/physical.py index a963721f..c01d5057 100644 --- a/daemon/core/nodes/physical.py +++ b/daemon/core/nodes/physical.py @@ -62,7 +62,7 @@ class PhysicalNode(CoreNodeBase): """ Create a terminal command string. - :param str sh: shell to execute command in + :param sh: shell to execute command in :return: str """ return sh @@ -71,8 +71,8 @@ class PhysicalNode(CoreNodeBase): """ Set hardware address for an interface. - :param int ifindex: index of interface to set hardware address for - :param str addr: hardware address to set + :param ifindex: index of interface to set hardware address for + :param addr: hardware address to set :return: nothing :raises CoreCommandError: when a non-zero exit status occurs """ @@ -86,8 +86,8 @@ class PhysicalNode(CoreNodeBase): """ Add an address to an interface. - :param int ifindex: index of interface to add address to - :param str addr: address to add + :param ifindex: index of interface to add address to + :param addr: address to add :return: nothing """ addr = utils.validate_ip(addr) @@ -100,8 +100,8 @@ class PhysicalNode(CoreNodeBase): """ Delete an address from an interface. - :param int ifindex: index of interface to delete - :param str addr: address to delete + :param ifindex: index of interface to delete + :param addr: address to delete :return: nothing """ interface = self._netif[ifindex] @@ -279,12 +279,12 @@ class Rj45Node(CoreNodeBase, CoreInterface): """ Create an RJ45Node instance. - :param core.emulator.session.Session session: core session instance - :param int _id: node id - :param str name: node name + :param session: core session instance + :param _id: node id + :param name: node name :param mtu: rj45 mtu - :param bool start: start flag - :param core.emulator.distributed.DistributedServer server: remote server node + :param start: start flag + :param server: remote server node will run on, default is None for localhost """ CoreNodeBase.__init__(self, session, _id, name, start, server) @@ -339,7 +339,7 @@ class Rj45Node(CoreNodeBase, CoreInterface): """ Attach a network. - :param core.nodes.base.CoreNetworkBase net: network to attach + :param net: network to attach :return: nothing """ CoreInterface.attachnet(self, net) @@ -367,14 +367,13 @@ class Rj45Node(CoreNodeBase, CoreInterface): represents an interface, we do not create another object here, but attach ourselves to the given network. - :param core.nodes.base.CoreNetworkBase net: new network instance - :param list[str] addrlist: address list - :param str hwaddr: hardware address - :param int ifindex: interface index - :param str ifname: interface name + :param net: new network instance + :param addrlist: address list + :param hwaddr: hardware address + :param ifindex: interface index + :param ifname: interface name :return: interface index - :rtype: int - :raises ValueError: when an interface has already been created, one max +:raises ValueError: when an interface has already been created, one max """ with self.lock: if ifindex is None: @@ -401,7 +400,7 @@ class Rj45Node(CoreNodeBase, CoreInterface): """ Delete a network interface. - :param int ifindex: interface index to delete + :param ifindex: interface index to delete :return: nothing """ if ifindex is None: @@ -422,11 +421,10 @@ class Rj45Node(CoreNodeBase, CoreInterface): return self here. This keeps the RJ45Node compatible with real nodes. - :param int ifindex: interface index to retrieve + :param ifindex: interface index to retrieve :param net: network to retrieve :return: a network interface - :rtype: core.nodes.interface,CoreInterface - """ +""" if net is not None and net == self.net: return self @@ -442,11 +440,10 @@ class Rj45Node(CoreNodeBase, CoreInterface): """ Retrieve network interface index. - :param core.nodes.interface.CoreInterface netif: network interface to retrieve + :param netif: network interface to retrieve index for :return: interface index, None otherwise - :rtype: int - """ +""" if netif != self: return None return self.ifindex @@ -455,7 +452,7 @@ class Rj45Node(CoreNodeBase, CoreInterface): """ Add address to to network interface. - :param str addr: address to add + :param addr: address to add :return: nothing :raises CoreCommandError: when there is a command exception """ @@ -468,7 +465,7 @@ class Rj45Node(CoreNodeBase, CoreInterface): """ Delete address from network interface. - :param str addr: address to delete + :param addr: address to delete :return: nothing :raises CoreCommandError: when there is a command exception """ @@ -525,12 +522,11 @@ class Rj45Node(CoreNodeBase, CoreInterface): """ Uses setposition from both parent classes. - :param float x: x position - :param float y: y position - :param float z: z position + :param x: x position + :param y: y position + :param z: z position :return: True if position changed, False otherwise - :rtype: bool - """ +""" result = CoreNodeBase.setposition(self, x, y, z) CoreInterface.setposition(self, x, y, z) return result @@ -539,7 +535,7 @@ class Rj45Node(CoreNodeBase, CoreInterface): """ Create a terminal command string. - :param str sh: shell to execute command in + :param sh: shell to execute command in :return: str """ raise NotImplementedError diff --git a/daemon/core/plugins/sdt.py b/daemon/core/plugins/sdt.py index 575cbcda..1ce6bb8d 100644 --- a/daemon/core/plugins/sdt.py +++ b/daemon/core/plugins/sdt.py @@ -38,7 +38,7 @@ class Bunch: """ Create a Bunch instance. - :param dict kwargs: keyword arguments + :param kwargs: keyword arguments """ self.__dict__.update(kwargs) @@ -71,7 +71,7 @@ class Sdt: """ Creates a Sdt instance. - :param core.emulator.session.Session session: session this manager is tied to + :param session: session this manager is tied to """ self.session = session self.sock = None @@ -92,7 +92,7 @@ class Sdt: """ Handler for node updates, specifically for updating their location. - :param core.emulator.data.NodeData node_data: node data being updated + :param node_data: node data being updated :return: nothing """ x = node_data.x_position @@ -117,7 +117,7 @@ class Sdt: """ Handler for link updates, checking for wireless link/unlink messages. - :param core.emulator.data.LinkData link_data: link data being updated + :param link_data: link data being updated :return: nothing """ if link_data.link_type == LinkTypes.WIRELESS.value: @@ -134,8 +134,7 @@ class Sdt: the option is missing. :return: True if enabled, False otherwise - :rtype: bool - """ +""" return self.session.options.get_config("enablesdt") == "1" def seturl(self) -> None: @@ -157,8 +156,7 @@ class Sdt: Connect to the SDT address/port if enabled. :return: True if connected, False otherwise - :rtype: bool - """ +""" if not self.is_enabled(): return False if self.connected: @@ -196,8 +194,7 @@ class Sdt: the virtual globe. :return: initialize command status - :rtype: bool - """ +""" if not self.cmd(f'path "{CORE_DATA_DIR}/icons/normal"'): return False # send node type to icon mappings @@ -239,10 +236,9 @@ class Sdt: as opposed to socket.sendto() because an exception is raised when there is no socket listener. - :param str cmdstr: command to send + :param cmdstr: command to send :return: True if command was successful, False otherwise - :rtype: bool - """ +""" if self.sock is None: return False try: @@ -269,12 +265,12 @@ class Sdt: """ Node is updated from a Node Message or mobility script. - :param int nodenum: node id to update + :param nodenum: node id to update :param flags: update flags :param x: x position :param y: y position :param z: z position - :param str name: node name + :param name: node name :param node_type: node type :param icon: node icon :return: nothing @@ -302,7 +298,7 @@ class Sdt: """ Node is updated upon receiving an EMANE Location Event. - :param int nodenum: node id to update geospatial for + :param nodenum: node id to update geospatial for :param lat: latitude :param lon: longitude :param alt: altitude @@ -321,10 +317,10 @@ class Sdt: """ Link is updated from a Link Message or by a wireless model. - :param int node1num: node one id - :param int node2num: node two id + :param node1num: node one id + :param node2num: node two id :param flags: link flags - :param bool wireless: flag to check if wireless or not + :param wireless: flag to check if wireless or not :return: nothing """ if node1num is None or node2num is None: @@ -509,10 +505,9 @@ class Sdt: """ Helper returns True if a node number corresponds to a WLAN or EMANE node. - :param int nodenum: node id to check + :param nodenum: node id to check :return: True if node is wlan or emane, False otherwise - :rtype: bool - """ +""" if nodenum in self.remotes: node_type = self.remotes[nodenum].type if node_type in ("wlan", "emane"): diff --git a/daemon/core/services/__init__.py b/daemon/core/services/__init__.py index 6c0c18ed..562b4bd7 100644 --- a/daemon/core/services/__init__.py +++ b/daemon/core/services/__init__.py @@ -16,6 +16,5 @@ def load(): Loads all services from the modules that reside under core.services. :return: list of services that failed to load - :rtype: list[str] - """ +""" return ServiceManager.add_services(_PATH) diff --git a/daemon/core/services/coreservices.py b/daemon/core/services/coreservices.py index 9abbc977..46cc6292 100644 --- a/daemon/core/services/coreservices.py +++ b/daemon/core/services/coreservices.py @@ -60,8 +60,7 @@ class ServiceDependencies: Generates the boot paths for the services provided to the class. :return: list of services to boot, in order - :rtype: list[core.coreservices.CoreService] - """ +""" paths = [] for name in self.node_services: service = self.node_services[name] @@ -149,11 +148,10 @@ class ServiceShim: Convert service properties into a string list of key=value pairs, separated by "|". - :param core.nodes.base.CoreNode node: node to get value list for - :param CoreService service: service to get value list for + :param node: node to get value list for + :param service: service to get value list for :return: value list string - :rtype: str - """ +""" start_time = 0 start_index = 0 valmap = [ @@ -178,8 +176,8 @@ class ServiceShim: Convert list of values into properties for this instantiated (customized) service. - :param CoreService service: service to get value list for - :param dict values: value list to set properties from + :param service: service to get value list for + :param values: value list to set properties from :return: nothing """ # TODO: support empty value? e.g. override default meta with '' @@ -195,8 +193,8 @@ class ServiceShim: """ Set values for this service. - :param CoreService service: service to get value list for - :param str key: key to set value for + :param service: service to get value list for + :param key: key to set value for :param value: value of key to set :return: nothing """ @@ -229,10 +227,9 @@ class ServiceShim: """ Build a list of services from an opaque data string. - :param str opaque: opaque data string + :param opaque: opaque data string :return: services - :rtype: list - """ +""" servicesstring = opaque.split(":") if servicesstring[0] != "service": return [] @@ -251,7 +248,7 @@ class ServiceManager: """ Add a service to manager. - :param CoreService service: service to add + :param service: service to add :return: nothing :raises ValueError: when service cannot be loaded """ @@ -281,10 +278,9 @@ class ServiceManager: """ Retrieve a service from the manager. - :param str name: name of the service to retrieve + :param name: name of the service to retrieve :return: service if it exists, None otherwise - :rtype: CoreService.class - """ +""" return cls.services.get(name) @classmethod @@ -292,10 +288,9 @@ class ServiceManager: """ Method for retrieving all CoreServices from a given path. - :param str path: path to retrieve services from + :param path: path to retrieve services from :return: list of core services that failed to load - :rtype: list[str] - """ +""" service_errors = [] services = utils.load_classes(path, CoreService) for service in services: @@ -326,7 +321,7 @@ class CoreServices: """ Creates a CoreServices instance. - :param core.session.Session session: session this manager is tied to + :param session: session this manager is tied to """ self.session = session # dict of default services tuples, key is node type @@ -347,8 +342,7 @@ class CoreServices: :param node_type: node type to get default services for :return: default services - :rtype: list[CoreService] - """ +""" logging.debug("getting default services for type: %s", node_type) results = [] defaults = self.default_services.get(node_type, []) @@ -368,9 +362,9 @@ class CoreServices: Get any custom service configured for the given node that matches the specified service name. If no custom service is found, return the specified service. - :param int node_id: object id to get service from - :param str service_name: name of service to retrieve - :param bool default_service: True to return default service when custom does + :param node_id: object id to get service from + :param service_name: name of service to retrieve + :param default_service: True to return default service when custom does not exist, False returns None :return: custom service from the node """ @@ -385,8 +379,8 @@ class CoreServices: Store service customizations in an instantiated service object using a list of values that came from a config message. - :param int node_id: object id to set custom service for - :param str service_name: name of service to set + :param node_id: object id to set custom service for + :param service_name: name of service to set :return: nothing """ logging.debug("setting custom service(%s) for node: %s", service_name, node_id) @@ -405,9 +399,9 @@ class CoreServices: """ Add services to a node. - :param core.nodes.base.CoreNode node: node to add services to - :param str node_type: node type to add services to - :param list[str] services: names of services to add to node + :param node: node to add services to + :param node_type: node type to add services to + :param services: names of services to add to node :return: nothing """ if not services: @@ -432,8 +426,7 @@ class CoreServices: to a session or opening XML. :return: list of tuples of node ids and services - :rtype: list[tuple] - """ +""" configs = [] for node_id in self.custom_services: custom_services = self.custom_services[node_id] @@ -447,10 +440,9 @@ class CoreServices: Return all customized files stored with a service. Used when reconnecting to a session or opening XML. - :param CoreService service: service to get files for + :param service: service to get files for :return: list of all custom service files - :rtype: list[tuple] - """ +""" files = [] if not service.custom: return files @@ -467,7 +459,7 @@ class CoreServices: """ Start all services on a node. - :param core.nodes.base.CoreNode node: node to start services on + :param node: node to start services on :return: nothing """ boot_paths = ServiceDependencies(node.services).boot_paths() @@ -483,8 +475,8 @@ class CoreServices: """ Start all service boot paths found, based on dependencies. - :param core.nodes.base.CoreNode node: node to start services on - :param list[CoreService] boot_path: service to start in dependent order + :param node: node to start services on + :param boot_path: service to start in dependent order :return: nothing """ logging.info( @@ -505,8 +497,8 @@ class CoreServices: Start a service on a node. Create private dirs, generate config files, and execute startup commands. - :param core.nodes.base.CoreNode node: node to boot services on - :param CoreService service: service to start + :param node: node to boot services on + :param service: service to start :return: nothing """ logging.info( @@ -570,12 +562,11 @@ class CoreServices: config references an existing file that should be copied. Returns True for local files, False for generated. - :param core.nodes.base.CoreNode node: node to copy service for - :param str filename: file name for a configured service - :param str cfg: configuration string + :param node: node to copy service for + :param filename: file name for a configured service + :param cfg: configuration string :return: True if successful, False otherwise - :rtype: bool - """ +""" if cfg[:7] == "file://": src = cfg[7:] src = src.split("\n")[0] @@ -589,11 +580,10 @@ class CoreServices: """ Run the validation command(s) for a service. - :param core.nodes.base.CoreNode node: node to validate service for - :param CoreService service: service to validate + :param node: node to validate service for + :param service: service to validate :return: service validation status - :rtype: int - """ +""" logging.debug("validating node(%s) service(%s)", node.name, service.name) cmds = service.validate if not service.custom: @@ -618,7 +608,7 @@ class CoreServices: """ Stop all services on a node. - :param core.netns.vnode.CoreNode node: node to stop services on + :param node: node to stop services on :return: nothing """ for service in node.services: @@ -628,8 +618,8 @@ class CoreServices: """ Stop a service on a node. - :param core.nodes.base.CoreNode node: node to stop a service on - :param CoreService service: service to stop + :param node: node to stop a service on + :param service: service to stop :return: status for stopping the services """ status = 0 @@ -652,9 +642,9 @@ class CoreServices: Send a File Message when the GUI has requested a service file. The file data is either auto-generated or comes from an existing config. - :param core.nodes.base.CoreNode node: node to get service file from - :param str service_name: service to get file from - :param str filename: file name to retrieve + :param node: node to get service file from + :param service_name: service to get file from + :param filename: file name to retrieve :return: file message for node """ # get service to get file from @@ -697,9 +687,9 @@ class CoreServices: in the service config. The filename must match one from the list of config files in the service. - :param int node_id: node id to set service file - :param str service_name: service name to set file for - :param str file_name: file name to set + :param node_id: node id to set service file + :param service_name: service name to set file for + :param file_name: file name to set :param data: data for file to set :return: nothing """ @@ -729,12 +719,11 @@ class CoreServices: """ Startup a node service. - :param core.nodes.base.CoreNode node: node to reconfigure service for - :param CoreService service: service to reconfigure - :param bool wait: determines if we should wait to validate startup + :param node: node to reconfigure service for + :param service: service to reconfigure + :param wait: determines if we should wait to validate startup :return: status of startup - :rtype: int - """ +""" cmds = service.startup if not service.custom: @@ -753,8 +742,8 @@ class CoreServices: """ Creates node service files. - :param core.nodes.base.CoreNode node: node to reconfigure service for - :param CoreService service: service to reconfigure + :param node: node to reconfigure service for + :param service: service to reconfigure :return: nothing """ # get values depending on if custom or not @@ -787,8 +776,8 @@ class CoreServices: """ Reconfigure a node service. - :param core.nodes.base.CoreNode node: node to reconfigure service for - :param CoreService service: service to reconfigure + :param node: node to reconfigure service for + :param service: service to reconfigure :return: nothing """ config_files = service.configs @@ -878,10 +867,9 @@ class CoreService: returns the cls._configs tuple, but this method may be overriden to provide node-specific filenames that may be based on other services. - :param core.nodes.base.CoreNode node: node to generate config for + :param node: node to generate config for :return: configuration files - :rtype: tuple - """ +""" return cls.configs @classmethod @@ -892,8 +880,8 @@ class CoreService: Return the configuration string to be written to a file or sent to the GUI for customization. - :param core.nodes.base.CoreNode node: node to generate config for - :param str filename: file name to generate config for + :param node: node to generate config for + :param filename: file name to generate config for :return: nothing """ raise NotImplementedError @@ -906,10 +894,9 @@ class CoreService: overridden to provide node-specific commands that may be based on other services. - :param core.nodes.base.CoreNode node: node to get startup for + :param node: node to get startup for :return: startup commands - :rtype: tuple - """ +""" return cls.startup @classmethod @@ -920,8 +907,7 @@ class CoreService: overridden to provide node-specific commands that may be based on other services. - :param core.nodes.base.CoreNode node: node to validate + :param node: node to validate :return: validation commands - :rtype: tuple - """ +""" return cls.validate diff --git a/daemon/core/utils.py b/daemon/core/utils.py index 72bff755..57e95a4f 100644 --- a/daemon/core/utils.py +++ b/daemon/core/utils.py @@ -49,9 +49,9 @@ def execute_file( Provides an alternative way to run execfile to be compatible for both python2/3. - :param str path: path of file to execute - :param dict exec_globals: globals values to pass to execution - :param dict exec_locals: local values to pass to execution + :param path: path of file to execute + :param exec_globals: globals values to pass to execution + :param exec_locals: local values to pass to execution :return: nothing """ if exec_globals is None: @@ -68,9 +68,8 @@ def hashkey(value: Union[str, int]) -> int: of the builtin hash, that no longer behaves consistently in python3. - :param str/int value: value to hash + :param value: value to hash :return: hash value - :rtype: int """ if isinstance(value, int): value = str(value) @@ -94,10 +93,9 @@ def _valid_module(path: str, file_name: str) -> bool: """ Check if file is a valid python module. - :param str path: path to file - :param str file_name: file name to check + :param path: path to file + :param file_name: file name to check :return: True if a valid python module file, False otherwise - :rtype: bool """ file_path = os.path.join(path, file_name) if not os.path.isfile(file_path): @@ -120,7 +118,6 @@ def _is_class(module: Any, member: Type, clazz: Type) -> bool: :param member: member to validate for service :param clazz: clazz type to check for validation :return: True if a valid service, False otherwise - :rtype: bool """ if not inspect.isclass(member): return False @@ -149,8 +146,8 @@ def which(command: str, required: bool) -> str: """ Find location of desired executable within current PATH. - :param str command: command to find location for - :param bool required: command is required to be found, false otherwise + :param command: command to find location for + :param required: command is required to be found, false otherwise :return: command location or None :raises ValueError: when not found and required """ @@ -173,7 +170,6 @@ def make_tuple(obj: Generic[T]) -> Tuple[T]: :param obj: object to convert to a tuple :return: converted tuple or the object itself - :rtype: tuple """ if hasattr(obj, "__iter__"): return tuple(obj) @@ -185,10 +181,9 @@ def make_tuple_fromstr(s: str, value_type: Callable[[str], T]) -> Tuple[T]: """ Create a tuple from a string. - :param str s: string to convert to a tuple + :param s: string to convert to a tuple :param value_type: type of values to be contained within tuple :return: tuple from string - :rtype: tuple """ # remove tuple braces and strip commands and space from all values in the tuple # string @@ -204,10 +199,9 @@ def mute_detach(args: str, **kwargs: Dict[str, Any]) -> int: """ Run a muted detached process by forking it. - :param str args: arguments for the command - :param dict kwargs: keyword arguments for the command + :param args: arguments for the command + :param kwargs: keyword arguments for the command :return: process id of the command - :rtype: int """ args = shlex.split(args) kwargs["preexec_fn"] = _detach_init @@ -227,13 +221,12 @@ def cmd( Execute a command on the host and return a tuple containing the exit status and result string. stderr output is folded into the stdout result string. - :param str args: command arguments - :param dict env: environment to run command with - :param str cwd: directory to run command in - :param bool wait: True to wait for status, False otherwise - :param bool shell: True to use shell, False otherwise + :param args: command arguments + :param env: environment to run command with + :param cwd: directory to run command in + :param wait: True to wait for status, False otherwise + :param shell: True to use shell, False otherwise :return: combined stdout and stderr - :rtype: str :raises CoreCommandError: when there is a non-zero exit status or the file to execute is not found """ @@ -258,9 +251,9 @@ def file_munge(pathname: str, header: str, text: str) -> None: """ Insert text at the end of a file, surrounded by header comments. - :param str pathname: file path to add text to - :param str header: header text comments - :param str text: text to append to file + :param pathname: file path to add text to + :param header: header text comments + :param text: text to append to file :return: nothing """ # prevent duplicates @@ -276,8 +269,8 @@ def file_demunge(pathname: str, header: str) -> None: """ Remove text that was inserted in a file surrounded by header comments. - :param str pathname: file path to open for removing a header - :param str header: header text to target for removal + :param pathname: file path to open for removing a header + :param header: header text to target for removal :return: nothing """ with open(pathname, "r") as read_file: @@ -306,11 +299,10 @@ def expand_corepath( """ Expand a file path given session information. - :param str pathname: file path to expand - :param core.emulator.session.Session session: core session object to expand path - :param core.nodes.base.CoreNode node: node to expand path with + :param pathname: file path to expand + :param session: core session object to expand path + :param node: node to expand path with :return: expanded path - :rtype: str """ if session is not None: pathname = pathname.replace("~", f"/home/{session.user}") @@ -329,9 +321,8 @@ def sysctl_devname(devname: str) -> Optional[str]: """ Translate a device name to the name used with sysctl. - :param str devname: device name to translate + :param devname: device name to translate :return: translated device name - :rtype: str """ if devname is None: return None @@ -343,8 +334,8 @@ def load_config(filename: str, d: Dict[str, str]) -> None: Read key=value pairs from a file, into a dict. Skip comments; strip newline characters and spacing. - :param str filename: file to read into a dictionary - :param dict d: dictionary to read file into + :param filename: file to read into a dictionary + :param d: dictionary to read file into :return: nothing """ with open(filename, "r") as f: @@ -408,7 +399,7 @@ def load_logging_config(config_path: str) -> None: """ Load CORE logging configuration file. - :param str config_path: path to logging config file + :param config_path: path to logging config file :return: nothing """ with open(config_path, "r") as log_config_file: @@ -423,10 +414,9 @@ def threadpool( Run provided functions, arguments, and keywords within a threadpool collecting results and exceptions. - :param iter funcs: iterable that provides a func, args, kwargs - :param int workers: number of workers for the threadpool + :param funcs: iterable that provides a func, args, kwargs + :param workers: number of workers for the threadpool :return: results and exceptions from running functions with args and kwargs - :rtype: tuple """ with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as executor: futures = [] @@ -450,7 +440,6 @@ def random_mac() -> str: Create a random mac address using Xen OID 00:16:3E. :return: random mac address - :rtype: str """ value = random.randint(0, 0xFFFFFF) value |= 0x00163E << 24 @@ -463,9 +452,8 @@ def validate_mac(value: str) -> str: """ Validate mac and return unix formatted version. - :param str value: address to validate + :param value: address to validate :return: unix formatted mac - :rtype: str """ try: mac = netaddr.EUI(value) @@ -479,9 +467,8 @@ def validate_ip(value: str) -> str: """ Validate ip address with prefix and return formatted version. - :param str value: address to validate + :param value: address to validate :return: formatted ip address - :rtype: str """ try: ip = netaddr.IPNetwork(value) diff --git a/daemon/core/xml/emanexml.py b/daemon/core/xml/emanexml.py index da1e089e..7d4ccd68 100644 --- a/daemon/core/xml/emanexml.py +++ b/daemon/core/xml/emanexml.py @@ -24,10 +24,9 @@ def is_external(config: Dict[str, str]) -> bool: """ Checks if the configuration is for an external transport. - :param dict config: configuration to check + :param config: configuration to check :return: True if external, False otherwise - :rtype: bool - """ +""" return config.get("external") == "1" @@ -35,7 +34,7 @@ def _value_to_params(value: str) -> Optional[Tuple[str]]: """ Helper to convert a parameter to a parameter tuple. - :param str value: value string to convert to tuple + :param value: value string to convert to tuple :return: parameter tuple, None otherwise """ try: @@ -63,10 +62,10 @@ def create_file( """ Create xml file. - :param lxml.etree.Element xml_element: root element to write to file - :param str doc_name: name to use in the emane doctype - :param str file_path: file path to write xml file to - :param core.emulator.distributed.DistributedServer server: remote server node + :param xml_element: root element to write to file + :param doc_name: name to use in the emane doctype + :param file_path: file path to write xml file to + :param server: remote server node will run on, default is None for localhost :return: nothing """ @@ -87,9 +86,9 @@ def add_param(xml_element: etree.Element, name: str, value: str) -> None: """ Add emane configuration parameter to xml element. - :param lxml.etree.Element xml_element: element to append parameter to - :param str name: name of parameter - :param str value: value for parameter + :param xml_element: element to append parameter to + :param name: name of parameter + :param value: value for parameter :return: nothing """ etree.SubElement(xml_element, "param", name=name, value=value) @@ -104,10 +103,10 @@ def add_configurations( """ Add emane model configurations to xml element. - :param lxml.etree.Element xml_element: xml element to add emane configurations to - :param list[core.config.Configuration] configurations: configurations to add to xml - :param dict config: configuration values - :param set config_ignore: configuration options to ignore + :param xml_element: xml element to add emane configurations to + :param configurations: configurations to add to xml + :param config: configuration values + :param config_ignore: configuration options to ignore :return: """ for configuration in configurations: @@ -137,16 +136,15 @@ def build_node_platform_xml( """ Create platform xml for a specific node. - :param core.emane.emanemanager.EmaneManager emane_manager: emane manager with emane + :param emane_manager: emane manager with emane configurations - :param core.nodes.network.CtrlNet control_net: control net node for this emane + :param control_net: control net node for this emane network - :param core.emane.nodes.EmaneNet node: node to write platform xml for - :param int nem_id: nem id to use for interfaces for this node - :param dict platform_xmls: stores platform xml elements to append nem entries to + :param node: node to write platform xml for + :param nem_id: nem id to use for interfaces for this node + :param platform_xmls: stores platform xml elements to append nem entries to :return: the next nem id that can be used for creating platform xml files - :rtype: int - """ +""" logging.debug( "building emane platform xml for node(%s) nem_id(%s): %s", node, @@ -258,9 +256,9 @@ def build_xml_files(emane_manager: "EmaneManager", node: EmaneNet) -> None: """ Generate emane xml files required for node. - :param core.emane.emanemanager.EmaneManager emane_manager: emane manager with emane + :param emane_manager: emane manager with emane configurations - :param core.emane.nodes.EmaneNet node: node to write platform xml for + :param node: node to write platform xml for :return: nothing """ logging.debug("building all emane xml for node(%s): %s", node, node.name) @@ -308,10 +306,10 @@ def build_transport_xml( """ Build transport xml file for node and transport type. - :param core.emane.emanemanager.EmaneManager emane_manager: emane manager with emane + :param emane_manager: emane manager with emane configurations - :param core.emane.nodes.EmaneNet node: node to write platform xml for - :param str transport_type: transport type to build xml for + :param node: node to write platform xml for + :param transport_type: transport type to build xml for :return: nothing """ transport_element = etree.Element( @@ -354,10 +352,10 @@ def create_phy_xml( """ Create the phy xml document. - :param core.emane.emanemodel.EmaneModel emane_model: emane model to create xml - :param dict config: all current configuration values - :param str file_path: path to write file to - :param core.emulator.distributed.DistributedServer server: remote server node + :param emane_model: emane model to create xml + :param config: all current configuration values + :param file_path: path to write file to + :param server: remote server node will run on, default is None for localhost :return: nothing """ @@ -387,10 +385,10 @@ def create_mac_xml( """ Create the mac xml document. - :param core.emane.emanemodel.EmaneModel emane_model: emane model to create xml - :param dict config: all current configuration values - :param str file_path: path to write file to - :param core.emulator.distributed.DistributedServer server: remote server node + :param emane_model: emane model to create xml + :param config: all current configuration values + :param file_path: path to write file to + :param server: remote server node will run on, default is None for localhost :return: nothing """ @@ -425,13 +423,13 @@ def create_nem_xml( """ Create the nem xml document. - :param core.emane.emanemodel.EmaneModel emane_model: emane model to create xml - :param dict config: all current configuration values - :param str nem_file: nem file path to write - :param str transport_definition: transport file definition path - :param str mac_definition: mac file definition path - :param str phy_definition: phy file definition path - :param core.emulator.distributed.DistributedServer server: remote server node + :param emane_model: emane model to create xml + :param config: all current configuration values + :param nem_file: nem file path to write + :param transport_definition: transport file definition path + :param mac_definition: mac file definition path + :param phy_definition: phy file definition path + :param server: remote server node will run on, default is None for localhost :return: nothing """ @@ -461,11 +459,11 @@ def create_event_service_xml( """ Create a emane event service xml file. - :param str group: event group - :param str port: event port - :param str device: event device - :param str file_directory: directory to create file in - :param core.emulator.distributed.DistributedServer server: remote server node + :param group: event group + :param port: event port + :param device: event device + :param file_directory: directory to create file in + :param server: remote server node will run on, default is None for localhost :return: nothing """ @@ -488,8 +486,8 @@ def transport_file_name(node_id: int, transport_type: str) -> str: """ Create name for a transport xml file. - :param int node_id: node id to generate transport file name for - :param str transport_type: transport type to generate transport file + :param node_id: node id to generate transport file name for + :param transport_type: transport type to generate transport file :return: """ return f"n{node_id}trans{transport_type}.xml" @@ -502,8 +500,7 @@ def _basename(emane_model: "EmaneModel", interface: CoreInterface = None) -> str :param emane_model: emane model to create name for :param interface: interface for this model :return: basename used for file creation - :rtype: str - """ +""" name = f"n{emane_model.id}" if interface: @@ -518,11 +515,10 @@ def nem_file_name(emane_model: "EmaneModel", interface: CoreInterface = None) -> """ Return the string name for the NEM XML file, e.g. "n3rfpipenem.xml" - :param core.emane.emanemodel.EmaneModel emane_model: emane model to create file + :param emane_model: emane model to create file :param interface: interface for this model :return: nem xml filename - :rtype: str - """ +""" basename = _basename(emane_model, interface) append = "" if interface and interface.transport_type == "raw": @@ -534,11 +530,10 @@ def shim_file_name(emane_model: "EmaneModel", interface: CoreInterface = None) - """ Return the string name for the SHIM XML file, e.g. "commeffectshim.xml" - :param core.emane.emanemodel.EmaneModel emane_model: emane model to create file + :param emane_model: emane model to create file :param interface: interface for this model :return: shim xml filename - :rtype: str - """ +""" name = _basename(emane_model, interface) return f"{name}shim.xml" @@ -547,11 +542,10 @@ def mac_file_name(emane_model: "EmaneModel", interface: CoreInterface = None) -> """ Return the string name for the MAC XML file, e.g. "n3rfpipemac.xml" - :param core.emane.emanemodel.EmaneModel emane_model: emane model to create file + :param emane_model: emane model to create file :param interface: interface for this model :return: mac xml filename - :rtype: str - """ +""" name = _basename(emane_model, interface) return f"{name}mac.xml" @@ -560,10 +554,9 @@ def phy_file_name(emane_model: "EmaneModel", interface: CoreInterface = None) -> """ Return the string name for the PHY XML file, e.g. "n3rfpipephy.xml" - :param core.emane.emanemodel.EmaneModel emane_model: emane model to create file + :param emane_model: emane model to create file :param interface: interface for this model :return: phy xml filename - :rtype: str - """ +""" name = _basename(emane_model, interface) return f"{name}phy.xml"