[NEW] maintenance_server_ssh
This commit is contained in:
2
maintenance_server_ssh/.gitignore
vendored
Normal file
2
maintenance_server_ssh/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.*~
|
||||||
|
*pyc
|
44
maintenance_server_ssh/README.rst
Normal file
44
maintenance_server_ssh/README.rst
Normal file
@@ -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 <https://github.com/elabore-coop/maintenance-tools/issues>`_. 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.
|
3
maintenance_server_ssh/__init__.py
Normal file
3
maintenance_server_ssh/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from . import models
|
37
maintenance_server_ssh/__manifest__.py
Normal file
37
maintenance_server_ssh/__manifest__.py
Normal file
@@ -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,
|
||||||
|
}
|
1
maintenance_server_ssh/models/__init__.py
Normal file
1
maintenance_server_ssh/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import maintenance_equipment
|
20
maintenance_server_ssh/models/maintenance_equipment.py
Normal file
20
maintenance_server_ssh/models/maintenance_equipment.py
Normal file
@@ -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
|
||||||
|
|
||||||
|
|
30
maintenance_server_ssh/views/maintenance_equipment_views.xml
Normal file
30
maintenance_server_ssh/views/maintenance_equipment_views.xml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="equipment_view_form_server_inherit" model="ir.ui.view">
|
||||||
|
<field name="name">equipment.form.server.inherit</field>
|
||||||
|
<field name="model">maintenance.equipment</field>
|
||||||
|
<field name="inherit_id" ref="maintenance.hr_equipment_view_form" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//notebook" position="inside">
|
||||||
|
<page name="ssh" string="SSH">
|
||||||
|
<group name="ssh_connection" string="SSH Connection">
|
||||||
|
<field name="server_domain" />
|
||||||
|
<field name="ssh_private_key_path" />
|
||||||
|
</group>
|
||||||
|
</page>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="equipment_view_tree_server_inherit" model="ir.ui.view">
|
||||||
|
<field name="name">equipment.tree.server.inherit</field>
|
||||||
|
<field name="model">maintenance.equipment</field>
|
||||||
|
<field name="inherit_id" ref="maintenance.hr_equipment_view_tree" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='category_id']" position="after">
|
||||||
|
<field name="server_domain" optional="hide" />
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
Reference in New Issue
Block a user