def transform(self, gameServers, all_gameServer_info=None):
"""
Transform funcion.
eg: it will transformat from
['astd_37wan_2', 'astd_51wan_99', 'astd_uoyoo_90']
to
{
'10.6.20.1':['astd_37wan_2', 'astd_51wan_99'],
'10.6.20.2':['astd_uoyoo_90']
}
"""
if not all_gameServer_info:
all_gameServer_info = self.all_gameServer_info
IPS = list(set([ all_gameServer_info[each] for each in gameServers ]))
locate_game_servers = { each:[] for each in IPS }
for each in gameServers:
locate_game_servers[all_gameServer_info[each]].append(each)
return locate_game_servers
# def sql_content_exec(self, gameServers, sql_content, backup='Yes', remote_dir=REMOTE_DIR):
# locate_game_servers = self.transform(gameServers)
# ips = locate_game_servers.keys()
#
# def _sql_content_exec(sql_content, locate_game_servers, backup):
# for gameServer in locate_game_servers[env.host_string]:
# backup_dir = '{}/{}'.format(remote_dir, gameServer)
# run('[ -d {0} ] || mkdir -p {0}'.format(backup_dir))
# if backup.lower() == 'yes':
# run('pandora --dump --opt -R {0} >{1}/rollback_{0}.sql'.format(gameServer, backup_dir))
# run('''pandora --update {} -e '{}' '''.format(gameServer, sql_content))
#
# execute(_sql_content_exec, sql_content, locate_game_servers, backup=backup, hosts=ips)
#
评论列表
文章目录