mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Testing AzureProvider. TODO: resolve 'Exception: Unknown provider class: octodns.provider.azure.AzureProvider'
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
from __future__ import absolute_import, division, print_function, \
|
||||
unicode_literals
|
||||
|
||||
|
||||
from azure.common.credentials import ServicePrincipalCredentials
|
||||
from azure.mgmt.dns import DnsManagementClient
|
||||
from azure.mgmt.dns.models import *
|
||||
@@ -13,10 +13,13 @@ from collections import defaultdict
|
||||
# from incf.countryutils.transformations import cca_to_ctca2 TODO: add geo sup.
|
||||
import logging
|
||||
import re
|
||||
from ..record import Record, Up
|
||||
|
||||
from ..record import Record, Update
|
||||
from .base import BaseProvider
|
||||
|
||||
class A(BaseProvider):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
#TODO: changes made to master include adding /build, Makefile to .gitignore and
|
||||
# making Makefile.
|
||||
@@ -38,60 +41,56 @@ class _AzureRecord(object):
|
||||
|
||||
|
||||
class AzureProvider(BaseProvider):
|
||||
'''
|
||||
Azure DNS Provider
|
||||
|
||||
azure.py:
|
||||
class: octodns.provider.azure.AzureProvider
|
||||
# Current support of authentication of access to Azure services only
|
||||
# includes using a Service Principal:
|
||||
# https://docs.microsoft.com/en-us/azure/azure-resource-manager/
|
||||
# resource-group-create-service-principal-portal
|
||||
# The Azure Active Directory Application ID (referred to client ID) req:
|
||||
client_id:
|
||||
# Authentication Key Value req:
|
||||
key:
|
||||
# Directory ID (referred to tenant ID) req:
|
||||
directory_id:
|
||||
# Subscription ID req:
|
||||
sub_id:
|
||||
# Resource Group name req:
|
||||
resource_group:
|
||||
|
||||
testing: test authentication vars located in /home/t-hehwan/vars.txt
|
||||
'''
|
||||
|
||||
# TODO. Will add support as project progresses.
|
||||
SUPPORTS_GEO = False
|
||||
|
||||
def __init__(self, id, client_id, key, directory_id, sub_id, \
|
||||
resource_group, *args, **kwargs):
|
||||
'''
|
||||
Azure DNS Provider
|
||||
|
||||
azure.py:
|
||||
class: octodns.provider.azure.AzureProvider
|
||||
# Current support of authentication of access to Azure services only
|
||||
# includes using a Service Principal:
|
||||
# https://docs.microsoft.com/en-us/azure/azure-resource-manager/
|
||||
# resource-group-create-service-principal-portal
|
||||
# The Azure Active Directory Application ID (referred to client ID) req:
|
||||
client_id:
|
||||
# Authentication Key Value req:
|
||||
key:
|
||||
# Directory ID (referred to tenant ID) req:
|
||||
directory_id:
|
||||
# Subscription ID req:
|
||||
sub_id:
|
||||
# Resource Group name req:
|
||||
resource_group:
|
||||
|
||||
testing: test authentication vars located in /home/t-hehwan/vars.txt
|
||||
'''
|
||||
SUPPORTS_GEO = False # TODO. Will add support as project progresses.
|
||||
|
||||
def __init__(self, id, client_id, key, directory_id, sub_id, resource_group, *args, **kwargs):
|
||||
self.log = logging.getLogger('AzureProvider[{}]'.format(id))
|
||||
self.log.debug('__init__: id=%s, client_id=%s, '
|
||||
'key=***, directory_id:%s', id, client_id, directory_id)
|
||||
'key=***, directory_id:%s', id, client_id, directory_id)
|
||||
super(AzureProvider, self).__init__(id, *args, **kwargs)
|
||||
|
||||
|
||||
credentials = ServicePrincipalCredentials(
|
||||
client_id = client_id, secret = key, tenant = directory_id
|
||||
client_id = client_id, secret = key, tenant = directory_id
|
||||
)
|
||||
self._dns_client = DnsManagementClient(credentials, sub_id)
|
||||
self._resource_group = resource_group
|
||||
|
||||
|
||||
self._azure_zones = None # will be a dictionary. key: name. val: id.
|
||||
self._azure_records = None # will be dict by octodns record, az record
|
||||
|
||||
|
||||
self._supported_types = ['A']
|
||||
|
||||
# TODO: health checks a la route53.
|
||||
|
||||
|
||||
|
||||
# TODO: health checks a la route53.
|
||||
|
||||
|
||||
|
||||
# TODO: add support for all types. First skeleton: add A.
|
||||
def supports(self, record):
|
||||
# TODO: possibly refactor
|
||||
return record._type in self._supported_types
|
||||
|
||||
|
||||
@property
|
||||
def azure_zones(self):
|
||||
if self._azure_zones is None:
|
||||
@@ -110,6 +109,7 @@ class AzureProvider(BaseProvider):
|
||||
self.log.debug('_get_zone_id: id=%s', id)
|
||||
return id
|
||||
if create:
|
||||
raise Exception
|
||||
#TODO
|
||||
return None
|
||||
|
||||
@@ -138,7 +138,7 @@ class AzureProvider(BaseProvider):
|
||||
|
||||
def _data_for_A(self, type, azrecord):
|
||||
return {
|
||||
'type': type
|
||||
'type': type,
|
||||
'ttl': azrecord['ttl'],
|
||||
'values': [ar.ipv4_address for ar in azrecord.arecords]
|
||||
}
|
||||
@@ -154,8 +154,7 @@ class AzureProvider(BaseProvider):
|
||||
ar = self._get_azure_record(new)
|
||||
|
||||
create = self._dns_client.record_sets.create_or_update
|
||||
create(ar.resource_group_name, ar.zone_name, ar.relative_record_set_name \
|
||||
ar.record_type, ar.params)
|
||||
create(ar.resource_group_name, ar.zone_name, ar.relative_record_set_name, ar.record_type, ar.params)
|
||||
|
||||
# type plan: Plan class from .base
|
||||
def _apply(self, plan):
|
||||
|
||||
5
rb.txt
5
rb.txt
@@ -3,5 +3,6 @@
|
||||
|
||||
sudo rm -r /home/t-hehwan/GitHub/octodns/build
|
||||
sudo rm -r /home/t-hehwan/GitHub/octodns/octodns.egg-info
|
||||
sudo python /home/t-hehwan/GitHub/octodns/setup.py build -q
|
||||
sudo python /home/t-hehwan/GitHub/octodns/setup.py install -q
|
||||
sudo python /home/t-hehwan/GitHub/octodns/setup.py -q build
|
||||
sudo python /home/t-hehwan/GitHub/octodns/setup.py -q install
|
||||
octodns-sync --config-file=./config/production.yaml
|
||||
Reference in New Issue
Block a user