# RDS-Manager

Zentrales Windows Remote Desktop Services Management für IKK Kliniken. Citrix-Alternative basierend auf Windows RDS mit IGEL Thin Clients.

## Features

- **RDS-Host Dashboard** — 40+ Session Hosts mit Live-CPU/RAM/Sessions
- **Session Collections** — Logische Gruppierung (Verwaltung, Klinik, Arzt, RemoteApp)
- **Session-Management** — Disconnect, Logoff, Migration zwischen Hosts
- **Drucker-Mappings** — Automatische Druckerzuordnung per Client-IP-Range
- **Software-Tracking** — Installierte Pakete im Golden Image (GOLDEN_IMAGE, MSIX, SCCM)
- **Farm-Updates** — Drain → Migrate → Reboot → Activate mit Batch-Verarbeitung
- **Netzwerk-Discovery** — Automatisches Finden von RDS-Hosts im Netzwerk
- **PowerShell Agent** — Dezentraler Agent auf dem RD Connection Broker
- **SSE Live-Updates** — Echtzeit-Aktualisierung im Browser

## Voraussetzungen

- Python 3.10+
- Windows Server 2022 mit RDS-Rolle (für Agent)
- IGEL Thin Clients (empfohlen)

## Installation

### Windows (Einzeiler)

```powershell
irm https://downloads.c3po42.de/rds-manager/install.ps1 | iex
```

### Linux / Server

```bash
curl -fsSL https://downloads.c3po42.de/rds-manager/install.sh | bash
```

### Manuell

```bash
pip install -r requirements.txt
python main.py
```

Öffnet automatisch http://localhost:8990

## Login

| Benutzer | Passwort | Rolle |
|----------|----------|-------|
| admin | admin | ADMIN |
| operator | op | OPERATOR |

## API-Endpunkte

| Methode | Pfad | Beschreibung |
|---------|------|-------------|
| POST | /api/auth/login | JWT-Login |
| GET | /api/dashboard | Gesamtübersicht |
| GET | /api/hosts | RDS-Hosts (Filter: Collection, Standort) |
| GET | /api/hosts/{id} | Host-Details |
| POST | /api/hosts/{id}/drain | Wartungsmodus an |
| POST | /api/hosts/{id}/activate | Wartungsmodus aus |
| POST | /api/hosts/{id}/reboot | Host neustarten |
| POST | /api/hosts/{id}/migrate-sessions | Sessions migrieren |
| GET | /api/sessions | Alle Sessions |
| POST | /api/sessions/{id}/disconnect | Session trennen |
| POST | /api/sessions/{id}/logoff | Session abmelden |
| GET | /api/collections | Session Collections |
| GET | /api/drucker | Drucker-Mappings |
| GET | /api/drucker/auto-zuordnung?client_ip=x | Auto-Zuordnung |
| GET | /api/software | Software-Pakete |
| GET | /api/farm-updates | Farm-Updates |
| POST | /api/farm-updates | Neues Farm-Update |
| POST | /api/farm-updates/{id}/start | Update starten |
| POST | /api/discover | Netzwerk-Scan |
| GET | /api/aktivitaeten | Audit-Log |
| GET | /api/events | SSE Live-Stream |
| POST | /api/agent/report | Agent-Report |

## Agent

Der PowerShell-Agent (`agent.ps1`) läuft auf dem RD Connection Broker und meldet alle 5 Minuten:
- RDS-Host-Status (CPU, RAM, Sessions, Wartungsmodus)
- Aktive Sessions (Benutzer, Client, Anwendungen)

```powershell
# Agent installieren (als Scheduled Task)
.\agent.ps1 -Install

# Manuelle Aktionen
.\agent.ps1 -Drain RDS-SRV01
.\agent.ps1 -Activate RDS-SRV01
.\agent.ps1 -Reboot RDS-SRV01
.\agent.ps1 -Disconnect 1234
.\agent.ps1 -Logoff 1234
```

## Architektur

```
IGEL Thin Client → RDP → RD Connection Broker → RDS Session Host
                                                       ↑
PowerShell Agent (agent.ps1) ───── POST /api/agent/report ─────→ RDS-Manager Dashboard
                                                                      ↑
                                                              Browser (HTTPS)
```

## Technologie

- **Backend:** FastAPI + SQLite (aiosqlite)
- **Frontend:** Vanilla JS + CSS (Dark Cyan Theme)
- **Auth:** JWT + bcrypt
- **Agent:** PowerShell 5.1+ (RDS-Cmdlets + WMI)
- **Live-Updates:** Server-Sent Events (SSE)
