Skip to content

Commit 10154bc

Browse files
Nowi Buildfrancoleyes
authored andcommitted
[IMP] cetmix_tower_server: add SSH terminal
1 parent f1bbd4f commit 10154bc

File tree

14 files changed

+1358
-4
lines changed

14 files changed

+1358
-4
lines changed

cetmix_tower_server/__manifest__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"security/cx_tower_key_value_security.xml",
5454
"security/cx_tower_tag_security.xml",
5555
"security/cx_tower_shortcut_security.xml",
56+
"security/cx_tower_terminal_session_security.xml",
5657
"security/cx_tower_server_wizard_access_rules.xml",
5758
"data/ir_cron.xml",
5859
"data/ir_config_parameter.xml",
@@ -102,7 +103,11 @@
102103
],
103104
"assets": {
104105
"web.assets_backend": [
106+
"cetmix_tower_server/static/lib/xterm/xterm.css",
107+
"cetmix_tower_server/static/lib/xterm/xterm.js",
108+
"cetmix_tower_server/static/lib/xterm/addons/addon-fit.js",
105109
"cetmix_tower_server/static/src/components/**/*.xml",
110+
"cetmix_tower_server/static/src/terminal/**/*.xml",
106111
"cetmix_tower_server/static/src/**/*.js",
107112
"cetmix_tower_server/static/src/**/*.scss",
108113
],

cetmix_tower_server/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from . import cx_tower_file
1616
from . import cx_tower_file_template
1717
from . import cx_tower_server
18+
from . import cx_tower_terminal_session
1819
from . import cx_tower_os
1920
from . import cx_tower_tag
2021
from . import cx_tower_command

cetmix_tower_server/models/cx_tower_server.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,11 @@ def action_run_command(self):
523523
"context": context,
524524
}
525525

526+
def action_open_terminal(self):
527+
"""Open an interactive SSH terminal for the current server."""
528+
self.ensure_one()
529+
return self.env["cx.tower.terminal.session"].action_open_for_server(self.id)
530+
526531
def action_run_flight_plan(self):
527532
"""
528533
Returns wizard action to select flightplan and run it
@@ -659,11 +664,10 @@ def _get_ssh_client(self, raise_on_error=False, timeout=5000, skip_host_key=Fals
659664
SSH: SSH manager instance or False and exception content
660665
"""
661666
self.ensure_one()
662-
self = self.sudo()
663667
try:
668+
self = self.sudo()
664669
host_key = self._get_secret_value("host_key")
665670

666-
# Check host only if IP address is present
667671
skip_host_key = skip_host_key or self.skip_host_key
668672
if (
669673
not host_key
@@ -680,7 +684,7 @@ def _get_ssh_client(self, raise_on_error=False, timeout=5000, skip_host_key=Fals
680684
username=self.ssh_username,
681685
password=self._get_ssh_password(),
682686
ssh_key=self._get_ssh_key(),
683-
host_key=host_key if host_key and not self.skip_host_key else None,
687+
host_key=host_key if host_key and not skip_host_key else None,
684688
mode=self.ssh_auth_mode,
685689
timeout=timeout,
686690
)

0 commit comments

Comments
 (0)