mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-11-02 02:42:08 +00:00
fix: name the guest in VM/CT health alerts, refresh AI models, propose the recipe's volume choice
- A health problem of a VM or CT names the guest in its title and in the Quiet Hours summary; a recovery shows its category by name in the reader's language. - AI model lists reviewed against each provider: Gemini adds 3.6/3.7/3.8 Flash, Groq adds gpt-oss-120b, and Groq/OpenRouter models no longer served are removed. - OCI installer proposes the volume choice the recipe declares, so a path meant for a host directory is proposed as one; Duplicati /source is proposed on a host directory.
This commit is contained in:
@@ -2125,9 +2125,22 @@ def render_template(event_type: str, data: Dict[str, Any],
|
||||
or ''
|
||||
)
|
||||
_ent = str(_ent).strip()
|
||||
# A VM or CT health issue records the guest as id, vmname and type.
|
||||
if not _ent and str(variables.get('category', '')) == 'vms' and variables.get('id'):
|
||||
_ent = f"{variables.get('type') or 'VM/CT'} {variables['id']}"
|
||||
if variables.get('vmname'):
|
||||
_ent += f" ({variables['vmname']})"
|
||||
variables['entity'] = _ent
|
||||
variables['entity_suffix'] = f' — {_ent}' if _ent else ''
|
||||
|
||||
# Health categories reach the templates by their key ("vms"); show the
|
||||
# name the health summary uses for them, in the reader's language.
|
||||
_category = str(variables.get('category', '')).strip()
|
||||
if _category:
|
||||
_category_label = runtime_message(f'healthDegraded.categories.{_category}', language)
|
||||
if _category_label:
|
||||
variables['category'] = _category_label
|
||||
|
||||
# `title_or_default` lets a template surface a caller-computed title
|
||||
# when the caller already knows the entity context (e.g.
|
||||
# flask_server's health collector), and fall back to a stock string
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
"""A health problem of a VM or CT names the guest in its title, and health
|
||||
categories are shown by their name, not by their internal key."""
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
SCRIPTS_DIR = Path(__file__).resolve().parents[1]
|
||||
if str(SCRIPTS_DIR) not in sys.path:
|
||||
sys.path.insert(0, str(SCRIPTS_DIR))
|
||||
|
||||
import notification_templates as templates
|
||||
|
||||
QMP = {'category': 'vms', 'severity': 'WARNING', 'error_key': 'vm_101',
|
||||
'reason': 'VM 101 (web): QMP command failed or timed out.',
|
||||
'id': '101', 'vmname': 'web', 'type': 'VM'}
|
||||
|
||||
|
||||
class VmHealthTitleTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
patcher = mock.patch.object(templates, '_get_hostname', return_value='pve')
|
||||
patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
def test_a_guest_problem_names_the_guest(self):
|
||||
title = templates.render_template('system_problem', dict(QMP))['title']
|
||||
self.assertEqual(title, 'pve: System problem detected — VM 101 (web)')
|
||||
|
||||
def test_a_container_without_a_name_is_named_by_its_id(self):
|
||||
data = dict(QMP, id='105', vmname='', type='CT')
|
||||
self.assertTrue(templates.render_template('system_problem', data)['title'].endswith('— CT 105'))
|
||||
|
||||
def test_the_recovery_names_the_category_and_the_guest(self):
|
||||
data = dict(QMP, severity='OK', original_severity='WARNING', duration='6m', is_recovery=True)
|
||||
title = templates.render_template('error_resolved', data)['title']
|
||||
self.assertEqual(title, 'pve: Resolved - VMs and containers — VM 101 (web)')
|
||||
|
||||
def test_the_category_follows_the_language_of_the_reader(self):
|
||||
data = dict(QMP, severity='OK', original_severity='WARNING', duration='6m', is_recovery=True)
|
||||
title = templates.render_template('error_resolved', data, 'es')['title']
|
||||
self.assertIn('Máquinas virtuales y contenedores', title)
|
||||
self.assertNotIn(' vms', title)
|
||||
|
||||
def test_a_category_without_a_name_keeps_its_key(self):
|
||||
data = {'category': 'temperature', 'severity': 'OK', 'reason': 'Back to normal',
|
||||
'original_severity': 'WARNING', 'duration': '3m', 'is_recovery': True}
|
||||
self.assertIn('Resolved - temperature', templates.render_template('error_resolved', data)['title'])
|
||||
|
||||
def test_other_events_with_an_id_are_not_given_a_guest(self):
|
||||
data = {'category': 'storage', 'severity': 'WARNING', 'reason': 'x', 'id': '7', 'type': 'VM'}
|
||||
self.assertNotIn('VM 7', templates.render_template('system_problem', data)['title'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user