Skip to content

Commit 197d621

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

File tree

11 files changed

+1639
-14
lines changed

11 files changed

+1639
-14
lines changed

cetmix_tower_server/__manifest__.py

Lines changed: 2 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",
@@ -103,6 +104,7 @@
103104
"assets": {
104105
"web.assets_backend": [
105106
"cetmix_tower_server/static/src/components/**/*.xml",
107+
"cetmix_tower_server/static/src/terminal/**/*.xml",
106108
"cetmix_tower_server/static/src/**/*.js",
107109
"cetmix_tower_server/static/src/**/*.scss",
108110
],

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: 17 additions & 13 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,29 +664,28 @@ 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:
664-
host_key = self._get_secret_value("host_key")
668+
server = self.sudo()
669+
host_key = server._get_secret_value("host_key")
665670

666-
# Check host only if IP address is present
667-
skip_host_key = skip_host_key or self.skip_host_key
671+
skip_host_key = skip_host_key or server.skip_host_key
668672
if (
669673
not host_key
670674
and not skip_host_key
671-
and (self.ip_v4_address or self.ip_v6_address)
675+
and (server.ip_v4_address or server.ip_v6_address)
672676
):
673677
raise ValidationError(
674-
_("Host key not found for server %(server)s", server=self.name)
678+
_("Host key not found for server %(server)s", server=server.name)
675679
)
676680

677681
connection = SSHConnection(
678-
host=self.ip_v4_address or self.ip_v6_address,
679-
port=self.ssh_port,
680-
username=self.ssh_username,
681-
password=self._get_ssh_password(),
682-
ssh_key=self._get_ssh_key(),
683-
host_key=host_key if host_key and not self.skip_host_key else None,
684-
mode=self.ssh_auth_mode,
682+
host=server.ip_v4_address or server.ip_v6_address,
683+
port=server.ssh_port,
684+
username=server.ssh_username,
685+
password=server._get_ssh_password(),
686+
ssh_key=server._get_ssh_key(),
687+
host_key=host_key if host_key and not skip_host_key else None,
688+
mode=server.ssh_auth_mode,
685689
timeout=timeout,
686690
)
687691
client = SSHManager(connection)

0 commit comments

Comments
 (0)