add move step support and fix some steps names
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
6ae2d4ded1
commit
e692c4df18
@ -344,3 +344,27 @@ class LinuxMachine:
|
|||||||
def disable_service(self, service: str):
|
def disable_service(self, service: str):
|
||||||
self.run_command(machine_utils.get_services_command(self.get_os_name(), "disable", service),
|
self.run_command(machine_utils.get_services_command(self.get_os_name(), "disable", service),
|
||||||
return_status_code=True)
|
return_status_code=True)
|
||||||
|
|
||||||
|
def move(self, source, destination, permission: int = None, owner: str = "root"):
|
||||||
|
self.run_command(f"mv {source} {destination}", return_status_code=True)
|
||||||
|
|
||||||
|
if permission is not None:
|
||||||
|
if "LXC" in str(self.__class__):
|
||||||
|
if self.pve.connection.sftp().is_remote_dir(source):
|
||||||
|
permission = 755
|
||||||
|
self.run_command(f"chmod -R {permission} {destination}", return_status_code=True)
|
||||||
|
else:
|
||||||
|
permission = 644
|
||||||
|
self.run_command(f"chmod {permission} {destination}", return_status_code=True)
|
||||||
|
else:
|
||||||
|
raise NotImplementedError("Permission setting is only supported for LXC machines")
|
||||||
|
|
||||||
|
if owner != "root":
|
||||||
|
if "LXC" in str(self.__class__):
|
||||||
|
if self.pve.connection.sftp().is_remote_dir(source):
|
||||||
|
self.run_command(f"chown -R {owner} {destination}", return_status_code=True)
|
||||||
|
else:
|
||||||
|
self.run_command(f"chown {owner} {destination}", return_status_code=True)
|
||||||
|
else:
|
||||||
|
raise NotImplementedError("Owner setting is only supported for LXC machines")
|
||||||
|
|
||||||
|
@ -47,6 +47,10 @@ def _run_folder_copy_step(linux_machine, step):
|
|||||||
logging.warning(f"Folder copy step only supported on LXCs")
|
logging.warning(f"Folder copy step only supported on LXCs")
|
||||||
|
|
||||||
|
|
||||||
|
def _run_move_step(linux_machine, step):
|
||||||
|
linux_machine.move(step["source"], step["destination"], step.get("permission", None), step.get("owner", "root"))
|
||||||
|
|
||||||
|
|
||||||
def _run_command_step(linux_machine, step):
|
def _run_command_step(linux_machine, step):
|
||||||
linux_machine.run_command(command=step["command"], working_directory=step.get("workdir"),
|
linux_machine.run_command(command=step["command"], working_directory=step.get("workdir"),
|
||||||
return_status_code=True)
|
return_status_code=True)
|
||||||
@ -148,6 +152,8 @@ def run_steps(linux_machine: LinuxMachine, steps: dict):
|
|||||||
_run_folder_create_step(linux_machine, step)
|
_run_folder_create_step(linux_machine, step)
|
||||||
case "folder_copy":
|
case "folder_copy":
|
||||||
_run_folder_copy_step(linux_machine, step)
|
_run_folder_copy_step(linux_machine, step)
|
||||||
|
case "move":
|
||||||
|
_run_move_step(linux_machine, step)
|
||||||
case "command":
|
case "command":
|
||||||
_run_command_step(linux_machine, step)
|
_run_command_step(linux_machine, step)
|
||||||
case "docker":
|
case "docker":
|
||||||
@ -186,3 +192,5 @@ def run_steps(linux_machine: LinuxMachine, steps: dict):
|
|||||||
_run_unzip_step(linux_machine, step)
|
_run_unzip_step(linux_machine, step)
|
||||||
case "wait":
|
case "wait":
|
||||||
_run_wait_step(step)
|
_run_wait_step(step)
|
||||||
|
case _:
|
||||||
|
logging.warning(f"Unknown step type {step['type']}")
|
||||||
|
Loading…
Reference in New Issue
Block a user