daemon: updates to expose node.create_cmd and not be private, added utility functions for running multiple commands on multiple nodes more efficiently

This commit is contained in:
Blake Harnden 2022-06-10 14:23:06 -07:00
parent 60a48c7084
commit 9c69881aad
5 changed files with 121 additions and 8 deletions

View file

@ -694,7 +694,7 @@ class CoreNode(CoreNodeBase):
finally:
self.rmnodedir()
def _create_cmd(self, args: str, shell: bool = False) -> str:
def create_cmd(self, args: str, shell: bool = False) -> str:
"""
Create command used to run commands within the context of a node.
@ -717,7 +717,7 @@ class CoreNode(CoreNodeBase):
:return: combined stdout and stderr
:raises CoreCommandError: when a non-zero exit status occurs
"""
args = self._create_cmd(args, shell)
args = self.create_cmd(args, shell)
if self.server is None:
return utils.cmd(args, wait=wait, shell=shell)
else:
@ -743,7 +743,7 @@ class CoreNode(CoreNodeBase):
:param sh: shell to execute command in
:return: str
"""
terminal = self._create_cmd(sh)
terminal = self.create_cmd(sh)
if self.server is None:
return terminal
else:

View file

@ -89,7 +89,7 @@ class DockerNode(CoreNode):
"""
return DockerOptions()
def _create_cmd(self, args: str, shell: bool = False) -> str:
def create_cmd(self, args: str, shell: bool = False) -> str:
"""
Create command used to run commands within the context of a node.

View file

@ -62,7 +62,7 @@ class LxcNode(CoreNode):
def create_options(cls) -> LxcOptions:
return LxcOptions()
def _create_cmd(self, args: str, shell: bool = False) -> str:
def create_cmd(self, args: str, shell: bool = False) -> str:
"""
Create command used to run commands within the context of a node.

View file

@ -249,7 +249,7 @@ class PhysicalNode(CoreNode):
iface.shutdown()
self.rmnodedir()
def _create_cmd(self, args: str, shell: bool = False) -> str:
def create_cmd(self, args: str, shell: bool = False) -> str:
if shell:
args = f'{BASH} -c "{args}"'
return args