added net_cmd to NodeBase for encapsulating network configuration commands

This commit is contained in:
bharnden 2019-10-01 21:06:11 -07:00
parent 4079df9739
commit 0fe8bea25b
3 changed files with 24 additions and 10 deletions

View file

@ -62,9 +62,9 @@ class NodeBase(object):
self.position = Position()
if session.options.get_config("ovs") == "True":
self.net_client = OvsNetClient(utils.check_cmd)
self.net_client = OvsNetClient(self.net_cmd)
else:
self.net_client = LinuxNetClient(utils.check_cmd)
self.net_client = LinuxNetClient(self.net_cmd)
def startup(self):
"""
@ -82,6 +82,18 @@ class NodeBase(object):
"""
raise NotImplementedError
def net_cmd(self, args):
"""
Runs a command that is used to configure and setup the network on the host
system.
:param list[str]|str args: command to run
:return: combined stdout and stderr
:rtype: str
:raises CoreCommandError: when a non-zero exit status occurs
"""
utils.check_cmd(args)
def setposition(self, x=None, y=None, z=None):
"""
Set the (x,y,z) position of the object.
@ -364,9 +376,10 @@ class CoreNodeBase(NodeBase):
return common
def network_cmd(self, args):
def node_net_cmd(self, args):
"""
Runs a command for a node that is used to configure and setup network interfaces.
Runs a command that is used to configure and setup the network within a
node.
:param list[str]|str args: command to run
:return: combined stdout and stderr
@ -451,9 +464,9 @@ class CoreNode(CoreNodeBase):
self.bootsh = bootsh
if session.options.get_config("ovs") == "True":
self.node_net_client = OvsNetClient(self.network_cmd)
self.node_net_client = OvsNetClient(self.node_net_cmd)
else:
self.node_net_client = LinuxNetClient(self.network_cmd)
self.node_net_client = LinuxNetClient(self.node_net_cmd)
if start:
self.startup()
@ -589,9 +602,10 @@ class CoreNode(CoreNodeBase):
"""
return self.client.cmd_output(args)
def network_cmd(self, args):
def node_net_cmd(self, args):
"""
Runs a command for a node that is used to configure and setup network interfaces.
Runs a command that is used to configure and setup the network within a
node.
:param list[str]|str args: command to run
:return: combined stdout and stderr

View file

@ -190,7 +190,7 @@ class DockerNode(CoreNode):
raise CoreCommandError(status, args, output)
return output
def network_cmd(self, args):
def node_net_cmd(self, args):
if not self.up:
logging.debug("node down, not running network command: %s", args)
return 0

View file

@ -193,7 +193,7 @@ class LxcNode(CoreNode):
raise CoreCommandError(status, args, output)
return output
def network_cmd(self, args):
def node_net_cmd(self, args):
if not self.up:
logging.debug("node down, not running network command: %s", args)
return 0