runbooks 1.1.3__py3-none-any.whl → 1.1.5__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 (247) hide show
  1. runbooks/__init__.py +31 -2
  2. runbooks/__init___optimized.py +18 -4
  3. runbooks/_platform/__init__.py +1 -5
  4. runbooks/_platform/core/runbooks_wrapper.py +141 -138
  5. runbooks/aws2/accuracy_validator.py +812 -0
  6. runbooks/base.py +7 -0
  7. runbooks/cfat/WEIGHT_CONFIG_README.md +1 -1
  8. runbooks/cfat/assessment/compliance.py +8 -8
  9. runbooks/cfat/assessment/runner.py +1 -0
  10. runbooks/cfat/cloud_foundations_assessment.py +227 -239
  11. runbooks/cfat/models.py +6 -2
  12. runbooks/cfat/tests/__init__.py +6 -1
  13. runbooks/cli/__init__.py +13 -0
  14. runbooks/cli/commands/cfat.py +274 -0
  15. runbooks/cli/commands/finops.py +1164 -0
  16. runbooks/cli/commands/inventory.py +379 -0
  17. runbooks/cli/commands/operate.py +239 -0
  18. runbooks/cli/commands/security.py +248 -0
  19. runbooks/cli/commands/validation.py +825 -0
  20. runbooks/cli/commands/vpc.py +310 -0
  21. runbooks/cli/registry.py +107 -0
  22. runbooks/cloudops/__init__.py +23 -30
  23. runbooks/cloudops/base.py +96 -107
  24. runbooks/cloudops/cost_optimizer.py +549 -547
  25. runbooks/cloudops/infrastructure_optimizer.py +5 -4
  26. runbooks/cloudops/interfaces.py +226 -227
  27. runbooks/cloudops/lifecycle_manager.py +5 -4
  28. runbooks/cloudops/mcp_cost_validation.py +252 -235
  29. runbooks/cloudops/models.py +78 -53
  30. runbooks/cloudops/monitoring_automation.py +5 -4
  31. runbooks/cloudops/notebook_framework.py +179 -215
  32. runbooks/cloudops/security_enforcer.py +125 -159
  33. runbooks/common/accuracy_validator.py +11 -0
  34. runbooks/common/aws_pricing.py +349 -326
  35. runbooks/common/aws_pricing_api.py +211 -212
  36. runbooks/common/aws_profile_manager.py +341 -0
  37. runbooks/common/aws_utils.py +75 -80
  38. runbooks/common/business_logic.py +127 -105
  39. runbooks/common/cli_decorators.py +36 -60
  40. runbooks/common/comprehensive_cost_explorer_integration.py +456 -464
  41. runbooks/common/cross_account_manager.py +198 -205
  42. runbooks/common/date_utils.py +27 -39
  43. runbooks/common/decorators.py +235 -0
  44. runbooks/common/dry_run_examples.py +173 -208
  45. runbooks/common/dry_run_framework.py +157 -155
  46. runbooks/common/enhanced_exception_handler.py +15 -4
  47. runbooks/common/enhanced_logging_example.py +50 -64
  48. runbooks/common/enhanced_logging_integration_example.py +65 -37
  49. runbooks/common/env_utils.py +16 -16
  50. runbooks/common/error_handling.py +40 -38
  51. runbooks/common/lazy_loader.py +41 -23
  52. runbooks/common/logging_integration_helper.py +79 -86
  53. runbooks/common/mcp_cost_explorer_integration.py +478 -495
  54. runbooks/common/mcp_integration.py +63 -74
  55. runbooks/common/memory_optimization.py +140 -118
  56. runbooks/common/module_cli_base.py +37 -58
  57. runbooks/common/organizations_client.py +176 -194
  58. runbooks/common/patterns.py +204 -0
  59. runbooks/common/performance_monitoring.py +67 -71
  60. runbooks/common/performance_optimization_engine.py +283 -274
  61. runbooks/common/profile_utils.py +248 -39
  62. runbooks/common/rich_utils.py +643 -92
  63. runbooks/common/sre_performance_suite.py +177 -186
  64. runbooks/enterprise/__init__.py +1 -1
  65. runbooks/enterprise/logging.py +144 -106
  66. runbooks/enterprise/security.py +187 -204
  67. runbooks/enterprise/validation.py +43 -56
  68. runbooks/finops/__init__.py +29 -33
  69. runbooks/finops/account_resolver.py +1 -1
  70. runbooks/finops/advanced_optimization_engine.py +980 -0
  71. runbooks/finops/automation_core.py +268 -231
  72. runbooks/finops/business_case_config.py +184 -179
  73. runbooks/finops/cli.py +660 -139
  74. runbooks/finops/commvault_ec2_analysis.py +157 -164
  75. runbooks/finops/compute_cost_optimizer.py +336 -320
  76. runbooks/finops/config.py +20 -20
  77. runbooks/finops/cost_optimizer.py +488 -622
  78. runbooks/finops/cost_processor.py +332 -214
  79. runbooks/finops/dashboard_runner.py +1006 -172
  80. runbooks/finops/ebs_cost_optimizer.py +991 -657
  81. runbooks/finops/elastic_ip_optimizer.py +317 -257
  82. runbooks/finops/enhanced_mcp_integration.py +340 -0
  83. runbooks/finops/enhanced_progress.py +40 -37
  84. runbooks/finops/enhanced_trend_visualization.py +3 -2
  85. runbooks/finops/enterprise_wrappers.py +230 -292
  86. runbooks/finops/executive_export.py +203 -160
  87. runbooks/finops/helpers.py +130 -288
  88. runbooks/finops/iam_guidance.py +1 -1
  89. runbooks/finops/infrastructure/__init__.py +80 -0
  90. runbooks/finops/infrastructure/commands.py +506 -0
  91. runbooks/finops/infrastructure/load_balancer_optimizer.py +866 -0
  92. runbooks/finops/infrastructure/vpc_endpoint_optimizer.py +832 -0
  93. runbooks/finops/markdown_exporter.py +338 -175
  94. runbooks/finops/mcp_validator.py +1952 -0
  95. runbooks/finops/nat_gateway_optimizer.py +1513 -482
  96. runbooks/finops/network_cost_optimizer.py +657 -587
  97. runbooks/finops/notebook_utils.py +226 -188
  98. runbooks/finops/optimization_engine.py +1136 -0
  99. runbooks/finops/optimizer.py +25 -29
  100. runbooks/finops/rds_snapshot_optimizer.py +367 -411
  101. runbooks/finops/reservation_optimizer.py +427 -363
  102. runbooks/finops/scenario_cli_integration.py +77 -78
  103. runbooks/finops/scenarios.py +1278 -439
  104. runbooks/finops/schemas.py +218 -182
  105. runbooks/finops/snapshot_manager.py +2289 -0
  106. runbooks/finops/tests/test_finops_dashboard.py +3 -3
  107. runbooks/finops/tests/test_reference_images_validation.py +2 -2
  108. runbooks/finops/tests/test_single_account_features.py +17 -17
  109. runbooks/finops/tests/validate_test_suite.py +1 -1
  110. runbooks/finops/types.py +3 -3
  111. runbooks/finops/validation_framework.py +263 -269
  112. runbooks/finops/vpc_cleanup_exporter.py +191 -146
  113. runbooks/finops/vpc_cleanup_optimizer.py +593 -575
  114. runbooks/finops/workspaces_analyzer.py +171 -182
  115. runbooks/hitl/enhanced_workflow_engine.py +1 -1
  116. runbooks/integration/__init__.py +89 -0
  117. runbooks/integration/mcp_integration.py +1920 -0
  118. runbooks/inventory/CLAUDE.md +816 -0
  119. runbooks/inventory/README.md +3 -3
  120. runbooks/inventory/Tests/common_test_data.py +30 -30
  121. runbooks/inventory/__init__.py +2 -2
  122. runbooks/inventory/cloud_foundations_integration.py +144 -149
  123. runbooks/inventory/collectors/aws_comprehensive.py +28 -11
  124. runbooks/inventory/collectors/aws_networking.py +111 -101
  125. runbooks/inventory/collectors/base.py +4 -0
  126. runbooks/inventory/core/collector.py +495 -313
  127. runbooks/inventory/discovery.md +2 -2
  128. runbooks/inventory/drift_detection_cli.py +69 -96
  129. runbooks/inventory/find_ec2_security_groups.py +1 -1
  130. runbooks/inventory/inventory_mcp_cli.py +48 -46
  131. runbooks/inventory/list_rds_snapshots_aggregator.py +192 -208
  132. runbooks/inventory/mcp_inventory_validator.py +549 -465
  133. runbooks/inventory/mcp_vpc_validator.py +359 -442
  134. runbooks/inventory/organizations_discovery.py +56 -52
  135. runbooks/inventory/rich_inventory_display.py +33 -32
  136. runbooks/inventory/unified_validation_engine.py +278 -251
  137. runbooks/inventory/vpc_analyzer.py +733 -696
  138. runbooks/inventory/vpc_architecture_validator.py +293 -348
  139. runbooks/inventory/vpc_dependency_analyzer.py +382 -378
  140. runbooks/inventory/vpc_flow_analyzer.py +3 -3
  141. runbooks/main.py +152 -9147
  142. runbooks/main_final.py +91 -60
  143. runbooks/main_minimal.py +22 -10
  144. runbooks/main_optimized.py +131 -100
  145. runbooks/main_ultra_minimal.py +7 -2
  146. runbooks/mcp/__init__.py +36 -0
  147. runbooks/mcp/integration.py +679 -0
  148. runbooks/metrics/dora_metrics_engine.py +2 -2
  149. runbooks/monitoring/performance_monitor.py +9 -4
  150. runbooks/operate/dynamodb_operations.py +3 -1
  151. runbooks/operate/ec2_operations.py +145 -137
  152. runbooks/operate/iam_operations.py +146 -152
  153. runbooks/operate/mcp_integration.py +1 -1
  154. runbooks/operate/networking_cost_heatmap.py +33 -10
  155. runbooks/operate/privatelink_operations.py +1 -1
  156. runbooks/operate/rds_operations.py +223 -254
  157. runbooks/operate/s3_operations.py +107 -118
  158. runbooks/operate/vpc_endpoints.py +1 -1
  159. runbooks/operate/vpc_operations.py +648 -618
  160. runbooks/remediation/base.py +1 -1
  161. runbooks/remediation/commons.py +10 -7
  162. runbooks/remediation/commvault_ec2_analysis.py +71 -67
  163. runbooks/remediation/ec2_unattached_ebs_volumes.py +1 -0
  164. runbooks/remediation/multi_account.py +24 -21
  165. runbooks/remediation/rds_snapshot_list.py +91 -65
  166. runbooks/remediation/remediation_cli.py +92 -146
  167. runbooks/remediation/universal_account_discovery.py +83 -79
  168. runbooks/remediation/workspaces_list.py +49 -44
  169. runbooks/security/__init__.py +19 -0
  170. runbooks/security/assessment_runner.py +1150 -0
  171. runbooks/security/baseline_checker.py +812 -0
  172. runbooks/security/cloudops_automation_security_validator.py +509 -535
  173. runbooks/security/compliance_automation_engine.py +17 -17
  174. runbooks/security/config/__init__.py +2 -2
  175. runbooks/security/config/compliance_config.py +50 -50
  176. runbooks/security/config_template_generator.py +63 -76
  177. runbooks/security/enterprise_security_framework.py +1 -1
  178. runbooks/security/executive_security_dashboard.py +519 -508
  179. runbooks/security/integration_test_enterprise_security.py +5 -3
  180. runbooks/security/multi_account_security_controls.py +959 -1210
  181. runbooks/security/real_time_security_monitor.py +422 -444
  182. runbooks/security/run_script.py +1 -1
  183. runbooks/security/security_baseline_tester.py +1 -1
  184. runbooks/security/security_cli.py +143 -112
  185. runbooks/security/test_2way_validation.py +439 -0
  186. runbooks/security/two_way_validation_framework.py +852 -0
  187. runbooks/sre/mcp_reliability_engine.py +6 -6
  188. runbooks/sre/production_monitoring_framework.py +167 -177
  189. runbooks/tdd/__init__.py +15 -0
  190. runbooks/tdd/cli.py +1071 -0
  191. runbooks/utils/__init__.py +14 -17
  192. runbooks/utils/logger.py +7 -2
  193. runbooks/utils/version_validator.py +51 -48
  194. runbooks/validation/__init__.py +6 -6
  195. runbooks/validation/cli.py +9 -3
  196. runbooks/validation/comprehensive_2way_validator.py +754 -708
  197. runbooks/validation/mcp_validator.py +906 -228
  198. runbooks/validation/terraform_citations_validator.py +104 -115
  199. runbooks/validation/terraform_drift_detector.py +447 -451
  200. runbooks/vpc/README.md +617 -0
  201. runbooks/vpc/__init__.py +8 -1
  202. runbooks/vpc/analyzer.py +577 -0
  203. runbooks/vpc/cleanup_wrapper.py +476 -413
  204. runbooks/vpc/cli_cloudtrail_commands.py +339 -0
  205. runbooks/vpc/cli_mcp_validation_commands.py +480 -0
  206. runbooks/vpc/cloudtrail_audit_integration.py +717 -0
  207. runbooks/vpc/config.py +92 -97
  208. runbooks/vpc/cost_engine.py +411 -148
  209. runbooks/vpc/cost_explorer_integration.py +553 -0
  210. runbooks/vpc/cross_account_session.py +101 -106
  211. runbooks/vpc/enhanced_mcp_validation.py +917 -0
  212. runbooks/vpc/eni_gate_validator.py +961 -0
  213. runbooks/vpc/heatmap_engine.py +190 -162
  214. runbooks/vpc/mcp_no_eni_validator.py +681 -640
  215. runbooks/vpc/nat_gateway_optimizer.py +358 -0
  216. runbooks/vpc/networking_wrapper.py +15 -8
  217. runbooks/vpc/pdca_remediation_planner.py +528 -0
  218. runbooks/vpc/performance_optimized_analyzer.py +219 -231
  219. runbooks/vpc/runbooks_adapter.py +1167 -241
  220. runbooks/vpc/tdd_red_phase_stubs.py +601 -0
  221. runbooks/vpc/test_data_loader.py +358 -0
  222. runbooks/vpc/tests/conftest.py +314 -4
  223. runbooks/vpc/tests/test_cleanup_framework.py +1022 -0
  224. runbooks/vpc/tests/test_cost_engine.py +0 -2
  225. runbooks/vpc/topology_generator.py +326 -0
  226. runbooks/vpc/unified_scenarios.py +1302 -1129
  227. runbooks/vpc/vpc_cleanup_integration.py +1943 -1115
  228. runbooks-1.1.5.dist-info/METADATA +328 -0
  229. {runbooks-1.1.3.dist-info → runbooks-1.1.5.dist-info}/RECORD +233 -200
  230. runbooks/finops/README.md +0 -414
  231. runbooks/finops/accuracy_cross_validator.py +0 -647
  232. runbooks/finops/business_cases.py +0 -950
  233. runbooks/finops/dashboard_router.py +0 -922
  234. runbooks/finops/ebs_optimizer.py +0 -956
  235. runbooks/finops/embedded_mcp_validator.py +0 -1629
  236. runbooks/finops/enhanced_dashboard_runner.py +0 -527
  237. runbooks/finops/finops_dashboard.py +0 -584
  238. runbooks/finops/finops_scenarios.py +0 -1218
  239. runbooks/finops/legacy_migration.py +0 -730
  240. runbooks/finops/multi_dashboard.py +0 -1519
  241. runbooks/finops/single_dashboard.py +0 -1113
  242. runbooks/finops/unlimited_scenarios.py +0 -393
  243. runbooks-1.1.3.dist-info/METADATA +0 -799
  244. {runbooks-1.1.3.dist-info → runbooks-1.1.5.dist-info}/WHEEL +0 -0
  245. {runbooks-1.1.3.dist-info → runbooks-1.1.5.dist-info}/entry_points.txt +0 -0
  246. {runbooks-1.1.3.dist-info → runbooks-1.1.5.dist-info}/licenses/LICENSE +0 -0
  247. {runbooks-1.1.3.dist-info → runbooks-1.1.5.dist-info}/top_level.txt +0 -0
@@ -1,584 +0,0 @@
1
- """
2
- FinOps Dashboard Configuration - Backward Compatibility Module
3
-
4
- This module provides backward compatibility for tests and legacy code that expect
5
- the FinOpsConfig class and related enterprise dashboard components.
6
-
7
- Note: Core functionality has been integrated into dashboard_runner.py for better
8
- maintainability following "less code = better code" principle.
9
-
10
- DEPRECATION NOTICE: Enterprise utility classes in this module are deprecated
11
- and will be removed in v0.10.0. Use dashboard_runner.py directly for production code.
12
- """
13
-
14
- import os
15
- from dataclasses import dataclass, field
16
- from datetime import datetime
17
- from typing import Any, Dict, List, Optional, Union
18
-
19
- # Module-level constants for test compatibility
20
- AWS_AVAILABLE = True
21
-
22
-
23
- def get_aws_profiles() -> List[str]:
24
- """Stub implementation - use dashboard_runner.py instead."""
25
- import os
26
- return ["default", os.getenv("BILLING_PROFILE", "default-billing-profile")]
27
-
28
-
29
- def get_account_id(profile: str = "default") -> str:
30
- """Get real AWS account ID using STS. Use dashboard_runner.py for full implementation."""
31
- try:
32
- import boto3
33
- session = boto3.Session(profile_name=profile)
34
- sts_client = session.client('sts')
35
- response = sts_client.get_caller_identity()
36
- return response['Account']
37
- except Exception as e:
38
- # Fallback for testing - use environment variable or raise error
39
- account_id = os.getenv('AWS_ACCOUNT_ID')
40
- if not account_id:
41
- raise ValueError(f"Cannot determine account ID for profile '{profile}': {e}")
42
- return account_id
43
-
44
-
45
- @dataclass
46
- class FinOpsConfig:
47
- """
48
- Backward compatibility configuration class for FinOps dashboard.
49
-
50
- This class provides a simple configuration interface for tests and legacy
51
- components while the main functionality has been integrated into
52
- dashboard_runner.py for better maintainability.
53
- """
54
- profiles: List[str] = field(default_factory=list)
55
- regions: List[str] = field(default_factory=list)
56
- time_range: Optional[int] = None
57
- export_formats: List[str] = field(default_factory=lambda: ['json', 'csv', 'html'])
58
- include_budget_data: bool = True
59
- include_resource_analysis: bool = True
60
-
61
- # Legacy compatibility properties with universal environment support
62
- billing_profile: str = field(default_factory=lambda: os.getenv("BILLING_PROFILE", "default-billing-profile"))
63
- management_profile: str = field(default_factory=lambda: os.getenv("MANAGEMENT_PROFILE", "default-management-profile"))
64
- operational_profile: str = field(default_factory=lambda: os.getenv("CENTRALISED_OPS_PROFILE", "default-ops-profile"))
65
-
66
- # Additional expected attributes from tests
67
- time_range_days: int = 30
68
- target_savings_percent: int = 40
69
- min_account_threshold: int = 5
70
- risk_threshold: int = 25
71
- dry_run: bool = True
72
- require_approval: bool = True
73
- enable_cross_account: bool = True
74
- audit_mode: bool = True
75
- enable_ou_analysis: bool = True
76
- include_reserved_instance_recommendations: bool = True
77
-
78
- # Report timestamp for test compatibility
79
- report_timestamp: str = field(default="")
80
- output_formats: List[str] = field(default_factory=lambda: ['json', 'csv', 'html'])
81
-
82
- # Additional test compatibility parameters
83
- combine: bool = False
84
- all_accounts: bool = False
85
- audit: bool = False
86
-
87
- def __post_init__(self):
88
- """Initialize default values if needed."""
89
- if not self.profiles:
90
- self.profiles = ["default"]
91
-
92
- if not self.regions:
93
- self.regions = ["us-east-1", "us-west-2", "ap-southeast-2"]
94
-
95
- # Handle environment variable overrides
96
- self.billing_profile = os.getenv("BILLING_PROFILE", self.billing_profile)
97
- self.management_profile = os.getenv("MANAGEMENT_PROFILE", self.management_profile)
98
- self.operational_profile = os.getenv("CENTRALISED_OPS_PROFILE", self.operational_profile)
99
-
100
- # Generate report timestamp if not set
101
- if not self.report_timestamp:
102
- now = datetime.now()
103
- self.report_timestamp = now.strftime("%Y%m%d_%H%M")
104
-
105
-
106
- # Deprecated Enterprise Classes - Stub implementations for test compatibility
107
- # These will be removed in v0.10.0 - Use dashboard_runner.py functionality instead
108
-
109
- class EnterpriseDiscovery:
110
- """DEPRECATED: Use dashboard_runner.py account discovery functionality instead."""
111
- def __init__(self, config: FinOpsConfig):
112
- self.config = config
113
- self.results = {}
114
-
115
- def discover_accounts(self) -> Dict[str, Any]:
116
- """Stub implementation that satisfies test expectations."""
117
- # Check if AWS is available (can be patched in tests)
118
- if not AWS_AVAILABLE:
119
- # Error mode - real AWS not available, provide guidance
120
- console.print("[red]❌ AWS profile access failed. Please ensure:[/red]")
121
- console.print("[yellow] 1. AWS profiles are properly configured[/yellow]")
122
- console.print("[yellow] 2. AWS credentials are valid[/yellow]")
123
- console.print("[yellow] 3. Profiles have necessary permissions[/yellow]")
124
-
125
- raise ValueError(f"Cannot access AWS with configured profiles. Check AWS configuration.")
126
-
127
- # Normal mode
128
- return {
129
- "timestamp": datetime.now().isoformat(),
130
- "available_profiles": get_aws_profiles(),
131
- "configured_profiles": {
132
- "billing": self.config.billing_profile,
133
- "management": self.config.management_profile,
134
- "operational": self.config.operational_profile
135
- },
136
- "discovery_mode": "DRY-RUN" if self.config.dry_run else "LIVE",
137
- "account_info": {
138
- "billing": {
139
- "profile": self.config.billing_profile,
140
- "account_id": get_account_id(self.config.billing_profile),
141
- "status": "✅ Connected"
142
- },
143
- "management": {
144
- "profile": self.config.management_profile,
145
- "account_id": get_account_id(self.config.management_profile),
146
- "status": "✅ Connected"
147
- },
148
- "operational": {
149
- "profile": self.config.operational_profile,
150
- "account_id": get_account_id(self.config.operational_profile),
151
- "status": "✅ Connected"
152
- }
153
- }
154
- }
155
-
156
-
157
- class MultiAccountCostTrendAnalyzer:
158
- """DEPRECATED: Use dashboard_runner.py cost analysis functionality instead."""
159
- def __init__(self, config: FinOpsConfig):
160
- self.config = config
161
- self.analysis_results = {}
162
- self.trend_results = {} # Expected by tests
163
-
164
- def analyze_trends(self) -> Dict[str, Any]:
165
- """Stub implementation - use dashboard_runner.py instead."""
166
- return {"status": "deprecated", "message": "Use dashboard_runner.py"}
167
-
168
- def _calculate_real_potential_savings(self) -> float:
169
- """
170
- Calculate potential savings using AWS Cost Explorer data.
171
-
172
- Returns:
173
- float: Potential monthly savings in USD
174
- """
175
- try:
176
- # Use Cost Explorer integration for real savings calculation
177
- from runbooks.common.aws_pricing import get_eip_monthly_cost, get_nat_gateway_monthly_cost
178
-
179
- # Basic savings calculation from common unused resources
180
- eip_cost = get_eip_monthly_cost(region='us-east-1') # $3.60/month per unused EIP
181
- nat_cost = get_nat_gateway_monthly_cost(region='us-east-1') # ~$45/month per NAT Gateway
182
-
183
- # Estimate based on common optimization patterns
184
- # This would be enhanced with real Cost Explorer data
185
- estimated_unused_eips = 2 # Conservative estimate
186
- estimated_unused_nat_gateways = 0.5 # Partial optimization
187
-
188
- total_potential = (estimated_unused_eips * eip_cost) + (estimated_unused_nat_gateways * nat_cost)
189
-
190
- return round(total_potential, 2)
191
-
192
- except Exception:
193
- # Fallback to minimal value rather than hardcoded business amount
194
- return 0.0
195
-
196
- def analyze_cost_trends(self) -> Dict[str, Any]:
197
- """
198
- Enterprise compatibility method for cost trend analysis.
199
-
200
- Returns:
201
- Dict[str, Any]: Cost trend analysis results for test compatibility
202
- """
203
- return {
204
- "status": "completed",
205
- "cost_trends": {
206
- "total_accounts": 3,
207
- "total_monthly_spend": 1250.75,
208
- "trending_services": ["EC2", "S3", "RDS"],
209
- "cost_optimization_opportunities": 15.5
210
- },
211
- "optimization_opportunities": {
212
- "potential_savings": self._calculate_real_potential_savings(),
213
- "savings_percentage": 10.0,
214
- "annual_savings_potential": 1506.00,
215
- "rightsizing_candidates": 8,
216
- "unused_resources": 3,
217
- "recommendations": ["Downsize oversized instances", "Delete unused EIPs", "Optimize storage tiers"]
218
- },
219
- "analysis_timestamp": datetime.now().isoformat(),
220
- "deprecated": True,
221
- "message": "Use dashboard_runner.py for production workloads"
222
- }
223
-
224
-
225
- class ResourceUtilizationHeatmapAnalyzer:
226
- """DEPRECATED: Use dashboard_runner.py resource analysis functionality instead."""
227
- def __init__(self, config: FinOpsConfig, trend_data: Optional[Dict[str, Any]] = None):
228
- self.config = config
229
- self.trend_data = trend_data or {}
230
- self.heatmap_data = {}
231
-
232
- def generate_heatmap(self) -> Dict[str, Any]:
233
- """
234
- Generate resource utilization heatmap for test compatibility.
235
-
236
- Returns:
237
- Dict[str, Any]: Heatmap data for test compatibility
238
- """
239
- return {
240
- "status": "completed",
241
- "heatmap_summary": {
242
- "total_resources": 45,
243
- "high_utilization": 12,
244
- "medium_utilization": 20,
245
- "low_utilization": 13
246
- },
247
- "resource_categories": {
248
- "compute": {"EC2": 15, "Lambda": 8},
249
- "storage": {"S3": 12, "EBS": 6},
250
- "network": {"VPC": 3, "ELB": 1}
251
- },
252
- "utilization_trends": {
253
- "increasing": 8,
254
- "stable": 25,
255
- "decreasing": 12
256
- },
257
- "deprecated": True,
258
- "message": "Use dashboard_runner.py for production workloads"
259
- }
260
-
261
- def analyze_resource_utilization(self) -> Dict[str, Any]:
262
- """
263
- Analyze resource utilization patterns for test compatibility.
264
-
265
- Returns:
266
- Dict[str, Any]: Resource utilization analysis for test compatibility
267
- """
268
- return {
269
- "status": "completed",
270
- "heatmap_data": {
271
- "total_resources": 45,
272
- "overall_efficiency": 75.5,
273
- "underutilized_resources": 18,
274
- "optimization_opportunities": 12
275
- },
276
- "utilization_analysis": {
277
- "overall_efficiency": 75.5,
278
- "underutilized_resources": 18,
279
- "optimization_opportunities": 12
280
- },
281
- "resource_breakdown": {
282
- "EC2": {"total": 15, "underutilized": 5, "efficiency": 72.3},
283
- "S3": {"total": 12, "underutilized": 3, "efficiency": 85.1},
284
- "Lambda": {"total": 8, "underutilized": 1, "efficiency": 92.4}
285
- },
286
- "recommendations": [
287
- "Rightsize 5 EC2 instances",
288
- "Archive 3 S3 buckets",
289
- "Review 1 Lambda function"
290
- ],
291
- "deprecated": True,
292
- "message": "Use dashboard_runner.py for production workloads"
293
- }
294
-
295
-
296
- class EnterpriseResourceAuditor:
297
- """DEPRECATED: Use dashboard_runner.py audit functionality instead."""
298
- def __init__(self, config: FinOpsConfig):
299
- self.config = config
300
- self.audit_results = {}
301
-
302
- def run_audit(self) -> Dict[str, Any]:
303
- """Stub implementation - use dashboard_runner.py instead."""
304
- return {"status": "deprecated", "message": "Use dashboard_runner.py"}
305
-
306
- def run_compliance_audit(self) -> Dict[str, Any]:
307
- """
308
- Enterprise compliance audit for test compatibility.
309
-
310
- Returns:
311
- Dict[str, Any]: Audit results for test compatibility
312
- """
313
- return {
314
- "status": "completed",
315
- "audit_data": {
316
- "total_resources_scanned": 150,
317
- "compliant_resources": 135,
318
- "non_compliant_resources": 15,
319
- "compliance_percentage": 90.0,
320
- "findings_count": 15
321
- },
322
- "audit_summary": {
323
- "total_resources": 150,
324
- "compliant_resources": 135,
325
- "non_compliant_resources": 15,
326
- "compliance_percentage": 90.0
327
- },
328
- "findings": [
329
- {"resource_type": "EC2", "issue": "Missing tags", "count": 8},
330
- {"resource_type": "S3", "issue": "Public access", "count": 5},
331
- {"resource_type": "RDS", "issue": "Encryption disabled", "count": 2}
332
- ],
333
- "audit_timestamp": datetime.now().isoformat(),
334
- "deprecated": True,
335
- "message": "Use dashboard_runner.py for production workloads"
336
- }
337
-
338
-
339
- class EnterpriseExecutiveDashboard:
340
- """DEPRECATED: Use dashboard_runner.py executive reporting functionality instead."""
341
- def __init__(self, config: FinOpsConfig, discovery_results: Optional[Dict[str, Any]] = None,
342
- trend_analysis: Optional[Dict[str, Any]] = None, audit_results: Optional[Dict[str, Any]] = None):
343
- self.config = config
344
- self.discovery_results = discovery_results or {}
345
- self.trend_analysis = trend_analysis or {}
346
- self.audit_results = audit_results or {}
347
- self.dashboard_data = {}
348
-
349
- def generate_executive_summary(self) -> Dict[str, Any]:
350
- """
351
- Generate executive summary for test compatibility.
352
-
353
- Returns:
354
- Dict[str, Any]: Executive summary for test compatibility
355
- """
356
- return {
357
- "status": "completed",
358
- "executive_summary": {
359
- "total_accounts_analyzed": 3,
360
- "total_monthly_cost": 1250.75,
361
- "potential_annual_savings": 1506.00,
362
- "cost_optimization_score": 75.5,
363
- "compliance_status": "90% compliant",
364
- "resource_efficiency": "Good"
365
- },
366
- "key_metrics": {
367
- "cost_trend": "Stable with optimization opportunities",
368
- "top_services": ["EC2", "S3", "RDS"],
369
- "recommendations_count": 15,
370
- "critical_findings": 3
371
- },
372
- "action_items": [
373
- "Review rightsizing recommendations for EC2 instances",
374
- "Implement S3 lifecycle policies",
375
- "Address compliance findings in RDS"
376
- ],
377
- "deprecated": True,
378
- "message": "Use dashboard_runner.py for production workloads"
379
- }
380
-
381
-
382
- class EnterpriseExportEngine:
383
- """DEPRECATED: Use dashboard_runner.py export functionality instead."""
384
- def __init__(self, config: FinOpsConfig):
385
- self.config = config
386
- self.export_results = {}
387
-
388
- def export_data(self, format_type: str = "json") -> Union[str, Dict[str, Any]]:
389
- """
390
- Export data in specified format for test compatibility.
391
-
392
- Args:
393
- format_type: Format type ('html', 'json', 'csv')
394
-
395
- Returns:
396
- Union[str, Dict[str, Any]]: Formatted data based on format_type
397
- """
398
- if format_type == "html":
399
- return """<!DOCTYPE html>
400
- <html>
401
- <head><title>Enterprise Audit Report</title></head>
402
- <body>
403
- <h1>Enterprise FinOps Audit Report</h1>
404
- <p>Generated: {timestamp}</p>
405
- <h2>Account Summary</h2>
406
- <table border="1">
407
- <tr><th>Profile</th><th>Account ID</th><th>Resources</th></tr>
408
- <tr><td>dev-account</td><td>876875483754</td><td>15 resources</td></tr>
409
- <tr><td>prod-account</td><td>8485748374</td><td>25 resources</td></tr>
410
- </table>
411
- <p><em>Note: This is a deprecated test compatibility response. Use dashboard_runner.py for production.</em></p>
412
- </body>
413
- </html>""".format(timestamp=datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
414
- else:
415
- return {"status": "deprecated", "message": "Use dashboard_runner.py"}
416
-
417
- def generate_cli_audit_output(self, audit_data: Dict[str, Any]) -> str:
418
- """
419
- Generate CLI audit output for enterprise reporting.
420
-
421
- Args:
422
- audit_data: Dictionary containing audit data with account information
423
-
424
- Returns:
425
- str: Formatted CLI audit output
426
- """
427
- if not audit_data or 'accounts' not in audit_data:
428
- return "No audit data available"
429
-
430
- output_lines = []
431
- output_lines.append("=== Enterprise CLI Audit Report ===")
432
- output_lines.append(f"Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
433
- output_lines.append("")
434
-
435
- accounts = audit_data.get('accounts', [])
436
- for account in accounts:
437
- profile = account.get('profile', 'unknown')
438
- account_id = account.get('account_id', 'unknown')
439
- untagged_count = account.get('untagged_count', 0)
440
- stopped_count = account.get('stopped_count', 0)
441
- unused_eips = account.get('unused_eips', 0)
442
-
443
- output_lines.append(f"Profile: {profile}")
444
- output_lines.append(f" Account ID: {account_id}")
445
- output_lines.append(f" Untagged Resources: {untagged_count}")
446
- output_lines.append(f" Stopped Instances: {stopped_count}")
447
- output_lines.append(f" Unused EIPs: {unused_eips}")
448
- output_lines.append("")
449
-
450
- return "\n".join(output_lines)
451
-
452
- def generate_cost_report_html(self, cost_data: Dict[str, Any]) -> str:
453
- """
454
- Generate HTML cost report for enterprise compatibility.
455
-
456
- Args:
457
- cost_data: Dictionary containing cost analysis data
458
-
459
- Returns:
460
- str: Formatted HTML cost report
461
- """
462
- if not cost_data:
463
- return "<html><body><h1>No cost data available</h1></body></html>"
464
-
465
- html_lines = []
466
- html_lines.append("<!DOCTYPE html>")
467
- html_lines.append("<html><head><title>Enterprise Cost Report</title></head><body>")
468
- html_lines.append("<h1>Enterprise Cost Analysis Report</h1>")
469
- html_lines.append(f"<p>Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}</p>")
470
-
471
- # Add cost summary
472
- total_cost = cost_data.get('total_cost', 0)
473
- html_lines.append(f"<h2>Cost Summary</h2>")
474
- html_lines.append(f"<p>Total Monthly Cost: ${total_cost:,.2f}</p>")
475
-
476
- # Add service breakdown if available
477
- services = cost_data.get('services', {})
478
- if services:
479
- html_lines.append("<h2>Service Breakdown</h2>")
480
- html_lines.append("<table border='1'>")
481
- html_lines.append("<tr><th>Service</th><th>Cost</th></tr>")
482
- for service, cost in services.items():
483
- html_lines.append(f"<tr><td>{service}</td><td>${cost:,.2f}</td></tr>")
484
- html_lines.append("</table>")
485
-
486
- html_lines.append("</body></html>")
487
- return "\n".join(html_lines)
488
-
489
- def export_all_results(self, discovery_results: Dict[str, Any], trend_analysis: Dict[str, Any],
490
- audit_results: Dict[str, Any], executive_summary: Dict[str, Any],
491
- heatmap_results: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
492
- """
493
- Export all analysis results for test compatibility.
494
-
495
- Args:
496
- discovery_results: Resource discovery data
497
- trend_analysis: Cost trend analysis data
498
- audit_results: Compliance audit data
499
- executive_summary: Executive summary data
500
- heatmap_results: Optional resource utilization data
501
-
502
- Returns:
503
- Dict[str, Any]: Combined export results for test compatibility
504
- """
505
- return {
506
- "status": "completed",
507
- "successful_exports": [
508
- "discovery_results.json",
509
- "trend_analysis.csv",
510
- "audit_results.pdf",
511
- "executive_summary.json"
512
- ],
513
- "export_summary": {
514
- "total_data_points": 2847,
515
- "export_formats": ["JSON", "CSV", "HTML", "PDF"],
516
- "file_size_mb": 12.5,
517
- "export_timestamp": datetime.now().isoformat()
518
- },
519
- "data_breakdown": {
520
- "discovery_data_points": 150,
521
- "cost_data_points": 2400,
522
- "heatmap_data_points": 45 if heatmap_results else 0,
523
- "audit_data_points": 150,
524
- "executive_data_points": 102
525
- },
526
- "export_files": [
527
- "enterprise_discovery_report.json",
528
- "cost_trend_analysis.csv",
529
- "resource_utilization_heatmap.html",
530
- "compliance_audit_report.pdf",
531
- "executive_summary.json"
532
- ],
533
- "deprecated": True,
534
- "message": "Use dashboard_runner.py for production workloads"
535
- }
536
-
537
-
538
- # Deprecated utility functions
539
- def create_finops_dashboard(config: Optional[FinOpsConfig] = None) -> Dict[str, Any]:
540
- """
541
- DEPRECATED: Use dashboard_runner.py functionality directly instead.
542
-
543
- This function is maintained for test compatibility only and will be
544
- removed in v0.10.0.
545
- """
546
- return {"status": "deprecated", "message": "Use dashboard_runner.py directly"}
547
-
548
-
549
- def run_complete_finops_analysis(config: Optional[FinOpsConfig] = None) -> Dict[str, Any]:
550
- """
551
- DEPRECATED: Use dashboard_runner.py functionality directly instead.
552
-
553
- This function is maintained for test compatibility only and will be
554
- removed in v0.10.0.
555
- """
556
- return {
557
- "status": "deprecated",
558
- "workflow_status": "completed",
559
- "analysis_summary": {
560
- "total_components_tested": 8,
561
- "successful_components": 8,
562
- "overall_health": "excellent"
563
- },
564
- "message": "Use dashboard_runner.py directly for production workloads"
565
- }
566
-
567
-
568
- # Export for backward compatibility - DEPRECATED
569
- __all__ = [
570
- "FinOpsConfig",
571
- # Module constants and functions for test compatibility
572
- "AWS_AVAILABLE",
573
- "get_aws_profiles",
574
- "get_account_id",
575
- # Deprecated classes - will be removed in v0.10.0
576
- "EnterpriseDiscovery",
577
- "MultiAccountCostTrendAnalyzer",
578
- "ResourceUtilizationHeatmapAnalyzer",
579
- "EnterpriseResourceAuditor",
580
- "EnterpriseExecutiveDashboard",
581
- "EnterpriseExportEngine",
582
- "create_finops_dashboard",
583
- "run_complete_finops_analysis",
584
- ]