Re: [Freeipa-devel] [PATCH] Add new version of DNS plugin: complete rework with baseldap + unit tests.

2010-12-01 Thread Adam Young

On 11/24/2010 02:28 PM, Pavel Zůna wrote:

On 2010-11-24 16:21, Adam Young wrote:

On 11/24/2010 03:46 AM, Pavel Zuna wrote:

On 11/24/2010 03:26 AM, Adam Young wrote:

On 11/23/2010 09:37 AM, Pavel Zuna wrote:

Finally managed to rewrite the DNS plugin again. Sorry, it took so
long, we had training in the office and I also had a nasty bug in
baseldap.py I couldn't find.

Anyway, this version has it all:
- changes we agreed on meeting, the resource abstraction is gone 
and

we now only have zones and records = adding new record automatically
updates and existing entry or creates it if it wasn't there and
deleting the last record deletes the whole entry - all of it
transparent to the user
- unit tests
- ipa help documentation

Fixes tickets:
#36
#450

I also closed bug #654412.

It has a new patch sequence number, because it depends on another
patch with a higher number and didn't want to create forward
dependencies.

Depends on my patches number:
35 (will repost if needed)
38 (posted a while ago on freeipa-devel)

Pavel


___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


I keep getting an error when doing simple things like install and ipa
help:
[ayo...@ipa freeipa]$ ./ipa help dns2
ipa: ERROR: AttributeError: cannot override NameSpace.idnsname value
Str('idnsname', cli_name='name', doc=Gettext('Zone name (FQDN)',
domain='ipa', localedir=None), label=Gettext('Zone name', 
domain='ipa',

localedir=None), multivalue=False, normalizer=lambda,
primary_key=True, query=True, required=True) with Str('idnsname',
attribute=True, cli_name='name', doc=Gettext('Record name',
domain='ipa', localedir=None), label=Gettext('Record name',
domain='ipa', localedir=None), multivalue=False, primary_key=True,
query=True, required=True)
Traceback (most recent call last):
File /home/ayoung/devel/freeipa/ipalib/cli.py, line 962, in run
api.finalize()
File /home/ayoung/devel/freeipa/ipalib/plugable.py, line 615, in
finalize
p.instance.finalize()
File /home/ayoung/devel/freeipa/ipalib/frontend.py, line 724, in
finalize
self._create_param_namespace('args')
File /home/ayoung/devel/freeipa/ipalib/frontend.py, line 350, in
_create_param_namespace
sort=False
File /home/ayoung/devel/freeipa/ipalib/base.py, line 407, in 
__init__

(self.__class__.__name__, name, self.__map[name], member)
AttributeError: cannot override NameSpace.idnsname value 
Str('idnsname',

cli_name='name', doc=Gettext('Zone name (FQDN)', domain='ipa',
localedir=None), label=Gettext('Zone name', domain='ipa',
localedir=None), multivalue=False, normalizer=lambda,
primary_key=True, query=True, required=True) with Str('idnsname',
attribute=True, cli_name='name', doc=Gettext('Record name',
domain='ipa', localedir=None), label=Gettext('Record name',
domain='ipa', localedir=None), multivalue=False, primary_key=True,
query=True, required=True)
ipa: ERROR: an internal error has occurred



That's because you need my patch number 35 for it to work...

Pavel


OK, with that change, the patch applies and works.

I've tested: creating a zone
Creating an a record
Adding an a record entry to an existing entry (calling ipa dnsrecord-add
a second time with just a different ip address)
Adding an  record.
Deleting one and multiple  records


One thing that is a little counter intuitive is that you have to specify
which records to delete: just running
ipa dnsrecord-del ayoung.test.ipa.redhat.com hiphop doesn't delete all
records with the A name of hiphop. I think this is the right behavior,
but it should be better documented.


Ok, I'm going to add a few lines about it in the docstring (ipa help).

Maybe we should have an option to delete all records associated with a 
resource name. For example when someone is deleting a host from DNS 
and wants all of its records gone.




Have to hold off on pushing it due to F14: python-netaddr Isn't in F14,
so we are adding a new python package with this plugin, too.




Pavel

ACK and pushed to master

Note that I got an OK on the added dependency on python-netaddr.

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Re: [Freeipa-devel] [PATCH] Add new version of DNS plugin: complete rework with baseldap + unit tests.

2010-11-24 Thread Adam Young

On 11/24/2010 03:46 AM, Pavel Zuna wrote:

On 11/24/2010 03:26 AM, Adam Young wrote:

On 11/23/2010 09:37 AM, Pavel Zuna wrote:

Finally managed to rewrite the DNS plugin again. Sorry, it took so
long, we had training in the office and I also had a nasty bug in
baseldap.py I couldn't find.

Anyway, this version has it all:
- changes we agreed on meeting, the resource abstraction is gone and
we now only have zones and records = adding new record automatically
updates and existing entry or creates it if it wasn't there and
deleting the last record deletes the whole entry - all of it
transparent to the user
- unit tests
- ipa help documentation

Fixes tickets:
#36
#450

I also closed bug #654412.

It has a new patch sequence number, because it depends on another
patch with a higher number and didn't want to create forward
dependencies.

Depends on my patches number:
35 (will repost if needed)
38 (posted a while ago on freeipa-devel)

Pavel


___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


I keep getting an error when doing simple things like install and ipa 
help:

[ayo...@ipa freeipa]$ ./ipa help dns2
ipa: ERROR: AttributeError: cannot override NameSpace.idnsname value
Str('idnsname', cli_name='name', doc=Gettext('Zone name (FQDN)',
domain='ipa', localedir=None), label=Gettext('Zone name', domain='ipa',
localedir=None), multivalue=False, normalizer=lambda,
primary_key=True, query=True, required=True) with Str('idnsname',
attribute=True, cli_name='name', doc=Gettext('Record name',
domain='ipa', localedir=None), label=Gettext('Record name',
domain='ipa', localedir=None), multivalue=False, primary_key=True,
query=True, required=True)
Traceback (most recent call last):
File /home/ayoung/devel/freeipa/ipalib/cli.py, line 962, in run
api.finalize()
File /home/ayoung/devel/freeipa/ipalib/plugable.py, line 615, in 
finalize

p.instance.finalize()
File /home/ayoung/devel/freeipa/ipalib/frontend.py, line 724, in 
finalize

self._create_param_namespace('args')
File /home/ayoung/devel/freeipa/ipalib/frontend.py, line 350, in
_create_param_namespace
sort=False
File /home/ayoung/devel/freeipa/ipalib/base.py, line 407, in __init__
(self.__class__.__name__, name, self.__map[name], member)
AttributeError: cannot override NameSpace.idnsname value Str('idnsname',
cli_name='name', doc=Gettext('Zone name (FQDN)', domain='ipa',
localedir=None), label=Gettext('Zone name', domain='ipa',
localedir=None), multivalue=False, normalizer=lambda,
primary_key=True, query=True, required=True) with Str('idnsname',
attribute=True, cli_name='name', doc=Gettext('Record name',
domain='ipa', localedir=None), label=Gettext('Record name',
domain='ipa', localedir=None), multivalue=False, primary_key=True,
query=True, required=True)
ipa: ERROR: an internal error has occurred



That's because you need my patch number 35 for it to work...

Pavel


OK, with that change, the patch applies and works.

I've tested:  creating a zone
Creating an a record
Adding an a record entry to an existing entry (calling ipa dnsrecord-add 
a second time with just a different ip address)

Adding an  record.
Deleting one and multiple  records


One thing that is a little counter intuitive is that you have to specify 
which records to delete:  just running
ipa dnsrecord-del ayoung.test.ipa.redhat.com hiphop  doesn't delete all 
records with the A name of hiphop.  I think this is the right behavior, 
but it should be better documented.



Have to hold off on pushing it due to F14: python-netaddr  Isn't in F14, 
so we are adding a new python package with this plugin, too.




___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] Add new version of DNS plugin: complete rework with baseldap + unit tests.

2010-11-24 Thread Adam Young

On 11/24/2010 10:21 AM, Adam Young wrote:

On 11/24/2010 03:46 AM, Pavel Zuna wrote:

On 11/24/2010 03:26 AM, Adam Young wrote:

On 11/23/2010 09:37 AM, Pavel Zuna wrote:

Finally managed to rewrite the DNS plugin again. Sorry, it took so
long, we had training in the office and I also had a nasty bug in
baseldap.py I couldn't find.

Anyway, this version has it all:
- changes we agreed on meeting, the resource abstraction is gone and
we now only have zones and records = adding new record automatically
updates and existing entry or creates it if it wasn't there and
deleting the last record deletes the whole entry - all of it
transparent to the user
- unit tests
- ipa help documentation

Fixes tickets:
#36
#450

I also closed bug #654412.

It has a new patch sequence number, because it depends on another
patch with a higher number and didn't want to create forward
dependencies.

Depends on my patches number:
35 (will repost if needed)
38 (posted a while ago on freeipa-devel)

Pavel


___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


I keep getting an error when doing simple things like install and 
ipa help:

[ayo...@ipa freeipa]$ ./ipa help dns2
ipa: ERROR: AttributeError: cannot override NameSpace.idnsname value
Str('idnsname', cli_name='name', doc=Gettext('Zone name (FQDN)',
domain='ipa', localedir=None), label=Gettext('Zone name', domain='ipa',
localedir=None), multivalue=False, normalizer=lambda,
primary_key=True, query=True, required=True) with Str('idnsname',
attribute=True, cli_name='name', doc=Gettext('Record name',
domain='ipa', localedir=None), label=Gettext('Record name',
domain='ipa', localedir=None), multivalue=False, primary_key=True,
query=True, required=True)
Traceback (most recent call last):
File /home/ayoung/devel/freeipa/ipalib/cli.py, line 962, in run
api.finalize()
File /home/ayoung/devel/freeipa/ipalib/plugable.py, line 615, in 
finalize

p.instance.finalize()
File /home/ayoung/devel/freeipa/ipalib/frontend.py, line 724, in 
finalize

self._create_param_namespace('args')
File /home/ayoung/devel/freeipa/ipalib/frontend.py, line 350, in
_create_param_namespace
sort=False
File /home/ayoung/devel/freeipa/ipalib/base.py, line 407, in __init__
(self.__class__.__name__, name, self.__map[name], member)
AttributeError: cannot override NameSpace.idnsname value 
Str('idnsname',

cli_name='name', doc=Gettext('Zone name (FQDN)', domain='ipa',
localedir=None), label=Gettext('Zone name', domain='ipa',
localedir=None), multivalue=False, normalizer=lambda,
primary_key=True, query=True, required=True) with Str('idnsname',
attribute=True, cli_name='name', doc=Gettext('Record name',
domain='ipa', localedir=None), label=Gettext('Record name',
domain='ipa', localedir=None), multivalue=False, primary_key=True,
query=True, required=True)
ipa: ERROR: an internal error has occurred



That's because you need my patch number 35 for it to work...

Pavel


OK, with that change, the patch applies and works.

I've tested:  creating a zone
Creating an a record
Adding an a record entry to an existing entry (calling ipa 
dnsrecord-add a second time with just a different ip address)

Adding an  record.
Deleting one and multiple  records


One thing that is a little counter intuitive is that you have to 
specify which records to delete:  just running
ipa dnsrecord-del ayoung.test.ipa.redhat.com hiphop  doesn't delete 
all records with the A name of hiphop.  I think this is the right 
behavior, but it should be better documented.



Have to hold off on pushing it due to F14: python-netaddr  Isn't in 
F14, so we are adding a new python package with this plugin, too.


Correction, Due to RHEL6.   unwise to take on a new dependency this 
close to ship.







___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


[Freeipa-devel] [PATCH] Add new version of DNS plugin: complete rework with baseldap + unit tests.

2010-11-23 Thread Pavel Zuna
Finally managed to rewrite the DNS plugin again. Sorry, it took so long, we had 
training in the office and I also had a nasty bug in baseldap.py I couldn't find.


Anyway, this version has it all:
- changes we agreed on meeting, the resource abstraction is gone and we now 
only have zones and records = adding new record automatically updates and 
existing entry or creates it if it wasn't there and deleting the last record 
deletes the whole entry - all of it transparent to the user

- unit tests
- ipa help documentation

Fixes tickets:
#36
#450

I also closed bug #654412.

It has a new patch sequence number, because it depends on another patch with a 
higher number and didn't want to create forward dependencies.


Depends on my patches number:
35 (will repost if needed)
38 (posted a while ago on freeipa-devel)

Pavel
From 9ff886618623abb7253956dc92e652361fe4076e Mon Sep 17 00:00:00 2001
From: Pavel Zuna pz...@redhat.com
Date: Mon, 8 Nov 2010 22:34:14 -0500
Subject: [PATCH 2/3] Add new version of DNS plugin: complete rework with baseldap + unit tests.

Ticket #36
Ticket #450
---
 ipa.spec.in  |1 +
 ipalib/plugins/dns2.py   |  584 ++
 tests/test_xmlrpc/test_dns_plugin.py |  341 
 3 files changed, 926 insertions(+), 0 deletions(-)
 create mode 100644 ipalib/plugins/dns2.py
 create mode 100644 tests/test_xmlrpc/test_dns_plugin.py

diff --git a/ipa.spec.in b/ipa.spec.in
index 5a3ea2b..1225bb0 100644
--- a/ipa.spec.in
+++ b/ipa.spec.in
@@ -178,6 +178,7 @@ Requires: gnupg
 Requires: pyOpenSSL
 Requires: python-nss = 0.9-8
 Requires: python-lxml
+Requires: python-netaddr
 
 %description python
 IPA is an integrated solution to provide centrally managed Identity (machine,
diff --git a/ipalib/plugins/dns2.py b/ipalib/plugins/dns2.py
new file mode 100644
index 000..2f72fec
--- /dev/null
+++ b/ipalib/plugins/dns2.py
@@ -0,0 +1,584 @@
+# Authors:
+#   Pavel Zuna pz...@redhat.com
+#
+# Copyright (C) 2010  Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; version 2 only
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Domain Name System (DNS)
+
+Manage DNS zone and resource records.
+
+EXAMPLES:
+
+ Add new zone:
+   ipa dnszone-add example.com --name_server nameserver.example.com
+   --admin_email ad...@example.com
+
+ edd second nameserver for example.com:
+   ipa dnsrecord-add example.com @ --ns-rec nameserver2.example.com
+
+ Delete previously added nameserver from example.com:
+   ipa dnsrecord-del example.com @ --ns-rec nameserver2.example.com
+
+ Add new A record for www.example.com: (random IP)
+   ipa dnsrecord-add example.com www --a-rec 80.142.15.2
+
+ Add new PTR record for www.example.com
+   ipa dnsrecord 15.142.80.in-addr.arpa 2 --ptr-rec www.example.com.
+
+ Show zone example.com:
+   ipa dnszone-show example.com
+
+ Find zone with example in it's domain name:
+   ipa dnszone-find example
+
+ Find records for resources with www in their name in zone example.com:
+   ipa dnsrecord-find example.com www
+
+ Find A records with value 10.10.0.1 in zone example.com
+   ipa dnsrecord-find example.com --a-rec 10.10.0.1
+
+ Show records for resource www in zone example.com
+   ipa dnsrecord-show example.com www
+
+ Delete zone example.com with all resource records:
+   ipa dnszone-del example.com
+
+ Resolve a host name to see if it exists (will add default IPA domain
+ if one is not included):
+   ipa dns-resolve www.example.com
+   ipa dns-resolve www
+
+
+
+import netaddr
+import time
+
+from ipalib import api, errors, output
+from ipalib import Command
+from ipalib import Flag, Int, List, Str, StrEnum
+from ipalib.plugins.baseldap import *
+from ipalib import _, ngettext
+from ipapython import dnsclient
+
+# supported resource record types
+_record_types = (
+u'A', u'', u'A6', u'AFSDB', u'APL', u'CERT', u'CNAME', u'DHCID', u'DLV',
+u'DNAME', u'DNSKEY', u'DS', u'HINFO', u'HIP', u'IPSECKEY', u'KEY', u'KX',
+u'LOC', u'MD', u'MINFO', u'MX', u'NAPTR', u'NS', u'NSEC', u'NSEC3',
+u'NSEC3PARAM', u'NXT', u'PTR', u'RRSIG', u'RP', u'SIG', u'SPF', u'SRV',
+u'SSHFP', u'TA', u'TKEY', u'TSIG', u'TXT',
+)
+
+# attributes derived from record types
+_record_attributes = [str('%srecord' % t.lower()) for t in _record_types]
+
+# supported DNS classes, IN = internet, rest is almost never 

Re: [Freeipa-devel] [PATCH] Add new version of DNS plugin: complete rework with baseldap + unit tests.

2010-11-23 Thread Adam Young

On 11/23/2010 09:37 AM, Pavel Zuna wrote:
Finally managed to rewrite the DNS plugin again. Sorry, it took so 
long, we had training in the office and I also had a nasty bug in 
baseldap.py I couldn't find.


Anyway, this version has it all:
- changes we agreed on meeting, the resource abstraction is gone and 
we now only have zones and records = adding new record automatically 
updates and existing entry or creates it if it wasn't there and 
deleting the last record deletes the whole entry - all of it 
transparent to the user

- unit tests
- ipa help documentation

Fixes tickets:
#36
#450

I also closed bug #654412.

It has a new patch sequence number, because it depends on another 
patch with a higher number and didn't want to create forward 
dependencies.


Depends on my patches number:
35 (will repost if needed)
38 (posted a while ago on freeipa-devel)

Pavel


___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


I keep getting an error when doing simple things like install and ipa help:
[ayo...@ipa freeipa]$ ./ipa help dns2
ipa: ERROR: AttributeError: cannot override NameSpace.idnsname value 
Str('idnsname', cli_name='name', doc=Gettext('Zone name (FQDN)', 
domain='ipa', localedir=None), label=Gettext('Zone name', domain='ipa', 
localedir=None), multivalue=False, normalizer=lambda, 
primary_key=True, query=True, required=True) with Str('idnsname', 
attribute=True, cli_name='name', doc=Gettext('Record name', 
domain='ipa', localedir=None), label=Gettext('Record name', 
domain='ipa', localedir=None), multivalue=False, primary_key=True, 
query=True, required=True)

Traceback (most recent call last):
  File /home/ayoung/devel/freeipa/ipalib/cli.py, line 962, in run
api.finalize()
  File /home/ayoung/devel/freeipa/ipalib/plugable.py, line 615, in 
finalize

p.instance.finalize()
  File /home/ayoung/devel/freeipa/ipalib/frontend.py, line 724, in 
finalize

self._create_param_namespace('args')
  File /home/ayoung/devel/freeipa/ipalib/frontend.py, line 350, in 
_create_param_namespace

sort=False
  File /home/ayoung/devel/freeipa/ipalib/base.py, line 407, in __init__
(self.__class__.__name__, name, self.__map[name], member)
AttributeError: cannot override NameSpace.idnsname value Str('idnsname', 
cli_name='name', doc=Gettext('Zone name (FQDN)', domain='ipa', 
localedir=None), label=Gettext('Zone name', domain='ipa', 
localedir=None), multivalue=False, normalizer=lambda, 
primary_key=True, query=True, required=True) with Str('idnsname', 
attribute=True, cli_name='name', doc=Gettext('Record name', 
domain='ipa', localedir=None), label=Gettext('Record name', 
domain='ipa', localedir=None), multivalue=False, primary_key=True, 
query=True, required=True)

ipa: ERROR: an internal error has occurred



___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Re: [Freeipa-devel] [PATCH] Add new version of DNS plugin: complete rework with baseldap + unit tests.

2010-11-09 Thread Adam Young

On 11/08/2010 11:07 PM, Pavel Zůna wrote:

Finally, there it is. :)

I redesigned the whole thing to fit the baseldap model.

Here's some example on how it's used:

# create zone 'example.com'
# ipa dnszone-add example.com --name=ns.example.com 
--admin=ad...@example.com


# create a resource in zone 'example.com' named 'machine1'
# (machine1.example.com) with A record 10.10.0.1
# ipa dnsres-add example.com machine1 --a-rec=10.10.0.1

# Add another A record to 'machine1' in 'example.com'
# ipa dnsres-add-record example.com machine1 --a-rec=10.10.0.2

# Remove one of the A records from 'machine1' in 'example.com'
# ipa dnsres-remove-record example.com machine1 --a-rec=10.10.0.1



The plugin is pretty complex and requires my patch number 35 to work. 
There is a bunch of unit tests, so hopefully it won't be too much pain 
to review.


You can use both dns and dns2 at the same time.

When dns2 is tested enough, it should replace the original dns plugin.

docstring (ipa help dns2) documentation will follow soon in a separate 
patch.


Pavel


___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Note that it has the patch format issue where Thunderbird prepends a  
keeping git am from applying.  Also, patch name is reversed:  we had 
standardized on freeipa_username



The lite server doesn't seem to want to respond to thenew commands.  ipa 
helpd dns2 brings up the right subset of helpstrings, but:



[ayo...@ipa freeipa]$ ./ipa  dnszone-find
ipa: ERROR: unknown command u'dnszone_find'

[ayo...@ipa freeipa]$ ./ipa  dnsres-find ayoung.boston.devel.redhat.com
ipa: ERROR: unknown command u'dnsres_find'


___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

[Freeipa-devel] [PATCH] Add new version of DNS plugin: complete rework with baseldap + unit tests.

2010-11-08 Thread Pavel Zůna

Finally, there it is. :)

I redesigned the whole thing to fit the baseldap model.

Here's some example on how it's used:

# create zone 'example.com'
# ipa dnszone-add example.com --name=ns.example.com 
--admin=ad...@example.com


# create a resource in zone 'example.com' named 'machine1'
# (machine1.example.com) with A record 10.10.0.1
# ipa dnsres-add example.com machine1 --a-rec=10.10.0.1

# Add another A record to 'machine1' in 'example.com'
# ipa dnsres-add-record example.com machine1 --a-rec=10.10.0.2

# Remove one of the A records from 'machine1' in 'example.com'
# ipa dnsres-remove-record example.com machine1 --a-rec=10.10.0.1



The plugin is pretty complex and requires my patch number 35 to work. 
There is a bunch of unit tests, so hopefully it won't be too much pain 
to review.


You can use both dns and dns2 at the same time.

When dns2 is tested enough, it should replace the original dns plugin.

docstring (ipa help dns2) documentation will follow soon in a separate 
patch.


Pavel
From defad70e665a5c126e56032bfc5ed698363eef9f Mon Sep 17 00:00:00 2001
From: Pavel Zuna pz...@redhat.com
Date: Mon, 8 Nov 2010 22:34:14 -0500
Subject: [PATCH] Add new version of DNS plugin: complete rework with baseldap + unit tests.

---
 ipalib/plugins/dns2.py   |  504 ++
 tests/test_xmlrpc/test_dns_plugin.py |  360 
 2 files changed, 864 insertions(+), 0 deletions(-)
 create mode 100644 ipalib/plugins/dns2.py
 create mode 100644 tests/test_xmlrpc/test_dns_plugin.py

diff --git a/ipalib/plugins/dns2.py b/ipalib/plugins/dns2.py
new file mode 100644
index 000..5b36d37
--- /dev/null
+++ b/ipalib/plugins/dns2.py
@@ -0,0 +1,504 @@
+# Authors:
+#   Pavel Zuna pz...@redhat.com
+#
+# Copyright (C) 2010  Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; version 2 only
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import time
+
+from ipalib import api, errors, output
+from ipalib import Command
+from ipalib import Flag, Int, List, Str, StrEnum
+from ipalib.plugins.baseldap import *
+from ipalib import _, ngettext
+
+# supported resource record types
+_record_types = (
+u'A', u'', u'A6', u'AFSDB', u'CERT', u'CNAME', u'DNAME',
+u'DS', u'HINFO', u'KEY', u'KX', u'LOC', u'MD', u'MINFO', u'MX',
+u'NAPTR', u'NS', u'NSEC', u'NXT', u'PTR', u'RRSIG', u'SSHFP',
+u'SRV', u'TXT',
+)
+
+# attributes derived from record types
+_record_attributes = [str('%srecord' % t.lower()) for t in _record_types]
+
+# supported DNS classes, IN = internet, rest is almost never used
+_record_classes = (u'IN', u'CS', u'CH', u'HS')
+
+# normalizer for admin email
+def _rname_normalizer(value):
+value = value.replace('@', '.')
+if not value.endswith('.'):
+value += '.'
+return value
+
+def _create_zone_serial(**kwargs):
+Generate serial number for zones.
+return int('%s01' % time.strftime('%Y%d%m'))
+
+
+class dnszone(LDAPObject):
+
+DNS Zone, container for resource records.
+
+container_dn = api.env.container_dns
+object_name = 'DNS zone'
+object_name_plural = 'DNS zones'
+object_class = ['top', 'idnsrecord', 'idnszone']
+default_attributes = [
+'idnsname', 'idnszoneactive', 'idnssoamname', 'idnssoarname',
+'idnssoaserial', 'idnssoarefresh', 'idnssoaretry', 'idnssoaexpire',
+'idnssoaminimum'
+] + _record_attributes
+label = _('DNS zone')
+
+takes_params = (
+Str('idnsname',
+cli_name='name',
+label=_('Zone name'),
+doc=_('Zone name (FQDN)'),
+normalizer=lambda value: value.lower(),
+primary_key=True,
+),
+Str('idnssoamname',
+cli_name='name_server',
+label=_('Authoritative name server'),
+doc=_('Authoritative name server'),
+),
+Str('idnssoarname',
+cli_name='admin_email',
+label=_('Administrator e-mail address'),
+doc=_('Administrator e-mail address'),
+default_from=lambda idnsname: 'root.%s' % idnsname,
+normalizer=_rname_normalizer,
+),
+Int('idnssoaserial?',
+cli_name='serial',
+label=_('SOA serial'),
+doc=_('SOA record serial number'),
+create_default=_create_zone_serial,
+autofill=True,
+),
+ 

Re: [Freeipa-devel] [PATCH] Add new version of DNS plugin: complete rework with baseldap + unit tests.

2010-11-08 Thread Pavel Zůna

On 2010-11-09 05:07, Pavel Zůna wrote:

Finally, there it is. :)

I redesigned the whole thing to fit the baseldap model.

Here's some example on how it's used:

# create zone 'example.com'
# ipa dnszone-add example.com --name=ns.example.com
--admin=ad...@example.com

# create a resource in zone 'example.com' named 'machine1'
# (machine1.example.com) with A record 10.10.0.1
# ipa dnsres-add example.com machine1 --a-rec=10.10.0.1

# Add another A record to 'machine1' in 'example.com'
# ipa dnsres-add-record example.com machine1 --a-rec=10.10.0.2

# Remove one of the A records from 'machine1' in 'example.com'
# ipa dnsres-remove-record example.com machine1 --a-rec=10.10.0.1



The plugin is pretty complex and requires my patch number 35 to work.
There is a bunch of unit tests, so hopefully it won't be too much pain
to review.

You can use both dns and dns2 at the same time.

When dns2 is tested enough, it should replace the original dns plugin.

docstring (ipa help dns2) documentation will follow soon in a separate
patch.

Pavel



Forgot to mention that this solves:

Ticket #36
Ticket #450

Pavel

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel