Add complete NexaFabric project structure including: - FastAPI backend with SQLAlchemy models, JWT auth, RBAC, audit logging, and provider interfaces - React + TypeScript frontend with Vite, Tailwind CSS, TanStack Query, and Zustand - Docker Compose configuration for PostgreSQL, Redis, API, worker, frontend, and nginx - GitHub Actions and GitLab CI workflows for testing, linting, building, and security scanning - Environment
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
from app.models.domain import Cluster, Policy
|
|
from app.schemas.domain import FirewallPreview
|
|
from app.services.policy_engine import PolicyEngine
|
|
from app.services.providers.base import ProviderConnection
|
|
from app.services.providers.registry import get_provider
|
|
|
|
|
|
class FirewallOrchestrator:
|
|
def __init__(self) -> None:
|
|
self.policy_engine = PolicyEngine()
|
|
|
|
async def preview(self, cluster: Cluster, policy: Policy) -> FirewallPreview:
|
|
compiled = self.policy_engine.compile(policy)
|
|
provider = get_provider(cluster.provider)
|
|
connection = ProviderConnection(
|
|
api_url=cluster.api_url,
|
|
token=cluster.token_ref or "",
|
|
verify_tls=cluster.verify_tls,
|
|
read_only=cluster.mode == "read_only",
|
|
)
|
|
provider_preview = await provider.preview_rules(connection, compiled["rules"])
|
|
return FirewallPreview(
|
|
policy_id=policy.id,
|
|
dry_run=True,
|
|
generated_rules=provider_preview["generated"],
|
|
warnings=[*compiled["warnings"], *provider_preview.get("warnings", [])],
|
|
conflicts=compiled["conflicts"],
|
|
)
|
|
|