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:
parent
60a48c7084
commit
9c69881aad
5 changed files with 121 additions and 8 deletions
|
@ -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:
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue