diff --git a/contrib/designate-dashboard/CONTRIBUTING.rst b/contrib/designate-dashboard/CONTRIBUTING.rst
new file mode 100644
index 000000000..51e5d6329
--- /dev/null
+++ b/contrib/designate-dashboard/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
\ No newline at end of file
diff --git a/contrib/designate-dashboard/HACKING.rst b/contrib/designate-dashboard/HACKING.rst
new file mode 100644
index 000000000..e0ddef5ac
--- /dev/null
+++ b/contrib/designate-dashboard/HACKING.rst
@@ -0,0 +1,4 @@
+designatedashboard Style Commandments
+===============================================
+
+Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/
\ No newline at end of file
diff --git a/contrib/designate-dashboard/LICENSE b/contrib/designate-dashboard/LICENSE
new file mode 100644
index 000000000..67db85882
--- /dev/null
+++ b/contrib/designate-dashboard/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.
diff --git a/contrib/designate-dashboard/MANIFEST.in b/contrib/designate-dashboard/MANIFEST.in
new file mode 100644
index 000000000..90f8a7aef
--- /dev/null
+++ b/contrib/designate-dashboard/MANIFEST.in
@@ -0,0 +1,6 @@
+include AUTHORS
+include ChangeLog
+exclude .gitignore
+exclude .gitreview
+
+global-exclude *.pyc
\ No newline at end of file
diff --git a/contrib/designate-dashboard/README.rst b/contrib/designate-dashboard/README.rst
new file mode 100644
index 000000000..baaf85c0a
--- /dev/null
+++ b/contrib/designate-dashboard/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!
diff --git a/contrib/designate-dashboard/babel.cfg b/contrib/designate-dashboard/babel.cfg
new file mode 100644
index 000000000..efceab818
--- /dev/null
+++ b/contrib/designate-dashboard/babel.cfg
@@ -0,0 +1 @@
+[python: **.py]
diff --git a/contrib/designate-dashboard/designatedashboard/__init__.py b/contrib/designate-dashboard/designatedashboard/__init__.py
new file mode 100644
index 000000000..45adf783e
--- /dev/null
+++ b/contrib/designate-dashboard/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()
diff --git a/contrib/designate-dashboard/designatedashboard/api/__init__.py b/contrib/designate-dashboard/designatedashboard/api/__init__.py
new file mode 100644
index 000000000..97ba63851
--- /dev/null
+++ b/contrib/designate-dashboard/designatedashboard/api/__init__.py
@@ -0,0 +1 @@
+from designatedashboard.api import designate # noqa
diff --git a/contrib/designate-dashboard/designatedashboard/api/designate.py b/contrib/designate-dashboard/designatedashboard/api/designate.py
new file mode 100644
index 000000000..b3137b88b
--- /dev/null
+++ b/contrib/designate-dashboard/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)
diff --git a/contrib/designate-dashboard/designatedashboard/dashboards/__init__.py b/contrib/designate-dashboard/designatedashboard/dashboards/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/contrib/designate-dashboard/designatedashboard/dashboards/project/__init__.py b/contrib/designate-dashboard/designatedashboard/dashboards/project/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/contrib/designate-dashboard/designatedashboard/dashboards/project/dns_domains/__init__.py b/contrib/designate-dashboard/designatedashboard/dashboards/project/dns_domains/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/contrib/designate-dashboard/designatedashboard/dashboards/project/dns_domains/forms.py b/contrib/designate-dashboard/designatedashboard/dashboards/project/dns_domains/forms.py
new file mode 100644
index 000000000..8b8147aa9
--- /dev/null
+++ b/contrib/designate-dashboard/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}(?= 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
diff --git a/contrib/designate-dashboard/designatedashboard/dashboards/project/dns_domains/panel.py b/contrib/designate-dashboard/designatedashboard/dashboards/project/dns_domains/panel.py
new file mode 100644
index 000000000..a7df87f0f
--- /dev/null
+++ b/contrib/designate-dashboard/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)
diff --git a/contrib/designate-dashboard/designatedashboard/dashboards/project/dns_domains/tables.py b/contrib/designate-dashboard/designatedashboard/dashboards/project/dns_domains/tables.py
new file mode 100644
index 000000000..2eec2ec9f
--- /dev/null
+++ b/contrib/designate-dashboard/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,)
diff --git a/contrib/designate-dashboard/designatedashboard/dashboards/project/dns_domains/templates/dns_domains/_create_domain.html b/contrib/designate-dashboard/designatedashboard/dashboards/project/dns_domains/templates/dns_domains/_create_domain.html
new file mode 100644
index 000000000..420574127
--- /dev/null
+++ b/contrib/designate-dashboard/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 %}
+
+
+
+
+
+
{% trans "Description" %}:
+
{% blocktrans %}
+ The Name field should contain a full-qualified domain name (with
+ trailing period).
+ {% endblocktrans %}
+
{% blocktrans %}
+ The Email field should contain a valid email address to be associated
+ with the domain.
+ {% endblocktrans %}
+
{% blocktrans %}
+ The optional TTL field can be any value between 0 and 2147483647
+ seconds.
+ {% endblocktrans %}