Skip to content

Commit

Permalink
node_network_config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nforsg committed Aug 17, 2023
1 parent b568282 commit 85ddb40
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Network configuration of a container in the emulation
"""
from typing import Dict, Any, Union
from typing import Dict, Any, Union, Optional
from csle_common.dao.emulation_config.packet_loss_type import PacketLossType
from csle_common.dao.emulation_config.packet_delay_distribution_type import PacketDelayDistributionType
import csle_common.constants.constants as constants
Expand Down Expand Up @@ -110,7 +110,7 @@ def __init__(self, interface: str = constants.NETWORKING.ETH0,
self.cell_overhead_bytes = cell_overhead_bytes

@staticmethod
def from_dict(d: Dict[str, Any]) -> Union[None, "NodeNetworkConfig"]:
def from_dict(d: Optional[Dict[str, Any]]) -> Union[None, "NodeNetworkConfig"]:
"""
Converts a dict representation to an instance
Expand Down Expand Up @@ -157,7 +157,7 @@ def to_dict(self) -> Dict[str, Any]:
:return: a dict representation of the object
"""
d = {}
d: Dict[str, Any] = {}
d["interface"] = self.interface
d["limit_packets_queue"] = self.limit_packets_queue
d["packet_delay_ms"] = self.packet_delay_ms
Expand Down Expand Up @@ -217,7 +217,7 @@ def __str__(self) -> str:
f"cell_overhead_bytes:{self.cell_overhead_bytes}"

@staticmethod
def from_json_file(json_file_path: str) -> "NodeNetworkConfig":
def from_json_file(json_file_path: str) -> Optional["NodeNetworkConfig"]:
"""
Reads a json file and converts it to a DTO
Expand All @@ -230,7 +230,7 @@ def from_json_file(json_file_path: str) -> "NodeNetworkConfig":
json_str = f.read()
return NodeNetworkConfig.from_dict(json.loads(json_str))

def copy(self) -> "NodeNetworkConfig":
def copy(self) -> Optional["NodeNetworkConfig"]:
"""
:return: a copy of the DTO
"""
Expand Down

0 comments on commit 85ddb40

Please sign in to comment.