Update update_zones.py bg script

This commit is contained in:
Khanh Ngo 2019-12-06 10:46:54 +07:00
parent 8de6df4d3b
commit 0234f21e1d

View File

@ -10,21 +10,26 @@
##############################################################
### Imports
from powerdnsadmin.models.domain import Domain
from config import BG_DOMAIN_UPDATES
import sys
import logging as logger
import logging
### Define logging
logging = logger.getLogger(__name__)
from flask import current_app
from powerdnsadmin import create_app
from powerdnsadmin.models.domain import Domain
from powerdnsadmin.models.setting import Setting
### Check if BG_DOMAIN_UPDATES is set to true
if not BG_DOMAIN_UPDATES:
logging.error('Set BG_DOMAIN_UPDATES to True in config.py')
app = create_app()
app.logger.setLevel(logging.INFO)
with app.app_context():
status = Setting().get('bg_domain_updates')
### Check if bg_domain_updates is set to true
if not status:
app.logger.error('Please turn on "bg_domain_updates" setting to run this job.')
sys.exit(1)
### Start the update process
logging.info('Update zones from nameserver API')
### Start the update process
app.logger.info('Update zones from nameserver API')
d = Domain().update()
d = Domain().update()