def __new__(cls, *args, **kwargs): if not hasattr(cls, '_instance'): Connect._instance = super().__new__(cls) Connect._instance.conf_file = utils.ConfFile() Connect._instance.cluster = Connect._instance.conf_file.cluster Connect.get_ssh_conn(Connect._instance) return Connect._instance
def configure_bonding_by_file(self, file): """create or modify bonding via yaml config file""" config = utils.ConfFile(file) host_config = config.get_config() self.modify_mode = True for host in host_config: node = host[0] bonding_name = host[1] mode = host[2] device_list = host[3] new_ip = host[4] print('-' * 15, node, '-' * 15) bonding = action.IpService(node) lc_device_date = bonding.get_device_status() if not self.check_device(device_list, lc_device_date): continue connection = bonding.get_connection() if self.check_bonding_exist(f'vtel_{bonding_name}', connection): print(f"Modify {bonding_name}.") self.modify_bonding_slave(node, bonding_name, device_list) self.modify_bonding_mode(node, bonding_name, mode) self.modify_bonding_ip(node, bonding_name, new_ip) else: print(f"Create {bonding_name}.") self.create_bonding(node, bonding_name, mode, device_list, new_ip)
def show(self, args): controller = control.Scheduler() controller.get_ssh_conn() 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 __new__(cls, *args, **kwargs): if not hasattr(cls, '_instance'): Connect._instance = super().__new__(cls) Connect._instance.conf_file = utils.ConfFile() Connect._instance.data = Connect._instance.conf_file.data Connect.get_master_ssh(Connect._instance) Connect.get_worker_ssh(Connect._instance) return Connect._instance
def modify_kk(self): handler = action.KubeKey() confile = utils.ConfFile() hosts = confile.get_kk_hosts() etcd = confile.get_kk_etcd() master = confile.get_kk_masters() worker = confile.get_kk_worker() vip = confile.get_kk_vip() port = confile.get_kk_port() handler.modify_config(hosts,etcd,master,worker,vip,port)
def apply_file(self, args): utils._init() logger = log.Log() utils.set_logger(logger) config = utils.ConfFile(args.file) test_mode = config.get_test_mode() if test_mode == 'quorum': test_quorum = control.QuorumAutoTest(config) # test_quorum.ssh_conn_build() test_quorum.test_drbd_quorum() if test_mode == 'drbd_in_used': test_iscsi = control.IscsiTest(config) test_iscsi.test_drbd_in_used()
def __init__(self): self.conf_file = utils.ConfFile() self.cluster = self.conf_file.cluster self.list_ssh = []