def find_snapshot_by_database_and_time(engine, server, database_obj, snap_time): """ Find snapshot object by database name and timetamp engine: server: A Delphix engine object. database_obj: The database reference to retrieve the snapshot snap_time: timstamp of the snapshot """ snapshots = snapshot.get_all(server, database=database_obj.reference) matches = [] for snapshot_obj in snapshots: if (str(snapshot_obj.latest_change_point.timestamp) == snap_time or str(snapshot_obj.first_change_point.timestamp) == snap_time): matches.append(snapshot_obj) if len(matches) == 1: snap_match = get_obj_name(server, database, matches[0].container) print_debug(engine["hostname"] + ": Found one and only one match. This is good.") print_debug(engine["hostname"] + ": " + snap_match) return matches[0] elif len(matches) > 1: print_debug(engine["hostname"] + ": " + matches) raise DlpxException("The time specified was not specific enough." " More than one match found.\n") else: raise DlpxException("No matches found for the time specified.\n")
def find_snapshot_by_database_and_name(engine, server, database_obj, snap_name): snapshots = snapshot.get_all(server, database=database_obj.reference) matches = [] for snapshot_obj in snapshots: if str(snapshot_obj.name).startswith(arguments["--timestamp"]): matches.append(snapshot_obj) if len(matches) == 1: print_debug(engine["hostname"] + ": Found one and only one match. This is good.") print_debug(engine["hostname"] + ": " + matches[0]) return matches[0] elif len(matches) > 1: print_error("The name specified was not specific enough. " "More than one match found.") for each in matches: print_debug(engine["hostname"] + ": " + each.name) else: print_error("No matches found for the time specified") print_error("No matching snapshot found")
def find_snapshot_by_database_and_time(engine, server, database_obj, snap_time): """ Find snapshot object by database name and timetamp engine: server: A Delphix engine object. database_obj: The database reference to retrieve the snapshot snap_time: timstamp of the snapshot """ snapshots = snapshot.get_all(server, database=database_obj.reference) matches = [] for snapshot_obj in snapshots: if str(snapshot_obj.latest_change_point.timestamp) == snap_time \ or str(snapshot_obj.first_change_point.timestamp) == snap_time: matches.append(snapshot_obj) if len(matches) == 1: snap_match = get_obj_name(server, database, matches[0].container) print_debug(engine['hostname'] + ': Found one and only one match. This is good.') print_debug(engine['hostname'] + ': ' + snap_match) return matches[0] elif len(matches) > 1: print_debug(engine["hostname"] + ": " + matches) raise DlpxException('The time specified was not specific enough.' ' More than one match found.\n') else: raise DlpxException('No matches found for the time specified.\n')
def list_snapshots(server): """ List all snapshots with timestamps """ header = 'Snapshot Name, First Change Point, Location, Latest Change Point' snapshots = snapshot.get_all(server) print header for snap in snapshots: container_name = get_obj_name(server, database, snap.container) snap_range = snapshot.timeflow_range(server, snap.reference) print '{}, {}, {}, {}, {}'.format(str(snap.name), container_name, snap_range.start_point.timestamp, snap_range.start_point.location, snap_range.end_point.timestamp)
def find_snapshot_by_database_and_name(engine, server, database_obj, snap_name): snapshots = snapshot.get_all(server, database=database_obj.reference) matches = [] for snapshot_obj in snapshots: if str(snapshot_obj.name).startswith(arguments['--timestamp']): matches.append(snapshot_obj) if len(matches) == 1: print_debug(engine["hostname"] + ": Found one and only one match. This is good.") print_debug(engine["hostname"] + ": " + matches[0]) return matches[0] elif len(matches) > 1: print_error("The name specified was not specific enough. " "More than one match found.") for each in matches: print_debug(engine["hostname"] + ": " + each.name) else: print_error("No matches found for the time specified") print_error("No matching snapshot found")