Browse Source

Added designate-dashboard code to contrib/designate-dashboard

Added to devstack as well.

Change-Id: I98eed46a8dd9918ba36c97fe40619ec42136c723
changes/37/193237/1
Graham Hayes 7 years ago
commit
561f3590a0
  1. 17
      CONTRIBUTING.rst
  2. 4
      HACKING.rst
  3. 175
      LICENSE
  4. 6
      MANIFEST.in
  5. 19
      README.rst
  6. 1
      babel.cfg
  7. 19
      designatedashboard/__init__.py
  8. 1
      designatedashboard/api/__init__.py
  9. 161
      designatedashboard/api/designate.py
  10. 0
      designatedashboard/dashboards/__init__.py
  11. 0
      designatedashboard/dashboards/project/__init__.py
  12. 0
      designatedashboard/dashboards/project/dns_domains/__init__.py
  13. 519
      designatedashboard/dashboards/project/dns_domains/forms.py
  14. 26
      designatedashboard/dashboards/project/dns_domains/panel.py
  15. 193
      designatedashboard/dashboards/project/dns_domains/tables.py
  16. 38
      designatedashboard/dashboards/project/dns_domains/templates/dns_domains/_create_domain.html
  17. 21
      designatedashboard/dashboards/project/dns_domains/templates/dns_domains/_create_record.html
  18. 36
      designatedashboard/dashboards/project/dns_domains/templates/dns_domains/_update_domain.html
  19. 21
      designatedashboard/dashboards/project/dns_domains/templates/dns_domains/_update_record.html
  20. 11
      designatedashboard/dashboards/project/dns_domains/templates/dns_domains/create_domain.html
  21. 11
      designatedashboard/dashboards/project/dns_domains/templates/dns_domains/create_record.html
  22. 11
      designatedashboard/dashboards/project/dns_domains/templates/dns_domains/index.html
  23. 32
      designatedashboard/dashboards/project/dns_domains/templates/dns_domains/records.html
  24. 11
      designatedashboard/dashboards/project/dns_domains/templates/dns_domains/update_domain.html
  25. 11
      designatedashboard/dashboards/project/dns_domains/templates/dns_domains/update_record.html
  26. 447
      designatedashboard/dashboards/project/dns_domains/tests.py
  27. 44
      designatedashboard/dashboards/project/dns_domains/urls.py
  28. 181
      designatedashboard/dashboards/project/dns_domains/views.py
  29. 21
      designatedashboard/exceptions.py
  30. 1
      designatedashboard/tests/.secret_key_store
  31. 0
      designatedashboard/tests/__init__.py
  32. 53
      designatedashboard/tests/base.py
  33. 133
      designatedashboard/tests/settings.py
  34. 448
      designatedashboard/tests/test_designatedashboard.py
  35. 75
      doc/source/conf.py
  36. 4
      doc/source/contributing.rst
  37. 24
      doc/source/index.rst
  38. 12
      doc/source/installation.rst
  39. 1
      doc/source/readme.rst
  40. 7
      doc/source/usage.rst
  41. 20
      enabled/_70_dns_add_group.py
  42. 26
      enabled/_71_dns_project.py
  43. 6
      openstack-common.conf
  44. 7
      requirements.txt
  45. 46
      setup.cfg
  46. 22
      setup.py
  47. BIN
      test
  48. 14
      test-requirements.txt
  49. 34
      tox.ini

17
CONTRIBUTING.rst

@ -0,0 +1,17 @@
If you would like to contribute to the development of OpenStack,
you must follow the steps in the "If you're a developer, start here"
section of this page:
http://wiki.openstack.org/HowToContribute
Once those steps have been completed, changes to OpenStack
should be submitted for review via the Gerrit tool, following
the workflow documented at:
http://wiki.openstack.org/GerritWorkflow
Pull requests submitted through GitHub will be ignored.
Bugs should be filed on Launchpad, not GitHub:
https://bugs.launchpad.net/designatedashboard

4
HACKING.rst

@ -0,0 +1,4 @@
designatedashboard Style Commandments
===============================================
Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/

175
LICENSE

@ -0,0 +1,175 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

6
MANIFEST.in

@ -0,0 +1,6 @@
include AUTHORS
include ChangeLog
exclude .gitignore
exclude .gitreview
global-exclude *.pyc

19
README.rst

@ -0,0 +1,19 @@
===============================
designatedashboard
===============================
Designate Horizon UI bits
* Free software: Apache license
Features
--------
* TODO
Howto
-----
1. Clone Horizon UI folder
2. Symlink enabled/* files to openstack_dashboard/local/enabled folder and run horizon!

1
babel.cfg

@ -0,0 +1 @@
[python: **.py]

19
designatedashboard/__init__.py

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import pbr.version
__version__ = pbr.version.VersionInfo(
'designatedashboard').version_string()

1
designatedashboard/api/__init__.py

@ -0,0 +1 @@
from designatedashboard.api import designate # noqa

161
designatedashboard/api/designate.py

@ -0,0 +1,161 @@
# Copyright 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import absolute_import
from horizon import exceptions
import logging
from designateclient.v1 import Client # noqa
from designateclient.v1.domains import Domain # noqa
from designateclient.v1.records import Record # noqa
from openstack_dashboard.api.base import url_for # noqa
LOG = logging.getLogger(__name__)
def designateclient(request):
designate_url = ""
try:
designate_url = url_for(request, 'dns')
except exceptions.ServiceCatalogException:
LOG.debug('no dns service configured.')
return None
LOG.debug('designateclient connection created using token "%s"'
'and url "%s"' % (request.user.token.id, designate_url))
return Client(endpoint=designate_url,
token=request.user.token.id,
username=request.user.username,
tenant_id=request.user.project_id)
def domain_get(request, domain_id):
d_client = designateclient(request)
if d_client is None:
return []
return d_client.domains.get(domain_id)
def domain_list(request):
d_client = designateclient(request)
if d_client is None:
return []
return d_client.domains.list()
def domain_create(request, name, email, ttl=None, description=None):
d_client = designateclient(request)
if d_client is None:
return None
options = {
'description': description,
}
# TTL needs to be optionally added as argument because the client
# won't accept a None value
if ttl is not None:
options['ttl'] = ttl
domain = Domain(name=name, email=email, **options)
return d_client.domains.create(domain)
def domain_update(request, domain_id, email, ttl, description=None):
d_client = designateclient(request)
if d_client is None:
return None
# A quirk of the designate client is that you need to start with a
# base record and then update individual fields in order to persist
# the data. The designate client will only send the 'changed' fields.
domain = Domain(id=domain_id, name='', email='')
domain.email = email
domain.ttl = ttl
domain.description = description
return d_client.domains.update(domain)
def domain_delete(request, domain_id):
d_client = designateclient(request)
if d_client is None:
return []
return d_client.domains.delete(domain_id)
def server_list(request, domain_id):
d_client = designateclient(request)
if d_client is None:
return []
return d_client.domains.list_domain_servers(domain_id)
def record_list(request, domain_id):
d_client = designateclient(request)
if d_client is None:
return []
return d_client.records.list(domain_id)
def record_get(request, domain_id, record_id):
d_client = designateclient(request)
if d_client is None:
return []
return d_client.records.get(domain_id, record_id)
def record_delete(request, domain_id, record_id):
d_client = designateclient(request)
if d_client is None:
return []
return d_client.records.delete(domain_id, record_id)
def record_create(request, domain_id, **kwargs):
d_client = designateclient(request)
if d_client is None:
return []
record = Record(**kwargs)
return d_client.records.create(domain_id, record)
def record_update(request, domain_id, record_id, **kwargs):
d_client = designateclient(request)
if d_client is None:
return []
# A quirk of the designate client is that you need to start with a
# base record and then update individual fields in order to persist
# the data. The designate client will only send the 'changed' fields.
record = Record(
id=record_id,
type='A',
name='',
data='')
record.type = kwargs.get('type', None)
record.name = kwargs.get('name', None)
record.data = kwargs.get('data', None)
record.priority = kwargs.get('priority', None)
record.ttl = kwargs.get('ttl', None)
record.description = kwargs.get('description', None)
return d_client.records.update(domain_id, record)

0
designatedashboard/dashboards/__init__.py

0
designatedashboard/dashboards/project/__init__.py

0
designatedashboard/dashboards/project/dns_domains/__init__.py

519
designatedashboard/dashboards/project/dns_domains/forms.py

@ -0,0 +1,519 @@
# Copyright 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import logging
import re
from django.core.exceptions import ValidationError # noqa
from django.core import validators
from django.utils.translation import ugettext_lazy as _
from horizon import forms
from horizon import messages
from designatedashboard import api
from designateclient import exceptions as designate_exceptions
LOG = logging.getLogger(__name__)
MAX_TTL = 2147483647
# These regexes were given to me by Kiall Mac Innes here:
# https://gerrit.hpcloud.net/#/c/25300/2/
DOMAIN_NAME_REGEX = r'^(?!.{255,})(?:(?!\-)[A-Za-z0-9_\-]{1,63}(?<!\-)\.)+$'
WILDCARD_DOMAIN_NAME_REGEX = r'^(?!.{255,})(?:(^\*|(?!\-)[A-Za-z0-9_\-]{1,63})(?<!\-)\.)+$' # noqa
SRV_NAME_REGEX = r'^(?:_[A-Za-z0-9_\-]{1,62}\.){2}'
SRV_DATA_REGEX = r'^(?:(?:6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{1,3}|[0-9])\s){2}(?!.{255,})((?!\-)[A-Za-z0-9_\-]{1,63}(?<!\-)\.)+$' # noqa
class DomainForm(forms.SelfHandlingForm):
'''Base class for DomainCreate and DomainUpdate forms.
Sets-up all of the common form fields.
'''
name = forms.RegexField(
label=_("Domain Name"),
regex=DOMAIN_NAME_REGEX,
error_messages={'invalid': _('Enter a valid domain name.')},
)
email = forms.EmailField(
label=_("Email"),
max_length=255,
)
ttl = forms.IntegerField(
label=_("TTL (seconds)"),
min_value=0,
max_value=MAX_TTL,
required=False,
)
description = forms.CharField(
label=_("Description"),
required=False,
max_length=160,
widget=forms.Textarea(),
)
class DomainCreate(DomainForm):
'''Form for creating new domain records.
Name and email address are
required.
'''
def handle(self, request, data):
try:
domain = api.designate.domain_create(
request,
name=data['name'],
email=data['email'],
ttl=data['ttl'],
description=data['description'])
messages.success(request,
_('Domain %(name)s created.') %
{"name": domain.name})
return domain
except designate_exceptions.RemoteError as ex:
if ex.code >= 500:
self.api_error(
_('Error: %(message)s (Request ID: %(request_id)s)')
% {
"request_id": ex.request_id,
"message": ex.message
})
else:
self.api_error(
_('Error: %(message)s')
% {
"message": ex.message
})
return False
except Exception:
messages.error(request, _('Unable to create domain.'))
return True
class DomainUpdate(DomainForm):
'''Form for displaying domain record details and updating them.'''
id = forms.CharField(
required=False,
widget=forms.HiddenInput()
)
serial = forms.CharField(
label=_("Serial"),
required=False,
widget=forms.TextInput(attrs={'readonly': 'readonly'}),
)
created_at = forms.CharField(
label=_("Created At"),
required=False,
widget=forms.TextInput(attrs={'readonly': 'readonly'}),
)
updated_at = forms.CharField(
label=_("Updated At"),
required=False,
widget=forms.TextInput(attrs={'readonly': 'readonly'}),
)
def __init__(self, request, *args, **kwargs):
super(DomainUpdate, self).__init__(request, *args, **kwargs)
# Mark name as read-only
self.fields['name'].required = False
self.fields['name'].widget.attrs['readonly'] = 'readonly'
self.fields['ttl'].required = True
# Customize display order for fields
self.fields.keyOrder = [
'id',
'name',
'serial',
'email',
'ttl',
'description',
'created_at',
'updated_at',
]
def handle(self, request, data):
try:
domain = api.designate.domain_update(
request,
domain_id=data['id'],
email=data['email'],
ttl=data['ttl'],
description=data['description'])
messages.success(request,
_('Domain %(name)s updated.') %
{"name": domain.name})
return domain
except designate_exceptions.RemoteError as ex:
if ex.code >= 500:
self.api_error(
_('Error: %(message)s (Request ID: %(request_id)s)')
% {
"request_id": ex.request_id,
"message": ex.message
})
else:
self.api_error(
_('Error: %(message)s')
% {
"message": ex.message
})
return False
except Exception:
messages.error(request, _('Unable to update domain.'))
return True
class RecordForm(forms.SelfHandlingForm):
'''Base class for RecordCreate and RecordUpdate forms.
Sets-up all of
the form fields and implements the complex validation logic.
'''
domain_id = forms.CharField(
widget=forms.HiddenInput())
domain_name = forms.CharField(
widget=forms.HiddenInput())
type = forms.ChoiceField(
label=_("Record Type"),
required=False,
choices=[
('a', _('A')),
('aaaa', _('AAAA')),
('cname', _('CNAME')),
('mx', _('MX')),
('ptr', _('PTR')),
('spf', _('SPF')),
('srv', _('SRV')),
('sshfp', _('SSHFP')),
('txt', _('TXT')),
],
widget=forms.Select(attrs={
'class': 'switchable',
'data-slug': 'record_type',
}),
)
name = forms.CharField(
max_length=256,
required=False,
widget=forms.TextInput(attrs={
'class': 'switched',
'data-switch-on': 'record_type',
'data-record_type-a': _('Name'),
'data-record_type-aaaa': _('Name'),
'data-record_type-cname': _('Name'),
'data-record_type-mx': _('Name'),
'data-record_type-ns': _('Name'),
'data-record_type-ptr': _('Name'),
'data-record_type-soa': _('Name'),
'data-record_type-spf': _('Name'),
'data-record_type-srv': _('Name'),
'data-record_type-sshfp': _('Name'),
'data-record_type-txt': _('Name'),
}),
)
data = forms.CharField(
required=False,
widget=forms.TextInput(attrs={
'class': 'switched',
'data-switch-on': 'record_type',
'data-record_type-a': _('IP Address'),
'data-record_type-aaaa': _('IP Address'),
'data-record_type-cname': _('Canonical Name'),
'data-record_type-ns': _('Name Server'),
'data-record_type-mx': _('Mail Server'),
'data-record_type-ptr': _('PTR Domain Name'),
'data-record_type-soa': _('Value'),
'data-record_type-srv': _('Value'),
}),
)
txt = forms.CharField(
label=_('TXT'),
required=False,
widget=forms.Textarea(attrs={
'class': 'switched',
'data-switch-on': 'record_type',
'data-record_type-txt': _('Text'),
'data-record_type-spf': _('Text'),
'data-record_type-sshfp': _('Text'),
}),
)
priority = forms.IntegerField(
min_value=0,
max_value=65535,
required=False,
widget=forms.TextInput(attrs={
'class': 'switched',
'data-switch-on': 'record_type',
'data-record_type-mx': _('Priority'),
'data-record_type-srv': _('Priority'),
}),
)
ttl = forms.IntegerField(
label=_('TTL'),
min_value=0,
max_value=MAX_TTL,
required=False,
widget=forms.TextInput(attrs={
'class': 'switched',
'data-switch-on': 'record_type',
'data-record_type-a': _('TTL'),
'data-record_type-aaaa': _('TTL'),
'data-record_type-cname': _('TTL'),
'data-record_type-mx': _('TTL'),
'data-record_type-ptr': _('TTL'),
'data-record_type-soa': _('TTL'),
'data-record_type-spf': _('TTL'),
'data-record_type-srv': _('TTL'),
'data-record_type-sshfp': _('TTL'),
'data-record_type-txt': _('TTL'),
}),
)
description = forms.CharField(
label=_("Description"),
required=False,
max_length=160,
widget=forms.Textarea(),
)
def clean_type(self):
'''Type value needs to be uppercased before it is sent to the API.'''
return self.cleaned_data['type'].upper()
def clean(self):
'''Handles the validation logic for the domain record form.
Validation gets pretty complicated due to the fact that the different
record types (A, AAAA, MX, etc) have different requirements for
each of the fields.
'''
cleaned_data = super(RecordForm, self).clean()
record_type = cleaned_data['type']
domain_name = cleaned_data['domain_name']
# Name field
if self._is_field_blank(cleaned_data, 'name'):
if record_type in ['A', 'AAAA', 'CNAME', 'SRV', 'TXT', 'PTR']:
self._add_required_field_error('name')
elif record_type == 'MX':
cleaned_data['name'] = domain_name
else:
if record_type == 'SRV':
if not re.match(SRV_NAME_REGEX, cleaned_data['name']):
self._add_field_error('name', _('Enter a valid SRV name'))
else:
cleaned_data['name'] += domain_name
else:
if not re.match(WILDCARD_DOMAIN_NAME_REGEX,
cleaned_data['name']):
self._add_field_error('name', _('Enter a valid hostname'))
elif not cleaned_data['name'].endswith(domain_name):
self._add_field_error(
'name',
_('Name must be in the current domain'))
# Data field
if self._is_field_blank(cleaned_data, 'data'):
if record_type in ['A', 'AAAA', 'CNAME', 'MX', 'SRV']:
self._add_required_field_error('data')
else:
if record_type == 'A':
try:
validators.validate_ipv4_address(cleaned_data['data'])
except ValidationError:
self._add_field_error('data',
_('Enter a valid IPv4 address'))
elif record_type == 'AAAA':
try:
validators.validate_ipv6_address(cleaned_data['data'])
except ValidationError:
self._add_field_error('data',
_('Enter a valid IPv6 address'))
elif record_type in ['CNAME', 'MX', 'PTR']:
if not re.match(DOMAIN_NAME_REGEX, cleaned_data['data']):
self._add_field_error('data', _('Enter a valid hostname'))
elif record_type == 'SRV':
if not re.match(SRV_DATA_REGEX, cleaned_data['data']):
self._add_field_error('data',
_('Enter a valid SRV record'))
# Txt field
if self._is_field_blank(cleaned_data, 'txt'):
if record_type == 'TXT':
self._add_required_field_error('txt')
else:
if record_type == 'TXT':
cleaned_data['data'] = cleaned_data['txt']
cleaned_data.pop('txt')
# Priority field
if self._is_field_blank(cleaned_data, 'priority'):
if record_type in ['MX', 'SRV']:
self._add_required_field_error('priority')
# Rename 'id' to 'record_id'
if 'id' in cleaned_data:
cleaned_data['record_id'] = cleaned_data.pop('id')
# Remove domain_name
cleaned_data.pop('domain_name')
return cleaned_data
def _add_required_field_error(self, field):
'''Set a required field error on the specified field.'''
self._add_field_error(field, _('This field is required'))
def _add_field_error(self, field, msg):
'''Set the specified msg as an error on the field.'''
self._errors[field] = self.error_class([msg])
def _is_field_blank(self, cleaned_data, field):
'''Returns a flag indicating whether the specified field is blank.'''
return field in cleaned_data and not cleaned_data[field]
class RecordCreate(RecordForm):
'''Form for creating a new domain record.'''
def handle(self, request, data):
try:
record = api.designate.record_create(request, **data)
messages.success(request,
_('Domain record %(name)s created.') %
{"name": record.name})
return record
except designate_exceptions.RemoteError as ex:
if ex.code >= 500:
self.api_error(
_('Error: %(message)s (Request ID: %(request_id)s)')
% {
"request_id": ex.request_id,
"message": ex.message
})
else:
self.api_error(
_('Error: %(message)s')
% {
"message": ex.message
})
return False
except Exception:
messages.error(request, _('Unable to create record.'))
return True
class RecordUpdate(RecordForm):
'''Form for editing a domain record.'''
id = forms.CharField(widget=forms.HiddenInput())
def __init__(self, request, *args, **kwargs):
super(RecordUpdate, self).__init__(request, *args, **kwargs)
# Force the type field to be read-only
self.fields['type'].widget.attrs['readonly'] = 'readonly'
if self['type'].value() in ('soa', 'ns'):
self.fields['type'].choices.append(('ns', _('NS')))
self.fields['type'].choices.append(('soa', _('SOA')))
self.fields['name'].widget.attrs['readonly'] = 'readonly'
self.fields['data'].widget.attrs['readonly'] = 'readonly'
self.fields['description'].widget.attrs['readonly'] = 'readonly'
self.fields['ttl'].widget.attrs['readonly'] = 'readonly'
# Filter the choice list so that it only contains the type for
# the current record. Ideally, we would just disable the select
# field, but that has the unfortunate side-effect of breaking
# the 'selectable' javascript code.
self.fields['type'].choices = (
[choice for choice in self.fields['type'].choices
if choice[0] == self.initial['type']])
def handle(self, request, data):
if data['type'] in ('SOA', 'NS'):
return True
try:
record = api.designate.record_update(request, **data)
messages.success(request,
_('Domain record %(name)s updated.') %
{"name": record.name})
return record
except designate_exceptions.RemoteError as ex:
if ex.code >= 500:
self.api_error(
_('Error: %(message)s (Request ID: %(request_id)s)')
% {
"request_id": ex.request_id,
"message": ex.message
})
else:
self.api_error(
_('Error: %(message)s')
% {
"message": ex.message
})
return False
except Exception:
messages.error(request, _('Unable to create record.'))
return True

26
designatedashboard/dashboards/project/dns_domains/panel.py

@ -0,0 +1,26 @@
# Copyright 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.utils.translation import ugettext_lazy as _ # noqa
import horizon
from openstack_dashboard.dashboards.project import dashboard
class DNSDomains(horizon.Panel):
name = _("Domains")
slug = 'dns_domains'
permissions = ('openstack.services.dns',)
dashboard.Project.register(DNSDomains)

193
designatedashboard/dashboards/project/dns_domains/tables.py

@ -0,0 +1,193 @@
# Copyright 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import logging
from django.core import urlresolvers
from django.utils.translation import ugettext_lazy as _ # noqa
from horizon import tables
from designatedashboard import api
LOG = logging.getLogger(__name__)
EDITABLE_RECORD_TYPES = (
"A",
"AAAA",
"CNAME",
"MX",
"PTR",
"SPF",
"SRV",
"SSHFP",
"TXT",
)
class CreateDomain(tables.LinkAction):
'''Link action for navigating to the CreateDomain view.'''
name = "create_domain"
verbose_name = _("Create Domain")
url = "horizon:project:dns_domains:create_domain"
classes = ("ajax-modal", "btn-create")
class EditDomain(tables.LinkAction):
'''Link action for navigating to the UpdateDomain view.'''
name = "edit_domain"
verbose_name = _("Edit Domain")
url = "horizon:project:dns_domains:update_domain"
classes = ("ajax-modal", "btn-edit")
class ManageRecords(tables.LinkAction):
'''Link action for navigating to the ManageRecords view.'''
name = "manage_records"
verbose_name = _("Manage Records")
url = "horizon:project:dns_domains:records"
classes = ("btn-edit")
class DeleteDomain(tables.BatchAction):
'''Batch action for deleting domains.'''
name = "delete"
action_present = _("Delete")
action_past = _("Deleted")
data_type_singular = _("Domain")
data_type_plural = _("Domains")
classes = ('btn-danger', 'btn-delete')
def action(self, request, domain_id):
api.designate.domain_delete(request, domain_id)
class CreateRecord(tables.LinkAction):
'''Link action for navigating to the CreateRecord view.'''
name = "create_record"
verbose_name = _("Create Record")
classes = ("ajax-modal", "btn-create")
def get_link_url(self, datum=None):
url = "horizon:project:dns_domains:create_record"
return urlresolvers.reverse(url, kwargs=self.table.kwargs)
class EditRecord(tables.LinkAction):
'''Link action for navigating to the UpdateRecord view.'''
name = "edit_record"
verbose_name = _("Edit Record")
classes = ("ajax-modal", "btn-edit")
def get_link_url(self, datum=None):
url = "horizon:project:dns_domains:update_record"
kwargs = {
'domain_id': datum.domain_id,
'record_id': datum.id,
}
return urlresolvers.reverse(url, kwargs=kwargs)
def allowed(self, request, record=None):
return record.type in EDITABLE_RECORD_TYPES
class DeleteRecord(tables.BatchAction):
'''Batch action for deleting domain records.'''
name = "delete"
action_present = _("Delete")
action_past = _("Deleted")
data_type_singular = _("Record")
data_type_plural = _("Records")
classes = ('btn-danger', 'btn-delete')
def action(self, request, record_id):
domain_id = self.table.kwargs['domain_id']
api.designate.record_delete(request, domain_id, record_id)
def allowed(self, request, record=None):
return record.type in EDITABLE_RECORD_TYPES
class DomainsTable(tables.DataTable):
'''Data table for displaying domain summary information.'''
name = tables.Column("name",
verbose_name=_("Name"),
link=("horizon:project:dns_domains:update_domain"),
link_classes=('ajax-modal',))
email = tables.Column("email",
verbose_name=_("Email"))
ttl = tables.Column("ttl",
verbose_name=_("TTL"))
serial = tables.Column("serial",
verbose_name=_("Serial"))
class Meta:
name = "domains"
verbose_name = _("Domains")
table_actions = (CreateDomain, DeleteDomain,)
row_actions = (ManageRecords, EditDomain, DeleteDomain,)
def update_record_link(record):
'''Returns a link to the view for updating DNS records.'''
return urlresolvers.reverse(
"horizon:project:dns_domains:update_record",
args=(record.domain_id, record.id))
class RecordsTable(tables.DataTable):
'''Data table for displaying summary information for a domains records.'''
name = tables.Column("name",
verbose_name=_("Name"),
link=update_record_link,
link_classes=('ajax-modal',)
)
type = tables.Column("type",
verbose_name=_("Type")
)
data = tables.Column("data",
verbose_name=_("Data")
)
priority = tables.Column("priority",
verbose_name=_("Priority"),
)
ttl = tables.Column("ttl",
verbose_name=_("TTL")
)
class Meta:
name = "records"
verbose_name = _("Records")
table_actions = (CreateRecord, DeleteRecord,)
row_actions = (EditRecord, DeleteRecord,)

38
designatedashboard/dashboards/project/dns_domains/templates/dns_domains/_create_domain.html

@ -0,0 +1,38 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n horizon humanize %}
{% block form_id %}{% endblock %}
{% block form_action %}{% url 'horizon:project:dns_domains:create_domain' %}{% endblock %}
{% block modal_id %}create_domain_modal{% endblock %}
{% block modal-header %}{% trans "Create Domain" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right quota-dynamic">
<h3>{% trans "Description" %}:</h3>
<p>{% blocktrans %}
The Name field should contain a full-qualified domain name (with
trailing period).
{% endblocktrans %}</p>
<p>{% blocktrans %}
The Email field should contain a valid email address to be associated
with the domain.
{% endblocktrans %}</p>
<p>{% blocktrans %}
The optional TTL field can be any value between 0 and 2147483647
seconds.
{% endblocktrans %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Create Domain" %}" />
<a href="{% url 'horizon:project:dns_domains:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

21
designatedashboard/dashboards/project/dns_domains/templates/dns_domains/_create_record.html

@ -0,0 +1,21 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n horizon humanize %}
{% block form_id %}{% endblock %}
{% block form_action %}{% url 'horizon:project:dns_domains:create_record' domain.id %}{% endblock %}
{% block modal_id %}create_record_modal{% endblock %}
{% block modal-header %}{% trans "Create Record for" %} {{ domain.name }}{% endblock %}
{% block modal-body %}
<div class="full">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Create Domain Record" %}" />
<a href="{% url 'horizon:project:dns_domains:records' domain.id %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

36
designatedashboard/dashboards/project/dns_domains/templates/dns_domains/_update_domain.html

@ -0,0 +1,36 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}update_domain_form{% endblock %}
{% block form_action %}{% url 'horizon:project:dns_domains:update_domain' domain.id %}{% endblock %}
{% block modal-header %}{% trans "Update Domain" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description" %}:</h3>
<p>{% blocktrans %}
From here you can edit the email address and TTL associated with a domain.
{% endblocktrans %}</p>
<p>{% blocktrans %}
The Email field should contain a valid email address to be associated
with the domain.
{% endblocktrans %}</p>
<p>{% blocktrans %}
The optional TTL field can be any value between 0 and 2147483647
seconds.
{% endblocktrans %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Update Domain" %}" />
<a href="{% url 'horizon:project:dns_domains:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

21
designatedashboard/dashboards/project/dns_domains/templates/dns_domains/_update_record.html

@ -0,0 +1,21 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}update_record_form{% endblock %}
{% block form_action %}{% url 'horizon:project:dns_domains:update_record' record.domain_id record.id %}{% endblock %}
{% block modal-header %}{% trans "Update Domain Record" %}{% endblock %}
{% block modal-body %}
<div class="full">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Update Domain Record" %}" />
<a href="{% url 'horizon:project:dns_domains:records' record.domain_id %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

11
designatedashboard/dashboards/project/dns_domains/templates/dns_domains/create_domain.html

@ -0,0 +1,11 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Create Domain" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Create Domain") %}
{% endblock page_header %}
{% block main %}
{% include 'project/dns_domains/_create_domain.html' %}
{% endblock %}

11
designatedashboard/dashboards/project/dns_domains/templates/dns_domains/create_record.html

@ -0,0 +1,11 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Create Domain Record" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Create Domain Record") %}
{% endblock page_header %}
{% block main %}
{% include 'project/dns_domains/_create_record.html' %}
{% endblock %}

11
designatedashboard/dashboards/project/dns_domains/templates/dns_domains/index.html

@ -0,0 +1,11 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Domains" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Domains") %}
{% endblock page_header %}
{% block main %}
{{ table.render }}
{% endblock %}

32
designatedashboard/dashboards/project/dns_domains/templates/dns_domains/records.html

@ -0,0 +1,32 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans 'Domain Records' %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Domain Records") %}
{% endblock page_header %}
{% block main %}
<div class="sub-content grid-content">
<div class="page_title table_header">
<div>
<h3>
<a href="{% url 'horizon:project:dns_domains:index' %}">{% trans "Domains" %}</a> : {{ domain.name }} &rarr;
{% trans "Records" %}
</h3>
</div>
<div class="table_actions">
<a href="{% url 'horizon:project:dns_domains:index' %}" class="close">&times;</a>
</div>
</div>
<div class="nameservers_wrapper">
<h3>Nameservers</h3>
<ul>
{% for server in servers %}
<li>{{ server.name }}</li>
{% endfor %}
</ul>
</div>
{{ table.render }}
{% endblock %}

11
designatedashboard/dashboards/project/dns_domains/templates/dns_domains/update_domain.html

@ -0,0 +1,11 @@
{% extends 'adminui/base.html' %}
{% load i18n %}
{% block title %}{% trans 'Update Domain' %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title="Domain" %}
{% endblock page_header %}
{% block main %}
{% include 'project/dns_domains/_update_domain.html' %}
{% endblock %}

11
designatedashboard/dashboards/project/dns_domains/templates/dns_domains/update_record.html

@ -0,0 +1,11 @@
{% extends 'adminui/base.html' %}
{% load i18n %}
{% block title %}{% trans 'Update Domain Record' %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title="Domain Record" %}
{% endblock page_header %}
{% block main %}
{% include 'project/dns_domains/_update_record.html' %}
{% endblock %}

447
designatedashboard/dashboards/project/dns_domains/tests.py

@ -0,0 +1,447 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Copyright 2012 Nebula, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import unicode_literals
from django.core.urlresolvers import reverse # noqa
from django import http
from mox import IsA # noqa
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
from designatedashboard.dashboards.project.dns_domains import forms
DOMAIN_ID = '123'
INDEX_URL = reverse('horizon:project:dns_domains:index')
RECORDS_URL = reverse('horizon:project:dns_domains:records', args=[DOMAIN_ID])
class DNSDomainsTests(test.TestCase):
def setUp(self):
super(DNSDomainsTests, self).setUp()
@test.create_stubs(
{api.designate: ('domain_list',)})
def test_index(self):
domains = self.dns_domains.list()
api.designate.domain_list(
IsA(http.HttpRequest)).AndReturn(domains)
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'project/dns_domains/index.html')
self.assertEqual(len(res.context['table'].data), len(domains))
@test.create_stubs(
{api.designate: ('domain_get', 'server_list', 'record_list')})
def test_records(self):
domain_id = '123'
domain = self.dns_domains.first()
servers = self.dns_servers.list()
records = self.dns_records.list()
api.designate.domain_get(
IsA(http.HttpRequest),
domain_id).AndReturn(domain)
api.designate.server_list(
IsA(http.HttpRequest),
domain_id).AndReturn(servers)
api.designate.record_list(
IsA(http.HttpRequest),
domain_id).AndReturn(records)
self.mox.ReplayAll()
res = self.client.get(RECORDS_URL)
self.assertTemplateUsed(res, 'project/dns_domains/records.html')
self.assertEqual(len(res.context['table'].data), len(records))
class BaseRecordFormCleanTests(test.TestCase):
DOMAIN_NAME = 'foo.com.'
HOSTNAME = 'www.foo.com.'
MSG_FIELD_REQUIRED = 'This field is required'
MSG_INVALID_HOSTNAME = 'Enter a valid hostname'
MSG_OUTSIDE_DOMAIN = 'Name must be in the current domain'
def setUp(self):
super(BaseRecordFormCleanTests, self).setUp()
# Request object with messages support
self.request = self.factory.get('', {})
# Set-up form instance
self.form = forms.RecordCreate(self.request)
self.form._errors = {}
self.form.cleaned_data = {
'domain_name': self.DOMAIN_NAME,
'name': '',
'data': '',
'txt': '',
'priority': None,
'ttl': None,
}
def assert_no_errors(self):
self.assertEqual(self.form._errors, {})
def assert_error(self, field, msg):
self.assertIn(msg, self.form._errors[field])
def assert_required_error(self, field):
self.assert_error(field, self.MSG_FIELD_REQUIRED)
class ARecordFormTests(BaseRecordFormCleanTests):
IPV4 = '1.1.1.1'
MSG_INVALID_IPV4 = 'Enter a valid IPv4 address'
def setUp(self):
super(ARecordFormTests, self).setUp()
self.form.cleaned_data['type'] = 'A'
self.form.cleaned_data['name'] = self.HOSTNAME
self.form.cleaned_data['data'] = self.IPV4
def test_valid_field_values(self):
self.form.clean()
self.assert_no_errors()
def test_valid_name_field_wild_card(self):
self.form.cleaned_data['name'] = '*.' + self.DOMAIN_NAME
self.form.clean()
self.assert_no_errors()
def test_missing_name_field(self):
self.form.cleaned_data['name'] = ''
self.form.clean()
self.assert_required_error('name')
def test_missing_data_field(self):
self.form.cleaned_data['data'] = ''
self.form.clean()
self.assert_required_error('data')
def test_invalid_name_field(self):
self.form.cleaned_data['name'] = 'foo'
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_invalid_name_field_starting_dash(self):
self.form.cleaned_data['name'] = '-ww.foo.com'
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_invalid_name_field_trailing_dash(self):
self.form.cleaned_data['name'] = 'www.foo.co-'
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_invalid_name_field_bad_wild_card(self):
self.form.cleaned_data['name'] = 'derp.*.' + self.DOMAIN_NAME
self.form.clean()
self.assert_error('name', self.MSG_INVALID_HOSTNAME)
def test_outside_of_domain_name_field(self):
self.form.cleaned_data['name'] = 'www.bar.com.'
self.form.clean()
self.assert_error('name', self.MSG_OUTSIDE_DOMAIN)
def test_invalid_data_field(self):
self.form.cleaned_data['data'] = 'foo'
self.form.clean()
self.assert_error('data', self.MSG_INVALID_IPV4)
class AAAARecordFormTests(BaseRecordFormCleanTests):
IPV6 = '1111:1111:1111:11::1'
MSG_INVALID_IPV6 = 'Enter a valid IPv6 address'
def setUp(self):
super(AAAARecordFormTests, self).setUp()
self.form.cleaned_data['type'] = 'AAAA'
self.form.cleaned_data['name'] = self.HOSTNAME
self.form.cleaned_data['data'] = self.IPV6
def test_valid_field_values(self):
self.form.clean()
self.assert_no_errors()
def test_valid_name_field_wild_card(self):
self.form.cleaned_data['name'] = '*.' + self.DOMAIN_NAME
self.form.clean()
self.assert_no_errors()