def find_snapshot(self, database_ref, timestamp, snap_name=None,
                      snap_time=None):
        """
        Method to find a snapshot by name

        database_obj: database reference for the snapshot lookup
        snap_name: name of the snapshot. Default: None
        snap_time: time of the snapshot. Default: None
        """

        snapshots = snapshot.get_all(self.engine, database=database_ref)

        matches = []
        for snapshot_obj in snapshots:
            if (str(snapshot_obj.name).startswith(timestamp) and
               snap_name is not None):

                matches.append(snapshot_obj)

            elif (str(snapshot_obj.latest_change_point.timestamp).startswith(timestamp)
                  and snap_time is not None):

                matches.append(snapshot_obj)

        if len(matches) == 1:
            return matches[0]

        elif len(matches) > 1:
            raise DlpxException('{}: The name specified was not specific '
                                'enough. More than one match found.\n'.format(
                                self.engine.address))

        elif len(matches) < 1:
            raise DlpxException('{}: No matches found for the time '
                                'specified.\n'.format(self.engine.address))
Esempio n. 2
0
def find_snapshot_by_database_and_time(engine, database_obj, snap_time):
    snapshots = snapshot.get_all(
        dx_session_obj.server_session, database=database_obj.reference
    )
    matches = []

    for snapshot_obj in snapshots:
        if str(snapshot_obj.latest_change_point.timestamp).startswith(
            arguments["--timestamp"]
        ):

            matches.append(snapshot_obj)

    if len(matches) == 1:
        print_debug(
            '%s": Found one and only one match. This is good.\n%s'
            % (engine["hostname"], matches[0]),
            debug,
        )

        return matches[0]

    elif len(matches) > 1:
        print_debug(matches, debug)

        raise DlpxException(
            "%s: The time specified was not specific enough."
            "More than one match found.\n" % (engine["hostname"])
        )
    else:
        raise DlpxException(
            "%s: No matches found for the time specified.\n" % (engine["hostname"])
        )
Esempio n. 3
0
def find_snapshot_by_database_and_name(engine, database_obj, snap_name):
    """
    Find snapshots by database and name. Return snapshot reference.

    engine: Dictionary of engines from config file.
    database_obj: Database object to find the snapshot against
    snap_name: Name of the snapshot
    """

    snapshots = snapshot.get_all(dx_session_obj.server_session,
                                 database=database_obj.reference)
    matches = []
    for snapshot_obj in snapshots:
        if str(snapshot_obj.name).startswith(arguments['--timestamp']):
            matches.append(snapshot_obj)

    for each in matches:
        print_debug(each.name, debug)

    if len(matches) == 1:
        print_debug(
            '%s: Found one and only one match. This is good.\n %s' %
            (engine['hostname'], matches[0]), debug)
        return matches[0]

    elif len(matches) > 1:
        raise DlpxException('%s: The name specified was not specific enough.'
                            ' More than one match found.\n' %
                            (engine['hostname'], ))

    else:
        raise DlpxException('%s: No matches found for the time specified.\n' %
                            (engine['hostname']))
def find_snapshot_by_database_and_time(engine, database_obj, snap_time):
    snapshots = snapshot.get_all(dx_session_obj.server_session,
                                 database=database_obj.reference)
    matches = []

    for snapshot_obj in snapshots:
        if str(snapshot_obj.latest_change_point.timestamp).startswith(arguments['--timestamp']):

            matches.append(snapshot_obj)

    if len(matches) == 1:
        print_debug('%s": Found one and only one match. This is good.\n%s' %
                    (engine['hostname'], matches[0]), debug)

        return matches[0]

    elif len(matches) > 1:
        print_debug(matches, debug)

        raise DlpxException('%s: The time specified was not specific enough.'
                            'More than one match found.\n' %
                            (engine['hostname']))
    else:
        raise DlpxException('%s: No matches found for the time specified.\n'
                            % (engine['hostname']))
def find_snapshot_by_database_and_name(engine, database_obj, snap_name):
    """
    Find snapshots by database and name. Return snapshot reference.

    engine: Dictionary of engines from config file.
    database_obj: Database object to find the snapshot against
    snap_name: Name of the snapshot
    """

    snapshots = snapshot.get_all(dx_session_obj.server_session,
                                 database=database_obj.reference)
    matches = []
    for snapshot_obj in snapshots:
        if str(snapshot_obj.name).startswith(arguments['--timestamp']):
            matches.append(snapshot_obj)

    for each in matches:
        print_debug(each.name, debug)

    if len(matches) == 1:
        print_debug('%s: Found one and only one match. This is good.\n %s' %
                    (engine['hostname'], matches[0]), debug)
        return matches[0]

    elif len(matches) > 1:
        raise DlpxException('%s: The name specified was not specific enough.'
                            ' More than one match found.\n' %
                            (engine['hostname'],))

    else:
        raise DlpxException('%s: No matches found for the time specified.\n'
                            % (engine['hostname']))
    def find_snapshot(self,
                      database_ref,
                      timestamp,
                      snap_name=None,
                      snap_time=None):
        """
        Method to find a snapshot by name

        database_obj: database reference for the snapshot lookup
        snap_name: name of the snapshot. Default: None
        snap_time: time of the snapshot. Default: None
        """

        snapshots = snapshot.get_all(self.engine, database=database_ref)

        matches = []
        for snapshot_obj in snapshots:
            if str(snapshot_obj.name).startswith(
                    timestamp) and snap_name is not None:

                matches.append(snapshot_obj)

            elif (str(snapshot_obj.latest_change_point.timestamp).startswith(
                    timestamp) and snap_time is not None):

                matches.append(snapshot_obj)

        if len(matches) == 1:
            return matches[0]

        elif len(matches) > 1:
            raise DlpxException("{}: The name specified was not specific "
                                "enough. More than one match found.\n".format(
                                    self.engine.address))

        elif len(matches) < 1:
            raise DlpxException("{}: No matches found for the time "
                                "specified.\n".format(self.engine.address))