feat: agent updates from SAC, poll config, SSH/WinRM fallback (0.12.0)
Add agent update settings, pending self-update via poll, desired config per host, and automatic or manual SSH/WinRM fallback when agents do not report agent.update events.
This commit is contained in:
@@ -7,11 +7,10 @@ from sqlalchemy.orm import Session
|
||||
from app.auth.api_key import get_api_key_auth
|
||||
from app.database import get_db
|
||||
from app.services.agent_commands import (
|
||||
command_to_dict,
|
||||
complete_command,
|
||||
get_command_for_host_poll,
|
||||
resolve_host_by_agent_instance_id,
|
||||
)
|
||||
from app.services.agent_poll import build_agent_poll_payload
|
||||
|
||||
router = APIRouter(prefix="/agent", tags=["agent"])
|
||||
|
||||
@@ -23,7 +22,10 @@ class AgentCommandResultBody(BaseModel):
|
||||
|
||||
|
||||
class AgentCommandsPollResponse(BaseModel):
|
||||
commands: list[dict[str, Any]]
|
||||
config_revision: int = 0
|
||||
config: dict[str, Any] = Field(default_factory=dict)
|
||||
update: dict[str, Any] = Field(default_factory=dict)
|
||||
commands: list[dict[str, Any]] = Field(default_factory=list)
|
||||
|
||||
|
||||
@router.get("/commands", response_model=AgentCommandsPollResponse)
|
||||
@@ -35,10 +37,8 @@ def poll_agent_commands(
|
||||
host = resolve_host_by_agent_instance_id(db, agent_instance_id)
|
||||
if host is None:
|
||||
raise HTTPException(status_code=404, detail="Unknown agent_instance_id")
|
||||
pending = get_command_for_host_poll(db, host)
|
||||
return AgentCommandsPollResponse(
|
||||
commands=[command_to_dict(c, include_run_as=True) for c in pending]
|
||||
)
|
||||
payload = build_agent_poll_payload(db, host)
|
||||
return AgentCommandsPollResponse(**payload)
|
||||
|
||||
|
||||
@router.post("/commands/{command_uuid}/result")
|
||||
|
||||
Reference in New Issue
Block a user