Skip to content

Commit

Permalink
update view domain migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
guoli.luo committed Jan 31, 2019
1 parent 2b09ab3 commit febccb2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
7 changes: 5 additions & 2 deletions dns_updater/workers/zone_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import print_function
from dns_updater.utils.updater_util import *
import time

TMP_DIR = CONF.etc.tmp_dir
ZONE_DIR = CONF.bind_conf.zone_dir
Expand Down Expand Up @@ -71,7 +72,7 @@ def handler():

tmp_zonefile_path = make_zone_file_from_dnsdb(name)
if not is_need_update_zone(tmp_zonefile_path, current_zonefile_path):
return
continue
checkzone(name, tmp_zonefile_path)
zone_file_dict[name] = {
'src': tmp_zonefile_path,
Expand All @@ -86,8 +87,10 @@ def handler():
reload_and_backup_zones(zone_file_dict)
DnsdbApi.update_zone_serial(name)
log.info('update_zone_serial')
return True
time.sleep(1)
except UpdaterErr as e:
log.error(e.message)
send_alarm_email(u'zone %s 更新失败\n原因: %s' % (name, e.message))
except Exception as e:
log.exception(e)
send_alarm_email(u'zone %s 更新失败\n原因: %s' % (name, e))
28 changes: 14 additions & 14 deletions dnsdb_common/dal/view_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def get_view_domain_info(domain):

return {
'domain_name': domain,
'is_migrate': ViewRecordDal.is_migrate_domain(domain),
'is_migrate': ViewRecordDal.is_migrate_domain(view_domain),
'cnames': cdn_conf,
'rooms': room_confs
}
Expand Down Expand Up @@ -435,7 +435,7 @@ def insert_view_domain(username, domain_name, cnames, rooms):
))
# 新增域名 更新dnsmaster2
ViewRecordDal.increase_serial_num(VIEW_ZONE)
ViewRecordDal.increase_serial_num(cname_zone)
# ViewRecordDal.increase_serial_num(cname_zone)

@staticmethod
def update_view_domain(username, domain_name, cnames, rooms):
Expand Down Expand Up @@ -577,16 +577,16 @@ def update_view_domain_state(domain_name, isp_dict):
@staticmethod
@commit_on_success
def delete_view_domain(domain_name):
session = db.session
record = DnsRecord.query.filter_by(record=domain_name).all()
if len(record):
raise BadParam('view domain has cname record: %s' % domain_name,
msg_ch=u'请先删除域名的cname记录')

zone = ViewRecordDal.get_view_domain_zone(domain_name)
session.query(ViewRecords).filter_by(domain_name=domain_name).delete()
session.query(ViewDomainNameState).filter_by(domain_name=domain_name).delete()
session.query(ViewDomainNames).filter_by(domain_name=domain_name).delete()

for update_zone in [zone, VIEW_ZONE]:
need_update = [VIEW_ZONE]

need_update.append(ViewRecordDal.get_view_domain_zone(domain_name))
ViewRecords.query.filter_by(domain_name=domain_name).delete()
ViewDomainNameState.query.filter_by(domain_name=domain_name).delete()
ViewDomainNames.query.filter_by(cname=domain_name).delete()

record = DnsRecord.query.filter_by(record=domain_name).first()
need_update.append(record.zone_name)
db.session.delete(record)

for update_zone in need_update:
ViewRecordDal.increase_serial_num(update_zone)

0 comments on commit febccb2

Please sign in to comment.