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))
|
logging.error('Can not update domain table.' + str(e))
|
||||||
return {'status': 'error', 'msg': 'Can not update domain table'}
|
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
|
Add a domain to power dns
|
||||||
"""
|
"""
|
||||||
headers = {}
|
headers = {}
|
||||||
headers['X-API-Key'] = PDNS_API_KEY
|
headers['X-API-Key'] = PDNS_API_KEY
|
||||||
post_data = {
|
|
||||||
"name": domain_name,
|
if soa_edit_api == 'OFF':
|
||||||
"kind": domain_type,
|
post_data = {
|
||||||
"masters": domain_master_ips,
|
"name": domain_name,
|
||||||
"nameservers": domain_ns
|
"kind": domain_type,
|
||||||
}
|
"masters": domain_master_ips,
|
||||||
|
"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:
|
try:
|
||||||
jdata = utils.fetch_json(urlparse.urljoin(PDNS_STATS_URL, '/servers/localhost/zones'), headers=headers, method='POST', data=post_data)
|
jdata = utils.fetch_json(urlparse.urljoin(PDNS_STATS_URL, '/servers/localhost/zones'), headers=headers, method='POST', data=post_data)
|
||||||
if 'error' in jdata.keys():
|
if 'error' in jdata.keys():
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group form-md-radios">
|
<div class="form-group form-md-radios">
|
||||||
<label>Type</label>
|
<label><strong>Type</strong></label>
|
||||||
<div class="md-radio-inline">
|
<div class="md-radio-inline">
|
||||||
<div class="md-radio">
|
<div class="md-radio">
|
||||||
<input type="radio" id="radio_type_native" name="radio_type" class="md-radiobtn" value="native" checked="" onclick="javascript:zoneTypeSelection();">
|
<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>
|
||||||
</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="form-actions">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-offset-1">
|
<div class="col-md-offset-1">
|
||||||
|
@ -159,6 +159,7 @@ def domain_add():
|
|||||||
try:
|
try:
|
||||||
domain_name = request.form.getlist('domain_name')[0]
|
domain_name = request.form.getlist('domain_name')[0]
|
||||||
domain_type = request.form.getlist('radio_type')[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:
|
if ' ' in domain_name or not domain_name or not domain_type:
|
||||||
return render_template('400.html', msg="Please correct your input"), 400
|
return render_template('400.html', msg="Please correct your input"), 400
|
||||||
@ -171,7 +172,7 @@ def domain_add():
|
|||||||
else:
|
else:
|
||||||
domain_master_ips = []
|
domain_master_ips = []
|
||||||
d = Domain()
|
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':
|
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 = 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()
|
history.add()
|
||||||
@ -231,6 +232,7 @@ def domain_management(domain_name):
|
|||||||
|
|
||||||
return redirect(url_for('domain_management', domain_name=domain_name))
|
return redirect(url_for('domain_management', domain_name=domain_name))
|
||||||
|
|
||||||
|
|
||||||
@app.route('/domain/<string:domain_name>/apply', methods=['POST'], strict_slashes=False)
|
@app.route('/domain/<string:domain_name>/apply', methods=['POST'], strict_slashes=False)
|
||||||
@login_required
|
@login_required
|
||||||
def record_apply(domain_name):
|
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)
|
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'])
|
@app.route('/domain/<string:domain_name>/record/<string:record_name>/type/<string:record_type>/delete', methods=['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
@admin_role_required
|
@admin_role_required
|
||||||
@ -444,7 +445,6 @@ def user_avatar(filename):
|
|||||||
@login_required
|
@login_required
|
||||||
def index():
|
def index():
|
||||||
return redirect(url_for('dashboard'))
|
return redirect(url_for('dashboard'))
|
||||||
#return make_response(jsonify( { 'status': 'ok', 'msg': 'This is a test page' } ), 200)
|
|
||||||
|
|
||||||
# END VIEWS
|
# END VIEWS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user