2019-05-12 08:27:07 +00:00
|
|
|
import requests
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
class ungleichDNS(object):
|
|
|
|
def __init__(self, parser, parents):
|
|
|
|
self.parser = parser
|
|
|
|
|
|
|
|
self.parser['dns'] = self.parser['sub'].add_parser(
|
2019-05-12 10:42:28 +00:00
|
|
|
'dns',
|
|
|
|
help="Manage DNS entries @ ungleich",
|
|
|
|
parents=[parents])
|
2019-05-12 08:27:07 +00:00
|
|
|
|
2019-05-18 16:39:28 +00:00
|
|
|
self.parser['dns'].add_argument('--set-reverse', help='REQUIRED: IPv6 Address of your VM', required=True)
|
|
|
|
self.parser['dns'].add_argument('--user', help='Your ungleich username', required=True)
|
|
|
|
self.parser['dns'].add_argument('--token', help='Your ungleich 6 digit OTP generated token', type=int, required=True)
|
|
|
|
self.parser['dns'].add_argument('--name', help='Hostname', required=True)
|
|
|
|
self.parser['dns'].add_argument('--email', help='registered email', required=True)
|
|
|
|
self.parser['dns'].add_argument('--realm', help='Otp realm', required=True)
|
2019-05-15 22:49:00 +00:00
|
|
|
self.parser['dns'].set_defaults(func=self._handle_dns)
|
2019-05-12 08:27:07 +00:00
|
|
|
|
2019-05-15 22:49:00 +00:00
|
|
|
def _handle_dns(self, args):
|
|
|
|
"""A dev endpoint for reverse-dns service."""
|
2019-05-12 08:27:07 +00:00
|
|
|
r = requests.post(
|
2019-05-15 22:49:00 +00:00
|
|
|
'https://dev.william.ungleich.cloud',
|
|
|
|
json={
|
|
|
|
'username': args.user,
|
|
|
|
'token': args.token,
|
|
|
|
'ipaddress': args.set_reverse,
|
|
|
|
'name': args.name,
|
|
|
|
'email': args.email,
|
|
|
|
'realm': args.realm
|
|
|
|
})
|
|
|
|
print(r.text)
|