initial commit: dynamic infra tooling cli

This commit is contained in:
Fredrick Amnehagen 2026-02-05 11:29:34 +01:00
commit db843ceec8
9 changed files with 339 additions and 0 deletions

27
infra_cli/ingress.py Normal file
View file

@ -0,0 +1,27 @@
from .ssh import SSHClient
class IngressManager:
def __init__(self, config):
self.host = config.get('haproxy.host')
self.user = config.get('haproxy.user', 'root')
self.ssh_key = config.get('haproxy.ssh_key')
self.client = SSHClient(self.host, self.user, self.ssh_key)
def add(self, domain, ip, port, https=False):
cmd = f"ingress-manager add {domain} {ip} {port}"
if https:
cmd += " --https"
res = self.client.run(cmd)
if res.returncode != 0:
raise RuntimeError(f"Failed to add ingress: {res.stderr}")
return res.stdout
def remove(self, domain):
res = self.client.run(f"ingress-manager remove {domain}")
if res.returncode != 0:
raise RuntimeError(f"Failed to remove ingress: {res.stderr}")
return res.stdout
def list(self):
res = self.client.run("ingress-manager list")
return res.stdout