Authored by root

脚本不再负责resolv文件刷新 交由tower schedule处理

... ... @@ -124,29 +124,30 @@ class EMRClusterScanner(object):
return True
def syncDNS(self,target='emr-recom'):
if target == 'emr-recom': #目前只负责同步emr-recom的DNS
cmd = 'ansible-playbook -i {0} {1}'.format(self.inventoryFile,self.playbook_resolv)
retry = 3
while retry > 0:
print cmd
output = os.popen(cmd).read()
if 'unreachable=1' in output or 'failed=1' in output:
with open('/var/log/supervisor/ansible.err','a') as f:
f.write(output+'\n\n')
f.close()
retry-=1
print "重新同步DNS...还剩{0}次".format(retry)
time.sleep(300)
continue
else:
with open('/var/log/supervisor/ansible.log','a') as f:
f.write(output+'\n\n')
f.close()
print "DNS 同步成功"
return True
return False
else:
return True
return True #脚本不再负责resolv文件刷新 交由tower schedule处理
#if target == 'emr-recom': #目前只负责同步emr-recom的DNS
# cmd = 'ansible-playbook -i {0} {1}'.format(self.inventoryFile,self.playbook_resolv)
# retry = 3
# while retry > 0:
# print cmd
# output = os.popen(cmd).read()
# if 'unreachable=1' in output or 'failed=1' in output:
# with open('/var/log/supervisor/ansible.err','a') as f:
# f.write(output+'\n\n')
# f.close()
# retry-=1
# print "重新同步DNS...还剩{0}次".format(retry)
# time.sleep(300)
# continue
# else:
# with open('/var/log/supervisor/ansible.log','a') as f:
# f.write(output+'\n\n')
# f.close()
# print "DNS 同步成功"
# return True
# return False
#else:
# return True
def checkDNS(self):
check_cmd = 'ansible-playbook -i {0} {1} --check'.format(self.inventoryFile,self.playbook_resolv)
... ...