feat(syslog): list patterns and add a ready-made one through MCP
Patterns could only be added on the Syslog page, so an agent asked to map them on the NASes couldn't. list_syslog_patterns gives each pattern's metric and the ready-made ones not added; add_syslog_preset (admin, audited) adds one. The key-picking helper moves beside the patterns for both callers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -87,6 +87,16 @@ def key_for(name: str) -> str:
|
||||
return _KEY.sub("_", name.lower()).strip("_")[:48] or "pattern"
|
||||
|
||||
|
||||
async def free_key(db, wanted: str) -> str:
|
||||
"""`wanted`, or that with a number where another pattern has it."""
|
||||
taken = set((await db.execute(select(SyslogPattern.key))).scalars())
|
||||
key, n = wanted, 2
|
||||
while key in taken:
|
||||
key = f"{wanted[:44]}_{n}"
|
||||
n += 1
|
||||
return key
|
||||
|
||||
|
||||
def parse_form(form) -> dict:
|
||||
"""A pattern's fields from its form, or PatternError saying what to fix."""
|
||||
name = (form.get("name") or "").strip()[:100]
|
||||
|
||||
Reference in New Issue
Block a user