Permalink
Browse files

merge

  • Loading branch information...
Kevin Ngo
Kevin Ngo committed Apr 14, 2012
2 parents ae290d9 + 8666787 commit 7437132aad42cb0d7d587b72ed2f1e4b36b78fcd
Showing with 551 additions and 181 deletions.
  1. +31 −1 README.md
  2. +0 −1 cyder/core/cyuser/backends.py
  3. +1 −1 cyder/cybind/generators/bind_reverse_domain_generator.py
  4. +0 −103 cyder/cybind/test.py
  5. +129 −0 cyder/cybind/tests.py
  6. +14 −3 cyder/cydns/address_record/models.py
  7. +9 −0 cyder/cydns/cname/models.py
  8. +3 −2 cyder/cydns/domain/models.py
  9. +10 −0 cyder/cydns/domain/templates/domain/domain_detail.html
  10. +5 −3 cyder/cydns/domain/tests.py
  11. +13 −0 cyder/cydns/models.py
  12. +2 −1 cyder/cydns/mx/models.py
  13. +7 −2 cyder/cydns/nameserver/nameserver/forms.py
  14. +2 −0 cyder/cydns/nameserver/nameserver/models.py
  15. +1 −0 cyder/cydns/nameserver/nameserver/urls.py
  16. +34 −0 cyder/cydns/nameserver/nameserver/views.py
  17. +2 −0 cyder/cydns/nameserver/reverse_nameserver/models.py
  18. +14 −0 cyder/cydns/ptr/models.py
  19. +5 −0 cyder/cydns/ptr/templates/ptr/ptr_detail.html
  20. +3 −0 cyder/cydns/reverse_domain/models.py
  21. +4 −2 cyder/cydns/soa/models.py
  22. +4 −1 cyder/cydns/srv/models.py
  23. +30 −30 cyder/cydns/validation.py
  24. 0 cyder/cysearch/__init__.py
  25. +25 −0 cyder/cysearch/templates/search/dns_results.html
  26. +8 −0 cyder/cysearch/templates/search/dns_search.html
  27. +9 −0 cyder/cysearch/urls.py
  28. +62 −0 cyder/cysearch/views.py
  29. +19 −5 cyder/maintain2cyder/zone.py
  30. +7 −4 cyder/search/utils.py
  31. +2 −1 cyder/settings/base.py
  32. 0 cyder/tests/__init__.py
  33. +2 −0 cyder/tests/all.py
  34. +1 −0 cyder/urls.py
  35. +1 −1 docs/README.mkd
  36. +67 −0 docs/dns_views.rst
  37. +5 −6 docs/domain.rst
  38. +1 −0 docs/index.rst
  39. +18 −13 docs/validation.rst
  40. +1 −1 wsgi/playdoh.wsgi
View
@@ -5,9 +5,12 @@ playdoh
>>> django.VERSION
(1, 3, 1, 'final', 0)
+aptitude install python-dev mysql-server python-pip python-virtualenv python-mysqldb git-core libmysqlclient-dev
+
CREATE USER 'cyder'@'localhost' IDENTIFIED BY '****';
GRANT ALL PRIVILEGES ON *.* TO 'cyder'@'localhost';
create database cyder;
+flush priviliges;
pip install coverage
@@ -18,4 +21,31 @@ pip install ipaddr
pip install Whoosh
pip install simplejson
-``
+
+pip install funfactory
+
+git clone https://github.com/uberj/cyder.git /data/cyder
+
+cd /data/cyder
+
+git clone --recursive git://github.com/mozilla/playdoh-lib.git ./vendor
+
+pip install -r requirements/compiled.txt
+
+```
+
+Sphinx Docs
+===========
+```
+aptitude install python-sphinx
+cd /data/cyder/docs
+make html
+```
+
+Apache setup
+==========
+```
+aptitude install apache2 libapache2-mod-wsgi
+a2enmod rewrite
+a2enmod proxy
+```
@@ -46,7 +46,6 @@ def has_perm(self, request, obj, action):
:class:`Domain` object.
>>> perm = request.user.get_profile().has_perm(request, domain,
... \'create\')
-
"""
user_level = None
user = request.user
@@ -4,7 +4,7 @@
import pdb
# Knobs
ip_just = 30
-name_just = 10
+name_just = 1
type_just = 15
class_just = 10
prio_just = 3
View
@@ -1,103 +0,0 @@
-import sys
-import os
-
-sys.path.append("/nfs/milo/u1/uberj/cyder_env/cyder/")
-# Edit this if necessary or override the variable in your environment.
-os.environ['DJANGO_SETTINGS_MODULE'] = 'cyder.settings'
-
-try:
- # For local development in a virtualenv:
- from funfactory import manage
-except ImportError, e:
- # Production:
- # Add a temporary path so that we can import the funfactory
- tmp_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
- 'vendor', 'src', 'funfactory')
- sys.path.append(tmp_path)
-
- from funfactory import manage
-
- # Let the path magic happen in setup_environ() !
- sys.path.remove(tmp_path)
-
-
-manage.setup_environ("/nfs/milo/u1/uberj/cyder_env/cyder/manage.py", more_pythonic=True)
-from django.core.exceptions import ValidationError
-
-from cyder.cydns.domain.models import Domain
-from cyder.cydns.reverse_domain.models import ReverseDomain
-from cyder.cydns.soa.models import SOA
-from cyder.cydns.ip.models import Ip
-from cyder.cydns.address_record.models import AddressRecord
-from cyder.cydns.nameserver.models import Nameserver
-from cyder.cybind.build import *
-
-def add_some_records():
- s1, s1_c = SOA.objects.get_or_create(primary = "ns1.foo.gaz", contact = "hostmaster.foo", comment="foo.gaz2")
- s2, s2_c = SOA.objects.get_or_create(primary = "ns1.foo.gaz", contact = "hostmaster.foo", comment="baz.gaz2")
- d, _ = Domain.objects.get_or_create(name="gaz")
- d.soa = None
- d.save()
- d1, _ = Domain.objects.get_or_create(name="foo.gaz")
- if s1_c:
- d1.soa = s1
- d1.save()
- d, _ = Domain.objects.get_or_create(name="baz.foo.gaz")
- if s1_c:
- d.soa = s1
- d.save()
- d, _ = Domain.objects.get_or_create(name="bar.foo.gaz")
- if s1_c:
- d.soa = s1
- d.save()
- d, _ = Domain.objects.get_or_create(name="baz.gaz")
- if s2_c:
- d.soa = s2
- d.save()
- d, _ = Domain.objects.get_or_create(name="gaz.gaz")
- d.soa = None
- d.save()
-
- _128 , _= ReverseDomain.objects.get_or_create(name='128')
-
- rs, _ = ReverseNameserver.objects.get_or_create( reverse_domain= _128, server="ns1.foo.com")
- rs.save()
- rs = ReverseNameserver.objects.get_or_create( reverse_domain= _128, server="ns1.foo1.com")
- rs.save()
-
- test_ip = Ip( ip_str = "128.193.0.1", ip_type = '4' )
- test_ip.save()
- try:
- _, _ = AddressRecord.objects.get_or_create( label = '', domain= d1 , ip = test_ip , ip_type='4')
- except ValidationError:
- pass
-
- test_ip1 = Ip( ip_str = "128.193.0.1", ip_type = '4' )
- test_ip1.save()
- try:
- _, _ = AddressRecord.objects.get_or_create( label = 'fdjoo',domain= d1 , ip = test_ip1 , ip_type='4')
- except ValidationError:
- pass
-
- test_ip2 = Ip( ip_str = "128.193.0.1", ip_type = '4' )
- test_ip2.save()
- try:
- _, _ = AddressRecord.objects.get_or_create( label = 'baddr',domain= d1 , ip = test_ip2 , ip_type='4')
- except ValidationError:
- pass
-
- data = { 'domain':d1 , 'server':'ns2.moot.ru' }
- try:
- _, _ = Nameserver.objects.get_or_create( **data )
- except ValidationError:
- pass
-
- data = { 'domain':d1 , 'server':'ns3.moot.ru' }
- try:
- _, _ = Nameserver.objects.get_or_create( **data )
- except ValidationError:
- pass
-
-
-
-add_some_records()
View
@@ -0,0 +1,129 @@
+import sys
+import os
+import pdb
+
+from django.test import TestCase
+
+from cyder.cydns.domain.models import Domain
+from cyder.cydns.reverse_domain.models import ReverseDomain
+from cyder.cydns.soa.models import SOA
+from cyder.cydns.srv.models import SRV
+from cyder.cydns.txt.models import TXT
+from cyder.cydns.ptr.models import PTR
+from cyder.cydns.mx.models import MX
+from cyder.cydns.cname.models import CNAME
+from cyder.cydns.address_record.models import AddressRecord
+from cyder.cydns.nameserver.nameserver.models import Nameserver
+from cyder.cydns.nameserver.reverse_nameserver.models import ReverseNameserver
+from cyder.cybind.build import *
+
+class BuildTests(TestCase):
+ def setUp(self):
+ s1, s1_c = SOA.objects.get_or_create(primary = "ns1.foo.gaz", contact =
+ "hostmaster.foo", comment="123foo.gaz2")
+ self.soa = s1
+ d, _ = Domain.objects.get_or_create(name="bgaz")
+ d.soa = s1
+ d.save()
+ self.dom = d
+ self.soa.dirty = False
+ self.dom.dirty = False
+
+ s2, s1_c = SOA.objects.get_or_create(primary = "ns1.foo.gaz", contact =
+ "hostmaster.foo", comment="123fooasdfsdf.gaz2")
+ self.rsoa = s2
+ rd, _ = ReverseDomain.objects.get_or_create(name="123")
+ rd.soa = s2
+ rd.save()
+ self.rdom = rd
+ self.rsoa.dirty = False
+ self.rdom.dirty = False
+
+
+ def test_dirty_a(self):
+ self.soa.dirty = False
+ self.dom.dirty = False
+ a, _ = AddressRecord.objects.get_or_create(label="asfd",
+ domain=self.dom, ip_str = "128.1.1.1", ip_type='4')
+ a.save()
+ self.assertTrue(self.dom.dirty)
+ self.assertFalse(self.soa.dirty)
+
+ def test_dirty_cname(self):
+ self.soa.dirty = False
+ self.dom.dirty = False
+ c = CNAME(label="asfd", domain=self.dom, data="nerp")
+ c.full_clean()
+ c.save()
+ self.assertTrue(self.dom.dirty)
+ self.assertFalse(self.soa.dirty)
+
+ def test_dirty_ptr(self):
+ self.rsoa.dirty = False
+ self.rdom.dirty = False
+ c = PTR(name="asfd", ip_str="123.123.123.123", ip_type="4")
+ c.full_clean()
+ c.save()
+ self.rdom = ReverseDomain.objects.get(pk=self.rdom.pk)
+ self.assertTrue(self.rdom.dirty)
+ self.assertFalse(self.rsoa.dirty)
+
+ def test_dirty_mx(self):
+ self.soa.dirty = False
+ self.dom.dirty = False
+ a, _ = MX.objects.get_or_create(label="asfd",
+ domain=self.dom, server = "asdf", priority=123, ttl=44)
+ a.save()
+ self.assertTrue(self.dom.dirty)
+ self.assertFalse(self.soa.dirty)
+
+ def test_dirty_ns(self):
+ self.soa.dirty = False
+ self.dom.dirty = False
+ a, _ = Nameserver.objects.get_or_create(domain=self.dom, server = "asdf")
+ a.save()
+ self.assertTrue(self.dom.dirty)
+ self.assertFalse(self.soa.dirty)
+
+ def test_dirty_rev_ns(self):
+ self.rsoa.dirty = False
+ self.rdom.dirty = False
+ a, _ = ReverseNameserver.objects.get_or_create(domain=self.rdom,
+ server = "asdf")
+ a.save()
+ self.assertTrue(self.rdom.dirty)
+ self.assertFalse(self.rsoa.dirty)
+
+ def test_dirty_rev_ns(self):
+ self.rsoa.dirty = False
+ self.rdom.dirty = False
+ a, _ = ReverseNameserver.objects.get_or_create(reverse_domain=self.rdom,
+ server = "asdf")
+ a.save()
+ self.assertTrue(self.rdom.dirty)
+ self.assertFalse(self.rsoa.dirty)
+
+ def test_dirty_soa(self):
+ self.soa.dirty = False
+ self.dom.dirty = False
+ self.soa.refresh = 123
+ self.soa.save()
+ self.assertTrue(self.soa.dirty)
+
+ def test_dirty_srv(self):
+ self.soa.dirty = False
+ self.dom.dirty = False
+ a, _ = SRV.objects.get_or_create(label="_asf", port=22, domain=self.dom,
+ target= "asdf", priority=123, weight=22)
+ a.save()
+ self.assertTrue(self.dom.dirty)
+ self.assertFalse(self.soa.dirty)
+
+ def test_dirty_txt(self):
+ self.soa.dirty = False
+ self.dom.dirty = False
+ a, _ = TXT.objects.get_or_create(label="asf", txt_data="test",
+ domain=self.dom)
+ a.save()
+ self.assertTrue(self.dom.dirty)
+ self.assertFalse(self.soa.dirty)
@@ -36,7 +36,8 @@ def details(self):
def clean(self):
self._check_glue_status()
super(AddressRecord, self).clean()
- super(AddressRecord, self).check_for_delegation()
+ if self.domain.delegated:
+ self.validate_delegation_conditions()
super(AddressRecord, self).check_for_cname()
self.clean_ip(update_reverse_domain=False) # Function from Ip class.
@@ -57,6 +58,16 @@ def delete(self, *args, **kwargs):
format(self.record_type()))
super(AddressRecord, self).delete(*args, **kwargs)
+ def validate_delegation_conditions(self):
+ """If our domain is delegated then an A record can only have a
+ name that is the same as a nameserver in that domain (glue)."""
+ if self.domain.nameserver_set.filter(server=self.fqdn).exists():
+ return
+ else:
+ # Confusing error messege?
+ raise ValidationError("You can only create A records in a "
+ "delegated domain that have an NS record pointing to them.")
+
def _check_glue_status(self):
"""If this record is a 'glue' record for a Nameserver instance,
do not allow modifications to this record. The Nameserver will
@@ -65,8 +76,8 @@ def _check_glue_status(self):
"""
if self.pk is None:
return
- # First get this object from the database and compare it to the nameserver.nameserver.
- # object about to be saved.
+ # First get this object from the database and compare it to the
+ # nameserver.nameserver. object about to be saved.
db_self = AddressRecord.objects.get(pk=self.pk)
if db_self.label == self.label and db_self.domain == self.domain:
return
@@ -36,6 +36,15 @@ class Meta:
unique_together = ('domain', 'label', 'data')
def save(self, *args, **kwargs):
+ # If label, and domain have not changed, don't mark our domain for
+ # rebuilding.
+ if self.pk: # We need to exist in the db first.
+ db_self = CNAME.objects.get(pk=self.pk)
+ if db_self.label == self.label and db_self.domain == self.domain:
+ kwargs['no_build'] = True
+ else:
+ kwargs['no_build'] = False # Either nothing has changed or
+ # just data_domain. We want rebuild.
super(CNAME, self).save(*args, **kwargs)
def clean(self, *args, **kwargs):
@@ -10,8 +10,7 @@
class Domain(models.Model, ObjectUrlMixin):
- """
- A Domain is used as a foreign key for most DNS records.
+ """A Domain is used as a foreign key for most DNS records.
A domain's SOA should be shared by only domains within it's zone.
@@ -35,6 +34,8 @@ class Domain(models.Model, ObjectUrlMixin):
master_domain = models.ForeignKey("self", null=True,
default=None, blank=True)
soa = models.ForeignKey(SOA, null=True, default=None, blank=True)
+ # This indicates if this domain (and zone) needs to be rebuilt
+ dirty = models.BooleanField(default=False)
delegated = models.BooleanField(default=False, null=False, blank=True)
class Meta:
@@ -33,6 +33,16 @@
<span class="nav-item">
<a class="sub-link nav-link" href="/cydns/ptr/{{ object.pk }}/create/">Create PTR</a>
</span>
+ <span class="nav-item">
+ <a class="sub-link nav-link" href="/cydns/nameserver/{{ object.pk }}/create/">Create NS</a>
+ </span>
+ {% else %}
+ <span class="nav-item">
+ <a class="sub-link nav-link" href="/cydns/nameserver/{{ object.pk }}/create/">Create NS</a>
+ </span>
+ <span class="nav-item">
+ <a class="sub-link nav-link" href="/cydns/address_record/{{ object.pk }}/create/">Create Address Record</a>
+ </span>
{% endif %}
{% endblock %}
Oops, something went wrong.

0 comments on commit 7437132

Please sign in to comment.