Add server_name field

It doesn't do any harm and makes my [script](https://github.com/aleksasiriski/hcloud-rffmpeg) possible to work. I've set so that `rffmpeg add` always uses "manual" as the name but that could also be an option just like weight.
This commit is contained in:
Aleksa Siriški 2022-11-15 01:04:38 +01:00 committed by GitHub
parent 883d433368
commit eacf5f6f8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -240,7 +240,7 @@ def get_target_host(config):
# Generate a mapping dictionary of hosts and processes
host_mappings = dict()
for host in hosts:
hid, hostname, weight = host
hid, hostname, weight, server_name = host
# Get the latest state
with dbconn(config) as cur:
@ -536,7 +536,7 @@ def run_control(config):
try:
with dbconn(config) as cur:
cur.execute(
"""CREATE TABLE hosts (id INTEGER PRIMARY KEY, hostname TEXT NOT NULL, weight INTEGER DEFAULT 1)"""
"""CREATE TABLE hosts (id INTEGER PRIMARY KEY, hostname TEXT NOT NULL, weight INTEGER DEFAULT 1, server_name TEXT NOT NULL)"""
)
cur.execute(
"""CREATE TABLE processes (id INTEGER PRIMARY KEY, host_id INTEGER, process_id INTEGER, cmd TEXT)"""
@ -590,7 +590,7 @@ def run_control(config):
}
for host in hosts:
hid, hostname, weight = host
hid, hostname, weight, server_name = host
# Get the latest state
with dbconn(config) as cur:
@ -705,7 +705,8 @@ def run_control(config):
click.echo("Adding new host '{}'".format(host))
with dbconn(config) as cur:
cur.execute(
"""INSERT INTO hosts (hostname, weight) VALUES (?, ?)""", (host, weight)
"INSERT INTO hosts (hostname, weight, server_name) VALUES (?, ?, ?)",
(host, weight, "manual"),
)
rffmpeg_click.add_command(rffmpeg_click_add)