summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/dns.py
diff options
context:
space:
mode:
authorPavel Zuna <pzuna@redhat.com>2010-03-30 18:56:02 +0200
committerMartin Nagy <mnagy@redhat.com>2010-04-19 11:38:19 +0200
commitbc5b5a82d9e55363a652d9675a1db6325e859b31 (patch)
tree0fb4d9bf26f68ba3485b4afb6f2fac4685d85a9f /ipalib/plugins/dns.py
parent18349dda0fa78840cbdbab25e86def2847f6cf9d (diff)
downloadfreeipa-bc5b5a82d9e55363a652d9675a1db6325e859b31.tar.gz
freeipa-bc5b5a82d9e55363a652d9675a1db6325e859b31.tar.xz
freeipa-bc5b5a82d9e55363a652d9675a1db6325e859b31.zip
Fix DNS plugin: proper output definitions, --all, dns-add-rr overwritting
The DNS plugin is getting old, tired and already looking forward to his pension in the Carribean. It will be replaced soon by a younger, faster, safer, shorter (in terms of code) and more maintainable version. Until that happens, here's some medicine for the old guy: - proper output definitions: the DNS plugin was created before we had the has_output attribute in place - --all: this is related to the output definitions as Command.get_options() adds the --all and --raw options automatically if has_output contains entries - dns-add-rr overwritting: missing .lower() caused records to be overwritten everytime a new one was added from the CLI
Diffstat (limited to 'ipalib/plugins/dns.py')
-rw-r--r--ipalib/plugins/dns.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index 5f6949a0f..4c81a8e7c 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -67,6 +67,7 @@ from ipalib import api, crud, errors, output
from ipalib import Object, Command
from ipalib import Flag, Int, Str, StrEnum
from ipalib import _, ngettext
+from ipalib.output import Output, standard_entry, standard_list_of_entries
# parent DN
_zone_container_dn = api.env.container_dns
@@ -310,7 +311,7 @@ class dns_find(crud.Search):
filter = ldap.make_filter_from_attr('idnsname', term, exact=False)
# select attributes we want to retrieve
- if options['all']:
+ if options.get('all', False):
attrs_list = ['*']
else:
attrs_list = _zone_default_attributes
@@ -362,7 +363,7 @@ class dns_show(crud.Retrieve):
dn = _get_zone_dn(ldap, idnsname)
# select attributes we want to retrieve
- if options['all']:
+ if options.get('all', False):
attrs_list = ['*']
else:
attrs_list = _zone_default_attributes
@@ -492,11 +493,11 @@ class dns_add_rr(Command):
),
)
- has_output = output.standard_entry
+ has_output = standard_entry
def execute(self, zone, idnsname, type, data, **options):
ldap = self.api.Backend.ldap2
- attr = '%srecord' % type
+ attr = ('%srecord' % type).lower()
# build entry DN
dn = _get_record_dn(ldap, zone, idnsname)
@@ -593,11 +594,11 @@ class dns_del_rr(Command):
),
)
- has_output = output.standard_entry
+ has_output = standard_entry
- def execute(self, zone, idnsname, type, data):
+ def execute(self, zone, idnsname, type, data, **options):
ldap = self.api.Backend.ldap2
- attr = '%srecord' % type
+ attr = ('%srecord' % type).lower()
# build entry DN
dn = _get_record_dn(ldap, zone, idnsname)
@@ -635,9 +636,9 @@ class dns_del_rr(Command):
(dn, entry_attrs) = ldap.get_entry(dn, ['idnsname', attr])
entry_attrs['dn'] = dn
- return dict(result=result, value=idnsname)
+ return dict(result=entry_attrs, value=idnsname)
- def output_for_cli(self, textui, result, zone, idnsname, type, data):
+ def output_for_cli(self, textui, result, zone, idnsname, type, data, **options):
output = '"%s %s %s" from zone "%s"' % (
idnsname, type, data, zone,
)
@@ -683,12 +684,12 @@ class dns_find_rr(Command):
),
)
- has_output = output.standard_list_of_entries
+ has_output = standard_list_of_entries
def execute(self, zone, term, **options):
ldap = self.api.Backend.ldap2
if 'type' in options:
- attr = '%srecord' % options['type']
+ attr = ('%srecord' % options['type']).lower()
else:
attr = None
@@ -722,7 +723,7 @@ class dns_find_rr(Command):
filter = ldap.combine_filters((filter, term_filter), ldap.MATCH_ALL)
# select attributes we want to retrieve
- if options['all']:
+ if options.get('all', False):
attrs_list = ['*']
elif attr is not None:
attrs_list = [attr]
@@ -793,7 +794,7 @@ class dns_show_rr(Command):
),
)
- has_output = output.standard_entry
+ has_output = standard_entry
def execute(self, zone, idnsname, **options):
# shows all records associated with resource
@@ -803,7 +804,7 @@ class dns_show_rr(Command):
dn = _get_record_dn(ldap, zone, idnsname)
# select attributes we want to retrieve
- if options['all']:
+ if options.get('all', False):
attrs_list = ['*']
else:
attrs_list = _record_default_attributes