daemon: updated ovs option to be a formal session option, will now display within gui, save to and be read from xml
This commit is contained in:
parent
b94d4d3507
commit
f4224d1b80
7 changed files with 20 additions and 8 deletions
|
@ -80,7 +80,7 @@ class CoreEmu:
|
||||||
:raises core.errors.CoreError: when an executable does not exist on path
|
:raises core.errors.CoreError: when an executable does not exist on path
|
||||||
"""
|
"""
|
||||||
requirements = COMMON_REQUIREMENTS
|
requirements = COMMON_REQUIREMENTS
|
||||||
use_ovs = self.config.get("ovs") == "True"
|
use_ovs = self.config.get("ovs") == "1"
|
||||||
if use_ovs:
|
if use_ovs:
|
||||||
requirements += OVS_REQUIREMENTS
|
requirements += OVS_REQUIREMENTS
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -217,6 +217,9 @@ class Session:
|
||||||
else:
|
else:
|
||||||
common_network.unlink(iface1, iface2)
|
common_network.unlink(iface1, iface2)
|
||||||
|
|
||||||
|
def use_ovs(self) -> bool:
|
||||||
|
return self.options.get_config("ovs") == "1"
|
||||||
|
|
||||||
def add_link(
|
def add_link(
|
||||||
self,
|
self,
|
||||||
node1_id: int,
|
node1_id: int,
|
||||||
|
|
|
@ -56,6 +56,9 @@ class SessionConfig(ConfigurableManager, ConfigurableOptions):
|
||||||
default=Sdt.DEFAULT_SDT_URL,
|
default=Sdt.DEFAULT_SDT_URL,
|
||||||
label="SDT3D URL",
|
label="SDT3D URL",
|
||||||
),
|
),
|
||||||
|
Configuration(
|
||||||
|
_id="ovs", _type=ConfigDataTypes.BOOL, default="0", label="Enable OVS"
|
||||||
|
),
|
||||||
]
|
]
|
||||||
config_type: RegisterTlvs = RegisterTlvs.UTILITY
|
config_type: RegisterTlvs = RegisterTlvs.UTILITY
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,9 @@ class NodeBase(abc.ABC):
|
||||||
self.icon: Optional[str] = None
|
self.icon: Optional[str] = None
|
||||||
self.position: Position = Position()
|
self.position: Position = Position()
|
||||||
self.up: bool = False
|
self.up: bool = False
|
||||||
use_ovs = session.options.get_config("ovs") == "True"
|
self.net_client: LinuxNetClient = get_net_client(
|
||||||
self.net_client: LinuxNetClient = get_net_client(use_ovs, self.host_cmd)
|
self.session.use_ovs(), self.host_cmd
|
||||||
|
)
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def startup(self) -> None:
|
def startup(self) -> None:
|
||||||
|
@ -471,8 +472,9 @@ class CoreNode(CoreNodeBase):
|
||||||
self.pid: Optional[int] = None
|
self.pid: Optional[int] = None
|
||||||
self.lock: RLock = RLock()
|
self.lock: RLock = RLock()
|
||||||
self._mounts: List[Tuple[str, str]] = []
|
self._mounts: List[Tuple[str, str]] = []
|
||||||
use_ovs = session.options.get_config("ovs") == "True"
|
self.node_net_client: LinuxNetClient = self.create_node_net_client(
|
||||||
self.node_net_client: LinuxNetClient = self.create_node_net_client(use_ovs)
|
self.session.use_ovs()
|
||||||
|
)
|
||||||
|
|
||||||
def create_node_net_client(self, use_ovs: bool) -> LinuxNetClient:
|
def create_node_net_client(self, use_ovs: bool) -> LinuxNetClient:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -68,8 +68,9 @@ class CoreInterface:
|
||||||
# id used to find flow data
|
# id used to find flow data
|
||||||
self.flow_id: Optional[int] = None
|
self.flow_id: Optional[int] = None
|
||||||
self.server: Optional["DistributedServer"] = server
|
self.server: Optional["DistributedServer"] = server
|
||||||
use_ovs = session.options.get_config("ovs") == "True"
|
self.net_client: LinuxNetClient = get_net_client(
|
||||||
self.net_client: LinuxNetClient = get_net_client(use_ovs, self.host_cmd)
|
self.session.use_ovs(), self.host_cmd
|
||||||
|
)
|
||||||
|
|
||||||
def host_cmd(
|
def host_cmd(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -756,7 +756,7 @@ class CtrlNet(CoreNetwork):
|
||||||
:param index: starting address index
|
:param index: starting address index
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
use_ovs = self.session.options.get_config("ovs") == "True"
|
use_ovs = self.session.use_ovs()
|
||||||
address = self.prefix[index]
|
address = self.prefix[index]
|
||||||
current = f"{address}/{self.prefix.prefixlen}"
|
current = f"{address}/{self.prefix.prefixlen}"
|
||||||
net_client = get_net_client(use_ovs, utils.cmd)
|
net_client = get_net_client(use_ovs, utils.cmd)
|
||||||
|
|
|
@ -118,6 +118,9 @@ def get_merged_config(filename):
|
||||||
# parse command line options
|
# parse command line options
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# convert ovs to internal format
|
||||||
|
args.ovs = "1" if args.ovs else "0"
|
||||||
|
|
||||||
# read the config file
|
# read the config file
|
||||||
if args.configfile is not None:
|
if args.configfile is not None:
|
||||||
filename = args.configfile
|
filename = args.configfile
|
||||||
|
|
Loading…
Add table
Reference in a new issue