def page_activated(self, advancing): if advancing and self.main.plan.state.dataBulkTransferParams[ "tableList"]: options = self.main.plan.state.dataBulkTransferParams copy_script = options.get("GenerateCopyScript", None) bulk_copy_script = options.get("GenerateBulkCopyScript", None) self.add_task(self._prepare_copy, "Prepare information for data copy", "Prepare Information for Data Copy") if copy_script != None: self._copy_script_task = self.add_task( self._create_copy_script, "Create shell script for data copy", "Create Shell Script for Data Copy") if bulk_copy_script != None: self._bulk_copy_script_task = self.add_task( self._create_bulk_copy_script, "Create shell script for bulk data copy", "Create Shell Script for Bulk Data Copy") if options.get("LiveDataCopy", False) or options.get( "GenerateDumpScript", False): self._migrate_task1 = self.add_threaded_task( self._count_rows, "Determine number of rows to copy", "Determine number of rows to copy") self._migrate_task2 = self.add_threaded_task( self._migrate_data, "Copy data to target RDBMS", "Copy data to target RDBMS") self._migrating_data = False self._progress_per_table = {} if options.get("LiveDataCopy", False): source_password = self.main.plan.migrationSource.password if source_password is None: source_password = request_password( self.main.plan.migrationSource.connection) target_password = self.main.plan.migrationTarget.password if target_password is None: if self.main.plan.migrationTarget.connection.hostIdentifier == self.main.plan.migrationSource.connection.hostIdentifier: if self.main.plan.migrationTarget.connection.parameterValues[ 'userName'] == self.main.plan.migrationSource.connection.parameterValues[ 'userName']: target_password = source_password if target_password is None: target_password = request_password( self.main.plan.migrationTarget.connection) else: source_password = None target_password = None self._transferer = DataMigrator( self, self.main.plan.state.dataBulkTransferParams, self.main.plan.migrationSource.connection, source_password, self.main.plan.migrationTarget.connection, target_password) self._transferer.copytable_path = self.main.plan.wbcopytables_path_bin WizardProgressPage.page_activated(self, advancing)
def page_activated(self, advancing): if advancing: options = self.main.plan.state.dataBulkTransferParams copy_script = options.get("GenerateCopyScript", None) bulk_copy_script = options.get("GenerateBulkCopyScript", None) self.add_task(self._prepare_copy, "Prepare information for data copy") if copy_script != None: self._copy_script_task = self.add_task(self._create_copy_script, "Create shell script for data copy") if bulk_copy_script != None: self._bulk_copy_script_task = self.add_task( self._create_bulk_copy_script, "Create shell script for bulk data copy" ) if options.get("LiveDataCopy", False) or options.get("GenerateDumpScript", False): self._migrate_task1 = self.add_threaded_task(self._count_rows, "Determine number of rows to copy") self._migrate_task2 = self.add_threaded_task(self._migrate_data, "Copy data to target RDBMS") self._migrating_data = False self._progress_per_table = {} if options.get("LiveDataCopy", False): source_password = self.main.plan.migrationSource.password if source_password is None: source_password = request_password(self.main.plan.migrationSource.connection) target_password = self.main.plan.migrationTarget.password if target_password is None: if ( self.main.plan.migrationTarget.connection.hostIdentifier == self.main.plan.migrationSource.connection.hostIdentifier ): if ( self.main.plan.migrationTarget.connection.parameterValues["userName"] == self.main.plan.migrationSource.connection.parameterValues["userName"] ): target_password = source_password if target_password is None: target_password = request_password(self.main.plan.migrationTarget.connection) else: source_password = None target_password = None self._transferer = DataMigrator( self, self.main.plan.state.dataBulkTransferParams, self.main.plan.migrationSource.connection, source_password, self.main.plan.migrationTarget.connection, target_password, ) self._transferer.copytable_path = self.main.plan.wbcopytables_path WizardProgressPage.page_activated(self, advancing)
def mysql_conn_string(conn): param = conn.parameterValues if conn.driver.name == "MysqlNative": return "%(userName)s@%(hostName)s:%(port)s" % param elif conn.driver.name == "MysqlNativeSocket": if not param.get('socket', False): try: connection = db_utils.MySQLConnection( conn, password=request_password(conn)) connection.connect() except (NotConnectedError, db_utils.MySQLError): raise Exception( 'There is no connection to the target MySQL server and the socket parameter in your ' 'target connection settings is blank. Please check that your target server is running ' 'or go back to the Target Selection page and set the socket parameter there.' ) result = connection.executeQuery("SHOW VARIABLES LIKE 'socket';") if result and result.nextRow(): socket = result.stringByName('Value') param = {'userName': param['userName'], 'socket': socket} connection.disconnect() else: raise Exception( 'Failed while querying the socket server variable and the socket parameter in your ' 'target connection settings is blank. Please go back to the Target Selection page and ' 'make sure that you have the socket parameter set.') return "%(userName)s@::%(socket)s" % param else: raise Exception( "Connection method type %s is not supported for migration" % conn.driver.name)
def mysql_conn_string(conn): param = conn.parameterValues if conn.driver.name == "MysqlNative": return "%(userName)s@%(hostName)s:%(port)s" % param elif conn.driver.name == "MysqlNativeSocket": if not param.get('socket', False): try: connection = db_utils.MySQLConnection(conn, password=request_password(conn)) connection.connect() except (NotConnectedError, db_utils.MySQLError): raise Exception('There is no connection to the target MySQL server and the socket parameter in your ' 'target connection settings is blank. Please check that your target server is running ' 'or go back to the Target Selection page and set the socket parameter there.') result = connection.executeQuery("SHOW VARIABLES LIKE 'socket';") if result and result.nextRow(): socket = result.stringByName('Value') param = { 'userName':param['userName'], 'socket':socket } connection.disconnect() else: raise Exception('Failed while querying the socket server variable and the socket parameter in your ' 'target connection settings is blank. Please go back to the Target Selection page and ' 'make sure that you have the socket parameter set.') return "%(userName)s@::%(socket)s" % param else: raise Exception("Connection method type %s is not supported for migration" % conn.driver.name)
def page_activated(self, advancing): if advancing: options = self.main.plan.state.dataBulkTransferParams copy_script = options.get("GenerateCopyScript", None) self._copy_script_task.set_enabled(copy_script != None) if options.get("LiveDataCopy", False) or options.get( "GenerateDumpScript", False): self._migrate_task1.set_enabled(True) self._migrate_task2.set_enabled(True) else: self._migrate_task1.set_enabled(False) self._migrate_task2.set_enabled(False) self._migrating_data = False self._progress_per_table = {} if options.get("LiveDataCopy", False): source_password = self.main.plan.migrationSource.password if source_password is None: source_password = request_password( self.main.plan.migrationSource.connection) target_password = self.main.plan.migrationTarget.password if target_password is None: if self.main.plan.migrationTarget.connection.hostIdentifier == self.main.plan.migrationSource.connection.hostIdentifier: if self.main.plan.migrationTarget.connection.parameterValues[ 'userName'] == self.main.plan.migrationSource.connection.parameterValues[ 'userName']: target_password = source_password if target_password is None: target_password = request_password( self.main.plan.migrationTarget.connection) else: source_password = None target_password = None self._transferer = DataMigrator( self, self.main.plan.state.dataBulkTransferParams, self.main.plan.migrationSource.connection, source_password, self.main.plan.migrationTarget.connection, target_password) self._transferer.copytable_path = self.main.plan.wbcopytables_path WizardProgressPage.page_activated(self, advancing)
def test_connection(self, source, caption): info_label = self.source_connection_status if caption == 'Source' else self.target_connection_status info_label.set_text('Testing network connectivity...') info_label.set_color('#aa3333') if test_connectivity(source.connection, 'Test %s DBMS Connection' % caption) == False: info_label.set_text('Server could not be contacted') return info_label.set_text('Testing connection to DBMS...') force_password = False attempt = 0 while True: try: if not source.connect(): info_label.set_text('Could not connect to DBMS') self.connections_ok = False return info_label.set_color('#33aa33') info_label.set_text('Connection succeeded.') self.connections_ok = True break except (DBLoginError, SystemError) as e: if attempt > 0: if isinstance(e, DBLoginError) and not force_password: force_password = True else: etext = str(e) if etext.startswith( 'Error(') and ': error calling ' in etext: try: etext = eval(etext[7:etext.rfind('):') - 1], {}, {})[1] except: pass info_label.set_text('Could not connect to DBMS: %s' % etext) self.connections_ok = False return attempt += 1 username = source.connection.parameterValues.userName storage_string = source.connection.hostIdentifier source.password = request_password(source.connection, username, storage_string, force_password) except Exception as e: etext = str(e) if etext.startswith('Error(') and etext.endswith(')'): etext = eval(etext[6:-1], {}, {})[1] info_label.set_text('Could not connect to DBMS: %s' % etext) self.connections_ok = False
def page_activated(self, advancing): if advancing: options = self.main.plan.state.dataBulkTransferParams copy_script = options.get("GenerateCopyScript", None) self._copy_script_task.set_enabled(copy_script != None) if options.get("LiveDataCopy", False) or options.get("GenerateDumpScript", False): self._migrate_task1.set_enabled(True) self._migrate_task2.set_enabled(True) else: self._migrate_task1.set_enabled(False) self._migrate_task2.set_enabled(False) self._migrating_data = False self._progress_per_table = {} if options.get("LiveDataCopy", False): source_password = self.main.plan.migrationSource.password if source_password is None: source_password = request_password(self.main.plan.migrationSource.connection) target_password = self.main.plan.migrationTarget.password if target_password is None: if self.main.plan.migrationTarget.connection.hostIdentifier == self.main.plan.migrationSource.connection.hostIdentifier: if self.main.plan.migrationTarget.connection.parameterValues['userName'] == self.main.plan.migrationSource.connection.parameterValues['userName']: target_password = source_password if target_password is None: target_password = request_password(self.main.plan.migrationTarget.connection) else: source_password = None target_password = None self._transferer = DataMigrator(self, self.main.plan.state.dataBulkTransferParams, self.main.plan.migrationSource.connection, source_password, self.main.plan.migrationTarget.connection, target_password) self._transferer.copytable_path = self.main.plan.wbcopytables_path WizardProgressPage.page_activated(self, advancing)
def test_connection(self, source, caption): info_label = self.source_connection_status if caption=='Source' else self.target_connection_status info_label.set_text('Testing network connectivity...') info_label.set_color('#aa3333') if test_connectivity(source.connection, 'Test %s DBMS Connection' % caption) == False: info_label.set_text('Server could not be contacted') return info_label.set_text('Testing connection to DBMS...') force_password = False attempt = 0 while True: try: if not source.connect(): info_label.set_text('Could not connect to DBMS') self.connections_ok = False return info_label.set_color('#33aa33') info_label.set_text('Connection succeeded.') self.connections_ok = True break except (DBLoginError, SystemError), e: if attempt > 0: if isinstance(e, DBLoginError) and not force_password: force_password = True else: etext = str(e) if etext.startswith('Error(') and ': error calling ' in etext: try: etext = eval(etext[7:etext.rfind('):')-1], {}, {})[1] except: pass info_label.set_text('Could not connect to DBMS: %s' % etext) self.connections_ok = False return attempt += 1 source.password = request_password(source.connection, force_password) except Exception, e: etext = str(e) if etext.startswith('Error(') and etext.endswith(')'): etext = eval(etext[6:-1], {}, {})[1] info_label.set_text('Could not connect to DBMS: %s' % etext) self.connections_ok = False