| |
| |
| |
| from fabric.colors import red,green,yellow |
| from fabric.api import env ,local, run, task , hosts ,execute , parallel,roles,serial,get,put,cd,prefix,warn_only |
| import time |
| import re |
| |
| switch = 'on' |
| |
| SERVER_CACHE = '/tmp/reXMin/' |
| |
| |
| TESTSTORAGE1_HOST = 'xxx.xxx.xx.221' |
| TESTSTORAGE2_HOST = 'xxx.xxx.xx.231' |
| TESTSTORAGE3_HOST = 'xxx.xxx.xx.234' |
| TESTSTORAGE4_HOST = 'xxx.xxx.xx.159' |
| BJPROJECT_HOST = 'xxx.xxx.xx.199' |
| PROJECT_HOST = 'xxx.xxx.xx.178' |
| TESTWORK_HOST = 'xxx.xxx.xx.222' |
| PUBLIC_HOST = 'xxx.xxx.xx.150' |
| DIR_HOME_HOST = 'xxx.xxx.xx.150' |
| |
| TESTSTORAGE6_TESTSTORAGEHEAD_HOST = 'xxx.xxx.xx.7' |
| TESTSTORAGE5_LOGIN07_HOST = 'xxx.xxx.xx.7' |
| PDD_LOGIN07_HOST = 'xxx.xxx.xx.7' |
| XXM_LOGIN07_HOST = 'xxx.xxx.xx.7' |
| XXXJ1_LOGIN07_HOST = 'xxx.xxx.xx.7' |
| TCX1X_LOGIN07_HOST = 'xxx.xxx.xx.7' |
| LOADTAN1_LOGIN07_HOST = 'xxx.xxx.xx.7' |
| LOADTAN2_LOGIN07_HOST = 'xxx.xxx.xx.7' |
| TESTSTORAGENAS01_LOGIN07_HOST = 'xxx.xxx.xx.7' |
| |
| XM2_HOST = 'xxx.xxx.xx.236' |
| |
| XM1_XMHEAD_HOST = 'xxx.xxx.xx.1' |
| XM3_XMHEAD_HOST = 'xxx.xxx.xx.1' |
| |
| STORAGE_USER = 'user1' |
| STORAGE_PASSWD = 'TestO.09c1' |
| |
| env.roledefs = { |
| 'TESTSTORAGE1': [TESTSTORAGE1_HOST], |
| 'TESTSTORAGE2': [TESTSTORAGE2_HOST], |
| 'TESTSTORAGE3': [TESTSTORAGE3_HOST], |
| 'TESTSTORAGE4': [TESTSTORAGE4_HOST], |
| 'bjPROJECT': [BJPROJECT_HOST], |
| 'PROJECT': [PROJECT_HOST], |
| 'TESTWORK': [TESTWORK_HOST], |
| 'public': [PUBLIC_HOST], |
| 'DIR_HOME': [DIR_HOME_HOST], |
| |
| 'TESTSTORAGE6': [TESTSTORAGE6_TESTSTORAGEHEAD_HOST], |
| 'TESTSTORAGE5': [TESTSTORAGE5_LOGIN07_HOST], |
| 'TESTCDD': [TESTCDD_LOGIN07_HOST], |
| 'RMX1': [RMX1_LOGIN07_HOST], |
| 'XXJ1': [XXJ1_LOGIN07_HOST], |
| 'TCX1': [TCX1_LOGIN07_HOST], |
| 'TAN1': [TAN1_LOGIN07_HOST], |
| 'TAN2': [TAN2_LOGIN07_HOST], |
| 'TESTSTORAGEnas01': [TESTSTORAGENAS01_LOGIN07_HOST], |
| |
| 'XM2': [XM2_HOST], |
| |
| 'XM1': [XM1_XMHEAD_HOST], |
| 'XM3': [XM3_XMHEAD_HOST], |
| } |
| |
| LOGING_USER = 'Test' |
| ISILON_PASSWD = 'test' |
| env.passwords = { |
| LOGING_USER + '@' + TESTSTORAGE1_HOST + ':22': ISILON_PASSWD, |
| LOGING_USER + '@' + TESTSTORAGE2_HOST + ':22': ISILON_PASSWD, |
| LOGING_USER + '@' + TESTSTORAGE3_HOST + ':22': ISILON_PASSWD, |
| LOGING_USER + '@' + TESTSTORAGE4_HOST + ':22': ISILON_PASSWD, |
| LOGING_USER + '@' + TESTWORK_HOST + ':22': ISILON_PASSWD, |
| LOGING_USER + '@' + PUBLIC_HOST + ':22': ISILON_PASSWD, |
| LOGING_USER + '@' + DIR_HOME_HOST +':22': ISILON_PASSWD, |
| LOGING_USER + '@' + BJPROJECT_HOST + ':22': ISILON_PASSWD, |
| LOGING_USER + '@' + PROJECT_HOST + ':22': ISILON_PASSWD, |
| LOGING_USER + '@' + XM2_HOST + ':22': ISILON_PASSWD, |
| } |
| env.key_filename = '~/.ssh/id_rsa' |
| env.user = LOGING_USER |
| |
| |
| rongzhiian_command_get = 'quota list' |
| isi_command_get = "isi quota quotas list | grep -w '{}' | awk \'{{print $5}}\'" |
| isi_command_set = 'isi quota quotas modify {} directory --hard-threshold {}' |
| rongzhiian_command_set = 'quota set' |
| create_bash = 'create_bash_expect.sh' |
| storage_name = { |
| 'TESTSTORAGE1': 'TESTSTORAGEPROJECT1', |
| 'TESTSTORAGE2': 'TESTSTORAGEPROJECT2', |
| 'TESTSTORAGE3': 'TESTSTORAGEPROJECT3', |
| 'TESTSTORAGE4': 'TESTSTORAGEPROJECT4', |
| 'BJPROJECT': 'BJPROJECT', |
| 'PROJECT': 'PROJECT', |
| 'TESTWORK': 'TESTWORK', |
| 'PUBLIC': 'PUBLIC', |
| 'DIR_HOME': 'dirhome', |
| 'TESTSTORAGE6': 'TESTSTORAGEPROJECT6', |
| 'TESTSTORAGE5': 'TESTSTORAGEPROJECT5', |
| 'TESTCDD': 'TESTCDD', |
| 'RMX1': 'RMX1', |
| 'XXJ1': 'XXJ1', |
| 'TCX1': 'TCX1', |
| 'TAN1': 'TAN1', |
| 'TAN2': 'TAN2', |
| 'TESTSTORAGENAS01': 'TESTSTORAGENAS01', |
| 'XM2': 'XMPROJECT2', |
| 'XM3': 'XMPROJECT3', |
| 'XM1': 'XMPROJECT1', |
| } |
| |
| |
| def switch_on(run_set): |
| if switch == 'off': |
| print(run_set) |
| if switch == 'on': |
| run(run_set) |
| |
| def prompt_file_list(): |
| prompt_file = open('change_storage.txt') |
| prompt_file_read = prompt_file.readlines() |
| for print_prompt in prompt_file_read: |
| print(red(print_prompt.replace('\n',""))) |
| check_file_list = input(green("请核对您的存储修改列表信息,如果有误请输入'q|quit|Q|QUIT'退出: ")) |
| if check_file_list == 'q' or check_file_list == 'quit' or check_file_list == 'Q' or check_file_list == 'QUIT': |
| exit('100') |
| draw_list = [] |
| for draw_cut in range(len(prompt_file_read)): |
| if '---' in prompt_file_read[draw_cut] and '增加量' in prompt_file_read[draw_cut]: |
| draw_list = prompt_file_read[1:draw_cut] |
| draw_re_list = [] |
| for draw_list_tuple in draw_list: |
| re_draw_list_tuple = re.sub(' +',' ',draw_list_tuple) |
| draw_re_list.append(re_draw_list_tuple.strip().replace(" ",",").replace("\t",",")) |
| |
| for draw_cut in range(len(prompt_file_read)): |
| if '---' in prompt_file_read[draw_cut] and '增加量' in prompt_file_read[draw_cut]: |
| add_list = prompt_file_read[draw_cut+1:] |
| add_re_list = [] |
| for add_list_tuple in add_list: |
| re_add_list_tuple = re.sub(' +',' ',add_list_tuple) |
| add_re_list.append(re_add_list_tuple.strip().replace(" ",",").replace("\t",",")) |
| return [draw_re_list,add_re_list] |
| |
| def mkdir_server_cache(): |
| mkdir_command = '[ -d {} ] || mkdir {}'.format(SERVER_CACHE,SERVER_CACHE) |
| run(mkdir_command) |
| def repliace_bash_file(command,ip_list): |
| replace_bash_file = 'bash_expect.sh' |
| replace_bash_file_create = create_bash |
| replace_bash_read = open(replace_bash_file, "r") |
| replace_bash_write = open(replace_bash_file_create, "w") |
| |
| with replace_bash_read as f: |
| read = f.read() |
| read = read.replace('$COMMAND$',command) |
| read = read.replace('$IP_LIST$',ip_list) |
| with replace_bash_write as f: |
| f.write(read) |
| |
| |
| |
| def repliace_auth_bash_file(command,ip_list): |
| replace_bash_file = 'auth_bash_expect.sh' |
| replace_bash_file_create = create_bash |
| replace_bash_read = open(replace_bash_file, "r") |
| replace_bash_write = open(replace_bash_file_create, "w") |
| |
| with replace_bash_read as f: |
| read = f.read() |
| read = read.replace('$COMMAND$',command) |
| read = read.replace('$IP_LIST$',ip_list) |
| read = read.replace("$USER$",STORAGE_USER) |
| read = read.replace("$PASSWD$",STORAGE_PASSWD) |
| |
| with replace_bash_write as f: |
| f.write(read) |
| |
| |
| def print_change_message(source_quota,source_size,change_size,): |
| print(source_quota,source_size,change_size) |
| print(green("您的配额路径是:") + red(str(source_quota)) + green(" ,原大小是:") + red(str(str(source_size)+"TB")) \ |
| + green(" ,将调整为:") + red(str(change_size)+"TB")) |
| time.sleep(2) |
| |
| def print_change_message(source_quota,source_size,change_size,): |
| print(source_quota,source_size,change_size) |
| print(green("您的配额路径是:") + red(str(source_quota)) + green(" ,原大小是:") + red(str(str(source_size)+"TB")) \ |
| + green(" ,将调整为:") + red(str(change_size)+"TB")) |
| time.sleep(2) |
| |
| |
| |
| |
| |
| |
| |
| |
| @roles('TESTSTORAGEnas01') |
| @parallel |
| def set_TESTSTORAGEnas01(size,dir,item,source_quota): |
| mkdir_server_cache() |
| vol = 'xtvol' |
| command = rongzhiian_command_get + ' ' + vol |
| ip_list = '/PUBLIC/software/public/System/Python-2.7.6/bin/xtcli -l 10.1.100.35' |
| repliace_bash_file(command,ip_list) |
| put(create_bash,SERVER_CACHE) |
| run_size='expect {}{} > {}{}'.format(SERVER_CACHE,create_bash,SERVER_CACHE,storage_name['TESTSTORAGENAS01']) |
| get_size="cat {}{} | grep -w '{}' | awk \'{{print $2}}\'".format(SERVER_CACHE,storage_name['TESTSTORAGENAS01'],dir) |
| run(run_size) |
| now_size=run(get_size).replace('TB',"").replace("T","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "TB" |
| command = "{} {} {} {}".format(rongzhiian_command_set,vol,'/'+dir,last_set_size) |
| repliace_bash_file(command,ip_list) |
| put(create_bash, SERVER_CACHE) |
| run_set = 'expect {}{}'.format(SERVER_CACHE,create_bash) |
| local('cat ' + create_bash) |
| switch_on(run_set) |
| |
| @roles('TAN2') |
| @parallel |
| def set_TAN2(size,dir,item,source_quota): |
| mkdir_server_cache() |
| vol = 'vol2' |
| command = rongzhiian_command_get + ' ' + vol |
| ip_list = '/PUBLIC/software/public/System/Python-2.7.6/bin/xtcli -l 10.1.100.227' |
| repliace_bash_file(command,ip_list) |
| put(create_bash,SERVER_CACHE) |
| run_size='expect {}{} > {}{}'.format(SERVER_CACHE,create_bash,SERVER_CACHE,storage_name['TAN2']) |
| get_size="cat {}{} | grep -w '{}' | awk \'{{print $2}}\'".format(SERVER_CACHE,storage_name['TAN2'],dir) |
| run(run_size) |
| now_size=run(get_size).replace('TB',"").replace("T","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "TB" |
| command = "{} {} {} {}".format(rongzhiian_command_set,vol,'/'+dir,last_set_size) |
| repliace_bash_file(command,ip_list) |
| put(create_bash, SERVER_CACHE) |
| run_set = 'expect {}{}'.format(SERVER_CACHE,create_bash) |
| local('cat ' + create_bash) |
| switch_on(run_set) |
| |
| @roles('TAN1') |
| @parallel |
| def set_TAN1(size,dir,item,source_quota): |
| mkdir_server_cache() |
| vol = 'xtvol1' |
| command = rongzhiian_command_get + ' ' + vol |
| ip_list = '/PUBLIC/software/public/System/Python-2.7.6/bin/xtcli -l 10.1.100.227' |
| repliace_bash_file(command,ip_list) |
| put(create_bash,SERVER_CACHE) |
| run_size='expect {}{} > {}{}'.format(SERVER_CACHE,create_bash,SERVER_CACHE,storage_name['TAN1']) |
| get_size="cat {}{} | grep -w '{}' | awk \'{{print $2}}\'".format(SERVER_CACHE,storage_name['TAN1'],dir) |
| run(run_size) |
| now_size=run(get_size).replace('TB',"").replace("T","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "TB" |
| command = "{} {} {} {}".format(rongzhiian_command_set,vol,'/'+dir,last_set_size) |
| repliace_bash_file(command,ip_list) |
| put(create_bash, SERVER_CACHE) |
| run_set = 'expect {}{}'.format(SERVER_CACHE,create_bash) |
| local('cat ' + create_bash) |
| switch_on(run_set) |
| |
| |
| @roles('TCX1') |
| @parallel |
| def set_TCX1(size,dir,item,source_quota): |
| mkdir_server_cache() |
| vol = 'vol2mirror' |
| command = rongzhiian_command_get + ' ' + vol |
| ip_list = '/PUBLIC/software/public/System/Python-2.7.6/bin/xtcli -l 10.1.100.251' |
| repliace_bash_file(command,ip_list) |
| put(create_bash,SERVER_CACHE) |
| run_size='expect {}{} > {}{}'.format(SERVER_CACHE,create_bash,SERVER_CACHE,storage_name['TCX1']) |
| get_size="cat {}{} | grep -w '{}' | awk \'{{print $2}}\'".format(SERVER_CACHE,storage_name['TCX1'],dir) |
| run(run_size) |
| now_size=run(get_size).replace('TB',"").replace("T","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "TB" |
| command = "{} {} {} {}".format(rongzhiian_command_set,vol,'/'+dir,last_set_size) |
| repliace_bash_file(command,ip_list) |
| put(create_bash, SERVER_CACHE) |
| run_set = 'expect {}{}'.format(SERVER_CACHE,create_bash) |
| local('cat ' + create_bash) |
| switch_on(run_set) |
| @roles('XXJ1') |
| @parallel |
| def set_XXJ1(size,dir,item,source_quota): |
| mkdir_server_cache() |
| vol = 'vol1mirror' |
| command = rongzhiian_command_get + ' ' + vol |
| ip_list = '/PUBLIC/software/public/System/Python-2.7.6/bin/xtcli -l 10.1.100.251' |
| repliace_bash_file(command,ip_list) |
| put(create_bash,SERVER_CACHE) |
| run_size='expect {}{} > {}{}'.format(SERVER_CACHE,create_bash,SERVER_CACHE,storage_name['XXJ1']) |
| get_size="cat {}{} | grep -w '{}' | awk \'{{print $2}}\'".format(SERVER_CACHE,storage_name['XXJ1'],dir) |
| run(run_size) |
| now_size=run(get_size).replace('TB',"").replace("T","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "TB" |
| command = "{} {} {} {}".format(rongzhiian_command_set,vol,'/'+dir,last_set_size) |
| repliace_bash_file(command,ip_list) |
| put(create_bash, SERVER_CACHE) |
| run_set = 'expect {}{}'.format(SERVER_CACHE,create_bash) |
| local('cat ' + create_bash) |
| switch_on(run_set) |
| @roles('RMX1') |
| @parallel |
| def set_RMX1(size,dir,item,source_quota): |
| mkdir_server_cache() |
| vol = 'vol2' |
| command = rongzhiian_command_get + ' ' + vol |
| ip_list = '/PUBLIC/software/public/System/Python-2.7.6/bin/xtcli -l 10.1.100.251' |
| repliace_bash_file(command,ip_list) |
| put(create_bash,SERVER_CACHE) |
| run_size='expect {}{} > {}{}'.format(SERVER_CACHE,create_bash,SERVER_CACHE,storage_name['RMX1']) |
| get_size="cat {}{} | grep -w '{}' | awk \'{{print $2}}\'".format(SERVER_CACHE,storage_name['RMX1'],dir) |
| run(run_size) |
| now_size=run(get_size).replace('TB',"").replace("T","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "TB" |
| command = "{} {} {} {}".format(rongzhiian_command_set,vol,'/'+dir,last_set_size) |
| repliace_bash_file(command,ip_list) |
| put(create_bash, SERVER_CACHE) |
| run_set = 'expect {}{}'.format(SERVER_CACHE,create_bash) |
| local('cat ' + create_bash) |
| switch_on(run_set) |
| |
| @roles('TESTCDD') |
| @parallel |
| def set_TESTCDD(size,dir,item,source_quota): |
| mkdir_server_cache() |
| vol = 'vol1' |
| command = rongzhiian_command_get + ' ' + vol |
| ip_list = '/PUBLIC/software/public/System/Python-2.7.6/bin/xtcli -l 10.1.100.251' |
| repliace_bash_file(command,ip_list) |
| put(create_bash,SERVER_CACHE) |
| run_size='expect {}{} > {}{}'.format(SERVER_CACHE,create_bash,SERVER_CACHE,storage_name['TAN1']) |
| get_size="cat {}{} | grep -w '{}' | awk \'{{print $2}}\'".format(SERVER_CACHE,storage_name['TAN1'],dir) |
| run(run_size) |
| now_size=run(get_size).replace('TB',"").replace("T","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "TB" |
| command = "{} {} {} {}".format(rongzhiian_command_set,vol,'/'+dir,last_set_size) |
| repliace_bash_file(command,ip_list) |
| put(create_bash, SERVER_CACHE) |
| run_set = 'expect {}{}'.format(SERVER_CACHE,create_bash) |
| local('cat ' + create_bash) |
| switch_on(run_set) |
| |
| @roles('TESTSTORAGE5') |
| @parallel |
| def set_TESTSTORAGE5(size,dir,item,source_quota): |
| mkdir_server_cache() |
| vol = 'vol1' |
| command = rongzhiian_command_get + ' ' + vol |
| ip_list = '/PUBLIC/software/public/System/Python-2.7.6/bin/alamocli -l 10.1.100.192 -c' |
| repliace_auth_bash_file(command,ip_list) |
| put(create_bash,SERVER_CACHE) |
| run_size='expect {}{} > {}{}'.format(SERVER_CACHE,create_bash,SERVER_CACHE,storage_name['TAN1']) |
| get_size="cat {}{} | grep -w '{}' | awk \'{{print $4}}\'".format(SERVER_CACHE,storage_name['TAN1'],dir) |
| run(run_size) |
| now_size=run(get_size).replace('TB',"").replace("T","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "TB" |
| command = "{} {} {} {}".format(rongzhiian_command_set,vol,'/'+dir,last_set_size) |
| repliace_auth_bash_file(command,ip_list) |
| put(create_bash, SERVER_CACHE) |
| run_set = 'expect {}{}'.format(SERVER_CACHE,create_bash) |
| local('cat ' + create_bash) |
| switch_on(run_set) |
| |
| |
| @roles('TESTSTORAGE6') |
| @parallel |
| def set_TESTSTORAGE6(size,dir,item,source_quota): |
| mkdir_server_cache() |
| vol = 'vol1' |
| command = rongzhiian_command_get + ' ' + vol |
| ip_list = '/PUBLIC/software/public/System/Python-2.7.6/bin/alamocli -l 10.1.190.1 -c' |
| repliace_auth_bash_file(command,ip_list) |
| put(create_bash,SERVER_CACHE) |
| run_size='expect {}{} > {}{}'.format(SERVER_CACHE,create_bash,SERVER_CACHE,storage_name['TESTSTORAGE6']) |
| get_size="cat {}{} | grep -w '{}' | awk \'{{print $4}}\'".format(SERVER_CACHE,storage_name['TESTSTORAGE6'],dir) |
| run(run_size) |
| now_size=run(get_size).replace('TB',"").replace("T","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "TB" |
| command = "{} {} {} {}".format(rongzhiian_command_set,vol,'/'+dir,last_set_size) |
| repliace_auth_bash_file(command,ip_list) |
| put(create_bash, SERVER_CACHE) |
| run_set = 'expect {}{}'.format(SERVER_CACHE,create_bash) |
| local('cat ' + create_bash) |
| switch_on(run_set) |
| |
| |
| |
| |
| @roles('XM1') |
| @parallel |
| def set_XM1(size,dir,item,source_quota): |
| mkdir_server_cache() |
| vol = 'vol1' |
| command = rongzhiian_command_get + ' ' + vol |
| ip_list = '/client_NL/Python2.7/bin/xtcli -l 10.2.100.1' |
| repliace_bash_file(command,ip_list) |
| put(create_bash,SERVER_CACHE) |
| run_size='expect {}{} > {}{}'.format(SERVER_CACHE,create_bash,SERVER_CACHE,storage_name['XM1']) |
| get_size="cat {}{} | grep -w '{}' | awk \'{{print $2}}\'".format(SERVER_CACHE,storage_name['XM1'],dir) |
| run(run_size) |
| now_size=run(get_size).replace('TB',"").replace("T","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "TB" |
| command = "{} {} {} {}".format(rongzhiian_command_set,vol,'/'+dir,last_set_size) |
| repliace_bash_file(command,ip_list) |
| put(create_bash, SERVER_CACHE) |
| run_set = 'expect {}{}'.format(SERVER_CACHE,create_bash) |
| local('cat ' + create_bash) |
| switch_on(run_set) |
| |
| |
| |
| @roles('XM3') |
| @parallel |
| def set_XM3(size,dir,item,source_quota): |
| mkdir_server_cache() |
| vol = 'xtvol' |
| command = rongzhiian_command_get + ' ' + vol |
| ip_list = '/client_NL/Python2.7/bin/xtcli -l 10.2.100.11' |
| repliace_bash_file(command,ip_list) |
| put(create_bash,SERVER_CACHE) |
| run_size='expect {}{} > {}{}'.format(SERVER_CACHE,create_bash,SERVER_CACHE,storage_name['XM3']) |
| get_size="cat {}{} | grep -w '{}' | awk \'{{print $2}}\'".format(SERVER_CACHE,storage_name['XM3'],dir) |
| run(run_size) |
| now_size=run(get_size).replace('TB',"").replace("T","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "TB" |
| command = "{} {} {} {}".format(rongzhiian_command_set,vol,'/'+dir,last_set_size) |
| repliace_bash_file(command,ip_list) |
| put(create_bash, SERVER_CACHE) |
| run_set = 'expect {}{}'.format(SERVER_CACHE,create_bash) |
| local('cat ' + create_bash) |
| switch_on(run_set) |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| @roles('PROJECT') |
| @parallel |
| def set_PROJECT(size,dir,item,source_quota): |
| mkdir_server_cache() |
| get_size = isi_command_get.format(dir) |
| now_size=run(get_size).replace('TB',"").replace("T","").replace("\r\n-\r\n-\r\n-\r\n-","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "T" |
| run_set = isi_command_set.format(dir,last_set_size) |
| switch_on(run_set) |
| |
| @roles('PROJECT') |
| @parallel |
| def set_PROJECT(size,dir,item,source_quota): |
| mkdir_server_cache() |
| get_size = isi_command_get.format(dir) |
| now_size=run(get_size).replace('TB',"").replace("T","").replace("\r\n-\r\n-\r\n-\r\n-","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "T" |
| run_set = isi_command_set.format(dir,last_set_size) |
| switch_on(run_set) |
| |
| @roles('bjPROJECT') |
| @parallel |
| def set_bjPROJECT(size,dir,item,source_quota): |
| mkdir_server_cache() |
| get_size = isi_command_get.format(dir) |
| now_size=run(get_size).replace('TB',"").replace("T","").replace("\r\n-\r\n-\r\n-\r\n-","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "T" |
| run_set = isi_command_set.format(dir,last_set_size) |
| switch_on(run_set) |
| |
| @roles('TESTSTORAGE4') |
| @parallel |
| def set_TESTSTORAGE4(size,dir,item,source_quota): |
| mkdir_server_cache() |
| get_size = isi_command_get.format(dir) |
| now_size=run(get_size).replace('TB',"").replace("T","").replace("\r\n-\r\n-\r\n-\r\n-","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "T" |
| run_set = isi_command_set.format(dir,last_set_size) |
| switch_on(run_set) |
| |
| |
| @roles('TESTSTORAGE3') |
| @parallel |
| def set_TESTSTORAGE3(size,dir,item,source_quota): |
| mkdir_server_cache() |
| get_size = isi_command_get.format(dir) |
| now_size=run(get_size).replace('TB',"").replace("T","").replace("\r\n-\r\n-\r\n-\r\n-","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "T" |
| run_set = isi_command_set.format(dir,last_set_size) |
| switch_on(run_set) |
| |
| @roles('TESTSTORAGE2') |
| @parallel |
| def set_TESTSTORAGE2(size,dir,item,source_quota): |
| mkdir_server_cache() |
| get_size = isi_command_get.format(dir) |
| now_size=run(get_size).replace('TB',"").replace("T","").replace("\r\n-\r\n-\r\n-\r\n-","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "T" |
| run_set = isi_command_set.format(dir,last_set_size) |
| switch_on(run_set) |
| |
| @roles('TESTSTORAGE1') |
| @parallel |
| def set_TESTSTORAGE1(size,dir,item,source_quota): |
| mkdir_server_cache() |
| get_size = isi_command_get.format(dir) |
| print(get_size) |
| |
| |
| |
| |
| get_size = isi_command_get.format(dir) |
| now_size=run(get_size).replace('TB',"").replace("T","").replace("\r\n-\r\n-\r\n-\r\n-","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| |
| |
| |
| |
| |
| |
| |
| print(set_size) |
| last_set_size = str(set_size) + "T" |
| run_set = isi_command_set.format(dir,last_set_size) |
| switch_on(run_set) |
| |
| |
| |
| @roles('XM2') |
| @parallel |
| def set_XM2(size,dir,item,source_quota): |
| mkdir_server_cache() |
| get_size = isi_command_get.format(dir) |
| now_size=run(get_size).replace('TB',"").replace("T","").replace("\r\n-\r\n-\r\n-\r\n-","") |
| if item == 'add': |
| set_size = float(now_size) + float(size) |
| if item == 'reduction': |
| set_size = float(now_size) - float(size) |
| print_change_message(source_quota=source_quota,source_size=now_size,change_size=set_size) |
| last_set_size = str(set_size) + "T" |
| run_set = isi_command_set.format(dir,last_set_size) |
| switch_on(run_set) |
| |
| @task(name='set_storage') |
| def set_storage(): |
| prompt_file =prompt_file_list() |
| |
| for storage_draw in prompt_file[0]: |
| item = 'reduction' |
| storage_draw_list = storage_draw.split(',') |
| if storage_draw_list[1][-1] == '/': |
| storage_draw_list[1] = storage_draw_list[1][:-1] |
| storage_dir_list = storage_draw_list[1].split('/') |
| if 'ifs' in storage_draw_list[1]: |
| dir = storage_draw_list[1] |
| else: |
| dir = str(storage_dir_list[2:]).replace("[","").replace("]","").replace(" ","").replace("'","").replace(",","/") |
| size = storage_draw_list[2] |
| print(storage_dir_list[1]) |
| |
| if 'ifs' not in storage_draw_list[1]: |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['TESTSTORAGENAS01']: |
| execute(set_TESTSTORAGEnas01,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['TAN2']: |
| execute(set_TAN2,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['TAN1']: |
| execute(set_TAN1,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['TCX1']: |
| execute(set_TCX1,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['XXJ1']: |
| execute(set_XXJ1,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['RMX1']: |
| execute(set_RMX1,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['TESTCDD']: |
| execute(set_TESTCDD,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['TESTSTORAGE5']: |
| execute(set_TESTSTORAGE5,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['TESTSTORAGE6']: |
| execute(set_TESTSTORAGE6,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域2' and storage_dir_list[1] == storage_name['XM1']: |
| execute(set_XM1,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域2' and storage_dir_list[1] == storage_name['XM3']: |
| execute(set_XM3,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| |
| if 'ifs' in storage_draw_list[1]: |
| |
| |
| |
| |
| if storage_draw_list[0] == '区域1' and storage_dir_list[2] == storage_name['PROJECT']: |
| execute(set_PROJECT,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[2] == storage_name['BJPROJECT']: |
| execute(set_bjPROJECT,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[2] == storage_name['TESTSTORAGE4']: |
| execute(set_TESTSTORAGE4,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[2] == storage_name['TESTSTORAGE3']: |
| execute(set_TESTSTORAGE3,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[2] == storage_name['TESTSTORAGE2']: |
| execute(set_TESTSTORAGE2,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[2] == storage_name['TESTSTORAGE1']: |
| execute(set_TESTSTORAGE1,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| |
| if storage_draw_list[0] == '区域2' and storage_dir_list[2] == storage_name['XM2']: |
| execute(set_XM2,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| |
| for storage_draw in prompt_file[1]: |
| item = 'add' |
| storage_draw_list = storage_draw.split(',') |
| if storage_draw_list[1][-1] == '/': |
| storage_draw_list[1] = storage_draw_list[1][:-1] |
| storage_dir_list = storage_draw_list[1].split('/') |
| if 'ifs' in storage_draw_list[1]: |
| dir = storage_draw_list[1] |
| else: |
| dir = storage_dir_list[-1] |
| size = storage_draw_list[2] |
| |
| if 'ifs' not in storage_draw_list[1]: |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['TESTSTORAGENAS01']: |
| execute(set_TESTSTORAGEnas01,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['TAN2']: |
| execute(set_TAN2,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['TCX1']: |
| execute(set_TCX1, size=size, dir=dir, item=item, source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['TAN1']: |
| execute(set_TAN1,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['XXJ1']: |
| execute(set_XXJ1,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['RMX1']: |
| execute(set_RMX1,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['TESTCDD']: |
| execute(set_TESTCDD,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['TESTSTORAGE5']: |
| execute(set_TESTSTORAGE5,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[1] == storage_name['TESTSTORAGE6']: |
| execute(set_TESTSTORAGE6,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域2' and storage_dir_list[1] == storage_name['XM1']: |
| execute(set_XM1,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域2' and storage_dir_list[1] == storage_name['XM3']: |
| execute(set_XM3,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| |
| if 'ifs' in storage_draw_list[1]: |
| |
| |
| |
| |
| if storage_draw_list[0] == '区域1' and storage_dir_list[2] == storage_name['PROJECT']: |
| execute(set_PROJECT,size=size,dir=dir,item=item,source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[2] == storage_name['BJPROJECT']: |
| execute(set_bjPROJECT, size=size, dir=dir, item=item, source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[2] == storage_name['TESTSTORAGE4']: |
| execute(set_TESTSTORAGE4, size=size, dir=dir, item=item, source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[2] == storage_name['TESTSTORAGE3']: |
| execute(set_TESTSTORAGE3, size=size, dir=dir, item=item, source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[2] == storage_name['TESTSTORAGE2']: |
| execute(set_TESTSTORAGE2, size=size, dir=dir, item=item, source_quota=storage_draw_list[1]) |
| if storage_draw_list[0] == '区域1' and storage_dir_list[2] == storage_name['TESTSTORAGE1']: |
| execute(set_TESTSTORAGE1, size=size, dir=dir, item=item, source_quota=storage_draw_list[1]) |
| |
| if storage_draw_list[0] == '区域2' and storage_dir_list[2] == storage_name['XM2']: |
| execute(set_XM2, size=size, dir=dir, item=item, source_quota=storage_draw_list[1]) |