daemon: added global type hinting to core.emulator.session and core.api.grpc.server
This commit is contained in:
parent
8d48393525
commit
91f1f7f004
2 changed files with 10 additions and 10 deletions
|
@ -6,7 +6,7 @@ import tempfile
|
|||
import threading
|
||||
import time
|
||||
from concurrent import futures
|
||||
from typing import Iterable, Optional, Type
|
||||
from typing import Iterable, Optional, Pattern, Type
|
||||
|
||||
import grpc
|
||||
from grpc import ServicerContext
|
||||
|
@ -118,8 +118,8 @@ from core.nodes.base import CoreNode, CoreNodeBase, NodeBase
|
|||
from core.nodes.network import WlanNode
|
||||
from core.services.coreservices import ServiceManager
|
||||
|
||||
_ONE_DAY_IN_SECONDS = 60 * 60 * 24
|
||||
_INTERFACE_REGEX = re.compile(r"veth(?P<node>[0-9a-fA-F]+)")
|
||||
_ONE_DAY_IN_SECONDS: int = 60 * 60 * 24
|
||||
_INTERFACE_REGEX: Pattern = re.compile(r"veth(?P<node>[0-9a-fA-F]+)")
|
||||
|
||||
|
||||
class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
||||
|
|
|
@ -11,7 +11,7 @@ import subprocess
|
|||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, TypeVar
|
||||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, TypeVar
|
||||
|
||||
from core import constants, utils
|
||||
from core.configservice.manager import ConfigServiceManager
|
||||
|
@ -59,7 +59,7 @@ from core.xml import corexml, corexmldeployment
|
|||
from core.xml.corexml import CoreXmlReader, CoreXmlWriter
|
||||
|
||||
# maps for converting from API call node type values to classes and vice versa
|
||||
NODES = {
|
||||
NODES: Dict[NodeTypes, Type[NodeBase]] = {
|
||||
NodeTypes.DEFAULT: CoreNode,
|
||||
NodeTypes.PHYSICAL: PhysicalNode,
|
||||
NodeTypes.SWITCH: SwitchNode,
|
||||
|
@ -74,11 +74,11 @@ NODES = {
|
|||
NodeTypes.DOCKER: DockerNode,
|
||||
NodeTypes.LXC: LxcNode,
|
||||
}
|
||||
NODES_TYPE = {NODES[x]: x for x in NODES}
|
||||
CONTAINER_NODES = {DockerNode, LxcNode}
|
||||
CTRL_NET_ID = 9001
|
||||
LINK_COLORS = ["green", "blue", "orange", "purple", "turquoise"]
|
||||
NT = TypeVar("NT", bound=NodeBase)
|
||||
NODES_TYPE: Dict[Type[NodeBase], NodeTypes] = {NODES[x]: x for x in NODES}
|
||||
CONTAINER_NODES: Set[Type[NodeBase]] = {DockerNode, LxcNode}
|
||||
CTRL_NET_ID: int = 9001
|
||||
LINK_COLORS: List[str] = ["green", "blue", "orange", "purple", "turquoise"]
|
||||
NT: TypeVar = TypeVar("NT", bound=NodeBase)
|
||||
|
||||
|
||||
class Session:
|
||||
|
|
Loading…
Reference in a new issue