diff --git a/activationDrill/drillServer.py b/activationDrill/drillServer.py index ae6988e..06074bf 100644 --- a/activationDrill/drillServer.py +++ b/activationDrill/drillServer.py @@ -153,19 +153,36 @@ class ActivationDrillServer: # Group snapshots by date date_groups = {} for snap in snapshots: - # Extract date from snapshot suffix (assuming YYYY-MM-DD_HH-MM-SS format) + # Parse snapshot suffix: format is [dataset-name]-YYYY-MM-DD_HH-MM-SS + # Example: pool1-hanaStandby_nfs-2025-08-05_15-36-10 try: - date_part = snap['suffix'].split('_')[0] if '_' in snap['suffix'] else snap['suffix'] - if len(date_part) >= 10: # YYYY-MM-DD - date_key = date_part[:10] - if date_key not in date_groups: - date_groups[date_key] = [] - date_groups[date_key].append(snap) - except: + suffix = snap['suffix'] + + # Find the last occurrence of a date pattern (YYYY-MM-DD) + # This handles cases where dataset names contain dashes + import re + date_pattern = r'(\d{4}-\d{2}-\d{2})_(\d{2}-\d{2}-\d{2})' + match = re.search(date_pattern, suffix) + + if match: + date_part = match.group(1) # YYYY-MM-DD + time_part = match.group(2) # HH-MM-SS + + if date_part not in date_groups: + date_groups[date_part] = [] + + # Store both date and time info + snap['parsed_date'] = date_part + snap['parsed_time'] = time_part.replace('-', ':') + date_groups[date_part].append(snap) + + except Exception as e: + print(f"{Colors.DIM}Warning: Could not parse snapshot {snap['suffix']}: {e}{Colors.ENDC}") continue if not date_groups: print(f"{Colors.RED}✗ No properly formatted snapshots found{Colors.ENDC}") + print(f"{Colors.DIM}Expected format: [dataset-name]-YYYY-MM-DD_HH-MM-SS{Colors.ENDC}") return None dates = sorted(date_groups.keys(), reverse=True) @@ -179,7 +196,14 @@ class ActivationDrillServer: print(f"\n{Colors.BOLD}Available Dates:{Colors.ENDC}") for i, date in enumerate(dates, 1): count = len(date_groups[date]) - print(f"{Colors.CYAN}{i:2d}.{Colors.ENDC} {date} ({count} snapshot{'s' if count > 1 else ''})") + # Format date nicely + try: + from datetime import datetime + date_obj = datetime.strptime(date, '%Y-%m-%d') + formatted_date = date_obj.strftime('%B %d, %Y (%A)') + print(f"{Colors.CYAN}{i:2d}.{Colors.ENDC} {formatted_date} ({count} snapshot{'s' if count > 1 else ''})") + except: + print(f"{Colors.CYAN}{i:2d}.{Colors.ENDC} {date} ({count} snapshot{'s' if count > 1 else ''})") # Select date while True: @@ -195,13 +219,28 @@ class ActivationDrillServer: # Show snapshots for selected date day_snapshots = date_groups[selected_date] - print(f"\n{Colors.BOLD}Snapshots for {selected_date}:{Colors.ENDC}") + + # Format the selected date nicely + try: + from datetime import datetime + date_obj = datetime.strptime(selected_date, '%Y-%m-%d') + formatted_date = date_obj.strftime('%B %d, %Y') + except: + formatted_date = selected_date + + print(f"\n{Colors.BOLD}Snapshots for {formatted_date}:{Colors.ENDC}") for i, snap in enumerate(day_snapshots, 1): - time_part = "Unknown" - if '_' in snap['suffix']: - time_part = snap['suffix'].split('_')[1].replace('-', ':') - print(f"{Colors.CYAN}{i:2d}.{Colors.ENDC} {time_part} - {snap['creation']}") + time_display = snap.get('parsed_time', 'Unknown time') + # Make creation time more readable + creation_parts = snap['creation'].split() + if len(creation_parts) >= 4: + # Show just date and time, skip timezone and year if same + creation_display = f"{creation_parts[1]} {creation_parts[2]} {creation_parts[3]}" + else: + creation_display = snap['creation'] + + print(f"{Colors.CYAN}{i:2d}.{Colors.ENDC} {time_display} {Colors.DIM}(created: {creation_display}){Colors.ENDC}") # Select specific snapshot while True: @@ -210,9 +249,11 @@ class ActivationDrillServer: idx = int(choice) - 1 if 0 <= idx < len(day_snapshots): selected_snap = day_snapshots[idx]['name'] + selected_time = day_snapshots[idx].get('parsed_time', 'Unknown') # Confirm selection - print(f"\n{Colors.YELLOW}Selected snapshot: {selected_snap}{Colors.ENDC}") + print(f"\n{Colors.YELLOW}Selected: {formatted_date} at {selected_time}{Colors.ENDC}") + print(f"{Colors.DIM}Snapshot: {selected_snap}{Colors.ENDC}") confirm = input(f"{Colors.BOLD}Proceed with this snapshot? (y/N): {Colors.ENDC}") if confirm.lower() == 'y': return selected_snap