Creating reverse zones from IP address.

A custom adder dialog has been added for DNS zones to simplify creating
reverse zones from IP address. The dialog provides a checkbox which
indicates whether the content of the zone name field is an IP address.
The IP address will be used to generate the reverse zone name and email
address.

Ticket #1045
This commit is contained in:
Endi S. Dewata 2011-07-19 11:11:36 -05:00 committed by Adam Young
parent 6d14331a05
commit 8e8ad513a7
2 changed files with 181 additions and 16 deletions

View File

@ -80,15 +80,155 @@ IPA.entity_factories.dnszone = function() {
}).
standard_association_facets().
adder_dialog({
factory: IPA.dnszone_adder_dialog,
width: 500,
height: 300,
fields: [
'idnsname',
{
factory: IPA.checkbox_widget,
name: 'name_from_ip',
undo: false
},
'idnssoamname',
'idnssoarname',
{factory:IPA.force_dnszone_add_checkbox_widget}]
{
factory: IPA.force_dnszone_add_checkbox_widget
}
]
}).
build();
};
IPA.dnszone_adder_dialog = function(spec) {
spec = spec || {};
var that = IPA.add_dialog(spec);
that.create = function() {
var table = $('<table/>').appendTo(that.container);
var field = that.fields.get('idnsname');
var tr = $('<tr/>').appendTo(table);
var td = $('<td/>', {
style: 'vertical-align: top;',
title: field.label
}).appendTo(tr);
td.append($('<label/>', {
text: field.label+':'
}));
td = $('<td/>', {
style: 'vertical-align: top;'
}).appendTo(tr);
var span = $('<span/>', {
name: field.name
}).appendTo(td);
field.create(span);
field.field_span = span;
field = that.fields.get('name_from_ip');
tr = $('<tr/>').appendTo(table);
td = $('<td/>', {
style: 'vertical-align: top;',
title: field.label
}).appendTo(tr);
td = $('<td/>', {
style: 'vertical-align: top;'
}).appendTo(tr);
span = $('<span/>', {
name: field.name
}).appendTo(td);
td.append($('<label/>', {
text: field.label
}));
field.create(span);
field.field_span = span;
tr = $('<tr/>').appendTo(table);
td = $('<td/>', {
colspan: 2,
html: '&nbsp;'
}).appendTo(tr);
var fields = that.fields.values;
for (var i=0; i<fields.length; i++) {
field = fields[i];
if (field.name == 'idnsname' || field.name == 'name_from_ip') continue;
if (field.hidden) continue;
tr = $('<tr/>').appendTo(table);
td = $('<td/>', {
style: 'vertical-align: top;',
title: field.label
}).appendTo(tr);
td.append($('<label/>', {
text: field.label+':'
}));
td = $('<td/>', {
style: 'vertical-align: top;'
}).appendTo(tr);
span = $('<span/>', {
name: field.name
}).appendTo(td);
field.create(span);
field.field_span = span;
}
};
that.save = function(record) {
var idnsname;
var name_from_ip;
var fields = that.fields.values;
for (var i=0; i<fields.length; i++) {
var field = fields[i];
if (field.name == 'idnsname') {
idnsname = field.save()[0];
} else if (field.name == 'name_from_ip') {
name_from_ip = field.save()[0];
if (name_from_ip) {
record.name_from_ip = idnsname;
} else {
record.idnsname = idnsname;
}
} else if (field.name == 'idnssoarname') {
field.optional = name_from_ip;
} else {
var values = field.save();
record[field.name] = values.join(',');
}
}
};
return that;
};
IPA.dns_record_search_load = function (result) {
this.table.empty();
var normalized_record;

View File

@ -2549,7 +2549,7 @@
"cli_name": "ipaentitlementid",
"cli_short_name": null,
"default": null,
"doc": "Enrollment UUID",
"doc": "Enrollment UUID (not implemented)",
"exclude": null,
"flags": [
"no_update",
@ -10345,6 +10345,33 @@
"required": true,
"type": "unicode"
},
{
"alwaysask": false,
"attribute": false,
"autofill": false,
"class": "Str",
"cli_name": "name_from_ip",
"cli_short_name": null,
"default": null,
"doc": "IP network to create reverse zone name from",
"exclude": null,
"flags": [],
"hint": null,
"include": null,
"label": "Reverse zone IP network",
"length": null,
"maxlength": null,
"minlength": null,
"multivalue": false,
"name": "name_from_ip",
"noextrawhitespace": true,
"pattern": null,
"pattern_errmsg": null,
"primary_key": false,
"query": false,
"required": false,
"type": "unicode"
},
{
"alwaysask": false,
"attribute": false,
@ -11047,12 +11074,12 @@
{
"alwaysask": false,
"attribute": false,
"autofill": false,
"autofill": true,
"class": "StrEnum",
"cli_name": "type",
"cli_short_name": null,
"default": null,
"doc": "Rule type (allow or deny)",
"default": "allow",
"doc": "Rule type (allow)",
"exclude": null,
"flags": [],
"hint": null,
@ -14456,12 +14483,12 @@
"cli_name": "runasusercat",
"cli_short_name": null,
"default": null,
"doc": "Run As User category the rule applies to",
"doc": "RunAs User category the rule applies to",
"exclude": null,
"flags": [],
"hint": null,
"include": null,
"label": "Run As User category",
"label": "RunAs User category",
"multivalue": false,
"name": "ipasudorunasusercategory",
"primary_key": false,
@ -14480,12 +14507,12 @@
"cli_name": "runasgroupcat",
"cli_short_name": null,
"default": null,
"doc": "Run As Group category the rule applies to",
"doc": "RunAs Group category the rule applies to",
"exclude": null,
"flags": [],
"hint": null,
"include": null,
"label": "Run As Group category",
"label": "RunAs Group category",
"multivalue": false,
"name": "ipasudorunasgroupcategory",
"primary_key": false,
@ -14752,7 +14779,7 @@
"cli_name": "ipasudorunas_user",
"cli_short_name": null,
"default": null,
"doc": "Run As User",
"doc": "RunAs User",
"exclude": null,
"flags": [
"no_update",
@ -14761,7 +14788,7 @@
],
"hint": null,
"include": null,
"label": "Run As User",
"label": "RunAs User",
"length": null,
"maxlength": null,
"minlength": null,
@ -14783,7 +14810,7 @@
"cli_name": "ipasudorunas_group",
"cli_short_name": null,
"default": null,
"doc": "Run As Group",
"doc": "RunAs Group",
"exclude": null,
"flags": [
"no_update",
@ -14792,7 +14819,7 @@
],
"hint": null,
"include": null,
"label": "Run As Group",
"label": "RunAs Group",
"length": null,
"maxlength": null,
"minlength": null,
@ -16167,9 +16194,7 @@
"memberof_group": [
"admins"
],
"nsaccountlock": [
"False"
],
"nsaccountlock": false,
"objectclass": [
"top",
"person",