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