Merge "Rename 'zone' to 'domain.'"
This commit is contained in:
commit
1fd74af148
@ -90,40 +90,40 @@ Get a list of registered DNS Domains published by the DNS drivers:
|
||||
GET /v1.1/<tenant_id>/os-floating-ip-dns/
|
||||
|
||||
# Sample Response:
|
||||
{'zone_entries' : [
|
||||
{'domain_entries' : [
|
||||
{'domain': 'domain1.example.org', 'scope': 'public', 'project': 'proj1'}
|
||||
{'domain': 'domain2.example.net', 'scope': 'public', 'project': 'proj2'}
|
||||
{'domain': 'example.net', 'scope': 'public', 'project': ''}
|
||||
{'domain': 'example.internal', 'scope': 'private', 'zone': 'zone1'}]}
|
||||
{'domain': 'example.internal', 'scope': 'private', 'availability_zone': 'zone1'}]}
|
||||
|
||||
|
||||
Create or modify a DNS domain:
|
||||
|
||||
PUT /v1.1/<tenant_id>/os-floating-ip-dns/<zone>
|
||||
PUT /v1.1/<tenant_id>/os-floating-ip-dns/<domain>
|
||||
|
||||
# Sample body, public domain:
|
||||
{'zone_entry' :
|
||||
{'domain_entry' :
|
||||
{'scope': 'public',
|
||||
'project' : 'project1'}}
|
||||
|
||||
# Sample body, public (projectless) domain:
|
||||
{'zone_entry' :
|
||||
{'domain_entry' :
|
||||
{'scope': 'public'}}
|
||||
|
||||
# Sample Response, public domain (success):
|
||||
{'zone_entry' :
|
||||
{'zone': 'domain1.example.org',
|
||||
{'domain_entry' :
|
||||
{'domain': 'domain1.example.org',
|
||||
'scope': 'public',
|
||||
'project': 'project1'}}
|
||||
|
||||
# Sample body, private domain:
|
||||
{'zone_entry' :
|
||||
{'domain_entry' :
|
||||
{'scope': 'private',
|
||||
'availability_zone': 'zone1'}}
|
||||
'availability_domain': 'zone1'}}
|
||||
|
||||
# Sample Response, private domain (success):
|
||||
{'zone_entry' :
|
||||
{'zone': 'domain1.private',
|
||||
{'domain_entry' :
|
||||
{'domain': 'domain1.private',
|
||||
'scope': 'private',
|
||||
'availability_zone': 'zone1'}}
|
||||
|
||||
@ -141,7 +141,7 @@ DELETE /v1.1/<tenant_id>/os-floating-ip-dns/<domain>
|
||||
|
||||
Create or modify a DNS entry:
|
||||
|
||||
PUT /v1.1/<tenant_id>/os-floating-ip-dns/<zone>/entries/<name>
|
||||
PUT /v1.1/<tenant_id>/os-floating-ip-dns/<domain>/entries/<name>
|
||||
|
||||
# Sample body:
|
||||
{ 'dns_entry' :
|
||||
@ -162,7 +162,7 @@ Find unique DNS entry for a given domain and name:
|
||||
{ 'dns_entry' :
|
||||
{ 'ip' : '192.168.53.11',
|
||||
'type' : 'A',
|
||||
'zone' : <domain>,
|
||||
'domain' : <domain>,
|
||||
'name' : <name> }}
|
||||
|
||||
|
||||
@ -174,11 +174,11 @@ Find DNS entries for a given domain and ip:
|
||||
{ 'dns_entries' : [
|
||||
{ 'ip' : <ip>,
|
||||
'type' : 'A',
|
||||
'zone' : <domain>,
|
||||
'domain' : <domain>,
|
||||
'name' : 'example1' }
|
||||
{ 'ip' : <ip>,
|
||||
'type' : 'A',
|
||||
'zone' : <domain>,
|
||||
'domain' : <domain>,
|
||||
'name' : 'example2' }]}
|
||||
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
"network:add_network_to_project": [],
|
||||
"network:get_instance_nw_info": [],
|
||||
|
||||
"network:get_dns_zones": [],
|
||||
"network:get_dns_domains": [],
|
||||
"network:add_dns_entry": [],
|
||||
"network:modify_dns_entry": [],
|
||||
"network:delete_dns_entry": [],
|
||||
|
@ -33,12 +33,12 @@ def make_dns_entry(elem):
|
||||
elem.set('id')
|
||||
elem.set('ip')
|
||||
elem.set('type')
|
||||
elem.set('zone')
|
||||
elem.set('domain')
|
||||
elem.set('name')
|
||||
|
||||
|
||||
def make_zone_entry(elem):
|
||||
elem.set('zone')
|
||||
def make_domain_entry(elem):
|
||||
elem.set('domain')
|
||||
elem.set('scope')
|
||||
elem.set('project')
|
||||
elem.set('availability_zone')
|
||||
@ -61,20 +61,20 @@ class FloatingIPDNSsTemplate(xmlutil.TemplateBuilder):
|
||||
return xmlutil.MasterTemplate(root, 1)
|
||||
|
||||
|
||||
class ZoneTemplate(xmlutil.TemplateBuilder):
|
||||
class DomainTemplate(xmlutil.TemplateBuilder):
|
||||
def construct(self):
|
||||
root = xmlutil.TemplateElement('zone_entry',
|
||||
selector='zone_entry')
|
||||
make_zone_entry(root)
|
||||
root = xmlutil.TemplateElement('domain_entry',
|
||||
selector='domain_entry')
|
||||
make_domain_entry(root)
|
||||
return xmlutil.MasterTemplate(root, 1)
|
||||
|
||||
|
||||
class ZonesTemplate(xmlutil.TemplateBuilder):
|
||||
class DomainsTemplate(xmlutil.TemplateBuilder):
|
||||
def construct(self):
|
||||
root = xmlutil.TemplateElement('zone_entries')
|
||||
elem = xmlutil.SubTemplateElement(root, 'zone_entry',
|
||||
selector='zone_entries')
|
||||
make_zone_entry(elem)
|
||||
root = xmlutil.TemplateElement('domain_entries')
|
||||
elem = xmlutil.SubTemplateElement(root, 'domain_entry',
|
||||
selector='domain_entries')
|
||||
make_domain_entry(elem)
|
||||
return xmlutil.MasterTemplate(root, 1)
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ def _translate_dns_entry_view(dns_entry):
|
||||
result['ip'] = dns_entry.get('ip')
|
||||
result['id'] = dns_entry.get('id')
|
||||
result['type'] = dns_entry.get('type')
|
||||
result['zone'] = dns_entry.get('zone')
|
||||
result['domain'] = dns_entry.get('domain')
|
||||
result['name'] = dns_entry.get('name')
|
||||
return {'dns_entry': result}
|
||||
|
||||
@ -93,32 +93,33 @@ def _translate_dns_entries_view(dns_entries):
|
||||
for entry in dns_entries]}
|
||||
|
||||
|
||||
def _translate_zone_entry_view(zone_entry):
|
||||
def _translate_domain_entry_view(domain_entry):
|
||||
result = {}
|
||||
result['domain'] = zone_entry.get('domain')
|
||||
result['scope'] = zone_entry.get('scope')
|
||||
result['project'] = zone_entry.get('project')
|
||||
result['availability_zone'] = zone_entry.get('availability_zone')
|
||||
return {'zone_entry': result}
|
||||
result['domain'] = domain_entry.get('domain')
|
||||
result['scope'] = domain_entry.get('scope')
|
||||
result['project'] = domain_entry.get('project')
|
||||
result['availability_zone'] = domain_entry.get('availability_zone')
|
||||
return {'domain_entry': result}
|
||||
|
||||
|
||||
def _translate_zone_entries_view(zone_entries):
|
||||
return {'zone_entries': [_translate_zone_entry_view(entry)['zone_entry']
|
||||
for entry in zone_entries]}
|
||||
def _translate_domain_entries_view(domain_entries):
|
||||
return {'domain_entries':
|
||||
[_translate_domain_entry_view(entry)['domain_entry']
|
||||
for entry in domain_entries]}
|
||||
|
||||
|
||||
def _unquote_zone(zone):
|
||||
"""Unquoting function for receiving a zone name in a URL.
|
||||
def _unquote_domain(domain):
|
||||
"""Unquoting function for receiving a domain name in a URL.
|
||||
|
||||
Zone names tend to have .'s in them. Urllib doesn't quote dots,
|
||||
Domain names tend to have .'s in them. Urllib doesn't quote dots,
|
||||
but Routes tends to choke on them, so we need an extra level of
|
||||
by-hand quoting here.
|
||||
"""
|
||||
return urllib.unquote(zone).replace('%2E', '.')
|
||||
return urllib.unquote(domain).replace('%2E', '.')
|
||||
|
||||
|
||||
def _create_dns_entry(ip, name, zone):
|
||||
return {'ip': ip, 'name': name, 'zone': zone}
|
||||
def _create_dns_entry(ip, name, domain):
|
||||
return {'ip': ip, 'name': name, 'domain': domain}
|
||||
|
||||
|
||||
def _create_domain_entry(domain, scope=None, project=None, av_zone=None):
|
||||
@ -133,26 +134,26 @@ class FloatingIPDNSDomainController(object):
|
||||
self.network_api = network.API()
|
||||
super(FloatingIPDNSDomainController, self).__init__()
|
||||
|
||||
@wsgi.serializers(xml=ZonesTemplate)
|
||||
@wsgi.serializers(xml=DomainsTemplate)
|
||||
def index(self, req):
|
||||
"""Return a list of available DNS zones."""
|
||||
"""Return a list of available DNS domains."""
|
||||
context = req.environ['nova.context']
|
||||
zones = self.network_api.get_dns_zones(context)
|
||||
zonelist = [_create_domain_entry(zone['domain'],
|
||||
zone.get('scope'),
|
||||
zone.get('project'),
|
||||
zone.get('availability_zone'))
|
||||
for zone in zones]
|
||||
domains = self.network_api.get_dns_domains(context)
|
||||
domainlist = [_create_domain_entry(domain['domain'],
|
||||
domain.get('scope'),
|
||||
domain.get('project'),
|
||||
domain.get('availability_zone'))
|
||||
for domain in domains]
|
||||
|
||||
return _translate_zone_entries_view(zonelist)
|
||||
return _translate_domain_entries_view(domainlist)
|
||||
|
||||
@wsgi.serializers(xml=ZoneTemplate)
|
||||
@wsgi.serializers(xml=DomainTemplate)
|
||||
def update(self, req, id, body):
|
||||
"""Add or modify domain entry"""
|
||||
context = req.environ['nova.context']
|
||||
fqdomain = _unquote_zone(id)
|
||||
fqdomain = _unquote_domain(id)
|
||||
try:
|
||||
entry = body['zone_entry']
|
||||
entry = body['domain_entry']
|
||||
scope = entry['scope']
|
||||
except (TypeError, KeyError):
|
||||
raise webob.exc.HTTPUnprocessableEntity()
|
||||
@ -168,14 +169,14 @@ class FloatingIPDNSDomainController(object):
|
||||
self.network_api.create_private_dns_domain(context,
|
||||
fqdomain,
|
||||
av_zone)
|
||||
return _translate_zone_entry_view({'domain': fqdomain,
|
||||
return _translate_domain_entry_view({'domain': fqdomain,
|
||||
'scope': scope,
|
||||
'availability_zone': av_zone})
|
||||
else:
|
||||
self.network_api.create_public_dns_domain(context,
|
||||
fqdomain,
|
||||
project)
|
||||
return _translate_zone_entry_view({'domain': fqdomain,
|
||||
return _translate_domain_entry_view({'domain': fqdomain,
|
||||
'scope': 'public',
|
||||
'project': project})
|
||||
except exception.NotAuthorized or exception.AdminRequired:
|
||||
@ -185,11 +186,11 @@ class FloatingIPDNSDomainController(object):
|
||||
"""Delete the domain identified by id. """
|
||||
context = req.environ['nova.context']
|
||||
params = req.str_GET
|
||||
zone = _unquote_zone(id)
|
||||
domain = _unquote_domain(id)
|
||||
|
||||
# Delete the whole domain
|
||||
try:
|
||||
self.network_api.delete_dns_domain(context, zone)
|
||||
self.network_api.delete_dns_domain(context, domain)
|
||||
except exception.NotAuthorized or exception.AdminRequired:
|
||||
return webob.Response(status_int=403)
|
||||
except exception.NotFound:
|
||||
@ -206,41 +207,41 @@ class FloatingIPDNSEntryController(object):
|
||||
super(FloatingIPDNSEntryController, self).__init__()
|
||||
|
||||
@wsgi.serializers(xml=FloatingIPDNSTemplate)
|
||||
def show(self, req, zone_id, id):
|
||||
"""Return the DNS entry that corresponds to zone_id and id."""
|
||||
def show(self, req, domain_id, id):
|
||||
"""Return the DNS entry that corresponds to domain_id and id."""
|
||||
context = req.environ['nova.context']
|
||||
zone = _unquote_zone(zone_id)
|
||||
domain = _unquote_domain(domain_id)
|
||||
name = id
|
||||
|
||||
entries = self.network_api.get_dns_entries_by_name(context,
|
||||
name, zone)
|
||||
entry = _create_dns_entry(entries[0], name, zone)
|
||||
name, domain)
|
||||
entry = _create_dns_entry(entries[0], name, domain)
|
||||
return _translate_dns_entry_view(entry)
|
||||
|
||||
@wsgi.serializers(xml=FloatingIPDNSsTemplate)
|
||||
def index(self, req, zone_id):
|
||||
"""Return a list of dns entries for the specified zone and ip."""
|
||||
def index(self, req, domain_id):
|
||||
"""Return a list of dns entries for the specified domain and ip."""
|
||||
context = req.environ['nova.context']
|
||||
params = req.GET
|
||||
floating_ip = params.get('ip')
|
||||
zone = _unquote_zone(zone_id)
|
||||
domain = _unquote_domain(domain_id)
|
||||
|
||||
if not floating_ip:
|
||||
raise webob.exc.HTTPUnprocessableEntity()
|
||||
|
||||
entries = self.network_api.get_dns_entries_by_address(context,
|
||||
floating_ip,
|
||||
zone)
|
||||
entrylist = [_create_dns_entry(floating_ip, entry, zone)
|
||||
domain)
|
||||
entrylist = [_create_dns_entry(floating_ip, entry, domain)
|
||||
for entry in entries]
|
||||
|
||||
return _translate_dns_entries_view(entrylist)
|
||||
|
||||
@wsgi.serializers(xml=FloatingIPDNSTemplate)
|
||||
def update(self, req, zone_id, id, body):
|
||||
def update(self, req, domain_id, id, body):
|
||||
"""Add or modify dns entry"""
|
||||
context = req.environ['nova.context']
|
||||
zone = _unquote_zone(zone_id)
|
||||
domain = _unquote_domain(domain_id)
|
||||
name = id
|
||||
try:
|
||||
entry = body['dns_entry']
|
||||
@ -249,28 +250,29 @@ class FloatingIPDNSEntryController(object):
|
||||
except (TypeError, KeyError):
|
||||
raise webob.exc.HTTPUnprocessableEntity()
|
||||
|
||||
entries = self.network_api.get_dns_entries_by_name(context, name, zone)
|
||||
entries = self.network_api.get_dns_entries_by_name(context,
|
||||
name, domain)
|
||||
if not entries:
|
||||
# create!
|
||||
self.network_api.add_dns_entry(context, address, name,
|
||||
dns_type, zone)
|
||||
dns_type, domain)
|
||||
else:
|
||||
# modify!
|
||||
self.network_api.modify_dns_entry(context, name, address, zone)
|
||||
self.network_api.modify_dns_entry(context, name, address, domain)
|
||||
|
||||
return _translate_dns_entry_view({'ip': address,
|
||||
'name': name,
|
||||
'type': dns_type,
|
||||
'zone': zone})
|
||||
'domain': domain})
|
||||
|
||||
def delete(self, req, zone_id, id):
|
||||
def delete(self, req, domain_id, id):
|
||||
"""Delete the entry identified by req and id. """
|
||||
context = req.environ['nova.context']
|
||||
zone = _unquote_zone(zone_id)
|
||||
domain = _unquote_domain(domain_id)
|
||||
name = id
|
||||
|
||||
try:
|
||||
self.network_api.delete_dns_entry(context, name, zone)
|
||||
self.network_api.delete_dns_entry(context, name, domain)
|
||||
except exception.NotFound:
|
||||
return webob.Response(status_int=404)
|
||||
|
||||
@ -298,7 +300,7 @@ class Floating_ip_dns(extensions.ExtensionDescriptor):
|
||||
|
||||
res = extensions.ResourceExtension('entries',
|
||||
FloatingIPDNSEntryController(),
|
||||
parent={'member_name': 'zone',
|
||||
parent={'member_name': 'domain',
|
||||
'collection_name': 'os-floating-ip-dns'})
|
||||
resources.append(res)
|
||||
|
||||
|
@ -557,7 +557,7 @@ class FloatingIpNotFound(NotFound):
|
||||
|
||||
|
||||
class FloatingIpDNSExists(Invalid):
|
||||
message = _("The DNS entry %(name)s already exists in zone %(zone)s.")
|
||||
message = _("The DNS entry %(name)s already exists in domain %(domain)s.")
|
||||
|
||||
|
||||
class FloatingIpNotFoundForAddress(FloatingIpNotFound):
|
||||
|
@ -370,7 +370,7 @@ DEFINE_string('console_manager', 'nova.console.manager.ConsoleProxyManager',
|
||||
DEFINE_string('instance_dns_manager',
|
||||
'nova.network.dns_driver.DNSDriver',
|
||||
'DNS Manager for instance IPs')
|
||||
DEFINE_string('instance_dns_zone', '',
|
||||
DEFINE_string('instance_dns_domain', '',
|
||||
'DNS Zone for instance IPs')
|
||||
DEFINE_string('floating_ip_dns_manager',
|
||||
'nova.network.dns_driver.DNSDriver',
|
||||
|
@ -230,71 +230,71 @@ class API(base.Base):
|
||||
{'method': 'get_instance_uuids_by_ip_filter',
|
||||
'args': args})
|
||||
|
||||
def get_dns_zones(self, context):
|
||||
"""Returns a list of available dns zones.
|
||||
def get_dns_domains(self, context):
|
||||
"""Returns a list of available dns domains.
|
||||
These can be used to create DNS entries for floating ips.
|
||||
"""
|
||||
return rpc.call(context,
|
||||
FLAGS.network_topic,
|
||||
{'method': 'get_dns_zones'})
|
||||
{'method': 'get_dns_domains'})
|
||||
|
||||
def add_dns_entry(self, context, address, name, dns_type, zone):
|
||||
def add_dns_entry(self, context, address, name, dns_type, domain):
|
||||
"""Create specified DNS entry for address"""
|
||||
args = {'address': address,
|
||||
'dns_name': name,
|
||||
'name': name,
|
||||
'dns_type': dns_type,
|
||||
'dns_zone': zone}
|
||||
'domain': domain}
|
||||
return rpc.call(context, FLAGS.network_topic,
|
||||
{'method': 'add_dns_entry',
|
||||
'args': args})
|
||||
|
||||
def modify_dns_entry(self, context, name, address, dns_zone):
|
||||
def modify_dns_entry(self, context, name, address, domain):
|
||||
"""Create specified DNS entry for address"""
|
||||
args = {'address': address,
|
||||
'dns_name': name,
|
||||
'dns_zone': dns_zone}
|
||||
'name': name,
|
||||
'domain': domain}
|
||||
return rpc.call(context, FLAGS.network_topic,
|
||||
{'method': 'modify_dns_entry',
|
||||
'args': args})
|
||||
|
||||
def delete_dns_entry(self, context, name, zone):
|
||||
def delete_dns_entry(self, context, name, domain):
|
||||
"""Delete the specified dns entry."""
|
||||
args = {'dns_name': name, 'dns_zone': zone}
|
||||
args = {'name': name, 'domain': domain}
|
||||
return rpc.call(context, FLAGS.network_topic,
|
||||
{'method': 'delete_dns_entry',
|
||||
'args': args})
|
||||
|
||||
def delete_dns_domain(self, context, fqdomain):
|
||||
def delete_dns_domain(self, context, domain):
|
||||
"""Delete the specified dns domain."""
|
||||
args = {'fqdomain': fqdomain}
|
||||
args = {'domain': domain}
|
||||
return rpc.call(context, FLAGS.network_topic,
|
||||
{'method': 'delete_dns_domain',
|
||||
'args': args})
|
||||
|
||||
def get_dns_entries_by_address(self, context, address, zone):
|
||||
"""Get entries for address and zone"""
|
||||
args = {'address': address, 'dns_zone': zone}
|
||||
def get_dns_entries_by_address(self, context, address, domain):
|
||||
"""Get entries for address and domain"""
|
||||
args = {'address': address, 'domain': domain}
|
||||
return rpc.call(context, FLAGS.network_topic,
|
||||
{'method': 'get_dns_entries_by_address',
|
||||
'args': args})
|
||||
|
||||
def get_dns_entries_by_name(self, context, name, zone):
|
||||
"""Get entries for name and zone"""
|
||||
args = {'name': name, 'dns_zone': zone}
|
||||
def get_dns_entries_by_name(self, context, name, domain):
|
||||
"""Get entries for name and domain"""
|
||||
args = {'name': name, 'domain': domain}
|
||||
return rpc.call(context, FLAGS.network_topic,
|
||||
{'method': 'get_dns_entries_by_name',
|
||||
'args': args})
|
||||
|
||||
def create_private_dns_domain(self, context, fqdomain, availability_zone):
|
||||
def create_private_dns_domain(self, context, domain, availability_zone):
|
||||
"""Create a private DNS domain with nova availability zone."""
|
||||
args = {'fqdomain': fqdomain, 'zone': availability_zone}
|
||||
args = {'domain': domain, 'av_zone': availability_zone}
|
||||
return rpc.call(context, FLAGS.network_topic,
|
||||
{'method': 'create_private_dns_domain',
|
||||
'args': args})
|
||||
|
||||
def create_public_dns_domain(self, context, fqdomain, project=None):
|
||||
def create_public_dns_domain(self, context, domain, project=None):
|
||||
"""Create a private DNS domain with optional nova project."""
|
||||
args = {'fqdomain': fqdomain, 'project': project}
|
||||
args = {'domain': domain, 'project': project}
|
||||
return rpc.call(context, FLAGS.network_topic,
|
||||
{'method': 'create_public_dns_domain',
|
||||
'args': args})
|
||||
|
@ -19,22 +19,22 @@ class DNSDriver(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def get_zones(self):
|
||||
def get_domains(self):
|
||||
return []
|
||||
|
||||
def create_entry(self, _name, _address, _type, _dnszone):
|
||||
def create_entry(self, _name, _address, _type, _domain):
|
||||
pass
|
||||
|
||||
def delete_entry(self, _name, _dnszone=""):
|
||||
def delete_entry(self, _name, _domain):
|
||||
pass
|
||||
|
||||
def modify_address(self, _name, _address, _dnszone):
|
||||
def modify_address(self, _name, _address, _domain):
|
||||
pass
|
||||
|
||||
def get_entries_by_address(self, _address, _dnszone=""):
|
||||
def get_entries_by_address(self, _address, _domain=""):
|
||||
return []
|
||||
|
||||
def get_entries_by_name(self, _name, _dnszone=""):
|
||||
def get_entries_by_name(self, _name, _domain=""):
|
||||
return []
|
||||
|
||||
def create_domain(self, _fqdomain):
|
||||
|
@ -104,7 +104,8 @@ class DNSEntry(object):
|
||||
if name.endswith(z):
|
||||
dequalified = name[0:name.rfind(z)]
|
||||
else:
|
||||
LOG.warn("Unable to dequalify. %s is not in %s.\n" % (name, zone))
|
||||
LOG.warn("Unable to dequalify. %s is not in %s.\n" % (name,
|
||||
self.qualified_domain))
|
||||
dequalified = None
|
||||
|
||||
return dequalified
|
||||
@ -134,20 +135,20 @@ class DomainEntry(DNSEntry):
|
||||
return soa
|
||||
|
||||
@classmethod
|
||||
def create_domain(cls, lobj, fqdomain):
|
||||
def create_domain(cls, lobj, domain):
|
||||
"""Create a new domain entry, and return an object that wraps it."""
|
||||
entry = cls._get_tuple_for_domain(lobj, fqdomain)
|
||||
entry = cls._get_tuple_for_domain(lobj, domain)
|
||||
if entry:
|
||||
raise exception.FloatingIpDNSExists(name=fqdomain, zone="")
|
||||
raise exception.FloatingIpDNSExists(name=domain, domain="")
|
||||
|
||||
newdn = "dc=%s,%s" % (fqdomain, flags.FLAGS.ldap_dns_base_dn)
|
||||
newdn = "dc=%s,%s" % (domain, flags.FLAGS.ldap_dns_base_dn)
|
||||
attrs = {'objectClass': ['domainrelatedobject', 'dnsdomain',
|
||||
'domain', 'dcobject', 'top'],
|
||||
'sOARecord': [cls._soa()],
|
||||
'associatedDomain': [fqdomain],
|
||||
'dc': fqdomain}
|
||||
'associatedDomain': [domain],
|
||||
'dc': domain}
|
||||
lobj.add_s(newdn, create_modlist(attrs))
|
||||
return DomainEntry(lobj, fqdomain)
|
||||
return DomainEntry(lobj, domain)
|
||||
|
||||
def __init__(self, ldap_object, domain):
|
||||
super(DomainEntry, self).__init__(ldap_object)
|
||||
@ -194,7 +195,7 @@ class DomainEntry(DNSEntry):
|
||||
def add_entry(self, name, address):
|
||||
if self.subentry_with_name(name):
|
||||
raise exception.FloatingIpDNSExists(name=name,
|
||||
zone=self.qualified_domain)
|
||||
domain=self.qualified_domain)
|
||||
|
||||
entries = self.subentries_with_ip(address)
|
||||
if entries:
|
||||
@ -289,24 +290,24 @@ class LdapDNS(object):
|
||||
self.lobj.simple_bind_s(flags.FLAGS.ldap_dns_user,
|
||||
flags.FLAGS.ldap_dns_password)
|
||||
|
||||
def get_zones(self):
|
||||
return flags.FLAGS.floating_ip_dns_zones
|
||||
def get_domains(self):
|
||||
return flags.FLAGS.floating_ip_dns_domains
|
||||
|
||||
def create_entry(self, name, address, type, dnszone):
|
||||
def create_entry(self, name, address, type, domain):
|
||||
if type.lower() != 'a':
|
||||
raise exception.InvalidInput(_("This driver only supports "
|
||||
"type 'a' entries."))
|
||||
|
||||
dEntry = DomainEntry(self.lobj, dnszone)
|
||||
dEntry = DomainEntry(self.lobj, domain)
|
||||
dEntry.add_entry(name, address)
|
||||
|
||||
def delete_entry(self, name, dnszone):
|
||||
dEntry = DomainEntry(self.lobj, dnszone)
|
||||
def delete_entry(self, name, domain):
|
||||
dEntry = DomainEntry(self.lobj, domain)
|
||||
dEntry.remove_entry(name)
|
||||
|
||||
def get_entries_by_address(self, address, dnszone):
|
||||
def get_entries_by_address(self, address, domain):
|
||||
try:
|
||||
dEntry = DomainEntry(self.lobj, dnszone)
|
||||
dEntry = DomainEntry(self.lobj, domain)
|
||||
except exception.NotFound:
|
||||
return []
|
||||
entries = dEntry.subentries_with_ip(address)
|
||||
@ -315,25 +316,25 @@ class LdapDNS(object):
|
||||
names.extend(entry.names)
|
||||
return names
|
||||
|
||||
def get_entries_by_name(self, name, dnszone):
|
||||
def get_entries_by_name(self, name, domain):
|
||||
try:
|
||||
dEntry = DomainEntry(self.lobj, dnszone)
|
||||
dEntry = DomainEntry(self.lobj, domain)
|
||||
except exception.NotFound:
|
||||
return []
|
||||
nEntry = dEntry.subentry_with_name(name)
|
||||
if nEntry:
|
||||
return [nEntry.ip]
|
||||
|
||||
def modify_address(self, name, address, dnszone):
|
||||
dEntry = DomainEntry(self.lobj, dnszone)
|
||||
def modify_address(self, name, address, domain):
|
||||
dEntry = DomainEntry(self.lobj, domain)
|
||||
nEntry = dEntry.subentry_with_name(name)
|
||||
nEntry.modify_address(name, address)
|
||||
|
||||
def create_domain(self, fqdomain):
|
||||
DomainEntry.create_domain(self.lobj, fqdomain)
|
||||
def create_domain(self, domain):
|
||||
DomainEntry.create_domain(self.lobj, domain)
|
||||
|
||||
def delete_domain(self, fqdomain):
|
||||
dEntry = DomainEntry(self.lobj, fqdomain)
|
||||
def delete_domain(self, domain):
|
||||
dEntry = DomainEntry(self.lobj, domain)
|
||||
dEntry.delete()
|
||||
|
||||
def delete_dns_file(self):
|
||||
|
@ -508,54 +508,55 @@ class FloatingIP(object):
|
||||
scope = domainref.scope
|
||||
if scope == 'private':
|
||||
av_zone = domainref.availability_zone
|
||||
this_zone = {'domain': domain,
|
||||
this_domain = {'domain': domain,
|
||||
'scope': scope,
|
||||
'availability_zone': av_zone}
|
||||
else:
|
||||
project = domainref.project_id
|
||||
this_zone = {'domain': domain,
|
||||
this_domain = {'domain': domain,
|
||||
'scope': scope,
|
||||
'project': project}
|
||||
return this_zone
|
||||
return this_domain
|
||||
|
||||
@wrap_check_policy
|
||||
def get_dns_zones(self, context):
|
||||
zones = []
|
||||
def get_dns_domains(self, context):
|
||||
domains = []
|
||||
|
||||
db_zone_list = self.db.dnsdomain_list(context)
|
||||
floating_driver_zone_list = self.floating_dns_manager.get_zones()
|
||||
instance_driver_zone_list = self.instance_dns_manager.get_zones()
|
||||
db_domain_list = self.db.dnsdomain_list(context)
|
||||
floating_driver_domain_list = self.floating_dns_manager.get_domains()
|
||||
instance_driver_domain_list = self.instance_dns_manager.get_domains()
|
||||
|
||||
for db_zone in db_zone_list:
|
||||
if (db_zone in floating_driver_zone_list or
|
||||
db_zone in instance_driver_zone_list):
|
||||
zone_entry = self._prepare_domain_entry(context, db_zone)
|
||||
if zone_entry:
|
||||
zones.append(zone_entry)
|
||||
for db_domain in db_domain_list:
|
||||
if (db_domain in floating_driver_domain_list or
|
||||
db_domain in instance_driver_domain_list):
|
||||
domain_entry = self._prepare_domain_entry(context,
|
||||
db_domain)
|
||||
if domain_entry:
|
||||
domains.append(domain_entry)
|
||||
else:
|
||||
LOG.warn(_('Database inconsistency: DNS domain |%s| is '
|
||||
'registered in the Nova db but not visible to '
|
||||
'either the floating or instance DNS driver. It '
|
||||
'will be ignored.'), db_zone)
|
||||
'will be ignored.'), db_domain)
|
||||
|
||||
return zones
|
||||
return domains
|
||||
|
||||
@wrap_check_policy
|
||||
def add_dns_entry(self, context, address, dns_name, dns_type, dns_zone):
|
||||
self.floating_dns_manager.create_entry(dns_name, address,
|
||||
dns_type, dns_zone)
|
||||
def add_dns_entry(self, context, address, name, dns_type, domain):
|
||||
self.floating_dns_manager.create_entry(name, address,
|
||||
dns_type, domain)
|
||||
|
||||
@wrap_check_policy
|
||||
def modify_dns_entry(self, context, address, dns_name, dns_zone):
|
||||
self.floating_dns_manager.modify_address(dns_name, address,
|
||||
dns_zone)
|
||||
def modify_dns_entry(self, context, address, name, domain):
|
||||
self.floating_dns_manager.modify_address(name, address,
|
||||
domain)
|
||||
|
||||
@wrap_check_policy
|
||||
def delete_dns_entry(self, context, dns_name, dns_zone):
|
||||
self.floating_dns_manager.delete_entry(dns_name, dns_zone)
|
||||
def delete_dns_entry(self, context, name, domain):
|
||||
self.floating_dns_manager.delete_entry(name, domain)
|
||||
|
||||
def _delete_all_entries_for_ip(self, context, address):
|
||||
domain_list = self.get_dns_zones(context)
|
||||
domain_list = self.get_dns_domains(context)
|
||||
for domain in domain_list:
|
||||
names = self.get_dns_entries_by_address(context,
|
||||
address,
|
||||
@ -564,42 +565,42 @@ class FloatingIP(object):
|
||||
self.delete_dns_entry(context, name, domain['domain'])
|
||||
|
||||
@wrap_check_policy
|
||||
def get_dns_entries_by_address(self, context, address, dns_zone):
|
||||
def get_dns_entries_by_address(self, context, address, domain):
|
||||
return self.floating_dns_manager.get_entries_by_address(address,
|
||||
dns_zone)
|
||||
domain)
|
||||
|
||||
@wrap_check_policy
|
||||
def get_dns_entries_by_name(self, context, name, dns_zone):
|
||||
def get_dns_entries_by_name(self, context, name, domain):
|
||||
return self.floating_dns_manager.get_entries_by_name(name,
|
||||
dns_zone)
|
||||
domain)
|
||||
|
||||
@wrap_check_policy
|
||||
def create_private_dns_domain(self, context, fqdomain, zone):
|
||||
self.db.dnsdomain_register_for_zone(context, fqdomain, zone)
|
||||
def create_private_dns_domain(self, context, domain, av_zone):
|
||||
self.db.dnsdomain_register_for_zone(context, domain, av_zone)
|
||||
try:
|
||||
self.instance_dns_manager.create_domain(fqdomain)
|
||||
self.instance_dns_manager.create_domain(domain)
|
||||
except exception.FloatingIpDNSExists:
|
||||
LOG.warn(_('Domain |%(domain)s| already exists, '
|
||||
'changing zone to |%(zone)s|.'),
|
||||
{'domain': fqdomain, 'zone': zone})
|
||||
'changing zone to |%(av_zone)s|.'),
|
||||
{'domain': domain, 'av_zone': av_zone})
|
||||
|
||||
@wrap_check_policy
|
||||
def create_public_dns_domain(self, context, fqdomain, project):
|
||||
self.db.dnsdomain_register_for_project(context, fqdomain, project)
|
||||
def create_public_dns_domain(self, context, domain, project):
|
||||
self.db.dnsdomain_register_for_project(context, domain, project)
|
||||
try:
|
||||
self.floating_dns_manager.create_domain(fqdomain)
|
||||
self.floating_dns_manager.create_domain(domain)
|
||||
except exception.FloatingIpDNSExists:
|
||||
LOG.warn(_('Domain |%(domain)s| already exists, '
|
||||
'changing project to |%(project)s|.'),
|
||||
{'domain': fqdomain, 'project': project})
|
||||
{'domain': domain, 'project': project})
|
||||
|
||||
@wrap_check_policy
|
||||
def delete_dns_domain(self, context, fqdomain):
|
||||
self.db.dnsdomain_unregister(context, fqdomain)
|
||||
self.floating_dns_manager.delete_domain(fqdomain)
|
||||
def delete_dns_domain(self, context, domain):
|
||||
self.db.dnsdomain_unregister(context, domain)
|
||||
self.floating_dns_manager.delete_domain(domain)
|
||||
|
||||
def _get_project_for_domain(self, context, fqdomain):
|
||||
return self.db.dnsdomain_project(context, fqdomain)
|
||||
def _get_project_for_domain(self, context, domain):
|
||||
return self.db.dnsdomain_project(context, domain)
|
||||
|
||||
|
||||
class NetworkManager(manager.SchedulerDependentManager):
|
||||
@ -629,7 +630,7 @@ class NetworkManager(manager.SchedulerDependentManager):
|
||||
self.driver = utils.import_object(network_driver)
|
||||
temp = utils.import_object(FLAGS.instance_dns_manager)
|
||||
self.instance_dns_manager = temp
|
||||
self.instance_dns_domain = FLAGS.instance_dns_zone
|
||||
self.instance_dns_domain = FLAGS.instance_dns_domain
|
||||
temp = utils.import_object(FLAGS.floating_ip_dns_manager)
|
||||
self.floating_dns_manager = temp
|
||||
self.network_api = network_api.API()
|
||||
|
@ -41,7 +41,7 @@ class MiniDNS(object):
|
||||
f.write("# minidns\n\n\n")
|
||||
f.close()
|
||||
|
||||
def get_zones(self):
|
||||
def get_domains(self):
|
||||
entries = []
|
||||
infile = open(self.filename, 'r')
|
||||
for line in infile:
|
||||
@ -51,26 +51,26 @@ class MiniDNS(object):
|
||||
infile.close()
|
||||
return entries
|
||||
|
||||
def qualify(self, name, zone):
|
||||
if zone:
|
||||
qualified = "%s.%s" % (name, zone)
|
||||
def qualify(self, name, domain):
|
||||
if domain:
|
||||
qualified = "%s.%s" % (name, domain)
|
||||
else:
|
||||
qualified = name
|
||||
|
||||
return qualified
|
||||
|
||||
def create_entry(self, name, address, type, dnszone):
|
||||
def create_entry(self, name, address, type, domain):
|
||||
|
||||
if type.lower() != 'a':
|
||||
raise exception.InvalidInput(_("This driver only supports "
|
||||
"type 'a'"))
|
||||
|
||||
if self.get_entries_by_name(name, dnszone):
|
||||
raise exception.FloatingIpDNSExists(name=name, zone=dnszone)
|
||||
if self.get_entries_by_name(name, domain):
|
||||
raise exception.FloatingIpDNSExists(name=name, domain=domain)
|
||||
|
||||
outfile = open(self.filename, 'a+')
|
||||
outfile.write("%s %s %s\n" %
|
||||
(address, self.qualify(name, dnszone), type))
|
||||
(address, self.qualify(name, domain), type))
|
||||
outfile.close()
|
||||
|
||||
def parse_line(self, line):
|
||||
@ -88,14 +88,14 @@ class MiniDNS(object):
|
||||
entry['domain'] = entry['name'].partition('.')[2]
|
||||
return entry
|
||||
|
||||
def delete_entry(self, name, dnszone=""):
|
||||
def delete_entry(self, name, domain):
|
||||
deleted = False
|
||||
infile = open(self.filename, 'r')
|
||||
outfile = tempfile.NamedTemporaryFile('w', delete=False)
|
||||
for line in infile:
|
||||
entry = self.parse_line(line)
|
||||
if ((not entry) or
|
||||
entry['name'] != self.qualify(name, dnszone).lower()):
|
||||
entry['name'] != self.qualify(name, domain).lower()):
|
||||
outfile.write(line)
|
||||
else:
|
||||
deleted = True
|
||||
@ -105,9 +105,9 @@ class MiniDNS(object):
|
||||
if not deleted:
|
||||
raise exception.NotFound
|
||||
|
||||
def modify_address(self, name, address, dnszone):
|
||||
def modify_address(self, name, address, domain):
|
||||
|
||||
if not self.get_entries_by_name(name, dnszone):
|
||||
if not self.get_entries_by_name(name, domain):
|
||||
raise exception.NotFound
|
||||
|
||||
infile = open(self.filename, 'r')
|
||||
@ -115,34 +115,34 @@ class MiniDNS(object):
|
||||
for line in infile:
|
||||
entry = self.parse_line(line)
|
||||
if (entry and
|
||||
entry['name'].lower() == self.qualify(name, dnszone).lower()):
|
||||
entry['name'].lower() == self.qualify(name, domain).lower()):
|
||||
outfile.write("%s %s %s\n" %
|
||||
(address, self.qualify(name, dnszone), entry['type']))
|
||||
(address, self.qualify(name, domain), entry['type']))
|
||||
else:
|
||||
outfile.write(line)
|
||||
infile.close()
|
||||
outfile.close()
|
||||
shutil.move(outfile.name, self.filename)
|
||||
|
||||
def get_entries_by_address(self, address, dnszone=""):
|
||||
def get_entries_by_address(self, address, domain=""):
|
||||
entries = []
|
||||
infile = open(self.filename, 'r')
|
||||
for line in infile:
|
||||
entry = self.parse_line(line)
|
||||
if entry and entry['address'].lower() == address.lower():
|
||||
if entry['name'].lower().endswith(dnszone.lower()):
|
||||
domain_index = entry['name'].lower().find(dnszone.lower())
|
||||
if entry['name'].lower().endswith(domain.lower()):
|
||||
domain_index = entry['name'].lower().find(domain.lower())
|
||||
entries.append(entry['name'][0:domain_index - 1])
|
||||
infile.close()
|
||||
return entries
|
||||
|
||||
def get_entries_by_name(self, name, dnszone=""):
|
||||
def get_entries_by_name(self, name, domain=""):
|
||||
entries = []
|
||||
infile = open(self.filename, 'r')
|
||||
for line in infile:
|
||||
entry = self.parse_line(line)
|
||||
if (entry and
|
||||
entry['name'].lower() == self.qualify(name, dnszone).lower()):
|
||||
entry['name'].lower() == self.qualify(name, domain).lower()):
|
||||
entries.append(entry['address'])
|
||||
infile.close()
|
||||
return entries
|
||||
@ -152,7 +152,7 @@ class MiniDNS(object):
|
||||
|
||||
def create_domain(self, fqdomain):
|
||||
if self.get_entries_by_name(fqdomain, ''):
|
||||
raise exception.FloatingIpDNSExists(name=fqdomain, zone='')
|
||||
raise exception.FloatingIpDNSExists(name=fqdomain, domain='')
|
||||
|
||||
outfile = open(self.filename, 'a+')
|
||||
outfile.write("%s %s %s\n" %
|
||||
|
@ -31,19 +31,19 @@ name2 = "anotherarbitraryname"
|
||||
testaddress = '10.0.0.66'
|
||||
testaddress2 = '10.0.0.67'
|
||||
|
||||
zone = "example.org"
|
||||
zone2 = "example.net"
|
||||
domain = "example.org"
|
||||
domain2 = "example.net"
|
||||
floating_ip_id = '1'
|
||||
|
||||
|
||||
def _quote_zone(zone):
|
||||
def _quote_domain(domain):
|
||||
"""
|
||||
Zone names tend to have .'s in them. Urllib doesn't quote dots,
|
||||
Domain names tend to have .'s in them. Urllib doesn't quote dots,
|
||||
but Routes tends to choke on them, so we need an extra level of
|
||||
by-hand quoting here. This function needs to duplicate the one in
|
||||
python-novaclient/novaclient/v1_1/floating_ip_dns.py
|
||||
"""
|
||||
return urllib.quote(zone.replace('.', '%2E'))
|
||||
return urllib.quote(domain.replace('.', '%2E'))
|
||||
|
||||
|
||||
def network_api_get_floating_ip(self, context, id):
|
||||
@ -51,7 +51,7 @@ def network_api_get_floating_ip(self, context, id):
|
||||
'fixed_ip': None}
|
||||
|
||||
|
||||
def network_get_dns_zones(self, context):
|
||||
def network_get_dns_domains(self, context):
|
||||
return [{'domain': 'example.org', 'scope': 'public'},
|
||||
{'domain': 'example.com', 'scope': 'public',
|
||||
'project': 'project1'},
|
||||
@ -59,25 +59,25 @@ def network_get_dns_zones(self, context):
|
||||
'availability_zone': 'avzone'}]
|
||||
|
||||
|
||||
def network_get_dns_entries_by_address(self, context, address, zone):
|
||||
def network_get_dns_entries_by_address(self, context, address, domain):
|
||||
return [name, name2]
|
||||
|
||||
|
||||
def network_get_dns_entries_by_name(self, context, address, zone):
|
||||
def network_get_dns_entries_by_name(self, context, address, domain):
|
||||
return [testaddress]
|
||||
|
||||
|
||||
def network_add_dns_entry(self, context, address, name, dns_type, zone):
|
||||
def network_add_dns_entry(self, context, address, name, dns_type, domain):
|
||||
return {'dns_entry': {'ip': testaddress,
|
||||
'name': name,
|
||||
'type': dns_type,
|
||||
'zone': zone}}
|
||||
'domain': domain}}
|
||||
|
||||
|
||||
def network_modify_dns_entry(self, context, address, name, zone):
|
||||
def network_modify_dns_entry(self, context, address, name, domain):
|
||||
return {'dns_entry': {'name': name,
|
||||
'ip': address,
|
||||
'zone': zone}}
|
||||
'domain': domain}}
|
||||
|
||||
|
||||
class FloatingIpDNSTest(test.TestCase):
|
||||
@ -93,8 +93,8 @@ class FloatingIpDNSTest(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(FloatingIpDNSTest, self).setUp()
|
||||
self.stubs.Set(network.api.API, "get_dns_zones",
|
||||
network_get_dns_zones)
|
||||
self.stubs.Set(network.api.API, "get_dns_domains",
|
||||
network_get_dns_domains)
|
||||
self.stubs.Set(network.api.API, "get_dns_entries_by_address",
|
||||
network_get_dns_entries_by_address)
|
||||
self.stubs.Set(network.api.API, "get_dns_entries_by_name",
|
||||
@ -117,10 +117,10 @@ class FloatingIpDNSTest(test.TestCase):
|
||||
self._delete_floating_ip()
|
||||
super(FloatingIpDNSTest, self).tearDown()
|
||||
|
||||
def test_dns_zones_list(self):
|
||||
def test_dns_domains_list(self):
|
||||
req = fakes.HTTPRequest.blank('/v2/123/os-floating-ip-dns')
|
||||
res_dict = self.domain_controller.index(req)
|
||||
entries = res_dict['zone_entries']
|
||||
entries = res_dict['domain_entries']
|
||||
self.assertTrue(entries)
|
||||
self.assertEqual(entries[0]['domain'], "example.org")
|
||||
self.assertFalse(entries[0]['project'])
|
||||
@ -137,27 +137,27 @@ class FloatingIpDNSTest(test.TestCase):
|
||||
params = "?%s" % urllib.urlencode(qparams) if qparams else ""
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/123/os-floating-ip-dns/%s/entries%s'
|
||||
% (_quote_zone(zone), params))
|
||||
entries = self.entry_controller.index(req, _quote_zone(zone))
|
||||
% (_quote_domain(domain), params))
|
||||
entries = self.entry_controller.index(req, _quote_domain(domain))
|
||||
|
||||
self.assertEqual(len(entries['dns_entries']), 2)
|
||||
self.assertEqual(entries['dns_entries'][0]['name'],
|
||||
name)
|
||||
self.assertEqual(entries['dns_entries'][1]['name'],
|
||||
name2)
|
||||
self.assertEqual(entries['dns_entries'][0]['zone'],
|
||||
zone)
|
||||
self.assertEqual(entries['dns_entries'][0]['domain'],
|
||||
domain)
|
||||
|
||||
def test_get_dns_entries_by_name(self):
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v2/123/os-floating-ip-dns/%s/entries/%s' %
|
||||
(_quote_zone(zone), name))
|
||||
entry = self.entry_controller.show(req, _quote_zone(zone), name)
|
||||
(_quote_domain(domain), name))
|
||||
entry = self.entry_controller.show(req, _quote_domain(domain), name)
|
||||
|
||||
self.assertEqual(entry['dns_entry']['ip'],
|
||||
testaddress)
|
||||
self.assertEqual(entry['dns_entry']['zone'],
|
||||
zone)
|
||||
self.assertEqual(entry['dns_entry']['domain'],
|
||||
domain)
|
||||
|
||||
def test_create_entry(self):
|
||||
body = {'dns_entry':
|
||||
@ -165,43 +165,43 @@ class FloatingIpDNSTest(test.TestCase):
|
||||
'dns_type': 'A'}}
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v2/123/os-floating-ip-dns/%s/entries/%s' %
|
||||
(_quote_zone(zone), name))
|
||||
entry = self.entry_controller.update(req, _quote_zone(zone),
|
||||
(_quote_domain(domain), name))
|
||||
entry = self.entry_controller.update(req, _quote_domain(domain),
|
||||
name, body)
|
||||
self.assertEqual(entry['dns_entry']['ip'], testaddress)
|
||||
|
||||
def test_create_domain(self):
|
||||
req = fakes.HTTPRequest.blank('/v2/123/os-floating-ip-dns/%s' %
|
||||
_quote_zone(zone))
|
||||
body = {'zone_entry':
|
||||
_quote_domain(domain))
|
||||
body = {'domain_entry':
|
||||
{'scope': 'private',
|
||||
'project': 'testproject'}}
|
||||
self.assertRaises(webob.exc.HTTPUnprocessableEntity,
|
||||
self.domain_controller.update,
|
||||
req, _quote_zone(zone), body)
|
||||
req, _quote_domain(domain), body)
|
||||
|
||||
body = {'zone_entry':
|
||||
body = {'domain_entry':
|
||||
{'scope': 'public',
|
||||
'availability_zone': 'zone1'}}
|
||||
self.assertRaises(webob.exc.HTTPUnprocessableEntity,
|
||||
self.domain_controller.update,
|
||||
req, _quote_zone(zone), body)
|
||||
req, _quote_domain(domain), body)
|
||||
|
||||
body = {'zone_entry':
|
||||
body = {'domain_entry':
|
||||
{'scope': 'public',
|
||||
'project': 'testproject'}}
|
||||
entry = self.domain_controller.update(req, _quote_zone(zone), body)
|
||||
self.assertEqual(entry['zone_entry']['domain'], zone)
|
||||
self.assertEqual(entry['zone_entry']['scope'], 'public')
|
||||
self.assertEqual(entry['zone_entry']['project'], 'testproject')
|
||||
entry = self.domain_controller.update(req, _quote_domain(domain), body)
|
||||
self.assertEqual(entry['domain_entry']['domain'], domain)
|
||||
self.assertEqual(entry['domain_entry']['scope'], 'public')
|
||||
self.assertEqual(entry['domain_entry']['project'], 'testproject')
|
||||
|
||||
body = {'zone_entry':
|
||||
body = {'domain_entry':
|
||||
{'scope': 'private',
|
||||
'availability_zone': 'zone1'}}
|
||||
entry = self.domain_controller.update(req, _quote_zone(zone), body)
|
||||
self.assertEqual(entry['zone_entry']['domain'], zone)
|
||||
self.assertEqual(entry['zone_entry']['scope'], 'private')
|
||||
self.assertEqual(entry['zone_entry']['availability_zone'], 'zone1')
|
||||
entry = self.domain_controller.update(req, _quote_domain(domain), body)
|
||||
self.assertEqual(entry['domain_entry']['domain'], domain)
|
||||
self.assertEqual(entry['domain_entry']['scope'], 'private')
|
||||
self.assertEqual(entry['domain_entry']['availability_zone'], 'zone1')
|
||||
|
||||
def test_delete_entry(self):
|
||||
self.called = False
|
||||
@ -218,11 +218,12 @@ class FloatingIpDNSTest(test.TestCase):
|
||||
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v2/123/os-floating-ip-dns/%s/entries/%s' %
|
||||
(_quote_zone(zone), name))
|
||||
entries = self.entry_controller.delete(req, _quote_zone(zone), name)
|
||||
(_quote_domain(domain), name))
|
||||
entries = self.entry_controller.delete(req, _quote_domain(domain),
|
||||
name)
|
||||
|
||||
self.assertTrue(self.called)
|
||||
self.assertEquals(self.deleted_domain, zone)
|
||||
self.assertEquals(self.deleted_domain, domain)
|
||||
self.assertEquals(self.deleted_name, name)
|
||||
|
||||
def test_delete_domain(self):
|
||||
@ -238,49 +239,49 @@ class FloatingIpDNSTest(test.TestCase):
|
||||
network_delete_dns_domain)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/123/os-floating-ip-dns/%s' %
|
||||
_quote_zone(zone))
|
||||
entries = self.domain_controller.delete(req, _quote_zone(zone))
|
||||
_quote_domain(domain))
|
||||
entries = self.domain_controller.delete(req, _quote_domain(domain))
|
||||
|
||||
self.assertTrue(self.called)
|
||||
self.assertEquals(self.deleted_domain, zone)
|
||||
self.assertEquals(self.deleted_domain, domain)
|
||||
|
||||
def test_modify(self):
|
||||
body = {'dns_entry':
|
||||
{'ip': testaddress2,
|
||||
'dns_type': 'A'}}
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v2/123/os-floating-ip-dns/%s/entries/%s' % (zone, name))
|
||||
entry = self.entry_controller.update(req, zone, name, body)
|
||||
'/v2/123/os-floating-ip-dns/%s/entries/%s' % (domain, name))
|
||||
entry = self.entry_controller.update(req, domain, name, body)
|
||||
|
||||
self.assertEqual(entry['dns_entry']['ip'], testaddress2)
|
||||
|
||||
|
||||
class FloatingIpDNSSerializerTest(test.TestCase):
|
||||
def test_zones_serializer(self):
|
||||
serializer = floating_ip_dns.ZonesTemplate()
|
||||
def test_domains(self):
|
||||
serializer = floating_ip_dns.DomainsTemplate()
|
||||
text = serializer.serialize(dict(
|
||||
zone_entries=[
|
||||
dict(zone=zone, scope='public', project='testproject'),
|
||||
dict(zone=zone2, scope='private',
|
||||
domain_entries=[
|
||||
dict(domain=domain, scope='public', project='testproject'),
|
||||
dict(domain=domain2, scope='private',
|
||||
availability_zone='avzone')]))
|
||||
|
||||
tree = etree.fromstring(text)
|
||||
self.assertEqual('zone_entries', tree.tag)
|
||||
self.assertEqual('domain_entries', tree.tag)
|
||||
self.assertEqual(2, len(tree))
|
||||
self.assertEqual(zone, tree[0].get('zone'))
|
||||
self.assertEqual(zone2, tree[1].get('zone'))
|
||||
self.assertEqual(domain, tree[0].get('domain'))
|
||||
self.assertEqual(domain2, tree[1].get('domain'))
|
||||
self.assertEqual('avzone', tree[1].get('availability_zone'))
|
||||
|
||||
def test_zone_serializer(self):
|
||||
serializer = floating_ip_dns.ZoneTemplate()
|
||||
def test_domain_serializer(self):
|
||||
serializer = floating_ip_dns.DomainTemplate()
|
||||
text = serializer.serialize(dict(
|
||||
zone_entry=dict(zone=zone,
|
||||
scope='public',
|
||||
project='testproject')))
|
||||
domain_entry=dict(domain=domain,
|
||||
scope='public',
|
||||
project='testproject')))
|
||||
|
||||
tree = etree.fromstring(text)
|
||||
self.assertEqual('zone_entry', tree.tag)
|
||||
self.assertEqual(zone, tree.get('zone'))
|
||||
self.assertEqual('domain_entry', tree.tag)
|
||||
self.assertEqual(domain, tree.get('domain'))
|
||||
self.assertEqual('testproject', tree.get('project'))
|
||||
|
||||
def test_entries_serializer(self):
|
||||
@ -289,11 +290,11 @@ class FloatingIpDNSSerializerTest(test.TestCase):
|
||||
dns_entries=[
|
||||
dict(ip=testaddress,
|
||||
type='A',
|
||||
zone=zone,
|
||||
domain=domain,
|
||||
name=name),
|
||||
dict(ip=testaddress2,
|
||||
type='C',
|
||||
zone=zone,
|
||||
domain=domain,
|
||||
name=name2)]))
|
||||
|
||||
tree = etree.fromstring(text)
|
||||
@ -303,11 +304,11 @@ class FloatingIpDNSSerializerTest(test.TestCase):
|
||||
self.assertEqual('dns_entry', tree[1].tag)
|
||||
self.assertEqual(testaddress, tree[0].get('ip'))
|
||||
self.assertEqual('A', tree[0].get('type'))
|
||||
self.assertEqual(zone, tree[0].get('zone'))
|
||||
self.assertEqual(domain, tree[0].get('domain'))
|
||||
self.assertEqual(name, tree[0].get('name'))
|
||||
self.assertEqual(testaddress2, tree[1].get('ip'))
|
||||
self.assertEqual('C', tree[1].get('type'))
|
||||
self.assertEqual(zone, tree[1].get('zone'))
|
||||
self.assertEqual(domain, tree[1].get('domain'))
|
||||
self.assertEqual(name2, tree[1].get('name'))
|
||||
|
||||
def test_entry_serializer(self):
|
||||
@ -316,12 +317,12 @@ class FloatingIpDNSSerializerTest(test.TestCase):
|
||||
dns_entry=dict(
|
||||
ip=testaddress,
|
||||
type='A',
|
||||
zone=zone,
|
||||
domain=domain,
|
||||
name=name)))
|
||||
|
||||
tree = etree.fromstring(text)
|
||||
|
||||
self.assertEqual('dns_entry', tree.tag)
|
||||
self.assertEqual(testaddress, tree.get('ip'))
|
||||
self.assertEqual(zone, tree.get('zone'))
|
||||
self.assertEqual(domain, tree.get('domain'))
|
||||
self.assertEqual(name, tree.get('name'))
|
||||
|
@ -117,7 +117,7 @@
|
||||
"network:add_network_to_project": [],
|
||||
"network:get_instance_nw_info": [],
|
||||
|
||||
"network:get_dns_zones": [],
|
||||
"network:get_dns_domains": [],
|
||||
"network:add_dns_entry": [],
|
||||
"network:modify_dns_entry": [],
|
||||
"network:delete_dns_entry": [],
|
||||
|
@ -1340,7 +1340,7 @@ class FloatingIPTestCase(test.TestCase):
|
||||
self.network.create_public_dns_domain(context_admin, domain2,
|
||||
'fakeproject')
|
||||
|
||||
domains = self.network.get_dns_zones(self.context)
|
||||
domains = self.network.get_dns_domains(self.context)
|
||||
self.assertEquals(len(domains), 2)
|
||||
self.assertEquals(domains[0]['domain'], domain1)
|
||||
self.assertEquals(domains[1]['domain'], domain2)
|
||||
@ -1377,7 +1377,7 @@ class FloatingIPTestCase(test.TestCase):
|
||||
{'domain': 'example.com', 'scope': 'public'},
|
||||
{'domain': 'test.example.org', 'scope': 'public'}]
|
||||
|
||||
self.stubs.Set(self.network, 'get_dns_zones', fake_domains)
|
||||
self.stubs.Set(self.network, 'get_dns_domains', fake_domains)
|
||||
|
||||
context_admin = context.RequestContext('testuser', 'testproject',
|
||||
is_admin=True)
|
||||
@ -1387,7 +1387,7 @@ class FloatingIPTestCase(test.TestCase):
|
||||
self.network.create_public_dns_domain(context_admin, domain2,
|
||||
'fakeproject')
|
||||
|
||||
domains = self.network.get_dns_zones(self.context)
|
||||
domains = self.network.get_dns_domains(self.context)
|
||||
for domain in domains:
|
||||
self.network.add_dns_entry(self.context, address,
|
||||
name1, "A", domain['domain'])
|
||||
@ -1469,7 +1469,7 @@ class InstanceDNSTestCase(test.TestCase):
|
||||
domain1, zone1)
|
||||
|
||||
self.network.create_private_dns_domain(context_admin, domain1, zone1)
|
||||
domains = self.network.get_dns_zones(self.context)
|
||||
domains = self.network.get_dns_domains(self.context)
|
||||
self.assertEquals(len(domains), 1)
|
||||
self.assertEquals(domains[0]['domain'], domain1)
|
||||
self.assertEquals(domains[0]['availability_zone'], zone1)
|
||||
@ -1480,8 +1480,8 @@ class InstanceDNSTestCase(test.TestCase):
|
||||
self.network.delete_dns_domain(context_admin, domain1)
|
||||
|
||||
|
||||
zone1 = "example.org"
|
||||
zone2 = "example.com"
|
||||
domain1 = "example.org"
|
||||
domain2 = "example.com"
|
||||
|
||||
|
||||
class LdapDNSTestCase(test.TestCase):
|
||||
@ -1490,48 +1490,48 @@ class LdapDNSTestCase(test.TestCase):
|
||||
super(LdapDNSTestCase, self).setUp()
|
||||
temp = utils.import_object('nova.network.ldapdns.FakeLdapDNS')
|
||||
self.driver = temp
|
||||
self.driver.create_domain(zone1)
|
||||
self.driver.create_domain(zone2)
|
||||
self.driver.create_domain(domain1)
|
||||
self.driver.create_domain(domain2)
|
||||
|
||||
def tearDown(self):
|
||||
super(LdapDNSTestCase, self).tearDown()
|
||||
self.driver.delete_domain(zone1)
|
||||
self.driver.delete_domain(zone2)
|
||||
self.driver.delete_domain(domain1)
|
||||
self.driver.delete_domain(domain2)
|
||||
|
||||
def test_ldap_dns_zones(self):
|
||||
flags.FLAGS.floating_ip_dns_zones = [zone1, zone2]
|
||||
def test_ldap_dns_domains(self):
|
||||
flags.FLAGS.floating_ip_dns_domains = [domain1, domain2]
|
||||
|
||||
zones = self.driver.get_zones()
|
||||
self.assertEqual(len(zones), 2)
|
||||
self.assertEqual(zones[0], zone1)
|
||||
self.assertEqual(zones[1], zone2)
|
||||
domains = self.driver.get_domains()
|
||||
self.assertEqual(len(domains), 2)
|
||||
self.assertEqual(domains[0], domain1)
|
||||
self.assertEqual(domains[1], domain2)
|
||||
|
||||
def test_ldap_dns_create_conflict(self):
|
||||
address1 = "10.10.10.11"
|
||||
name1 = "foo"
|
||||
name2 = "bar"
|
||||
|
||||
self.driver.create_entry(name1, address1, "A", zone1)
|
||||
self.driver.create_entry(name1, address1, "A", domain1)
|
||||
|
||||
self.assertRaises(exception.FloatingIpDNSExists,
|
||||
self.driver.create_entry,
|
||||
name1, address1, "A", zone1)
|
||||
name1, address1, "A", domain1)
|
||||
|
||||
def test_ldap_dns_create_and_get(self):
|
||||
address1 = "10.10.10.11"
|
||||
name1 = "foo"
|
||||
name2 = "bar"
|
||||
entries = self.driver.get_entries_by_address(address1, zone1)
|
||||
entries = self.driver.get_entries_by_address(address1, domain1)
|
||||
self.assertFalse(entries)
|
||||
|
||||
self.driver.create_entry(name1, address1, "A", zone1)
|
||||
self.driver.create_entry(name2, address1, "A", zone1)
|
||||
entries = self.driver.get_entries_by_address(address1, zone1)
|
||||
self.driver.create_entry(name1, address1, "A", domain1)
|
||||
self.driver.create_entry(name2, address1, "A", domain1)
|
||||
entries = self.driver.get_entries_by_address(address1, domain1)
|
||||
self.assertEquals(len(entries), 2)
|
||||
self.assertEquals(entries[0], name1)
|
||||
self.assertEquals(entries[1], name2)
|
||||
|
||||
entries = self.driver.get_entries_by_name(name1, zone1)
|
||||
entries = self.driver.get_entries_by_name(name1, domain1)
|
||||
self.assertEquals(len(entries), 1)
|
||||
self.assertEquals(entries[0], address1)
|
||||
|
||||
@ -1540,17 +1540,17 @@ class LdapDNSTestCase(test.TestCase):
|
||||
name1 = "foo"
|
||||
name2 = "bar"
|
||||
|
||||
self.driver.create_entry(name1, address1, "A", zone1)
|
||||
self.driver.create_entry(name2, address1, "A", zone1)
|
||||
entries = self.driver.get_entries_by_address(address1, zone1)
|
||||
self.driver.create_entry(name1, address1, "A", domain1)
|
||||
self.driver.create_entry(name2, address1, "A", domain1)
|
||||
entries = self.driver.get_entries_by_address(address1, domain1)
|
||||
self.assertEquals(len(entries), 2)
|
||||
|
||||
self.driver.delete_entry(name1, zone1)
|
||||
entries = self.driver.get_entries_by_address(address1, zone1)
|
||||
self.driver.delete_entry(name1, domain1)
|
||||
entries = self.driver.get_entries_by_address(address1, domain1)
|
||||
LOG.debug("entries: %s" % entries)
|
||||
self.assertEquals(len(entries), 1)
|
||||
self.assertEquals(entries[0], name2)
|
||||
|
||||
self.assertRaises(exception.NotFound,
|
||||
self.driver.delete_entry,
|
||||
name1, zone1)
|
||||
name1, domain1)
|
||||
|
Loading…
Reference in New Issue
Block a user