runbooks 0.7.7__py3-none-any.whl → 0.9.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. runbooks/__init__.py +1 -1
  2. runbooks/base.py +2 -2
  3. runbooks/cfat/README.md +12 -1
  4. runbooks/cfat/__init__.py +8 -4
  5. runbooks/cfat/assessment/collectors.py +171 -14
  6. runbooks/cfat/assessment/compliance.py +546 -522
  7. runbooks/cfat/assessment/runner.py +129 -10
  8. runbooks/cfat/models.py +6 -2
  9. runbooks/common/__init__.py +152 -0
  10. runbooks/common/accuracy_validator.py +1039 -0
  11. runbooks/common/context_logger.py +440 -0
  12. runbooks/common/cross_module_integration.py +594 -0
  13. runbooks/common/enhanced_exception_handler.py +1108 -0
  14. runbooks/common/enterprise_audit_integration.py +634 -0
  15. runbooks/common/logger.py +14 -0
  16. runbooks/common/mcp_integration.py +539 -0
  17. runbooks/common/performance_monitor.py +387 -0
  18. runbooks/common/profile_utils.py +216 -0
  19. runbooks/common/rich_utils.py +622 -0
  20. runbooks/enterprise/__init__.py +68 -0
  21. runbooks/enterprise/error_handling.py +411 -0
  22. runbooks/enterprise/logging.py +439 -0
  23. runbooks/enterprise/multi_tenant.py +583 -0
  24. runbooks/feedback/user_feedback_collector.py +440 -0
  25. runbooks/finops/README.md +129 -14
  26. runbooks/finops/__init__.py +22 -3
  27. runbooks/finops/account_resolver.py +279 -0
  28. runbooks/finops/accuracy_cross_validator.py +638 -0
  29. runbooks/finops/aws_client.py +721 -36
  30. runbooks/finops/budget_integration.py +313 -0
  31. runbooks/finops/cli.py +90 -33
  32. runbooks/finops/cost_processor.py +211 -37
  33. runbooks/finops/dashboard_router.py +900 -0
  34. runbooks/finops/dashboard_runner.py +1334 -399
  35. runbooks/finops/embedded_mcp_validator.py +288 -0
  36. runbooks/finops/enhanced_dashboard_runner.py +526 -0
  37. runbooks/finops/enhanced_progress.py +327 -0
  38. runbooks/finops/enhanced_trend_visualization.py +423 -0
  39. runbooks/finops/finops_dashboard.py +41 -0
  40. runbooks/finops/helpers.py +639 -323
  41. runbooks/finops/iam_guidance.py +400 -0
  42. runbooks/finops/markdown_exporter.py +466 -0
  43. runbooks/finops/multi_dashboard.py +1502 -0
  44. runbooks/finops/optimizer.py +396 -395
  45. runbooks/finops/profile_processor.py +2 -2
  46. runbooks/finops/runbooks.inventory.organizations_discovery.log +0 -0
  47. runbooks/finops/runbooks.security.report_generator.log +0 -0
  48. runbooks/finops/runbooks.security.run_script.log +0 -0
  49. runbooks/finops/runbooks.security.security_export.log +0 -0
  50. runbooks/finops/service_mapping.py +195 -0
  51. runbooks/finops/single_dashboard.py +710 -0
  52. runbooks/finops/tests/__init__.py +19 -0
  53. runbooks/finops/tests/results_test_finops_dashboard.xml +1 -0
  54. runbooks/finops/tests/run_comprehensive_tests.py +421 -0
  55. runbooks/finops/tests/run_tests.py +305 -0
  56. runbooks/finops/tests/test_finops_dashboard.py +705 -0
  57. runbooks/finops/tests/test_integration.py +477 -0
  58. runbooks/finops/tests/test_performance.py +380 -0
  59. runbooks/finops/tests/test_performance_benchmarks.py +500 -0
  60. runbooks/finops/tests/test_reference_images_validation.py +867 -0
  61. runbooks/finops/tests/test_single_account_features.py +715 -0
  62. runbooks/finops/tests/validate_test_suite.py +220 -0
  63. runbooks/finops/types.py +1 -1
  64. runbooks/hitl/enhanced_workflow_engine.py +725 -0
  65. runbooks/inventory/README.md +12 -1
  66. runbooks/inventory/artifacts/scale-optimize-status.txt +12 -0
  67. runbooks/inventory/collectors/aws_comprehensive.py +192 -185
  68. runbooks/inventory/collectors/enterprise_scale.py +281 -0
  69. runbooks/inventory/core/collector.py +299 -12
  70. runbooks/inventory/list_ec2_instances.py +21 -20
  71. runbooks/inventory/list_ssm_parameters.py +31 -3
  72. runbooks/inventory/organizations_discovery.py +1315 -0
  73. runbooks/inventory/rich_inventory_display.py +360 -0
  74. runbooks/inventory/run_on_multi_accounts.py +32 -16
  75. runbooks/inventory/runbooks.security.report_generator.log +0 -0
  76. runbooks/inventory/runbooks.security.run_script.log +0 -0
  77. runbooks/inventory/vpc_flow_analyzer.py +1030 -0
  78. runbooks/main.py +4171 -1615
  79. runbooks/metrics/dora_metrics_engine.py +1293 -0
  80. runbooks/monitoring/performance_monitor.py +433 -0
  81. runbooks/operate/README.md +394 -0
  82. runbooks/operate/__init__.py +2 -2
  83. runbooks/operate/base.py +291 -11
  84. runbooks/operate/deployment_framework.py +1032 -0
  85. runbooks/operate/deployment_validator.py +853 -0
  86. runbooks/operate/dynamodb_operations.py +10 -6
  87. runbooks/operate/ec2_operations.py +321 -11
  88. runbooks/operate/executive_dashboard.py +779 -0
  89. runbooks/operate/mcp_integration.py +750 -0
  90. runbooks/operate/nat_gateway_operations.py +1120 -0
  91. runbooks/operate/networking_cost_heatmap.py +685 -0
  92. runbooks/operate/privatelink_operations.py +940 -0
  93. runbooks/operate/s3_operations.py +10 -6
  94. runbooks/operate/vpc_endpoints.py +644 -0
  95. runbooks/operate/vpc_operations.py +1038 -0
  96. runbooks/remediation/README.md +489 -13
  97. runbooks/remediation/__init__.py +2 -2
  98. runbooks/remediation/acm_remediation.py +1 -1
  99. runbooks/remediation/base.py +1 -1
  100. runbooks/remediation/cloudtrail_remediation.py +1 -1
  101. runbooks/remediation/cognito_remediation.py +1 -1
  102. runbooks/remediation/commons.py +8 -4
  103. runbooks/remediation/dynamodb_remediation.py +1 -1
  104. runbooks/remediation/ec2_remediation.py +1 -1
  105. runbooks/remediation/ec2_unattached_ebs_volumes.py +1 -1
  106. runbooks/remediation/kms_enable_key_rotation.py +1 -1
  107. runbooks/remediation/kms_remediation.py +1 -1
  108. runbooks/remediation/lambda_remediation.py +1 -1
  109. runbooks/remediation/multi_account.py +1 -1
  110. runbooks/remediation/rds_remediation.py +1 -1
  111. runbooks/remediation/s3_block_public_access.py +1 -1
  112. runbooks/remediation/s3_enable_access_logging.py +1 -1
  113. runbooks/remediation/s3_encryption.py +1 -1
  114. runbooks/remediation/s3_remediation.py +1 -1
  115. runbooks/remediation/vpc_remediation.py +475 -0
  116. runbooks/security/ENTERPRISE_SECURITY_FRAMEWORK.md +506 -0
  117. runbooks/security/README.md +12 -1
  118. runbooks/security/__init__.py +166 -33
  119. runbooks/security/compliance_automation.py +634 -0
  120. runbooks/security/compliance_automation_engine.py +1021 -0
  121. runbooks/security/enterprise_security_framework.py +931 -0
  122. runbooks/security/enterprise_security_policies.json +293 -0
  123. runbooks/security/integration_test_enterprise_security.py +879 -0
  124. runbooks/security/module_security_integrator.py +641 -0
  125. runbooks/security/report_generator.py +10 -0
  126. runbooks/security/run_script.py +27 -5
  127. runbooks/security/security_baseline_tester.py +153 -27
  128. runbooks/security/security_export.py +456 -0
  129. runbooks/sre/README.md +472 -0
  130. runbooks/sre/__init__.py +33 -0
  131. runbooks/sre/mcp_reliability_engine.py +1049 -0
  132. runbooks/sre/performance_optimization_engine.py +1032 -0
  133. runbooks/sre/reliability_monitoring_framework.py +1011 -0
  134. runbooks/validation/__init__.py +10 -0
  135. runbooks/validation/benchmark.py +489 -0
  136. runbooks/validation/cli.py +368 -0
  137. runbooks/validation/mcp_validator.py +797 -0
  138. runbooks/vpc/README.md +478 -0
  139. runbooks/vpc/__init__.py +38 -0
  140. runbooks/vpc/config.py +212 -0
  141. runbooks/vpc/cost_engine.py +347 -0
  142. runbooks/vpc/heatmap_engine.py +605 -0
  143. runbooks/vpc/manager_interface.py +649 -0
  144. runbooks/vpc/networking_wrapper.py +1289 -0
  145. runbooks/vpc/rich_formatters.py +693 -0
  146. runbooks/vpc/tests/__init__.py +5 -0
  147. runbooks/vpc/tests/conftest.py +356 -0
  148. runbooks/vpc/tests/test_cli_integration.py +530 -0
  149. runbooks/vpc/tests/test_config.py +458 -0
  150. runbooks/vpc/tests/test_cost_engine.py +479 -0
  151. runbooks/vpc/tests/test_networking_wrapper.py +512 -0
  152. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/METADATA +175 -65
  153. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/RECORD +157 -60
  154. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/entry_points.txt +1 -1
  155. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/WHEEL +0 -0
  156. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/licenses/LICENSE +0 -0
  157. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,327 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Enhanced Progress Bar Implementation - Smooth Progress Tracking
4
+
5
+ This module provides enhanced progress bar implementations that address the
6
+ 0%→100% jump issue by providing meaningful incremental progress updates
7
+ during AWS API operations and data processing.
8
+
9
+ Features:
10
+ - Smooth incremental progress updates
11
+ - Real-time operation tracking
12
+ - Context-aware progress estimation
13
+ - Rich CLI integration with beautiful progress bars
14
+ - Performance monitoring and timing
15
+ - Operation-specific progress patterns
16
+
17
+ Author: CloudOps Runbooks Team
18
+ Version: 0.8.0
19
+ """
20
+
21
+ import time
22
+ from contextlib import contextmanager
23
+ from typing import Any, Callable, Dict, Iterator, List, Optional, Union
24
+
25
+ from rich.console import Console
26
+ from rich.progress import (
27
+ BarColumn,
28
+ Progress,
29
+ SpinnerColumn,
30
+ TaskProgressColumn,
31
+ TextColumn,
32
+ TimeElapsedColumn,
33
+ TimeRemainingColumn,
34
+ )
35
+
36
+ from ..common.rich_utils import console as rich_console
37
+
38
+
39
+ class EnhancedProgressTracker:
40
+ """
41
+ Enhanced progress tracking with smooth incremental updates.
42
+
43
+ Provides context-aware progress estimation for AWS operations
44
+ and prevents jarring 0%→100% jumps by breaking operations into
45
+ meaningful sub-steps with realistic timing.
46
+ """
47
+
48
+ def __init__(self, console: Optional[Console] = None):
49
+ self.console = console or rich_console
50
+ self.operation_timing = {
51
+ "aws_cost_data": {"steps": 5, "estimated_seconds": 8},
52
+ "budget_analysis": {"steps": 3, "estimated_seconds": 4},
53
+ "service_analysis": {"steps": 4, "estimated_seconds": 6},
54
+ "multi_account_analysis": {"steps": 6, "estimated_seconds": 12},
55
+ "resource_discovery": {"steps": 8, "estimated_seconds": 15},
56
+ }
57
+
58
+ @contextmanager
59
+ def create_enhanced_progress(
60
+ self, operation_type: str = "default", total_items: Optional[int] = None
61
+ ) -> Iterator["ProgressContext"]:
62
+ """
63
+ Create enhanced progress context with smooth incremental updates.
64
+
65
+ Args:
66
+ operation_type: Type of operation for timing estimation
67
+ total_items: Total number of items to process (for accurate progress)
68
+
69
+ Yields:
70
+ ProgressContext: Enhanced progress context manager
71
+ """
72
+ timing_info = self.operation_timing.get(operation_type, {"steps": 5, "estimated_seconds": 8})
73
+
74
+ progress = Progress(
75
+ SpinnerColumn(),
76
+ TextColumn("[progress.description]{task.description}"),
77
+ BarColumn(complete_style="bright_green", finished_style="bright_green"),
78
+ TaskProgressColumn(),
79
+ TimeElapsedColumn(),
80
+ TimeRemainingColumn(),
81
+ console=self.console,
82
+ transient=False,
83
+ )
84
+
85
+ with progress:
86
+ context = ProgressContext(progress, timing_info, total_items)
87
+ yield context
88
+
89
+ def create_multi_stage_progress(self, stages: List[Dict[str, Any]]) -> "MultiStageProgress":
90
+ """
91
+ Create multi-stage progress for complex operations.
92
+
93
+ Args:
94
+ stages: List of stage definitions with names and estimated durations
95
+
96
+ Returns:
97
+ MultiStageProgress: Multi-stage progress manager
98
+ """
99
+ return MultiStageProgress(self.console, stages)
100
+
101
+
102
+ class ProgressContext:
103
+ """
104
+ Enhanced progress context with smooth incremental updates.
105
+
106
+ Provides methods for updating progress with realistic timing
107
+ and prevents jarring progress jumps.
108
+ """
109
+
110
+ def __init__(self, progress: Progress, timing_info: Dict[str, Any], total_items: Optional[int] = None):
111
+ self.progress = progress
112
+ self.timing_info = timing_info
113
+ self.total_items = total_items or 100
114
+ self.current_step = 0
115
+ self.max_steps = timing_info["steps"]
116
+ self.estimated_seconds = timing_info["estimated_seconds"]
117
+ self.step_duration = self.estimated_seconds / self.max_steps
118
+ self.task_id = None
119
+
120
+ def start_operation(self, description: str) -> None:
121
+ """Start the operation with initial progress."""
122
+ self.task_id = self.progress.add_task(description, total=self.total_items)
123
+ self.current_step = 0
124
+
125
+ def update_step(self, step_name: str, increment: Optional[int] = None) -> None:
126
+ """
127
+ Update progress to next step with smooth incremental updates.
128
+
129
+ Args:
130
+ step_name: Name of the current step
131
+ increment: Optional specific increment amount
132
+ """
133
+ if self.task_id is None:
134
+ return
135
+
136
+ self.current_step += 1
137
+
138
+ # Calculate target progress based on current step
139
+ target_progress = (self.current_step / self.max_steps) * self.total_items
140
+
141
+ if increment:
142
+ target_progress = min(self.total_items, increment)
143
+
144
+ # Update with smooth incremental steps
145
+ current_progress = self.progress.tasks[self.task_id].completed
146
+ steps_needed = max(1, int((target_progress - current_progress) / 5)) # Break into 5 increments
147
+ increment_size = (target_progress - current_progress) / steps_needed
148
+
149
+ for i in range(steps_needed):
150
+ new_progress = current_progress + (increment_size * (i + 1))
151
+ self.progress.update(self.task_id, completed=min(self.total_items, new_progress), description=step_name)
152
+ # Small delay for smooth visual effect
153
+ time.sleep(0.1)
154
+
155
+ def complete_operation(self, final_message: str = "Operation completed") -> None:
156
+ """Complete the operation with 100% progress."""
157
+ if self.task_id is not None:
158
+ self.progress.update(self.task_id, completed=self.total_items, description=final_message)
159
+
160
+
161
+ class MultiStageProgress:
162
+ """
163
+ Multi-stage progress manager for complex operations.
164
+
165
+ Manages multiple progress bars for operations with distinct phases,
166
+ providing clear visual feedback for each stage of processing.
167
+ """
168
+
169
+ def __init__(self, console: Console, stages: List[Dict[str, Any]]):
170
+ self.console = console
171
+ self.stages = stages
172
+ self.current_stage = 0
173
+ self.progress = None
174
+ self.active_tasks = {}
175
+
176
+ def __enter__(self) -> "MultiStageProgress":
177
+ self.progress = Progress(
178
+ TextColumn("[progress.description]{task.description}"),
179
+ BarColumn(complete_style="bright_green"),
180
+ TaskProgressColumn(),
181
+ TimeElapsedColumn(),
182
+ console=self.console,
183
+ transient=False,
184
+ )
185
+
186
+ self.progress.__enter__()
187
+
188
+ # Initialize all stage tasks
189
+ for i, stage in enumerate(self.stages):
190
+ task_id = self.progress.add_task(
191
+ stage["name"],
192
+ total=stage.get("total", 100),
193
+ visible=(i == 0), # Only show first stage initially
194
+ )
195
+ self.active_tasks[i] = task_id
196
+
197
+ return self
198
+
199
+ def __exit__(self, *args) -> None:
200
+ if self.progress:
201
+ self.progress.__exit__(*args)
202
+
203
+ def advance_stage(self, stage_index: int, progress_amount: int, description: Optional[str] = None) -> None:
204
+ """Advance progress for a specific stage."""
205
+ if stage_index in self.active_tasks and self.progress:
206
+ task_id = self.active_tasks[stage_index]
207
+
208
+ # Make current stage visible if not already
209
+ if not self.progress.tasks[task_id].visible:
210
+ self.progress.update(task_id, visible=True)
211
+
212
+ # Update progress
213
+ update_kwargs = {"advance": progress_amount}
214
+ if description:
215
+ update_kwargs["description"] = description
216
+
217
+ self.progress.update(task_id, **update_kwargs)
218
+
219
+ def complete_stage(self, stage_index: int) -> None:
220
+ """Mark a stage as completed."""
221
+ if stage_index in self.active_tasks and self.progress:
222
+ task_id = self.active_tasks[stage_index]
223
+ stage_total = self.progress.tasks[task_id].total or 100
224
+ self.progress.update(task_id, completed=stage_total)
225
+
226
+ def next_stage(self) -> bool:
227
+ """Move to the next stage and return True if successful."""
228
+ if self.current_stage < len(self.stages) - 1:
229
+ self.current_stage += 1
230
+
231
+ # Mark current stage as visible
232
+ if self.current_stage in self.active_tasks and self.progress:
233
+ task_id = self.active_tasks[self.current_stage]
234
+ self.progress.update(task_id, visible=True)
235
+
236
+ return True
237
+ return False
238
+
239
+
240
+ # Convenience functions for common progress patterns
241
+
242
+
243
+ def track_aws_cost_analysis(items: List[Any], console: Optional[Console] = None) -> Iterator[Any]:
244
+ """
245
+ Track AWS cost analysis with enhanced progress.
246
+
247
+ Args:
248
+ items: Items to process
249
+ console: Optional console instance
250
+
251
+ Yields:
252
+ Items with progress tracking
253
+ """
254
+ tracker = EnhancedProgressTracker(console)
255
+
256
+ with tracker.create_enhanced_progress("aws_cost_data", len(items)) as progress:
257
+ progress.start_operation("Analyzing AWS cost data...")
258
+
259
+ for i, item in enumerate(items):
260
+ progress.update_step(f"Processing item {i + 1}/{len(items)}", i + 1)
261
+ yield item
262
+
263
+ progress.complete_operation("Cost analysis completed")
264
+
265
+
266
+ def track_multi_account_analysis(accounts: List[str], console: Optional[Console] = None) -> Iterator[str]:
267
+ """
268
+ Track multi-account analysis with enhanced progress.
269
+
270
+ Args:
271
+ accounts: Account profiles to process
272
+ console: Optional console instance
273
+
274
+ Yields:
275
+ Account profiles with progress tracking
276
+ """
277
+ tracker = EnhancedProgressTracker(console)
278
+
279
+ with tracker.create_enhanced_progress("multi_account_analysis", len(accounts)) as progress:
280
+ progress.start_operation("Analyzing multiple accounts...")
281
+
282
+ for i, account in enumerate(accounts):
283
+ progress.update_step(f"Analyzing account: {account}", i + 1)
284
+ yield account
285
+
286
+ progress.complete_operation("Multi-account analysis completed")
287
+
288
+
289
+ @contextmanager
290
+ def enhanced_finops_progress(
291
+ operation_name: str, total_steps: int = 100, console: Optional[Console] = None
292
+ ) -> Iterator[Callable[[int, str], None]]:
293
+ """
294
+ Context manager for enhanced FinOps operations progress.
295
+
296
+ Args:
297
+ operation_name: Name of the operation
298
+ total_steps: Total number of progress steps
299
+ console: Optional console instance
300
+
301
+ Yields:
302
+ Progress update function: (step, description) -> None
303
+ """
304
+ console = console or rich_console
305
+
306
+ progress = Progress(
307
+ SpinnerColumn(),
308
+ TextColumn("[progress.description]{task.description}"),
309
+ BarColumn(complete_style="bright_green", finished_style="bright_green"),
310
+ TaskProgressColumn(),
311
+ TimeElapsedColumn(),
312
+ console=console,
313
+ transient=False,
314
+ )
315
+
316
+ with progress:
317
+ task_id = progress.add_task(operation_name, total=total_steps)
318
+
319
+ def update_progress(step: int, description: str) -> None:
320
+ progress.update(task_id, completed=step, description=description)
321
+
322
+ yield update_progress
323
+
324
+
325
+ def create_progress_tracker(console: Optional[Console] = None) -> EnhancedProgressTracker:
326
+ """Factory function to create enhanced progress tracker."""
327
+ return EnhancedProgressTracker(console=console)