40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
import requests
|
|
import json
|
|
import boto3
|
|
import time
|
|
|
|
HOSTED_ZONE="Z00156242SK162FEXDPVF"
|
|
CLUSTER_ID="29062"
|
|
POOL_ID="49934"
|
|
TOKEN={"Authorization": "Bearer a821bb97039cbd8b259e19ef9f7ea7a4e295a7399e00709fc27cad2b1f3742f4"}
|
|
|
|
print("COTURN DNS NODE REGISTER STARTED")
|
|
|
|
while(True):
|
|
r = requests.get("https://api.linode.com/v4/lke/clusters/"+CLUSTER_ID+"/pools/"+POOL_ID, headers=TOKEN)
|
|
|
|
ips=[]
|
|
|
|
for node in r.json()['nodes']:
|
|
ip = requests.get("https://api.linode.com/v4/linode/instances/"+str(node['instance_id'])+"/ips", headers=TOKEN)
|
|
#print(ip.json())
|
|
ips.append({'Value': ip.json()['ipv4']['public'][0]['address']})
|
|
|
|
print("Node IPs: "+str(ips))
|
|
client = boto3.client('route53')
|
|
response = client.change_resource_record_sets(
|
|
HostedZoneId=HOSTED_ZONE,
|
|
ChangeBatch= {
|
|
'Comment': 'COTURN NODES',
|
|
'Changes': [
|
|
{
|
|
'Action': 'UPSERT',
|
|
'ResourceRecordSet': {
|
|
'Name': 'coturn.staging.video.jamkazam.com',
|
|
'Type': 'A',
|
|
'TTL': 300,
|
|
'ResourceRecords': ips
|
|
}
|
|
}]
|
|
})
|
|
time.sleep(60) |