changes to update commands to leverage either node_net_cmd/net_cmd
This commit is contained in:
parent
bc58693339
commit
f6cdeb23de
13 changed files with 67 additions and 37 deletions
|
@ -630,29 +630,31 @@ class CoreNode(CoreNodeBase):
|
|||
"""
|
||||
return self.client.cmd_output(args)
|
||||
|
||||
def node_net_cmd(self, args):
|
||||
def node_net_cmd(self, args, wait=True):
|
||||
"""
|
||||
Runs a command that is used to configure and setup the network within a
|
||||
node.
|
||||
|
||||
:param list[str]|str args: command to run
|
||||
:param list[str] args: command to run
|
||||
:param bool wait: True to wait for status, False otherwise
|
||||
:return: combined stdout and stderr
|
||||
:rtype: str
|
||||
:raises CoreCommandError: when a non-zero exit status occurs
|
||||
"""
|
||||
if self.server is None:
|
||||
logging.info("node(%s) cmd: %s", self.name, args)
|
||||
return self.check_cmd(args)
|
||||
return self.client.check_cmd(args, wait=wait)
|
||||
else:
|
||||
args = self.client._cmd_args() + args
|
||||
args = " ".join(args)
|
||||
return distributed.remote_cmd(self.server, args)
|
||||
return distributed.remote_cmd(self.server, args, wait=wait)
|
||||
|
||||
def check_cmd(self, args):
|
||||
"""
|
||||
Runs shell command on node.
|
||||
|
||||
:param list[str]|str args: command to run
|
||||
:param bool wait: True to wait for status, False otherwise
|
||||
:return: combined stdout and stderr
|
||||
:rtype: str
|
||||
:raises CoreCommandError: when a non-zero exit status occurs
|
||||
|
|
|
@ -97,17 +97,18 @@ class VnodeClient(object):
|
|||
status = p.wait()
|
||||
return status, output.decode("utf-8").strip()
|
||||
|
||||
def check_cmd(self, args):
|
||||
def check_cmd(self, args, wait=True):
|
||||
"""
|
||||
Run command and return exit status and combined stdout and stderr.
|
||||
|
||||
:param list[str]|str args: command to run
|
||||
:param bool wait: True to wait for command status, False otherwise
|
||||
:return: combined stdout and stderr
|
||||
:rtype: str
|
||||
:raises core.CoreCommandError: when there is a non-zero exit status
|
||||
"""
|
||||
status, output = self.cmd_output(args)
|
||||
if status != 0:
|
||||
if wait and status != 0:
|
||||
raise CoreCommandError(status, args, output)
|
||||
return output.strip()
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ class PhysicalNode(CoreNodeBase):
|
|||
return output.strip()
|
||||
|
||||
def shcmd(self, cmdstr, sh="/bin/sh"):
|
||||
return self.cmd([sh, "-c", cmdstr])
|
||||
return self.node_net_cmd([sh, "-c", cmdstr])
|
||||
|
||||
def sethwaddr(self, ifindex, addr):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue