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:
Blake Harnden 2020-06-25 22:05:10 -07:00
parent b94d4d3507
commit f4224d1b80
7 changed files with 20 additions and 8 deletions

View file

@ -80,7 +80,7 @@ class CoreEmu:
:raises core.errors.CoreError: when an executable does not exist on path
"""
requirements = COMMON_REQUIREMENTS
use_ovs = self.config.get("ovs") == "True"
use_ovs = self.config.get("ovs") == "1"
if use_ovs:
requirements += OVS_REQUIREMENTS
else:

View file

@ -217,6 +217,9 @@ class Session:
else:
common_network.unlink(iface1, iface2)
def use_ovs(self) -> bool:
return self.options.get_config("ovs") == "1"
def add_link(
self,
node1_id: int,

View file

@ -56,6 +56,9 @@ class SessionConfig(ConfigurableManager, ConfigurableOptions):
default=Sdt.DEFAULT_SDT_URL,
label="SDT3D URL",
),
Configuration(
_id="ovs", _type=ConfigDataTypes.BOOL, default="0", label="Enable OVS"
),
]
config_type: RegisterTlvs = RegisterTlvs.UTILITY

View file

@ -73,8 +73,9 @@ class NodeBase(abc.ABC):
self.icon: Optional[str] = None
self.position: Position = Position()
self.up: bool = False
use_ovs = session.options.get_config("ovs") == "True"
self.net_client: LinuxNetClient = get_net_client(use_ovs, self.host_cmd)
self.net_client: LinuxNetClient = get_net_client(
self.session.use_ovs(), self.host_cmd
)
@abc.abstractmethod
def startup(self) -> None:
@ -471,8 +472,9 @@ class CoreNode(CoreNodeBase):
self.pid: Optional[int] = None
self.lock: RLock = RLock()
self._mounts: List[Tuple[str, str]] = []
use_ovs = session.options.get_config("ovs") == "True"
self.node_net_client: LinuxNetClient = self.create_node_net_client(use_ovs)
self.node_net_client: LinuxNetClient = self.create_node_net_client(
self.session.use_ovs()
)
def create_node_net_client(self, use_ovs: bool) -> LinuxNetClient:
"""

View file

@ -68,8 +68,9 @@ class CoreInterface:
# id used to find flow data
self.flow_id: Optional[int] = None
self.server: Optional["DistributedServer"] = server
use_ovs = session.options.get_config("ovs") == "True"
self.net_client: LinuxNetClient = get_net_client(use_ovs, self.host_cmd)
self.net_client: LinuxNetClient = get_net_client(
self.session.use_ovs(), self.host_cmd
)
def host_cmd(
self,

View file

@ -756,7 +756,7 @@ class CtrlNet(CoreNetwork):
:param index: starting address index
:return: nothing
"""
use_ovs = self.session.options.get_config("ovs") == "True"
use_ovs = self.session.use_ovs()
address = self.prefix[index]
current = f"{address}/{self.prefix.prefixlen}"
net_client = get_net_client(use_ovs, utils.cmd)

View file

@ -118,6 +118,9 @@ def get_merged_config(filename):
# parse command line options
args = parser.parse_args()
# convert ovs to internal format
args.ovs = "1" if args.ovs else "0"
# read the config file
if args.configfile is not None:
filename = args.configfile