mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 05:58:25 +00:00
droplets: Garbage collect A records before creating droplet.
This commit is contained in:
@@ -156,9 +156,19 @@ def create_droplet(my_token, template_id, username, tags, user_data):
|
|||||||
|
|
||||||
def create_dns_record(my_token, username, ip_address):
|
def create_dns_record(my_token, username, ip_address):
|
||||||
# type: (str, str, str) -> None
|
# type: (str, str, str) -> None
|
||||||
print("Creating A record for {0}.zulipdev.org that points to {1}.".format(username, ip_address))
|
|
||||||
domain = digitalocean.Domain(token=my_token, name='zulipdev.org')
|
domain = digitalocean.Domain(token=my_token, name='zulipdev.org')
|
||||||
domain.load()
|
domain.load()
|
||||||
|
records = domain.get_records()
|
||||||
|
|
||||||
|
count = 0
|
||||||
|
for record in records:
|
||||||
|
if record.name == username and record.domain == 'zulipdev.org' and record.type == 'A':
|
||||||
|
record.destroy()
|
||||||
|
count = count + 1
|
||||||
|
if count:
|
||||||
|
print("Deleted {0} existing A records for {1}.zulipdev.org.".format(count, username))
|
||||||
|
|
||||||
|
print("Creating new A record for {0}.zulipdev.org that points to {1}.".format(username, ip_address))
|
||||||
domain.create_new_domain_record(type='A', name=username, data=ip_address)
|
domain.create_new_domain_record(type='A', name=username, data=ip_address)
|
||||||
|
|
||||||
def print_completion(username):
|
def print_completion(username):
|
||||||
|
|||||||
Reference in New Issue
Block a user