def rewind_database(dlpx_obj, vdb_name, timestamp, timestamp_type='SNAPSHOT'): """ This function performs the rewind (rollback) dlpx_obj: Virtualization Engine session object vdb_name: VDB to be rewound timestamp: Point in time to rewind the VDB timestamp_type: The type of timestamp being used for the rewind """ engine_name = dlpx_obj.dlpx_engines.keys()[0] dx_timeflow_obj = DxTimeflow(dlpx_obj.server_session) container_obj = find_obj_by_name(dlpx_obj.server_session, database, vdb_name) # Sanity check to make sure our container object has a reference if container_obj.reference: try: if container_obj.virtual is not True: raise DlpxException('{} in engine {} is not a virtual object. ' 'Skipping.\n'.format(container_obj.name, engine_name)) elif container_obj.staging is True: raise DlpxException('{} in engine {} is a virtual object. ' 'Skipping.\n'.format(container_obj.name, engine_name)) elif container_obj.runtime.enabled == "ENABLED": print_info('\nINFO: {} Rewinding {} to {}\n'.format( engine_name, container_obj.name, timestamp)) # This exception is raised if rewinding a vFiles VDB # since AppDataContainer does not have virtual, staging or # enabled attributes. except AttributeError: pass print_debug('{}: Type: {}'.format(engine_name, container_obj.type)) # If the vdb is a Oracle type, we need to use a OracleRollbackParameters if str(container_obj.reference).startswith("ORACLE"): rewind_params = OracleRollbackParameters() else: rewind_params = RollbackParameters() rewind_params.timeflow_point_parameters = \ dx_timeflow_obj.set_timeflow_point(container_obj, timestamp_type, timestamp) print_debug('{}: {}'.format(engine_name, str(rewind_params))) try: # Rewind the VDB database.rollback(dlpx_obj.server_session, container_obj.reference, rewind_params) dlpx_obj.jobs[engine_name] = dlpx_obj.server_session.last_job print_info('VDB {} was rolled back.'.format(container_obj.name)) except (RequestError, HttpError, JobError) as e: print_exception('ERROR: {} encountered an error on {}' ' during the rewind process:\n{}'.format( engine_name, container_obj.name, e)) # Don't do anything if the database is disabled else: print_info('{}: {} is not enabled. Skipping sync.'.format(engine_name, container_obj.name))
def create_vfiles_vdb( engine, jobs, vfiles_group, vfiles_name, environment_obj, container_obj, pre_refresh=None, post_refresh=None, pre_rollback=None, post_rollback=None, configure_clone=None, ): """ Create a Vfiles VDB """ vfiles_obj = None try: vfiles_obj = find_obj_by_name( dx_session_obj.server_session, database, vfiles_name ) except DlpxException: pass if vfiles_obj is None: vfiles_repo = find_repo_by_environment_ref( engine, "Unstructured Files", environment_obj.reference ) vfiles_params = AppDataProvisionParameters() vfiles_params.source = AppDataVirtualSource() vfiles_params.source_config = AppDataDirectSourceConfig() vdb_restart_reobj = re.compile("true", re.IGNORECASE) if vdb_restart_reobj.search(str(arguments["--vdb_restart"])): vfiles_params.source.allow_auto_vdb_restart_on_host_reboot = True elif vdb_restart_reobj.search(str(arguments["--vdb_restart"])) is None: vfiles_params.source.allow_auto_vdb_restart_on_host_reboot = False vfiles_params.container = { "type": "AppDataContainer", "group": vfiles_group.reference, "name": vfiles_name, } vfiles_params.source_config.name = arguments["--target"] vfiles_params.source_config.path = arguments["--vfiles_path"] vfiles_params.source_config.environment_user = environment_obj.primary_user vfiles_params.source_config.repository = vfiles_repo.reference vfiles_params.source.parameters = {} vfiles_params.source.name = vfiles_name vfiles_params.source.name = vfiles_name vfiles_params.source.operations = VirtualSourceOperations() if pre_refresh: vfiles_params.source.operations.pre_refresh = [ {"type": "RunCommandOnSourceOperation", "command": pre_refresh} ] if post_refresh: vfiles_params.source.operations.post_refresh = [ {"type": "RunCommandOnSourceOperation", "command": post_refresh} ] if pre_rollback: vfiles_params.source.operations.pre_rollback = [ {"type": "RunCommandOnSourceOperation", "command": pre_rollback} ] if post_rollback: vfiles_params.source.operations.post_rollback = [ {"type": "RunCommandOnSourceOperation", "command": post_rollback} ] if configure_clone: vfiles_params.source.operations.configure_clone = [ {"type": "RunCommandOnSourceOperation", "command": configure_clone} ] if arguments["--timestamp_type"] is None: vfiles_params.timeflow_point_parameters = { "type": "TimeflowPointSemantic", "container": container_obj.reference, "location": "LATEST_POINT", } elif arguments["--timestamp_type"].upper() == "SNAPSHOT": try: dx_timeflow_obj = DxTimeflow(dx_session_obj.server_session) dx_snap_params = dx_timeflow_obj.set_timeflow_point( container_obj, arguments["--timestamp_type"], arguments["--timestamp"], arguments["--timeflow"], ) except RequestError as e: raise DlpxException("Could not set the timeflow point:\n%s" % (e)) if dx_snap_params.type == "TimeflowPointSemantic": vfiles_params.timeflow_point_parameters = { "type": dx_snap_params.type, "container": dx_snap_params.container, "location": dx_snap_params.location, } elif dx_snap_params.type == "TimeflowPointTimestamp": vfiles_params.timeflow_point_parameters = { "type": dx_snap_params.type, "timeflow": dx_snap_params.timeflow, "timestamp": dx_snap_params.timestamp, } print_info("%s: Provisioning %s\n" % (engine["hostname"], vfiles_name)) try: database.provision(dx_session_obj.server_session, vfiles_params) except (JobError, RequestError, HttpError) as e: raise DlpxException( "\nERROR: Could not provision the database:" "\n%s" % (e) ) # Add the job into the jobs dictionary so we can track its progress jobs[engine["hostname"]] = dx_session_obj.server_session.last_job # return the job object to the calling statement so that we can tell if # a job was created or not (will return None, if no job) return dx_session_obj.server_session.last_job else: print_info( "\nERROR %s: %s already exists. \n" % (engine["hostname"], vfiles_name) ) return vfiles_obj.reference
def create_oracle_si_vdb( engine, jobs, vdb_name, vdb_group_obj, environment_obj, container_obj, pre_refresh=None, post_refresh=None, pre_rollback=None, post_rollback=None, configure_clone=None, ): """ Create an Oracle SI VDB """ vdb_obj = None try: vdb_obj = find_obj_by_name(dx_session_obj.server_session, database, vdb_name) except DlpxException: pass if vdb_obj == None: vdb_params = OracleProvisionParameters() vdb_params.open_resetlogs = True if arguments["--noopen"]: vdb_params.open_resetlogs = False vdb_params.container = OracleDatabaseContainer() vdb_params.container.group = vdb_group_obj.reference vdb_params.container.name = vdb_name vdb_params.source = OracleVirtualSource() vdb_params.source.allow_auto_vdb_restart_on_host_reboot = False if arguments["--instname"]: inst_name = arguments["--instname"] elif arguments["--instname"] == None: inst_name = vdb_name if arguments["--uniqname"]: unique_name = arguments["--uniqname"] elif arguments["--uniqname"] == None: unique_name = vdb_name if arguments["--db"]: db = arguments["--db"] elif arguments["--db"] == None: db = vdb_name vdb_params.source.mount_base = arguments["--mntpoint"] if arguments["--mapfile"]: vdb_params.source.file_mapping_rules = arguments["--mapfile"] if arguments["--template"]: template_obj = find_obj_by_name( dx_session_obj.server_session, database.template, arguments["--template"], ) vdb_params.source.config_template = template_obj.reference vdb_params.source_config = OracleSIConfig() vdb_params.source.operations = VirtualSourceOperations() if pre_refresh: vdb_params.source.operations.pre_refresh = [ {"type": "RunCommandOnSourceOperation", "command": pre_refresh} ] if post_refresh: vdb_params.source.operations.post_refresh = [ {"type": "RunCommandOnSourceOperation", "command": post_refresh} ] if pre_rollback: vdb_params.source.operations.pre_rollback = [ {"type": "RunCommandOnSourceOperation", "command": pre_rollback} ] if post_rollback: vdb_params.source.operations.post_rollback = [ {"type": "RunCommandOnSourceOperation", "command": post_rollback} ] if configure_clone: vdb_params.source.operations.configure_clone = [ {"type": "RunCommandOnSourceOperation", "command": configure_clone} ] vdb_repo = find_dbrepo_by_environment_ref_and_install_path( engine, dx_session_obj.server_session, "OracleInstall", environment_obj.reference, arguments["--envinst"], ) vdb_params.source_config.database_name = db vdb_params.source_config.unique_name = unique_name vdb_params.source_config.instance = OracleInstance() vdb_params.source_config.instance.instance_name = inst_name vdb_params.source_config.instance.instance_number = 1 vdb_params.source_config.repository = vdb_repo.reference dx_timeflow_obj = DxTimeflow(dx_session_obj.server_session) vdb_params.timeflow_point_parameters = dx_timeflow_obj.set_timeflow_point( container_obj, arguments["--timestamp_type"], arguments["--timestamp"] ) print(vdb_params, "\n\n\n") print_info(engine["hostname"] + ": Provisioning " + vdb_name) database.provision(dx_session_obj.server_session, vdb_params) # Add the job into the jobs dictionary so we can track its progress jobs[engine["hostname"]] = dx_session_obj.server_session.last_job # return the job object to the calling statement so that we can tell if # a job was created or not (will return None, if no job) return dx_session_obj.server_session.last_job else: raise DlpxException( "\nERROR: %s: %s alread exists\n" % (engine["hostname"], vdb_name) )
def create_vfiles_vdb(engine, jobs, vfiles_group, vfiles_name, environment_obj, container_obj, pre_refresh=None, post_refresh=None, pre_rollback=None, post_rollback=None, configure_clone=None): ''' Create a Vfiles VDB ''' vfiles_obj = None try: vfiles_obj = find_obj_by_name(dx_session_obj.server_session, database, vfiles_name) except DlpxException: pass if vfiles_obj is None: vfiles_repo = find_repo_by_environment_ref(engine, 'Unstructured Files', environment_obj.reference) vfiles_params = AppDataProvisionParameters() vfiles_params.source = AppDataVirtualSource() vfiles_params.source_config = AppDataDirectSourceConfig() vdb_restart_reobj = re.compile('true', re.IGNORECASE) if vdb_restart_reobj.search(str(arguments['--vdb_restart'])): vfiles_params.source.allow_auto_vdb_restart_on_host_reboot = True elif vdb_restart_reobj.search(str(arguments['--vdb_restart'])) is None: vfiles_params.source.allow_auto_vdb_restart_on_host_reboot = False vfiles_params.container = { 'type': 'AppDataContainer', 'group': vfiles_group.reference, 'name': vfiles_name } vfiles_params.source_config.name = arguments['--target'] vfiles_params.source_config.path = arguments['--vfiles_path'] vfiles_params.source_config.environment_user = \ environment_obj.primary_user vfiles_params.source_config.repository = vfiles_repo.reference vfiles_params.source.parameters = {} vfiles_params.source.name = vfiles_name vfiles_params.source.name = vfiles_name vfiles_params.source.operations = VirtualSourceOperations() if pre_refresh: vfiles_params.source.operations.pre_refresh = [{ 'type': 'RunCommandOnSourceOperation', 'command': pre_refresh }] if post_refresh: vfiles_params.source.operations.post_refresh = [{ 'type': 'RunCommandOnSourceOperation', 'command': post_refresh }] if pre_rollback: vfiles_params.source.operations.pre_rollback = [{ 'type': 'RunCommandOnSourceOperation', 'command': pre_rollback }] if post_rollback: vfiles_params.source.operations.post_rollback = [{ 'type': 'RunCommandOnSourceOperation', 'command': post_rollback }] if configure_clone: vfiles_params.source.operations.configure_clone = [{ 'type': 'RunCommandOnSourceOperation', 'command': configure_clone }] if arguments['--timestamp_type'] is None: vfiles_params.timeflow_point_parameters = { 'type': 'TimeflowPointSemantic', 'container': container_obj.reference, 'location': 'LATEST_POINT' } elif arguments['--timestamp_type'].upper() == 'SNAPSHOT': try: dx_timeflow_obj = DxTimeflow(dx_session_obj.server_session) dx_snap_params = dx_timeflow_obj.set_timeflow_point( container_obj, arguments['--timestamp_type'], arguments['--timestamp'], arguments['--timeflow']) except RequestError as e: raise DlpxException('Could not set the timeflow point:\n%s' % (e)) if dx_snap_params.type == 'TimeflowPointSemantic': vfiles_params.timeflow_point_parameters = { 'type': dx_snap_params.type, 'container': dx_snap_params.container, 'location': dx_snap_params.location } elif dx_snap_params.type == 'TimeflowPointTimestamp': vfiles_params.timeflow_point_parameters = { 'type': dx_snap_params.type, 'timeflow': dx_snap_params.timeflow, 'timestamp': dx_snap_params.timestamp } print_info('%s: Provisioning %s\n' % (engine["hostname"], vfiles_name)) try: database.provision(dx_session_obj.server_session, vfiles_params) except (JobError, RequestError, HttpError) as e: raise DlpxException('\nERROR: Could not provision the database:' '\n%s' % (e)) #Add the job into the jobs dictionary so we can track its progress jobs[engine['hostname']] = dx_session_obj.server_session.last_job #return the job object to the calling statement so that we can tell if # a job was created or not (will return None, if no job) return dx_session_obj.server_session.last_job else: print_info('\nERROR %s: %s already exists. \n' % (engine['hostname'], vfiles_name)) return vfiles_obj.reference
def refresh_database(vdb_name, timestamp, timestamp_type="SNAPSHOT"): """ This function actually performs the refresh engine: dlpx_obj: Virtualization Engine session object vdb_name: VDB to be refreshed """ # Sanity check to make sure our source object has a reference dx_timeflow_obj = DxTimeflow(dx_session_obj.server_session) container_obj = find_obj_by_name(dx_session_obj.server_session, database, vdb_name) source_obj = find_source_by_dbname(dx_session_obj.server_session, database, vdb_name) # Sanity check to make sure our container object has a reference if container_obj.reference: try: if container_obj.virtual is not True: raise DlpxException("{} is not a virtual object. " "Skipping.\n".format(container_obj.name)) elif container_obj.staging is True: raise DlpxException("{} is a virtual object. " "Skipping.\n".format(container_obj.name)) elif container_obj.runtime.enabled == "ENABLED": print_info("\nINFO: Refrshing {} to {}\n".format( container_obj.name, timestamp)) # This exception is raised if rewinding a vFiles VDB # since AppDataContainer does not have virtual, staging or # enabled attributes. except AttributeError: pass if source_obj.reference: # We can only refresh VDB's if source_obj.virtual != True: print_info( "\nINFO: {} is not a virtual object. Skipping.\n".format( container_obj.name)) # Ensure this source is not a staging database. We can't act upon those. elif source_obj.staging == True: print_info("\nINFO: {} is a staging database. Skipping.\n".format( container_obj.name)) # Ensure the source is enabled. We can't refresh disabled databases. elif source_obj.runtime.enabled == "ENABLED": source_db = database.get(dx_session_obj.server_session, container_obj.provision_container) if not source_db: print_error( "\nERROR: Was unable to retrieve the source container for {} \n" .format(container_obj.name)) print_info("\nINFO: Refreshing {} from {}\n".format( container_obj.name, source_db.name)) # If the vdb is a Oracle type, we need to use a # OracleRefreshParameters """ rewind_params = RollbackParameters() rewind_params.timeflow_point_parameters = dx_timeflow_obj.set_timeflow_point( container_obj, timestamp_type, timestamp ) print_debug('{}: {}'.format(engine_name, str(rewind_params))) """ if str(container_obj.reference).startswith("ORACLE"): refresh_params = OracleRefreshParameters() else: refresh_params = RefreshParameters() try: refresh_params.timeflow_point_parameters = ( dx_timeflow_obj.set_timeflow_point(source_db, timestamp_type, timestamp)) print_info("\nINFO: Refresh prams {}\n".format(refresh_params)) # Sync it database.refresh( dx_session_obj.server_session, container_obj.reference, refresh_params, ) dx_session_obj.jobs[ dx_session_obj.server_session. address] = dx_session_obj.server_session.last_job except RequestError as e: print("\nERROR: Could not set timeflow point:\n%s\n" % (e.message.action)) sys.exit(1) except DlpxException as e: print("ERROR: Could not set timeflow point:\n%s\n" % (e.message)) sys.exit(1) # Don't do anything if the database is disabled else: print_info("\nINFO: {} is not enabled. Skipping sync.\n".format( container_obj.name))
def create_oracle_si_vdb(engine, jobs, vdb_name, vdb_group_obj, environment_obj, container_obj, pre_refresh=None, post_refresh=None, pre_rollback=None, post_rollback=None, configure_clone=None): ''' Create an Oracle SI VDB ''' vdb_obj = None try: vdb_obj = find_obj_by_name(dx_session_obj.server_session, database, vdb_name) except DlpxException: pass if vdb_obj == None: vdb_params = OracleProvisionParameters() vdb_params.open_resetlogs = True if arguments['--noopen']: vdb_params.open_resetlogs = False vdb_params.container = OracleDatabaseContainer() vdb_params.container.group = vdb_group_obj.reference vdb_params.container.name = vdb_name vdb_params.source = OracleVirtualSource() vdb_params.source.allow_auto_vdb_restart_on_host_reboot = False if arguments['--instname']: inst_name = arguments['--instname'] elif arguments['--instname'] == None: inst_name = vdb_name if arguments['--uniqname']: unique_name = arguments['--uniqname'] elif arguments['--uniqname'] == None: unique_name = vdb_name if arguments['--db']: db = arguments['--db'] elif arguments['--db'] == None: db = vdb_name vdb_params.source.mount_base = arguments['--mntpoint'] if arguments['--mapfile']: vdb_params.source.file_mapping_rules = arguments['--mapfile'] if arguments['--template']: template_obj = find_obj_by_name(dx_session_obj.server_session, database.template, arguments['--template']) vdb_params.source.config_template = template_obj.reference vdb_params.source_config = OracleSIConfig() vdb_params.source.operations = VirtualSourceOperations() if pre_refresh: vdb_params.source.operations.pre_refresh = [{ 'type': 'RunCommandOnSourceOperation', 'command': pre_refresh }] if post_refresh: vdb_params.source.operations.post_refresh = [{ 'type': 'RunCommandOnSourceOperation', 'command': post_refresh }] if pre_rollback: vdb_params.source.operations.pre_rollback = [{ 'type': 'RunCommandOnSourceOperation', 'command': pre_rollback }] if post_rollback: vdb_params.source.operations.post_rollback = [{ 'type': 'RunCommandOnSourceOperation', 'command': post_rollback }] if configure_clone: vdb_params.source.operations.configure_clone = [{ 'type': 'RunCommandOnSourceOperation', 'command': configure_clone }] vdb_repo = find_dbrepo_by_environment_ref_and_install_path(engine, dx_session_obj.server_session, 'OracleInstall', environment_obj.reference, arguments['--envinst']) vdb_params.source_config.database_name = db vdb_params.source_config.unique_name = unique_name vdb_params.source_config.instance = OracleInstance() vdb_params.source_config.instance.instance_name = inst_name vdb_params.source_config.instance.instance_number = 1 vdb_params.source_config.repository = vdb_repo.reference dx_timeflow_obj = DxTimeflow(dx_session_obj.server_session) vdb_params.timeflow_point_parameters = \ dx_timeflow_obj.set_timeflow_point(container_obj, arguments['--timestamp_type'], arguments['--timestamp']) print vdb_params, '\n\n\n' print_info(engine["hostname"] + ": Provisioning " + vdb_name) database.provision(dx_session_obj.server_session, vdb_params) #Add the job into the jobs dictionary so we can track its progress jobs[engine['hostname']] = dx_session_obj.server_session.last_job #return the job object to the calling statement so that we can tell if # a job was created or not (will return None, if no job) return dx_session_obj.server_session.last_job else: raise DlpxException('\nERROR: %s: %s alread exists\n' % (engine['hostname'], vdb_name))
def create_vfiles_vdb(engine, jobs, vfiles_group, vfiles_name, environment_obj, container_obj, pre_refresh=None, post_refresh=None, pre_rollback=None, post_rollback=None, configure_clone=None): ''' Create a Vfiles VDB ''' vfiles_obj = None try: vfiles_obj = find_obj_by_name(dx_session_obj.server_session, database, vfiles_name) except DlpxException: pass if vfiles_obj is None: vfiles_repo = find_repo_by_environment_ref(engine, 'Unstructured Files', environment_obj.reference) vfiles_params = AppDataProvisionParameters() vfiles_params.source = AppDataVirtualSource() vfiles_params.source_config = AppDataDirectSourceConfig() vdb_restart_reobj = re.compile('true', re.IGNORECASE) if vdb_restart_reobj.search(str(arguments['--vdb_restart'])): vfiles_params.source.allow_auto_vdb_restart_on_host_reboot = True elif vdb_restart_reobj.search(str(arguments['--vdb_restart'])) is None: vfiles_params.source.allow_auto_vdb_restart_on_host_reboot = False vfiles_params.container = { 'type': 'AppDataContainer', 'group': vfiles_group.reference, 'name': vfiles_name } vfiles_params.source_config.name = arguments['--target'] vfiles_params.source_config.path = arguments['--vfiles_path'] vfiles_params.source_config.environment_user = \ environment_obj.primary_user vfiles_params.source_config.repository = vfiles_repo.reference vfiles_params.source.parameters = {} vfiles_params.source.name = vfiles_name vfiles_params.source.name = vfiles_name vfiles_params.source.operations = VirtualSourceOperations() if pre_refresh: vfiles_params.source.operations.pre_refresh = [{ 'type': 'RunCommandOnSourceOperation', 'command': pre_refresh }] if post_refresh: vfiles_params.source.operations.post_refresh = [{ 'type': 'RunCommandOnSourceOperation', 'command': post_refresh }] if pre_rollback: vfiles_params.source.operations.pre_rollback = [{ 'type': 'RunCommandOnSourceOperation', 'command': pre_rollback }] if post_rollback: vfiles_params.source.operations.post_rollback = [{ 'type': 'RunCommandOnSourceOperation', 'command': post_rollback }] if configure_clone: vfiles_params.source.operations.configure_clone = [{ 'type': 'RunCommandOnSourceOperation', 'command': configure_clone }] if arguments['--timestamp_type'] is None: vfiles_params.timeflow_point_parameters = { 'type': 'TimeflowPointSemantic', 'container': container_obj.reference, 'location': 'LATEST_POINT'} elif arguments['--timestamp_type'].upper() == 'SNAPSHOT': try: dx_timeflow_obj = DxTimeflow(dx_session_obj.server_session) dx_snap_params = dx_timeflow_obj.set_timeflow_point( container_obj, arguments['--timestamp_type'], arguments['--timestamp'], arguments['--timeflow']) except RequestError as e: raise DlpxException('Could not set the timeflow point:\n%s' % (e)) if dx_snap_params.type == 'TimeflowPointSemantic': vfiles_params.timeflow_point_parameters = {'type': dx_snap_params.type, 'container': dx_snap_params.container, 'location': dx_snap_params.location} elif dx_snap_params.type == 'TimeflowPointTimestamp': vfiles_params.timeflow_point_parameters = {'type': dx_snap_params.type, 'timeflow': dx_snap_params.timeflow, 'timestamp': dx_snap_params.timestamp} print_info('%s: Provisioning %s\n' % (engine["hostname"], vfiles_name)) try: database.provision(dx_session_obj.server_session, vfiles_params) except (JobError, RequestError, HttpError) as e: raise DlpxException('\nERROR: Could not provision the database:' '\n%s' % (e)) #Add the job into the jobs dictionary so we can track its progress jobs[engine['hostname']] = dx_session_obj.server_session.last_job #return the job object to the calling statement so that we can tell if # a job was created or not (will return None, if no job) return dx_session_obj.server_session.last_job else: print_info('\nERROR %s: %s already exists. \n' % (engine['hostname'], vfiles_name)) return vfiles_obj.reference
def refresh_database(vdb_name,timestamp, timestamp_type='SNAPSHOT'): """ This function actually performs the refresh engine: dlpx_obj: Virtualization Engine session object vdb_name: VDB to be refreshed """ #Sanity check to make sure our source object has a reference dx_timeflow_obj = DxTimeflow(dx_session_obj.server_session) container_obj = find_obj_by_name(dx_session_obj.server_session, database, vdb_name) source_obj = find_source_by_dbname(dx_session_obj.server_session, database, vdb_name) # Sanity check to make sure our container object has a reference if container_obj.reference: try: if container_obj.virtual is not True: raise DlpxException('{} is not a virtual object. ' 'Skipping.\n'.format(container_obj.name)) elif container_obj.staging is True: raise DlpxException('{} is a virtual object. ' 'Skipping.\n'.format(container_obj.name)) elif container_obj.runtime.enabled == "ENABLED": print_info('\nINFO: Refrshing {} to {}\n'.format( container_obj.name, timestamp)) # This exception is raised if rewinding a vFiles VDB # since AppDataContainer does not have virtual, staging or # enabled attributes. except AttributeError: pass if source_obj.reference: #We can only refresh VDB's if source_obj.virtual != True: print_info('\nINFO: {} is not a virtual object. Skipping.\n'.format( container_obj.name)) #Ensure this source is not a staging database. We can't act upon those. elif source_obj.staging == True: print_info('\nINFO: {} is a staging database. Skipping.\n'.format( container_obj.name)) #Ensure the source is enabled. We can't refresh disabled databases. elif source_obj.runtime.enabled == "ENABLED" : source_db = database.get(dx_session_obj.server_session, container_obj.provision_container) if not source_db: print_error('\nERROR: Was unable to retrieve the source container for {} \n'.format( container_obj.name)) print_info('\nINFO: Refreshing {} from {}\n'.format( container_obj.name, source_db.name)) #If the vdb is a Oracle type, we need to use a # OracleRefreshParameters ''' rewind_params = RollbackParameters() rewind_params.timeflow_point_parameters = \ dx_timeflow_obj.set_timeflow_point(container_obj, timestamp_type, timestamp) print_debug('{}: {}'.format(engine_name, str(rewind_params))) ''' if str(container_obj.reference).startswith("ORACLE"): refresh_params = OracleRefreshParameters() else: refresh_params = RefreshParameters() try: refresh_params.timeflow_point_parameters = \ dx_timeflow_obj.set_timeflow_point(source_db, timestamp_type, timestamp) print_info('\nINFO: Refresh prams {}\n'.format( refresh_params)) #Sync it database.refresh(dx_session_obj.server_session, container_obj.reference, refresh_params) dx_session_obj.jobs[dx_session_obj.server_session.address] = \ dx_session_obj.server_session.last_job except RequestError as e: print '\nERROR: Could not set timeflow point:\n%s\n' % ( e.message.action) sys.exit(1) except DlpxException as e: print 'ERROR: Could not set timeflow point:\n%s\n' % (e.message) sys.exit(1) #Don't do anything if the database is disabled else: print_info('\nINFO: {} is not enabled. Skipping sync.\n'.format( container_obj.name))