Ejemplo n.º 1
0
    def __init__(self, provider_name, credential_args):

        dns_provider = providers.get_driver(provider_name.lower())

        credential_list = [x.strip() for x in credential_args.split(',')]
        credentials = (credential_list[0], credential_list[1])

        self.dns_API = dns_provider(*credentials)
Ejemplo n.º 2
0
def _get_driver(profile):
    config = __salt__['config.option']('libcloud_dns')[profile]
    cls = get_driver(config['driver'])
    key = config.get('key')
    secret = config.get('secret', None)
    secure = config.get('secure', True)
    host = config.get('host', None)
    port = config.get('port', None)
    return cls(key, secret, secure, host, port)
Ejemplo n.º 3
0
def _get_driver(profile):
    config = __salt__['config.option']('libcloud_dns')[profile]
    cls = get_driver(config['driver'])
    key = config.get('key')
    secret = config.get('secret', None)
    secure = config.get('secure', True)
    host = config.get('host', None)
    port = config.get('port', None)
    return cls(key, secret, secure, host, port)
Ejemplo n.º 4
0
def _get_driver(profile):
    config = __salt__["config.option"]("libcloud_dns")[profile]
    cls = get_driver(config["driver"])
    args = config.copy()
    del args["driver"]
    args["key"] = config.get("key")
    args["secret"] = config.get("secret", None)
    args["secure"] = config.get("secure", True)
    args["host"] = config.get("host", None)
    args["port"] = config.get("port", None)
    return cls(**args)
Ejemplo n.º 5
0
def _get_driver(profile):
    config = __salt__['config.option']('libcloud_dns')[profile]
    cls = get_driver(config['driver'])
    args = config.copy()
    del args['driver']
    args['key'] = config.get('key')
    args['secret'] = config.get('secret', None)
    args['secure'] = config.get('secure', True)
    args['host'] = config.get('host', None)
    args['port'] = config.get('port', None)
    return cls(**args)
Ejemplo n.º 6
0
    def __init__(self, deployment):
        self.logger = logging.getLogger("DNS(google)")
        self.deployment = deployment
        self.gce = self.deployment['gce']
        self.credentials = json.load(open(self.gce['account'], 'r'))

        self.driver = get_driver('google')
        self.dns = self.driver(self.credentials['client_email'],
                               self.credentials['private_key'],
                               project=self.gce['project'],
                               credential_file=os.path.join(
                                   os.path.curdir, 'openshifter',
                                   deployment.name, 'credentials.cache'))
Ejemplo n.º 7
0
 def __init__(self, credentials: LibCloudCredentials):
     super().__init__(credentials)
     # Create new libcloud Provider instance
     self.driver_cls = get_driver(credentials.provider)
     self.driver = self.driver_cls(
         key=credentials.key,
         secret=credentials.secret,
         secure=credentials.secure,
         host=credentials.host,
         port=credentials.port,
         api_version=credentials.api_version,
         region=credentials.region,
     )
Ejemplo n.º 8
0
    def purge(self):
        """

        """
        if self.dns_id and \
                self.dns_id.application_id.type_id.name == 'clouddns':

            Driver = get_driver(getattr(Provider, self.provider_id.name))
            driver = Driver(
                self.provider_id.login, self.provider_id.secret_key)

            zones = driver.list_zones
            for zone in zones:
                if zone.domain == self.name:
                    driver.delete_zone(zone)
Ejemplo n.º 9
0
    def deploy(self):
        """

        """

        super(ClouderDomain, self).deploy()

        if self.dns_id and \
                self.dns_id.application_id.type_id.name == 'clouddns':

            Driver = get_driver(getattr(Provider, self.provider_id.name))
            driver = Driver(
                self.provider_id.login, self.provider_id.secret_key)

            # Create a new zone
            driver.create_zone(domain=self.name)
Ejemplo n.º 10
0
    def deploy_dns_config(self, name, type, value):
        super(ClouderBaseLink, self).deploy_dns_config(name, type, value)

        if self.name.type_id.name == 'clouddns':

            Driver = get_driver(
                getattr(Provider, self.target.provider_id.name))
            driver = Driver(
                self.provider_id.login, self.target.provider_id.secret_key)

            zones = driver.list_zones
            for zone in zones:
                if zone.domain == self.base_id.domain_id.name:
                    zone.create_record(
                        name=name, type=getattr(RecordType, type),
                        data=value)
Ejemplo n.º 11
0
    def delete_dns_record(self, domain_name, domain_dns_value):
        self.logger.info("delete_dns_record")

        extractedDomain = tldextract.extract(domain_name)
        domainSuffix = extractedDomain.domain + "." + extractedDomain.suffix

        if extractedDomain.subdomain is "":
            subDomain = "_acme-challenge"
        else:
            subDomain = "_acme-challenge." + extractedDomain.subdomain

        cls = get_driver(Provider.AURORADNS)
        driver = cls(key=self.AURORA_API_KEY, secret=self.AURORA_SECRET_KEY)
        zone = driver.get_zone(domainSuffix)

        records = driver.list_records(zone)
        for x in records:
            if x.name == subDomain and x.type == "TXT":
                record_id = x.id
                self.logger.info(
                    "Found record "
                    + subDomain
                    + "."
                    + domainSuffix
                    + " with id : "
                    + record_id
                    + "."
                )
                record = driver.get_record(zone_id=zone.id, record_id=record_id)
                driver.delete_record(record)
                self.logger.info(
                    "Deleted record "
                    + subDomain
                    + "."
                    + domainSuffix
                    + " with id : "
                    + record_id
                    + "."
                )
            else:
                self.logger.info(
                    "Record " + subDomain + "." + domainSuffix + " not found. No record to delete."
                )

        self.logger.info("delete_dns_record_success")
        return
Ejemplo n.º 12
0
    def purge_dns_config(self, name, type):

        super(ClouderBaseLink, self).purge_dns_config(name, type)

        if self.name.type_id.name == 'clouddns':

            Driver = get_driver(
                getattr(Provider, self.target.provider_id.name))
            driver = Driver(
                self.provider_id.login, self.target.provider_id.secret_key)

            zones = driver.list_zones
            for zone in zones:
                if zone.domain == self.base_id.domain_id.name:
                    records = driver.list_records(zone)
                    for record in records:
                        if record.name == name and \
                                record.type == getattr(RecordType, type):
                            driver.delete_record(record)
Ejemplo n.º 13
0
    def create_dns_record(self, domain_name, domain_dns_value):
        self.logger.info("create_dns_record")

        extractedDomain = tldextract.extract(domain_name)
        domainSuffix = extractedDomain.domain + "." + extractedDomain.suffix

        if extractedDomain.subdomain == "":
            subDomain = "_acme-challenge"
        else:
            subDomain = "_acme-challenge." + extractedDomain.subdomain

        cls = get_driver(Provider.AURORADNS)
        driver = cls(key=self.AURORA_API_KEY, secret=self.AURORA_SECRET_KEY)
        zone = driver.get_zone(domainSuffix)
        zone.create_record(name=subDomain,
                           type=RecordType.TXT,
                           data=domain_dns_value)

        self.logger.info("create_dns_record_success")
        return
Ejemplo n.º 14
0
def get_driver_and_zones(driver_name, account_name):
    """
    Get the DNS driver, authenticate, and get some zones.
    """
    secret_site = "libcloud/" + driver_name
    cls = get_driver(driver_name)
    pw = get_password(secret_site, account_name)

    if not pw:
        pw = getpass("Password:"******"Password:")
        else:
            set_password(secret_site, account_name, pw)
            return dns, zones
Ejemplo n.º 15
0
    def create_dns_record(self, domain_name, domain_dns_value):
        # if we have been given a wildcard name, strip wildcard
        domain_name = domain_name.lstrip("*.")

        extractedDomain = tldextract.extract(domain_name)
        domainSuffix = extractedDomain.domain + "." + extractedDomain.suffix

        if extractedDomain.subdomain is "":
            subDomain = "_acme-challenge"
        else:
            subDomain = "_acme-challenge." + extractedDomain.subdomain

        cls = get_driver(Provider.AURORADNS)
        driver = cls(key=self.AURORA_API_KEY, secret=self.AURORA_SECRET_KEY)
        zone = driver.get_zone(domainSuffix)
        zone.create_record(name=subDomain,
                           type=RecordType.TXT,
                           data=domain_dns_value)

        return
Ejemplo n.º 16
0
def get_driver_and_zones(driver_name, account_name):
    """
    Get the DNS driver, authenticate, and get some zones.
    """
    secret_site = "libcloud/" + driver_name
    cls = get_driver(driver_name)
    pw = get_password(secret_site, account_name)

    if not pw:
        pw = getpass("Password:"******"Password:")
        else:
            set_password(secret_site, account_name, pw)
            return dns, zones
Ejemplo n.º 17
0
    def create_dns_record(self, domain_name, domain_dns_value):
        self.logger.info('create_dns_record')
        # if we have been given a wildcard name, strip wildcard
        domain_name = domain_name.lstrip('*.')

        extractedDomain = tldextract.extract(domain_name)
        domainSuffix = extractedDomain.domain + '.' + extractedDomain.suffix

        if extractedDomain.subdomain is '':
            subDomain = '_acme-challenge'
        else:
            subDomain = '_acme-challenge.' + extractedDomain.subdomain

        cls = get_driver(Provider.AURORADNS)
        driver = cls(key=self.AURORA_API_KEY, secret=self.AURORA_SECRET_KEY)
        zone = driver.get_zone(domainSuffix)
        zone.create_record(name=subDomain,
                           type=RecordType.TXT,
                           data=domain_dns_value)

        self.logger.info('create_dns_record_success')
        return
Ejemplo n.º 18
0
    def delete_dns_record(self, domain_name, domain_dns_value):

        extractedDomain = tldextract.extract(domain_name)
        domainSuffix = extractedDomain.domain + "." + extractedDomain.suffix

        if extractedDomain.subdomain is "":
            subDomain = "_acme-challenge"
        else:
            subDomain = "_acme-challenge." + extractedDomain.subdomain

        cls = get_driver(Provider.AURORADNS)
        driver = cls(key=self.AURORA_API_KEY, secret=self.AURORA_SECRET_KEY)
        zone = driver.get_zone(domainSuffix)

        records = driver.list_records(zone)
        for x in records:
            if x.name == subDomain and x.type == "TXT":
                record_id = x.id
                record = driver.get_record(zone_id=zone.id,
                                           record_id=record_id)
                driver.delete_record(record)
        return
Ejemplo n.º 19
0
    def create_dns_record(self, domain_name, base64_of_acme_keyauthorization):
        self.logger.info('create_dns_record')

        # delete any prior existing DNS authorizations that may exist already
        self.delete_dns_record(
            domain_name=domain_name,
            base64_of_acme_keyauthorization=base64_of_acme_keyauthorization)

        extractedDomain = tldextract.extract(domain_name)
        domainSuffix = extractedDomain.domain + '.' + extractedDomain.suffix

        if extractedDomain.subdomain is '':
            subDomain = '_acme-challenge'
        else:
            subDomain = '_acme-challenge.' + extractedDomain.subdomain

        cls = get_driver(Provider.AURORADNS)
        driver = cls(key=self.AURORA_API_KEY, secret=self.AURORA_SECRET_KEY)
        zone = driver.get_zone(domainSuffix)
        zone.create_record(name=subDomain,
                           type=RecordType.TXT,
                           data=base64_of_acme_keyauthorization)
        return
Ejemplo n.º 20
0
    def create(cls, reactor, driver_name, username, password, zone_name=None,
               settle_delay=60.0):
        """
        Create a responder.

        :param reactor: The Twisted reactor to use for threading support.
        :param str driver_name: The name of the libcloud DNS driver to use.
        :param str username: The username to authenticate with (the meaning of
            this is driver-specific).
        :param str password: The username to authenticate with (the meaning of
            this is driver-specific).
        :param str zone_name: The zone name to respond in, or ``None`` to
            automatically detect zones.  Usually auto-detection should be fine,
            unless restricting responses to a single specific zone is desired.
        :param float settle_delay: The time, in seconds, to allow for the DNS
            provider to propagate record changes.
        """
        return cls(
            reactor=reactor,
            thread_pool=pool(const(1), threadFactory=_daemon_thread),
            driver=get_driver(driver_name)(username, password),
            zone_name=zone_name,
            settle_delay=settle_delay)
Ejemplo n.º 21
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.WORLDWIDEDNS)

# Normal account
driver = cls('username', 'apikey')

# Reseller account
driver = cls('username', 'apikey', reseller_id='reseller_id')
Ejemplo n.º 22
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.DIGITAL_OCEAN)
driver = cls(key='access token')
Ejemplo n.º 23
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.BUDDYNS)
driver = cls("<api key>")
Ejemplo n.º 24
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.CLOUDFLARE)
driver = cls("<api token>")
Ejemplo n.º 25
0
import functools
import sys
import time
import types

from libcloud.common.types import LibcloudError
from libcloud.dns.base import Zone
from libcloud.dns.types import ZoneDoesNotExistError, ZoneAlreadyExistsError
from libcloud.dns.types import RecordDoesNotExistError, RecordAlreadyExistsError
from libcloud.dns.providers import get_driver

from dnsmadeeasy.driver import DNSMadeEasyDNSDriver, \
    DNSMadeEasyRateLimitExceededError

Driver = get_driver('dnsmadeeasy')

def drivertest(f):
    """Marks a function as a test for the DNS driver"""
    @functools.wraps(f)
    def inner():
        try:
            return f(Driver(API_KEY, API_SECRET, True))
        except DNSMadeEasyRateLimitExceededError as e:
            printf('Rate limit exceeded (0 of %d requests remaining); '
                    'terminating prematuely', e.request_limit)
            sys.exit(2)
    return test(inner)


def domain_names():
Ejemplo n.º 26
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.VULTR)
driver = cls(key='api_key')
Ejemplo n.º 27
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

username = "******"
password = "******"
host = "onapp.test"

cls = get_driver(Provider.ONAPP)
driver = cls(key=username, secret=password, host=host)
Ejemplo n.º 28
0
from libcloud.dns.providers import get_driver
from libcloud.dns.types import Provider, RecordType

CREDENTIALS_ZERIGO = ("email", "api key")

cls = get_driver(Provider.ZERIGO)
driver = cls(*CREDENTIALS_ZERIGO)

zone = [z for z in driver.list_zones() if z.domain == "example.com"][0]

ttl = 900
record = zone.create_record(name="www", type=RecordType.A, data="127.0.0.1", ttl=ttl)
Ejemplo n.º 29
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.WORLDWIDEDNS)

# Normal account
driver = cls("username", "apikey")

# Reseller account
driver = cls("username", "apikey", reseller_id="reseller_id")
Ejemplo n.º 30
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.DNSIMPLE)

driver = cls("username", "apikey")
Ejemplo n.º 31
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.POWERDNS)

# powerdns3.example.com is running PowerDNS v3.x.
driver = cls(key='changeme', host='powerdns3.example.com', port=8081)

# OR:

# powerdns4.example.com is running PowerDNS v4.x, so it uses api_version v1.
driver = cls(key='changeme',
             host='powerdns4.example.com',
             port=8081,
             api_version='v1')
Ejemplo n.º 32
0
 def _driver(self, name, key=None):
     key = key or environ.get("{0}_ACCESS_TOKEN".format(name.upper()))
     return self._drivercache.get(name, get_driver(name)(key))
Ejemplo n.º 33
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.ZONOMI)
driver = cls('apikey')
Ejemplo n.º 34
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.POWERDNS)

# powerdns3.example.com is running PowerDNS v3.x.
driver = cls(key='changeme', host='powerdns3.example.com', port=8081)

# OR:

# powerdns4.example.com is running PowerDNS v4.x, so it uses api_version v1.
driver = cls(key='changeme', host='powerdns4.example.com', port=8081,
             api_version='v1')
Ejemplo n.º 35
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

DNSDriver = get_driver(Provider.GOOGLE)
driver = DNSDriver('client ID', 'client secret', project='project ID')
Ejemplo n.º 36
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.NFSN)
driver = cls('<account name>', '<api key>')
Ejemplo n.º 37
0
def get_connection():
    driver = get_driver(Provider.RACKSPACE)
    conn = driver(username, api_key, region = 'us')
    return conn
Ejemplo n.º 38
0
                    help='The desired TTL of the DNS record')
parser.add_argument('--provider', metavar='<PROVIDER>', default=Provider.ROUTE53,
                    help='The value of the DNS record')
parser.add_argument('--record', metavar='<RECORD>', default=os.environ.get('RECORD'),
                    help='The the DNS record to create')
args = parser.parse_args()

CREDENTIALS = (args.identity, args.secret)
DOMAIN = 'robszumski.com.'
RECORD_NAME = 'test'
RECORD_TYPE = RecordType.A
VALUE = '54.81.103.88'
TTL = 300
DEBUG = True

cls = get_driver(Provider.ROUTE53)
driver = cls(*CREDENTIALS)

zone = [z for z in driver.list_zones() if z.domain == args.domain][0]

records = driver.list_records(zone)

exists = any(record.name == args.record for record in records)

extra = {'ttl': args.ttl}

if exists is False:
  try:
    record = zone.create_record(name=args.record, type=args.type, data=args.value,
      extra=extra)
    print "Created record for %s.%s with value %s" % (args.record, args.domain, args.value)
Ejemplo n.º 39
0
def get_connection():
    driver = get_driver(Provider.RACKSPACE_US)
    conn = driver(username, api_key)
    return conn
Ejemplo n.º 40
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.AURORADNS)

driver = cls('myapikey', 'mysecret')
Ejemplo n.º 41
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.RCODEZERO)

APIKEY_RCODEZERO = "secrettoken"
API_HOST = "my.rcodezero.at"

cls = get_driver(Provider.RCODEZERO)
driver = cls(APIKEY_RCODEZERO, host=API_HOST)
Ejemplo n.º 42
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.DURABLEDNS)
driver = cls('api_user', 'api_key')
Ejemplo n.º 43
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.CLOUDFLARE)
driver = cls('<email address>', '<api key>')
Ejemplo n.º 44
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.POINTDNS)
driver = cls('username', 'apikey')
Ejemplo n.º 45
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.LIQUIDWEB)
driver = cls(user_id='user', key='api_key')
Ejemplo n.º 46
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.BUDDYNS)
driver = cls('<api key>')
Ejemplo n.º 47
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.ZONOMI)
driver = cls("apikey")
Ejemplo n.º 48
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.DNSIMPLE)

driver = cls('username', 'apikey')
Ejemplo n.º 49
0
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from pprint import pprint

from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

Zerigo = get_driver(Provider.ZERIGO)

driver = Zerigo('email', 'key')

zones = driver.list_zones()
pprint(zones)

records = zones[0].list_records()
pprint(records)
Ejemplo n.º 50
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.HOSTVIRTUAL)
driver = cls(key='my secret key')
Ejemplo n.º 51
0
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.GODADDY)
driver = cls('customer_id', 'api_key', 'api_secret')

zones = driver.list_zones()
for zone in zones:
    print("Domain : %s" % zone.domain)
    print("Expires: %s" % zone.extra['expires'])
Ejemplo n.º 52
0
from libcloud.dns.providers import get_driver
from libcloud.dns.types import Provider, RecordType

CREDENTIALS_ZERIGO = ('email', 'api key')

cls = get_driver(Provider.ZERIGO)
driver = cls(*CREDENTIALS_ZERIGO)

zone = [z for z in driver.list_zones() if z.domain == 'example.com'][0]

extra = {'ttl': 900}
record = zone.create_record(name='www', type=RecordType.A, data='127.0.0.1',
                            extra=extra)