Authored by root

Append java handler

... ... @@ -7,6 +7,7 @@ import os
import sys
import json
import argparse
from switch_lb import LBSwitch
... ... @@ -33,7 +34,17 @@ class vars_maker():
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.target_dns = ["db_cms_write","db_passport_write","db_shops_write","db_order_write","db_uic_write","db_ordersplit_1_write","db_ordersplit_2_write","db_ordersplit_3_write","db_ordersplit_4_write"]
self.target_dns = [
"db_cms_write",
"db_passport_write",
"db_shops_write",
"db_order_write",
"db_uic_write",
"db_ordersplit_1_write",
"db_ordersplit_2_write",
"db_ordersplit_3_write",
"db_ordersplit_4_write"
]
def splitVar(self,entry):
#将参数配置文件根据格式dns:ip分割成key,value形式
... ... @@ -149,13 +160,31 @@ class cobar_handler():
print rsp
return True
class clb_handler():
def __init__(self, secretId, secretKey, az1_lb_id, az2_lb_id, az3_lb_id, az1_innerlb_id, zone):
self.zone = zone
self.clbClient = LBSwitch(secretId, secretKey, az1_lb_id, az2_lb_id, az3_lb_id, az1_innerlb_id)
def start(self):
if self.zone == 'zone1':
ret = self.clbClient.all_to_az1()
elif self.zone == 'zone2':
ret = self.clbClient.all_to_az2()
else:
print 'Zone name {0} can not be recongnized'.format(self.zone)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--zone',type=str,help='The zone which will be the new center, must be in [zone1,zone2]')
parser.add_argument('--passwd',type=str,help='Cobar server mysql password')
parser.add_argument('--secretId',type=str,help='Qcloud secret id')
parser.add_argument('--secretKey',type=str,help='Qcloud secret key')
parser.add_argument('--az1_lb_id',type=str,help='Zone1 outer CLB id')
parser.add_argument('--az2_lb_id',type=str,help='Zone2 outer CLB id')
parser.add_argument('--az3_lb_id',type=str,help='Zone3 outer CLB id')
parser.add_argument('--az1_innerlb_id',type=str,help='Zone1 internal CLB id')
args = parser.parse_args()
... ... @@ -167,6 +196,9 @@ if __name__ == '__main__':
dnsMan = dns_handler(args.zone)
dnsMan.start()
cobarMan = cobar_handler(args.passwd)
cobar.start()
cobarMan.start()
clbMan = clbHandler(args.secretId, args.secretKey, args.az1_lb_id, args.az2_lb_id, args.az3_lb_id, args.az1_innerlb_id, args.zone)
clbMan.start()
... ...