def execute_start_command(self):
        # Connect to the new master
        if self._new_master.connect() == False:
            return MHA_online_change_helper.CODE_ERR_GENERAL

        return_val = MHA_online_change_helper.CODE_SUCCESS

        # Remove the read_only flag
        self.debug_message("Removing the read_only flag from the new master")
        self._new_master.unset_read_only()

        # If we have to manage the VIP, then assign the VIP on the new master
        if self._new_master_config_helper.get_manage_vip() == True:
            self.debug_message("Assigning the VIP to the new master")
            is_vip_assigned = MHA_VIP_helper.assign_vip(
                    config_helper=self._new_master_config_helper,
                    host_ip=self._new_master_ip,
                    ssh_user=None,
                    ssh_port=self._new_master_ssh_port,
                    ssh_options=self._ssh_options)

            if is_vip_assigned == False:
                return_val = MHA_online_change_helper.CODE_ERR_GENERAL

        # Disconnect from the new master
        self._new_master.disconnect()

        return return_val
    def rollback_stop_command(self):
	# Connect to the original master
        if self._orig_master.connect() == False:
            return MHA_online_change_helper.CODE_ERR_GENERAL
	
	rollback_error = 0

	# remove the read_only flag from the orignal master
	self.debug_message("Removing the read_only flag from original master")
	if self._orig_master.unset_read_only() == False:
	    self.debug_message("\tError, please try manually")
	    rollback_error += 1

        # If we have to manage the VIP, then add the VIP back on the original master
        if self._orig_master_config_helper.get_manage_vip() == True:
            self.debug_message("Assigning back the VIP to the original master")
            is_vip_assigned = MHA_VIP_helper.assign_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_assigned == False:
                rollback_error += 1

	if rollback_error > 0:
	    self.debug_message("Rollback FAILED, there were %s errors" % rollback_error)
	else:
	    self.debug_message("Rollback completed OK")

	# Disconnect from the original master and restore binlogging
	self._orig_master.disconnect()

	return MHA_online_change_helper.CODE_ERR_GENERAL
    def execute_start_command(self):
        # Connect to the new master
        if self._new_master.connect() == False:
            return MHA_online_change_helper.CODE_ERR_GENERAL

        return_val = MHA_online_change_helper.CODE_SUCCESS

        # Remove the read_only flag
        self.debug_message("Removing the read_only flag from the new master")
        self._new_master.unset_read_only()

        # If we have to manage the VIP, then assign the VIP on the new master
        if self._new_master_config_helper.get_manage_vip() == True:
            self.debug_message("Assigning the VIP to the new master")
            is_vip_assigned = MHA_VIP_helper.assign_vip(
                config_helper=self._new_master_config_helper,
                host_ip=self._new_master_ip,
                ssh_user=None,
                ssh_port=self._new_master_ssh_port,
                ssh_options=self._ssh_options)

            if is_vip_assigned == False:
                return_val = MHA_online_change_helper.CODE_ERR_GENERAL

        # Disconnect from the new master
        self._new_master.disconnect()

        return return_val
    def execute_start_command(self, orig_master_host, orig_master_ip, 
                                new_master_host, new_master_ip, new_master_port,
                                ssh_user, ssh_options, ssh_port):
        config_helper = MHA_config_helper(host=new_master_host)
        
        new_master = MySQL_helper(host=new_master_ip, 
                                    user=config_helper.get_mysql_user(),
                                    password=config_helper.get_mysql_password(),
                                    port=new_master_port)

        if ssh_port is None:
            ssh_port = 22

        # Connect to the new master
        if new_master.connect() == False:
            return MHA_IP_failover_helper.CODE_ERR_GENERAL

        # If we have to manage the VIP, then assign the VIP to the new master
        if config_helper.get_manage_vip() == True:
            return_val = MHA_VIP_helper.assign_vip(config_helper=config_helper,
                                                host_ip=new_master_ip,
                                                ssh_user=ssh_user,
                                                ssh_port=ssh_port,
                                                ssh_options=ssh_options)

        if return_val == False:
            new_master.disconnect()
            return MHA_IP_failover_helper.CODE_ERR_GENERAL

        # Remove the read_only flag
        self.debug_message("Removing the read_only flag from the new master")
        new_master.unset_read_only()

        # Disconnect from the new master
        new_master.disconnect()

        return MHA_IP_failover_helper.CODE_SUCCESS
Beispiel #5
0
    def execute_start_command(self, orig_master_host, orig_master_ip,
                              new_master_host, new_master_ip, ssh_user,
                              ssh_options, ssh_port):
        config_helper = MHA_config_helper(host=new_master_host)

        new_master = MySQL_helper(host=new_master_ip,
                                  user=config_helper.get_mysql_user(),
                                  password=config_helper.get_mysql_password())

        if ssh_port is None:
            ssh_port = 22

        # Connect to the new master
        if new_master.connect() == False:
            return MHA_IP_failover_helper.CODE_ERR_GENERAL

        # If we have to manage the VIP, then assign the VIP to the new master
        if config_helper.get_manage_vip() == True:
            return_val = MHA_VIP_helper.assign_vip(config_helper=config_helper,
                                                   host_ip=new_master_ip,
                                                   ssh_user=ssh_user,
                                                   ssh_port=ssh_port,
                                                   ssh_options=ssh_options)

        if return_val == False:
            new_master.disconnect()
            return MHA_IP_failover_helper.CODE_ERR_GENERAL

        # Remove the read_only flag
        self.debug_message("Removing the read_only flag from the new master")
        new_master.unset_read_only()

        # Disconnect from the new master
        new_master.disconnect()

        return MHA_IP_failover_helper.CODE_SUCCESS
    def rollback_stop_command(self):
        # Connect to the original master
        if self._orig_master.connect() == False:
            return MHA_online_change_helper.CODE_ERR_GENERAL

        rollback_error = 0

        # remove the read_only flag from the orignal master
        self.debug_message("Removing the read_only flag from original master")
        if self._orig_master.unset_read_only() == False:
            self.debug_message("\tError, please try manually")
            rollback_error += 1

        # If we have to manage the VIP, then add the VIP back on the original master
        if self._orig_master_config_helper.get_manage_vip() == True:
            self.debug_message("Assigning back the VIP to the original master")
            is_vip_assigned = MHA_VIP_helper.assign_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_assigned == False:
                rollback_error += 1

        if rollback_error > 0:
            self.debug_message("Rollback FAILED, there were %s errors" %
                               rollback_error)
        else:
            self.debug_message("Rollback completed OK")

# Disconnect from the original master and restore binlogging
        self._orig_master.disconnect()

        return MHA_online_change_helper.CODE_ERR_GENERAL