def execute_stopssh_command(self, orig_master_host, orig_master_ip, ssh_user, ssh_options, ssh_port): config_helper = MHA_config_helper(host=orig_master_host) #orig_master = MySQL_helper(host=orig_master_ip, # user=config_helper.get_mysql_user(), # password=config_helper.get_mysql_password()) if ssh_port is None: ssh_port = 22 # If we have to manage the VIP, then remove the VIP from the original master if config_helper.get_manage_vip() == True: return_val = MHA_VIP_helper.remove_vip(config_helper=config_helper, host_ip=orig_master_ip, ssh_user=ssh_user, ssh_port=ssh_port, ssh_options=ssh_options) if return_val == True: exit_code = MHA_IP_failover_helper.CODE_SUCCESS else: exit_code = MHA_IP_failover_helper.CODE_ERR_GENERAL return exit_code
def execute_stopssh_command(self, orig_master_host, orig_master_ip, ssh_user, ssh_options, ssh_port): config_helper = MHA_config_helper(host=orig_master_host) orig_master = MySQL_helper(host=orig_master_ip, user=config_helper.get_mysql_user(), password=config_helper.get_mysql_password()) if ssh_port is None: ssh_port = 22 # If we have to manage the VIP, then remove the VIP from the original master if config_helper.get_manage_vip() == True: return_val = MHA_VIP_helper.remove_vip(config_helper=config_helper, host_ip=orig_master_ip, ssh_user=ssh_user, ssh_port=ssh_port, ssh_options=ssh_options) if return_val == True: exit_code = MHA_IP_failover_helper.CODE_SUCCESS else: exit_code = MHA_IP_failover_helper.CODE_ERR_GENERAL return exit_code
def execute_stop_command(self): # Connect to the new master if self._new_master.connect() == False: return MHA_online_change_helper.CODE_ERR_GENERAL # Set read_only=1 on the new master to avoid any data inconsistency self.debug_message("Setting read_only=1 on the new master ...") self._new_master.set_read_only() if self._new_master.is_read_only() == False: return MHA_online_change_helper.CODE_ERR_GENERAL # Disconnect from the new master because we do not want to change anything on it now self._new_master.disconnect() # Connect to the original master if self._orig_master.connect() == False: return MHA_online_change_helper.CODE_ERR_GENERAL # we execute everything below in try..finally because we have to # disconnect and enable log_bin at all cost try: # Setting read_only=1 on the original master self._orig_master.set_read_only() if self._orig_master.is_read_only() == False: return MHA_online_change_helper.CODE_ERR_GENERAL # If we have to manage the VIP, then remove the VIP from the original master if self._orig_master_config_helper.get_manage_vip() == True: self.debug_message("Removing the VIP from the original master") is_vip_removed = MHA_VIP_helper.remove_vip( config_helper=self._orig_master_config_helper, host_ip=self._orig_master_ip, ssh_user=None, ssh_port=self._orig_master_ssh_port, ssh_options=self._ssh_options) if is_vip_removed == False: return MHA_online_change_helper.CODE_ERR_GENERAL # Wait upto 5 seconds for all connected threads to disconnect self.debug_message("Waiting 5s for all connected threads to disconnect") slept_seconds = 0 while slept_seconds < 5: threads = self.get_connected_threads(self._orig_master) if len(threads) > 0: time.sleep(1) slept_seconds += 1 else: break # Terminate all threads self.debug_message("Terminating all application threads ...") threads = self.get_connected_threads(self._orig_master) if threads == False: return MHA_online_change_helper.CODE_ERR_GENERAL for thread in threads: self.debug_message("\tTerminating thread Id => %s, User => %s, Host => %s" % (thread['Id'], thread['User'], thread['Host'])) self._orig_master.kill_connection(connection_id=thread['Id']) finally: # Disconnect from the original master and restore binlogging self._orig_master.disconnect() return MHA_online_change_helper.CODE_SUCCESS
def execute_stop_command(self): # Connect to the new master if self._new_master.connect() == False: return MHA_online_change_helper.CODE_ERR_GENERAL # Set read_only=1 on the new master to avoid any data inconsistency self.debug_message("Setting read_only=1 on the new master ...") self._new_master.set_read_only() if self._new_master.is_read_only() == False: return MHA_online_change_helper.CODE_ERR_GENERAL # Disconnect from the new master because we do not want to change anything on it now self._new_master.disconnect() # Connect to the original master if self._orig_master.connect() == False: return MHA_online_change_helper.CODE_ERR_GENERAL # we execute everything below in try..finally because we have to # disconnect and enable log_bin at all cost try: # Setting read_only=1 on the original master self._orig_master.set_read_only() if self._orig_master.is_read_only() == False: return MHA_online_change_helper.CODE_ERR_GENERAL # If we have to manage the VIP, then remove the VIP from the original master if self._orig_master_config_helper.get_manage_vip() == True: self.debug_message("Removing the VIP from the original master") is_vip_removed = MHA_VIP_helper.remove_vip( config_helper=self._orig_master_config_helper, host_ip=self._orig_master_ip, ssh_user=None, ssh_port=self._orig_master_ssh_port, ssh_options=self._ssh_options) if is_vip_removed == False: return MHA_online_change_helper.CODE_ERR_GENERAL # Wait upto 5 seconds for all connected threads to disconnect self.debug_message( "Waiting 5s for all connected threads to disconnect") slept_seconds = 0 while slept_seconds < 5: threads = self.get_connected_threads(self._orig_master) if len(threads) > 0: time.sleep(1) slept_seconds += 1 else: break # Terminate all threads self.debug_message("Terminating all application threads ...") threads = self.get_connected_threads(self._orig_master) if threads == False: return MHA_online_change_helper.CODE_ERR_GENERAL for thread in threads: self.debug_message( "\tTerminating thread Id => %s, User => %s, Host => %s" % (thread['Id'], thread['User'], thread['Host'])) self._orig_master.kill_connection(connection_id=thread['Id']) finally: # Disconnect from the original master and restore binlogging self._orig_master.disconnect() return MHA_online_change_helper.CODE_SUCCESS