Authored by root

Add az3 for dns switch

... ... @@ -47,16 +47,19 @@ class switch_handler():
#Load DNS params
self.zone1_yml = '{0}/inventories/az1/group_vars/all.yml'.format(self.project_home)
self.zone2_yml = '{0}/inventories/az2/group_vars/all.yml'.format(self.project_home)
self.zone3_yml = '{0}/inventories/az3/group_vars/all.yml'.format(self.project_home)
self.zone1_tmp_yml = '{0}/inventories/az1/group_vars/.switch.yml.tmp'.format(self.project_home)
self.zone2_tmp_yml = '{0}/inventories/az2/group_vars/.switch.yml.tmp'.format(self.project_home)
self.zone3_tmp_yml = '{0}/inventories/az3/group_vars/.switch.yml.tmp'.format(self.project_home)
self.az1_vars = open(self.zone1_yml).read().strip('\n').split('\n')
self.az2_vars = open(self.zone2_yml).read().strip('\n').split('\n')
self.az3_vars = open(self.zone3_yml).read().strip('\n').split('\n')
self.dns_playbook = '{0}/playbooks/yoho.dns.yml'.format(self.project_home)
def run(self):
os.chdir(self.project_home)
varsMarker = vars_maker(self.az1_vars,self.az2_vars,self.zone1_tmp_yml,self.zone2_tmp_yml)
varsMarker = vars_maker(self.az1_vars,self.az2_vars,self.az3_vars,self.zone1_tmp_yml,self.zone2_tmp_yml,self.zone3_tmp_yml)
dbHandler = db_handler(self.zone,self.project_home,self.db_playbook,self.key_file)
dnsHandler = dns_handler(self.zone,self.project_home,self.dns_playbook,self.key_file)
cobarHandler = cobar_handler(self.zone,self.project_home,self.cobar_playbook,self.key_file,self.passwd)
... ...
... ... @@ -17,15 +17,17 @@ class vars_maker():
demo = vars_maker()
demo.start()
"""
def __init__(self, az1_vars, az2_vars, zone1_tmp_yml, zone2_tmp_yml):
def __init__(self, az1_vars, az2_vars, az3_vars, zone1_tmp_yml, zone2_tmp_yml, zone3_tmp_yml):
self.az1_write_map = {}
self.az2_read_map = {}
self.tmp_dns_map = {}
self.az1_vars = az1_vars
self.az2_vars = az2_vars
self.az3_vars = az3_vars
self.zone1_tmp_yml = zone1_tmp_yml
self.zone2_tmp_yml = zone2_tmp_yml
self.zone3_tmp_yml = zone3_tmp_yml
self.target_dns = [
"db_cms_write",
... ... @@ -72,6 +74,9 @@ class vars_maker():
elif zoneNum == 2:
tmp_yml = self.zone2_tmp_yml
var_rows = self.az2_vars
elif zoneNum == 3:
tmp_yml = self.zone3_tmp_yml
var_rows = self.az3_vars
else:
print 'Wrong zone number! Must be integer in value [1,2,3]!'
return False
... ... @@ -102,6 +107,6 @@ class vars_maker():
self.tmp_dns_map[tmp_dns] = tmp_ip
print 'Write DNS after switch:'
print json.dumps(self.tmp_dns_map,indent=2)
for zoneNum in [1,2]:
for zoneNum in [1,2,3]:
self.update_tmp_vars(zoneNum)
return True
... ...