diff --git a/maintenance_server_ssh/.gitignore b/maintenance_server_ssh/.gitignore new file mode 100644 index 0000000..6da5887 --- /dev/null +++ b/maintenance_server_ssh/.gitignore @@ -0,0 +1,2 @@ +*.*~ +*pyc diff --git a/maintenance_server_ssh/README.rst b/maintenance_server_ssh/README.rst new file mode 100644 index 0000000..4b923f4 --- /dev/null +++ b/maintenance_server_ssh/README.rst @@ -0,0 +1,44 @@ +====================================== +maintenance_server_ssh +====================================== + +Create an SSH remote connection for maintenance equipment, usable for other modules + +Installation +============ + +Use Odoo normal module installation procedure to install +``maintenance_server_ssh``. + +Known issues / Roadmap +====================== + +None yet. + +Bug Tracker +=========== + +Bugs are tracked on `our issues website `_. In case of +trouble, please check there if your issue has already been +reported. If you spotted it first, help us smashing it by providing a +detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Clément Thomas + +Funders +------- + +The development of this module has been financially supported by: +* Elabore (https://elabore.coop) + + +Maintainer +---------- + +This module is maintained by Elabore. diff --git a/maintenance_server_ssh/__init__.py b/maintenance_server_ssh/__init__.py new file mode 100644 index 0000000..cde864b --- /dev/null +++ b/maintenance_server_ssh/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/maintenance_server_ssh/__manifest__.py b/maintenance_server_ssh/__manifest__.py new file mode 100644 index 0000000..1bbd251 --- /dev/null +++ b/maintenance_server_ssh/__manifest__.py @@ -0,0 +1,37 @@ +# Copyright 2023 Stéphan Sainléger (Elabore) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "maintenance_server_ssh", + "version": "14.0.1.0.0", + "author": "Elabore", + "website": "https://elabore.coop", + "maintainer": "Clément Thomas", + "license": "AGPL-3", + "category": "Tools", + "summary": "Monitor some data on remote hosts", + # any module necessary for this one to work correctly + "depends": [ + "base", + "maintenance", + ], + "qweb": [ + # "static/src/xml/*.xml", + ], + "external_dependencies": { + "python": [], + }, + # always loaded + "data": [ + "views/maintenance_equipment_views.xml", + ], + # only loaded in demonstration mode + "demo": [], + "js": [], + "css": [], + "installable": True, + # Install this module automatically if all dependency have been previously + # and independently installed. Used for synergetic or glue modules. + "auto_install": False, + "application": False, +} \ No newline at end of file diff --git a/maintenance_server_ssh/models/__init__.py b/maintenance_server_ssh/models/__init__.py new file mode 100644 index 0000000..b31f6b6 --- /dev/null +++ b/maintenance_server_ssh/models/__init__.py @@ -0,0 +1 @@ +from . import maintenance_equipment \ No newline at end of file diff --git a/maintenance_server_ssh/models/maintenance_equipment.py b/maintenance_server_ssh/models/maintenance_equipment.py new file mode 100644 index 0000000..b661642 --- /dev/null +++ b/maintenance_server_ssh/models/maintenance_equipment.py @@ -0,0 +1,20 @@ +from odoo import fields, models +import subprocess +import sys +import psutil + + +class MaintenanceEquipment(models.Model): + _inherit = 'maintenance.equipment' + + server_domain = fields.Char('Server Domain') + ssh_private_key_path = fields.Char("SSH private key path", default="/opt/odoo/auto/dev/ssh_keys/id_rsa") + + def get_ssh_connection(self): + import paramiko + ssh = paramiko.SSHClient() + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + ssh.connect(self.server_domain, username="root", key_filename=self.ssh_private_key_path) + return ssh + + \ No newline at end of file diff --git a/maintenance_server_ssh/views/maintenance_equipment_views.xml b/maintenance_server_ssh/views/maintenance_equipment_views.xml new file mode 100644 index 0000000..a5f1018 --- /dev/null +++ b/maintenance_server_ssh/views/maintenance_equipment_views.xml @@ -0,0 +1,30 @@ + + + + equipment.form.server.inherit + maintenance.equipment + + + + + + + + + + + + + + + equipment.tree.server.inherit + maintenance.equipment + + + + + + + + + \ No newline at end of file