def refresh_container(self, parent_bookmark_ref, db_type, child_db_ref):
        """
        Refreshes a container

        parent_bookmark_ref: The parent's bookmark reference.
        db_type: The database type
        child_db_ref: The child database reference
        """

        if db_type == "Oracle":
            tf_params = OracleRefreshParameters()
        else:
            tf_params = RefreshParameters()

        tf_params.timeflow_point_parameters = {
            "type": "TimeflowPointBookmark",
            "bookmark": parent_bookmark_ref,
        }

        try:
            with job_context.asyncly(self.engine):
                db_ret_val = database.refresh(self.engine, child_db_ref,
                                              tf_params)
            return db_ret_val

        except RequestError as e:
            dlpx_err = e.message
            raise DlpxException(dlpx_err.action)

        except (JobError, HttpError) as e:
            print_exception("Exception caught during refresh:\n{}".format(
                sys.exc_info()[0]))
    def refresh_container(self, parent_bookmark_ref, db_type, child_db_ref):
        """
        Refreshes a container

        parent_bookmark_ref: The parent's bookmark reference.
        db_type: The database type
        child_db_ref: The child database reference
        """

        if db_type == 'Oracle':
            tf_params = OracleRefreshParameters()
        else:
            tf_params = RefreshParameters()

        tf_params.timeflow_point_parameters = {'type': 'TimeflowPointBookmark',
                                               'bookmark': parent_bookmark_ref}

        try:
            with job_context.async(self.engine):
                db_ret_val = database.refresh(self.engine, child_db_ref,
                                                   tf_params)
            return db_ret_val
Esempio n. 3
0
    def refresh_container(self, parent_bookmark_ref, db_type, child_db_ref):
        """
        Refreshes a container

        parent_bookmark_ref: The parent's bookmark reference.
        db_type: The database type
        child_db_ref: The child database reference
        """

        if db_type == 'Oracle':
            tf_params = OracleRefreshParameters()
        else:
            tf_params = RefreshParameters()

        tf_params.timeflow_point_parameters = {
            'type': 'TimeflowPointBookmark',
            'bookmark': parent_bookmark_ref
        }

        try:
            with job_context. async (self.engine):
                db_ret_val = database.refresh(self.engine, child_db_ref,
                                              tf_params)
            return db_ret_val
Esempio n. 4
0
def refresh_database(engine, server, jobs, source_obj, container_obj):
    """
    This function actually performs the refresh
    engine:
    server: Engine object
    jobs: list containing running jobs
    source_obj: source object used to refresh from snapshot or timeflow
    container_obj: VDB container
    """

    # Sanity check to make sure our source object has a reference
    if source_obj.reference:
        # We can only refresh VDB's
        if source_obj.virtual != True:
            print_warning(engine["hostname"] + ": " + container_obj.name +
                          " is not a virtual object. Skipping.")

        # Ensure this source is not a staging database. We can't act upon those.
        elif source_obj.staging == True:
            print_warning(engine["hostname"] + ": " + container_obj.name +
                          " is a staging database. Skipping.")

        # Ensure the source is enabled. We can't refresh disabled databases.
        elif source_obj.runtime.enabled == "ENABLED":
            source_db = database.get(server, container_obj.provision_container)
            if not source_db:
                print_error(
                    engine["hostname"] +
                    ":Was unable to retrieve the source container for " +
                    container_obj.name)
            print_info(engine["hostname"] + ": Refreshing " +
                       container_obj.name + " from " + source_db.name)
            print_debug(engine["hostname"] + ": Type: " + source_obj.type)
            print_debug(engine["hostname"] + ":" + source_obj.type)

            # If the vdb is a Oracle type, we need to use a
            # OracleRefreshParameters

            if str(container_obj.reference).startswith("ORACLE"):
                refresh_params = OracleRefreshParameters()
            else:
                refresh_params = RefreshParameters()

            try:
                refresh_params.timeflow_point_parameters = set_timeflow_point(
                    engine, server, source_db)
                print_debug(engine["hostname"] + ":" + str(refresh_params))

                # Sync it
                database.refresh(server, container_obj.reference,
                                 refresh_params)
                jobs[container_obj] = server.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)

            # 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 server.last_job

        # Don't do anything if the database is disabled
        else:
            print_warning(engine["hostname"] + ": " + container_obj.name +
                          " is not enabled. Skipping sync")
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 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 refresh_database(engine, server, jobs, source_obj, container_obj):
    """
    This function actually performs the refresh
    engine:
    server: Engine object
    jobs: list containing running jobs
    source_obj: source object used to refresh from snapshot or timeflow
    container_obj: VDB container
    """

    #Sanity check to make sure our source object has a reference
    if source_obj.reference:
        #We can only refresh VDB's
        if source_obj.virtual != True:
            print_warning(engine["hostname"] + ": " + container_obj.name + 
                          " is not a virtual object. Skipping.")

        #Ensure this source is not a staging database. We can't act upon those.
        elif source_obj.staging == True:
            print_warning(engine["hostname"] + ": " + container_obj.name + 
                          " is a staging database. Skipping.")

        #Ensure the source is enabled. We can't refresh disabled databases.
        elif source_obj.runtime.enabled == "ENABLED" :
            source_db = database.get(server, container_obj.provision_container)
            if not source_db:
                print_error(engine["hostname"] + 
                            ":Was unable to retrieve the source container for "
                            + container_obj.name)
            print_info(engine["hostname"] + ": Refreshing " + 
                       container_obj.name + " from " + source_db.name)
            print_debug(engine["hostname"] + ": Type: " + source_obj.type )
            print_debug(engine["hostname"] + ":" + source_obj.type)

            #If the vdb is a Oracle type, we need to use a 
            # OracleRefreshParameters

            if str(container_obj.reference).startswith("ORACLE"):
                refresh_params = OracleRefreshParameters()
            else:
                refresh_params = RefreshParameters()
            
            try:
                refresh_params.timeflow_point_parameters = set_timeflow_point(
                                                           engine, server, 
                                                           source_db)
                print_debug(engine["hostname"] + ":" + str(refresh_params))

                #Sync it
                database.refresh(server, container_obj.reference, 
                                 refresh_params)
                jobs[container_obj] = server.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)


            #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 server.last_job

        #Don't do anything if the database is disabled
        else:
            print_warning(engine["hostname"] + ": " + container_obj.name + 
                          " is not enabled. Skipping sync")