mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-09 15:10:27 +00:00
Allow to set SOA-EDIT-API option when create new domain (zone)
This commit is contained in:
parent
3af9fc42e2
commit
a4df1e47fe
@ -458,18 +458,29 @@ class Domain(db.Model):
|
||||
logging.error('Can not update domain table.' + str(e))
|
||||
return {'status': 'error', 'msg': 'Can not update domain table'}
|
||||
|
||||
def add(self, domain_name, domain_type, domain_ns=[], domain_master_ips=[]):
|
||||
def add(self, domain_name, domain_type, soa_edit_api, domain_ns=[], domain_master_ips=[]):
|
||||
"""
|
||||
Add a domain to power dns
|
||||
"""
|
||||
headers = {}
|
||||
headers['X-API-Key'] = PDNS_API_KEY
|
||||
|
||||
if soa_edit_api == 'OFF':
|
||||
post_data = {
|
||||
"name": domain_name,
|
||||
"kind": domain_type,
|
||||
"masters": domain_master_ips,
|
||||
"nameservers": domain_ns
|
||||
"nameservers": domain_ns,
|
||||
}
|
||||
else:
|
||||
post_data = {
|
||||
"name": domain_name,
|
||||
"kind": domain_type,
|
||||
"masters": domain_master_ips,
|
||||
"nameservers": domain_ns,
|
||||
"soa_edit_api": soa_edit_api
|
||||
}
|
||||
|
||||
try:
|
||||
jdata = utils.fetch_json(urlparse.urljoin(PDNS_STATS_URL, '/servers/localhost/zones'), headers=headers, method='POST', data=post_data)
|
||||
if 'error' in jdata.keys():
|
||||
|
@ -68,7 +68,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group form-md-radios">
|
||||
<label>Type</label>
|
||||
<label><strong>Type</strong></label>
|
||||
<div class="md-radio-inline">
|
||||
<div class="md-radio">
|
||||
<input type="radio" id="radio_type_native" name="radio_type" class="md-radiobtn" value="native" checked="" onclick="javascript:zoneTypeSelection();">
|
||||
@ -102,6 +102,73 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group form-md-radios">
|
||||
<label><strong>SOA-EDIT-API</strong></label>
|
||||
<div class="md-radio-inline">
|
||||
<div class="md-radio">
|
||||
<input type="radio" id="radio_off" name="radio_type_soa_edit_api" class="md-radiobtn" value="OFF" checked="">
|
||||
<label for="radio_off">
|
||||
<span class="inc"></span>
|
||||
<span class="check"></span>
|
||||
<span class="box"></span>
|
||||
(OFF)</label>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="md-radio">
|
||||
<input type="radio" id="radio_inception_increment" name="radio_type_soa_edit_api" class="md-radiobtn" value="INCEPTION-INCREMENT" checked="">
|
||||
<label for="radio_inception_increment">
|
||||
<span class="inc"></span>
|
||||
<span class="check"></span>
|
||||
<span class="box"></span>
|
||||
INCEPTION-INCREMENT</label>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="md-radio">
|
||||
<input type="radio" id="radio_inception" name="radio_type_soa_edit_api" class="md-radiobtn" value="INCEPTION">
|
||||
<label for="radio_inception">
|
||||
<span class="inc"></span>
|
||||
<span class="check"></span>
|
||||
<span class="box"></span>
|
||||
INCEPTION</label>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="md-radio">
|
||||
<input type="radio" id="radio_increment_week" name="radio_type_soa_edit_api" class="md-radiobtn" value="INCREMENT-WEEK">
|
||||
<label for="radio_increment_week">
|
||||
<span class="inc"></span>
|
||||
<span class="check"></span>
|
||||
<span class="box"></span>
|
||||
INCREMENT-WEEK</label>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="md-radio">
|
||||
<input type="radio" id="radio_increment_weeks" name="radio_type_soa_edit_api" class="md-radiobtn" value="INCREMENT-WEEKS">
|
||||
<label for="radio_increment_weeks">
|
||||
<span class="inc"></span>
|
||||
<span class="check"></span>
|
||||
<span class="box"></span>
|
||||
INCREMENT-WEEKS</label>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="md-radio">
|
||||
<input type="radio" id="radio_epoch" name="radio_type_soa_edit_api" class="md-radiobtn" value="EPOCH">
|
||||
<label for="radio_epoch">
|
||||
<span class="inc"></span>
|
||||
<span class="check"></span>
|
||||
<span class="box"></span>
|
||||
EPOCH</label>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="md-radio">
|
||||
<input type="radio" id="radio_inception_epoch" name="radio_type_soa_edit_api" class="md-radiobtn" value="INCEPTION-EPOCH">
|
||||
<label for="radio_inception_epoch">
|
||||
<span class="inc"></span>
|
||||
<span class="check"></span>
|
||||
<span class="box"></span>
|
||||
INCEPTION-EPOCH</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<div class="row">
|
||||
<div class="col-md-offset-1">
|
||||
|
@ -159,6 +159,7 @@ def domain_add():
|
||||
try:
|
||||
domain_name = request.form.getlist('domain_name')[0]
|
||||
domain_type = request.form.getlist('radio_type')[0]
|
||||
soa_edit_api = request.form.getlist('radio_type_soa_edit_api')[0]
|
||||
|
||||
if ' ' in domain_name or not domain_name or not domain_type:
|
||||
return render_template('400.html', msg="Please correct your input"), 400
|
||||
@ -171,7 +172,7 @@ def domain_add():
|
||||
else:
|
||||
domain_master_ips = []
|
||||
d = Domain()
|
||||
result = d.add(domain_name=domain_name, domain_type=domain_type, domain_master_ips=domain_master_ips)
|
||||
result = d.add(domain_name=domain_name, domain_type=domain_type, soa_edit_api=soa_edit_api, domain_master_ips=domain_master_ips)
|
||||
if result['status'] == 'ok':
|
||||
history = History(msg='Add domain %s' % domain_name, detail=str({'domain_type': domain_type, 'domain_master_ips': domain_master_ips}), created_by=current_user.username)
|
||||
history.add()
|
||||
@ -231,6 +232,7 @@ def domain_management(domain_name):
|
||||
|
||||
return redirect(url_for('domain_management', domain_name=domain_name))
|
||||
|
||||
|
||||
@app.route('/domain/<string:domain_name>/apply', methods=['POST'], strict_slashes=False)
|
||||
@login_required
|
||||
def record_apply(domain_name):
|
||||
@ -291,7 +293,6 @@ def record_update(domain_name):
|
||||
return make_response(jsonify( {'status': 'error', 'msg': 'Error when applying new changes'} ), 500)
|
||||
|
||||
|
||||
|
||||
@app.route('/domain/<string:domain_name>/record/<string:record_name>/type/<string:record_type>/delete', methods=['GET'])
|
||||
@login_required
|
||||
@admin_role_required
|
||||
@ -444,7 +445,6 @@ def user_avatar(filename):
|
||||
@login_required
|
||||
def index():
|
||||
return redirect(url_for('dashboard'))
|
||||
#return make_response(jsonify( { 'status': 'ok', 'msg': 'This is a test page' } ), 200)
|
||||
|
||||
# END VIEWS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user