💥 add all the files
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
|||||||
|
FROM python:3
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
COPY requirements.txt ./
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
CMD [ "python", "./Update_dynhost.py" ]
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: dyndns-python
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: CronJob
|
||||||
|
spec:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchFields:
|
||||||
|
- key: metadata.name
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- kube-master
|
||||||
|
metadata:
|
||||||
|
name: dyndns-pythonrenew
|
||||||
|
namespace: dyndns-python
|
||||||
|
spec:
|
||||||
|
schedule: "0 * * * *"
|
||||||
|
jobTemplate:
|
||||||
|
spec:
|
||||||
|
ttlSecondsAfterFinished: 100
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
# nodeName: kube-master
|
||||||
|
containers:
|
||||||
|
- name: dyndns-python
|
||||||
|
# image: dyndns_python:latest
|
||||||
|
image: localhost:31795/dyndns_python
|
||||||
|
restartPolicy: Never
|
||||||
|
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
'''
|
||||||
|
First, install the latest release of Python wrapper: $ pip install ovh
|
||||||
|
'''
|
||||||
|
import json
|
||||||
|
import ovh
|
||||||
|
import requests
|
||||||
|
import credentials as credential_perso
|
||||||
|
|
||||||
|
|
||||||
|
# Instanciate an OVH Client.
|
||||||
|
# You can generate new credentials with full access to your account on
|
||||||
|
# the token creation page
|
||||||
|
client = ovh.Client(
|
||||||
|
|
||||||
|
endpoint=credential_perso.endpoint,
|
||||||
|
application_key=credential_perso.application_key,
|
||||||
|
application_secret=credential_perso.application_secret,
|
||||||
|
consumer_key=credential_perso.consumer_key,
|
||||||
|
)
|
||||||
|
|
||||||
|
new_subdomain = credential_perso.my_subdomain
|
||||||
|
new_domain = credential_perso.my_zone
|
||||||
|
|
||||||
|
def Domain_id():
|
||||||
|
domain_id = client.get('/domain/zone/'+new_domain+'/dynHost/record', subDomain=new_subdomain)
|
||||||
|
return domain_id
|
||||||
|
|
||||||
|
def update_zone(subdomain,new_ip,domain_id):
|
||||||
|
result = client.put('/domain/zone/'+new_domain+'/dynHost/record/'+domain_id,
|
||||||
|
ip=new_ip,
|
||||||
|
subDomain=subdomain)
|
||||||
|
refresh_dns()
|
||||||
|
return result
|
||||||
|
|
||||||
|
def refresh_dns():
|
||||||
|
result_refresh = client.post('/domain/zone/'+new_domain+'/refresh')
|
||||||
|
return result_refresh
|
||||||
|
|
||||||
|
def MyIP():
|
||||||
|
response = requests.get('https://ifconfig.me/ip')
|
||||||
|
return response.text
|
||||||
|
|
||||||
|
result_update = update_zone(new_subdomain,MyIP(),str(Domain_id()[0]))
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
endpoint = 'ovh-eu'
|
||||||
|
application_key = 'HmqcHin8SVEgAyQU'
|
||||||
|
application_secret = 'jxCrdTVgftimcf4T4GnJWXvehjqQwfdz'
|
||||||
|
consumer_key = 'VH0vWJx5oDqg8FnXNHSNKUDlsie0pQ9c'
|
||||||
|
my_zone = 'geeraert.eu'
|
||||||
|
my_subdomain = 'tryton'
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
ovh
|
||||||
|
requests
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user