def clear_crm(self, args): sc = control.PacemakerConsole() print('清除 crm 集群的相关资源') if args.subargs_clear: sc.clear_crm_res(args.node) else: sc.clear_crm_res()
def build_pacemaker(self, args): controller = control.PacemakerConsole() print('start to set up packmaker') controller.packmaker_conf_change() if all(controller.check_packmaker()): print('successfully configure packmaker') else: print('failed to configure packmaker') sys.exit()
def build_ra(self, args): controller = control.PacemakerConsole() print('start to replace RA') controller.replace_ra() if all(controller.check_ra()): print('successfully replace RA') else: print('failed to replace RA') sys.exit()
def build_service(self, args): controller = control.PacemakerConsole() print('start to set up service') controller.service_set() if all(controller.check_service()): print('successfully configure service') else: print('failed to configure service') sys.exit()
def build_targetcli(self, args): # conf and check targecli controller = control.PacemakerConsole() t_beginning = time.time() timeout = 30 while True: controller.targetcli_conf_change() if all(controller.check_targetcli()): print('successfully configure targetcli') break seconds_passed = time.time() - t_beginning if timeout and seconds_passed > timeout: raise TimeoutError("failed to configure targetcli")
def build_corosync(self, args): controller = control.PacemakerConsole() print('start to synchronised time') controller.sync_time() print('start to set up corosync') controller.corosync_conf_change() print('start to restart corosync') controller.restart_corosync() print('check corosync, please wait') if all(controller.check_corosync()): print('successfully configure corosync') else: print('failed to configure corosync') sys.exit()
def show_pacemaker_cluster(self, args): controller = control.PacemakerConsole() conf = utils.ConfFile() l_node = [i['hostname'] for i in conf.cluster['node']] l_ssh = ['T' if i else 'F' for i in controller.check_ssh_authorized()] l_hostname = ['T' if i else 'F' for i in controller.check_hostname()] l_corosync = ['T' if i else 'F' for i in controller.check_corosync()] l_packmaker = ['T' if i else 'F' for i in controller.check_packmaker()] l_targetcli = ['T' if i else 'F' for i in controller.check_targetcli()] l_service = ['T' if i else 'F' for i in controller.check_service()] table = utils.Table() table.header = [ 'node', 'ssh', 'hostname', 'corosync', 'pacemaker', 'targetcli', 'service' ] for i in range(len(l_node)): table.add_data([ l_node[i], l_ssh[i], l_hostname[i], l_corosync[i], l_packmaker[i], l_targetcli[i], l_service[i] ]) table.print_table()
def build_ssh(self, args): controller = control.PacemakerConsole() print('start to build ssh connect') controller.ssh_conn_build() # ssh免密授权
def build_hostname(self, args): controller = control.PacemakerConsole() print('start to modify hostname') controller.modify_hostname()
def build_ip(self, args): controller = control.PacemakerConsole() print('start to set private ip') controller.set_ip_on_device()
def clear_corosync(self, args): sc = control.PacemakerConsole() print('恢复 corosync 配置文件') sc.recover_corosync_conf()
def clear_crm_node(self, args): sc = control.PacemakerConsole() print("清除 crm 节点") sc.clear_crm_node()
def clear_crm(self,args): sc = control.PacemakerConsole() print('清除 crm 集群的相关资源') sc.clear_crm_res(args.node)