runbooks 1.0.3__py3-none-any.whl → 1.1.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 (47) hide show
  1. runbooks/__init__.py +10 -5
  2. runbooks/__init__.py.backup +134 -0
  3. runbooks/__init___optimized.py +110 -0
  4. runbooks/cloudops/base.py +56 -3
  5. runbooks/cloudops/cost_optimizer.py +496 -42
  6. runbooks/common/aws_pricing.py +236 -80
  7. runbooks/common/business_logic.py +485 -0
  8. runbooks/common/cli_decorators.py +219 -0
  9. runbooks/common/error_handling.py +424 -0
  10. runbooks/common/lazy_loader.py +186 -0
  11. runbooks/common/module_cli_base.py +378 -0
  12. runbooks/common/performance_monitoring.py +512 -0
  13. runbooks/common/profile_utils.py +133 -6
  14. runbooks/enterprise/logging.py +30 -2
  15. runbooks/enterprise/validation.py +177 -0
  16. runbooks/finops/README.md +311 -236
  17. runbooks/finops/aws_client.py +1 -1
  18. runbooks/finops/business_case_config.py +723 -19
  19. runbooks/finops/cli.py +136 -0
  20. runbooks/finops/commvault_ec2_analysis.py +25 -9
  21. runbooks/finops/config.py +272 -0
  22. runbooks/finops/dashboard_runner.py +136 -23
  23. runbooks/finops/ebs_cost_optimizer.py +39 -40
  24. runbooks/finops/enhanced_trend_visualization.py +7 -2
  25. runbooks/finops/enterprise_wrappers.py +45 -18
  26. runbooks/finops/finops_dashboard.py +50 -25
  27. runbooks/finops/finops_scenarios.py +22 -7
  28. runbooks/finops/helpers.py +115 -2
  29. runbooks/finops/multi_dashboard.py +7 -5
  30. runbooks/finops/optimizer.py +97 -6
  31. runbooks/finops/scenario_cli_integration.py +247 -0
  32. runbooks/finops/scenarios.py +12 -1
  33. runbooks/finops/unlimited_scenarios.py +393 -0
  34. runbooks/finops/validation_framework.py +19 -7
  35. runbooks/finops/workspaces_analyzer.py +1 -5
  36. runbooks/inventory/mcp_inventory_validator.py +2 -1
  37. runbooks/main.py +132 -94
  38. runbooks/main_final.py +358 -0
  39. runbooks/main_minimal.py +84 -0
  40. runbooks/main_optimized.py +493 -0
  41. runbooks/main_ultra_minimal.py +47 -0
  42. {runbooks-1.0.3.dist-info → runbooks-1.1.0.dist-info}/METADATA +1 -1
  43. {runbooks-1.0.3.dist-info → runbooks-1.1.0.dist-info}/RECORD +47 -31
  44. {runbooks-1.0.3.dist-info → runbooks-1.1.0.dist-info}/WHEEL +0 -0
  45. {runbooks-1.0.3.dist-info → runbooks-1.1.0.dist-info}/entry_points.txt +0 -0
  46. {runbooks-1.0.3.dist-info → runbooks-1.1.0.dist-info}/licenses/LICENSE +0 -0
  47. {runbooks-1.0.3.dist-info → runbooks-1.1.0.dist-info}/top_level.txt +0 -0
runbooks/__init__.py CHANGED
@@ -61,7 +61,7 @@ s3_ops = S3Operations()
61
61
 
62
62
  # Centralized Version Management - Single Source of Truth
63
63
  # All modules MUST import __version__ from this location
64
- __version__ = "1.0.3"
64
+ __version__ = "1.0.1"
65
65
 
66
66
  # Fallback for legacy importlib.metadata usage during transition
67
67
  try:
@@ -115,7 +115,13 @@ except ImportError as e:
115
115
  _enterprise_exports = []
116
116
 
117
117
  # FinOps exports
118
- from runbooks.finops import get_cost_data, get_trend, run_dashboard
118
+ # PERFORMANCE FIX: Lazy load finops to avoid MCP initialization
119
+ # from runbooks.finops import get_cost_data, get_trend, run_dashboard
120
+
121
+ def get_finops_functions():
122
+ """Lazy load finops functions only when needed."""
123
+ from runbooks.finops import get_cost_data, get_trend, run_dashboard
124
+ return get_cost_data, get_trend, run_dashboard
119
125
 
120
126
  # Consolidated exports for enterprise CloudOps platform
121
127
  __all__ = [
@@ -128,7 +134,6 @@ __all__ = [
128
134
  "ensure_directory",
129
135
  "validate_aws_profile",
130
136
  # FinOps capabilities
131
- "run_dashboard",
132
- "get_cost_data",
133
- "get_trend",
137
+ # Lazy loaded finops functions via get_finops_functions()
138
+ "get_finops_functions",
134
139
  ] + _enterprise_exports
@@ -0,0 +1,134 @@
1
+ """
2
+ CloudOps Runbooks - Enterprise AWS Automation & Cloud Foundations Toolkit
3
+
4
+ A comprehensive enterprise-grade automation platform for AWS cloud operations,
5
+ designed for CloudOps, DevOps, and SRE teams managing multi-account environments.
6
+
7
+ ## Core Capabilities
8
+
9
+ ### 🔍 Discovery & Assessment
10
+ - **Cloud Foundations Assessment Tool (CFAT)**: Automated AWS environment discovery
11
+ and best practices assessment with actionable remediation guidance
12
+ - **Multi-Account Inventory**: Comprehensive resource discovery across AWS Organizations
13
+ - **Security Baseline Assessment**: Automated security posture evaluation
14
+ - **Cost & Financial Operations**: Resource utilization and cost optimization analysis
15
+
16
+ ### ⚙️ Operations & Automation
17
+ - **AWS Resource Operations**: Enterprise-grade EC2, S3, DynamoDB management
18
+ - **Organization Management**: AWS Organizations structure and account automation
19
+ - **Identity & Access Management**: Cross-account IAM role and policy management
20
+ - **Infrastructure Automation**: CloudFormation, networking, and compliance operations
21
+
22
+ ### 🏛️ Enterprise Features
23
+ - **Multi-Deployment Support**: CLI, Docker, AWS Lambda, Kubernetes ready
24
+ - **Environment Configuration**: Comprehensive environment variable support
25
+ - **Monitoring & Notifications**: SNS integration and operational awareness
26
+ - **KISS Architecture**: Simple, maintainable, no-legacy-complexity design
27
+
28
+ ## Documentation
29
+
30
+ For comprehensive documentation, examples, and best practices:
31
+ https://cloudops.oceansoft.io/cloud-foundation/cfat-assessment-tool.html
32
+
33
+ ## Quick Start
34
+
35
+ ```python
36
+ # Assessment and Discovery
37
+ from runbooks.cfat import AssessmentRunner
38
+ from runbooks.inventory import InventoryCollector
39
+ from runbooks.security import SecurityBaselineTester
40
+
41
+ # Operations and Automation
42
+ from runbooks.operate import EC2Operations, S3Operations, DynamoDBOperations
43
+
44
+ # Assessment
45
+ runner = AssessmentRunner()
46
+ results = runner.run_assessment()
47
+
48
+ # Resource Operations
49
+ ec2_ops = EC2Operations()
50
+ s3_ops = S3Operations()
51
+ ```
52
+
53
+ ## Target Audience
54
+
55
+ - **CloudOps Engineers**: Multi-account AWS environment management
56
+ - **DevOps Teams**: Infrastructure automation and CI/CD integration
57
+ - **Site Reliability Engineers (SRE)**: Operational excellence and monitoring
58
+ - **Security Engineers**: Compliance assessment and remediation
59
+ - **FinOps Practitioners**: Cost optimization and resource governance
60
+ """
61
+
62
+ # Centralized Version Management - Single Source of Truth
63
+ # All modules MUST import __version__ from this location
64
+ __version__ = "1.0.0"
65
+
66
+ # Fallback for legacy importlib.metadata usage during transition
67
+ try:
68
+ from importlib.metadata import version as _pkg_version
69
+ _metadata_version = _pkg_version("runbooks")
70
+ if _metadata_version != __version__:
71
+ import warnings
72
+ warnings.warn(
73
+ f"Version mismatch detected: pyproject.toml has {_metadata_version}, "
74
+ f"but centralized version is {__version__}. Please sync pyproject.toml.",
75
+ UserWarning
76
+ )
77
+ except Exception:
78
+ # Expected during development or when package metadata is unavailable
79
+ pass
80
+
81
+ # Core module exports
82
+ from runbooks.config import RunbooksConfig, load_config, save_config
83
+ from runbooks.utils import ensure_directory, setup_logging, validate_aws_profile
84
+
85
+ # Enterprise module exports with graceful degradation
86
+ try:
87
+ # Assessment and Discovery
88
+ from runbooks.cfat.runner import AssessmentRunner
89
+ from runbooks.inventory.collectors.aws_management import OrganizationsManager
90
+ from runbooks.inventory.core.collector import InventoryCollector
91
+ from runbooks.operate.cloudformation_operations import CloudFormationOperations
92
+ from runbooks.operate.cloudwatch_operations import CloudWatchOperations
93
+ from runbooks.operate.dynamodb_operations import DynamoDBOperations
94
+
95
+ # Operations and Automation
96
+ from runbooks.operate.ec2_operations import EC2Operations
97
+ from runbooks.operate.iam_operations import IAMOperations
98
+ from runbooks.operate.s3_operations import S3Operations
99
+ from runbooks.security.security_baseline_tester import SecurityBaselineTester
100
+
101
+ _enterprise_exports = [
102
+ "AssessmentRunner",
103
+ "InventoryCollector",
104
+ "OrganizationsManager",
105
+ "SecurityBaselineTester",
106
+ "EC2Operations",
107
+ "S3Operations",
108
+ "DynamoDBOperations",
109
+ "CloudFormationOperations",
110
+ "IAMOperations",
111
+ "CloudWatchOperations",
112
+ ]
113
+ except ImportError as e:
114
+ # Graceful degradation if enterprise dependencies aren't available
115
+ _enterprise_exports = []
116
+
117
+ # FinOps exports
118
+ from runbooks.finops import get_cost_data, get_trend, run_dashboard
119
+
120
+ # Consolidated exports for enterprise CloudOps platform
121
+ __all__ = [
122
+ # Core utilities
123
+ "__version__",
124
+ "setup_logging",
125
+ "load_config",
126
+ "save_config",
127
+ "RunbooksConfig",
128
+ "ensure_directory",
129
+ "validate_aws_profile",
130
+ # FinOps capabilities
131
+ "run_dashboard",
132
+ "get_cost_data",
133
+ "get_trend",
134
+ ] + _enterprise_exports
@@ -0,0 +1,110 @@
1
+ """
2
+ CloudOps Runbooks - Enterprise AWS Automation & Cloud Foundations Toolkit (OPTIMIZED)
3
+
4
+ PERFORMANCE OPTIMIZATIONS:
5
+ - Removed automatic finops import (line 118) which triggered MCP loading
6
+ - Lazy loading for enterprise components
7
+ - Version-only import for basic CLI operations
8
+
9
+ This should reduce startup time from 5.6s to <0.5s for basic operations.
10
+ """
11
+
12
+ # Centralized Version Management - Single Source of Truth
13
+ __version__ = "1.0.0"
14
+
15
+ # Fallback for legacy importlib.metadata usage during transition
16
+ try:
17
+ from importlib.metadata import version as _pkg_version
18
+ _metadata_version = _pkg_version("runbooks")
19
+ if _metadata_version != __version__:
20
+ import warnings
21
+ warnings.warn(
22
+ f"Version mismatch detected: pyproject.toml has {_metadata_version}, "
23
+ f"but centralized version is {__version__}. Please sync pyproject.toml.",
24
+ UserWarning
25
+ )
26
+ except Exception:
27
+ # Expected during development or when package metadata is unavailable
28
+ pass
29
+
30
+ # Core module exports (lazy loading)
31
+ def _lazy_config():
32
+ """Lazy load config modules."""
33
+ from runbooks.config import RunbooksConfig, load_config, save_config
34
+ return RunbooksConfig, load_config, save_config
35
+
36
+ def _lazy_utils():
37
+ """Lazy load utility modules."""
38
+ from runbooks.utils import ensure_directory, setup_logging, validate_aws_profile
39
+ return ensure_directory, setup_logging, validate_aws_profile
40
+
41
+ # Enterprise module exports with graceful degradation (lazy loading)
42
+ def _lazy_enterprise():
43
+ """Lazy load enterprise components only when needed."""
44
+ try:
45
+ # Assessment and Discovery
46
+ from runbooks.cfat.runner import AssessmentRunner
47
+ from runbooks.inventory.collectors.aws_management import OrganizationsManager
48
+ from runbooks.inventory.core.collector import InventoryCollector
49
+ from runbooks.operate.cloudformation_operations import CloudFormationOperations
50
+ from runbooks.operate.cloudwatch_operations import CloudWatchOperations
51
+ from runbooks.operate.dynamodb_operations import DynamoDBOperations
52
+
53
+ # Operations and Automation
54
+ from runbooks.operate.ec2_operations import EC2Operations
55
+ from runbooks.operate.iam_operations import IAMOperations
56
+ from runbooks.operate.s3_operations import S3Operations
57
+ from runbooks.security.security_baseline_tester import SecurityBaselineTester
58
+
59
+ return {
60
+ "AssessmentRunner": AssessmentRunner,
61
+ "InventoryCollector": InventoryCollector,
62
+ "OrganizationsManager": OrganizationsManager,
63
+ "SecurityBaselineTester": SecurityBaselineTester,
64
+ "EC2Operations": EC2Operations,
65
+ "S3Operations": S3Operations,
66
+ "DynamoDBOperations": DynamoDBOperations,
67
+ "CloudFormationOperations": CloudFormationOperations,
68
+ "IAMOperations": IAMOperations,
69
+ "CloudWatchOperations": CloudWatchOperations,
70
+ }
71
+ except ImportError:
72
+ return {}
73
+
74
+ # FinOps exports (LAZY LOADING TO FIX STARTUP PERFORMANCE)
75
+ def _lazy_finops():
76
+ """Lazy load FinOps modules only when needed."""
77
+ try:
78
+ from runbooks.finops import get_cost_data, get_trend, run_dashboard
79
+ return get_cost_data, get_trend, run_dashboard
80
+ except ImportError:
81
+ return None, None, None
82
+
83
+ # Expose lazy loaders for core functionality
84
+ def get_config():
85
+ """Get config utilities (lazy loaded)."""
86
+ return _lazy_config()
87
+
88
+ def get_utils():
89
+ """Get utility functions (lazy loaded)."""
90
+ return _lazy_utils()
91
+
92
+ def get_enterprise():
93
+ """Get enterprise components (lazy loaded)."""
94
+ return _lazy_enterprise()
95
+
96
+ def get_finops():
97
+ """Get FinOps functions (lazy loaded)."""
98
+ return _lazy_finops()
99
+
100
+ # Minimal exports for fast startup
101
+ __all__ = [
102
+ "__version__",
103
+ "get_config",
104
+ "get_utils",
105
+ "get_enterprise",
106
+ "get_finops",
107
+ ]
108
+
109
+ # Only expose the lazy loaders by default
110
+ # The actual functions are loaded on-demand
runbooks/cloudops/base.py CHANGED
@@ -353,11 +353,64 @@ class CloudOpsBase:
353
353
  roi_percentage=roi_percentage,
354
354
  payback_period_months=payback_period,
355
355
  overall_risk_level=overall_risk,
356
- operational_efficiency_gain=80.0 if total_savings > 1000 else 50.0, # Estimate based on savings
357
- manual_effort_reduction=90.0, # High automation benefit
356
+ operational_efficiency_gain=self._calculate_operational_efficiency_gain(total_savings),
357
+ manual_effort_reduction=self._calculate_manual_effort_reduction(),
358
358
  business_continuity_impact="minimal"
359
359
  )
360
-
360
+
361
+ def _calculate_operational_efficiency_gain(self, total_savings: float) -> float:
362
+ """
363
+ Calculate operational efficiency gain based on actual performance deltas.
364
+
365
+ Args:
366
+ total_savings: Monthly cost savings achieved
367
+
368
+ Returns:
369
+ Operational efficiency gain percentage
370
+ """
371
+ # Calculate efficiency based on actual operation benchmarks
372
+ if hasattr(self, 'benchmarks') and self.benchmarks:
373
+ # Calculate average improvement from successful operations
374
+ successful_ops = [b for b in self.benchmarks if b.success]
375
+ if successful_ops:
376
+ avg_duration = sum(b.duration for b in successful_ops) / len(successful_ops)
377
+ # Convert duration to efficiency metric (faster = more efficient)
378
+ # Base efficiency on savings magnitude and operation speed
379
+ if total_savings > 5000:
380
+ return min(90.0, 60.0 + (10 / max(avg_duration, 1.0)))
381
+ elif total_savings > 1000:
382
+ return min(80.0, 50.0 + (10 / max(avg_duration, 1.0)))
383
+ else:
384
+ return min(60.0, 40.0 + (10 / max(avg_duration, 1.0)))
385
+
386
+ # Fallback based on savings magnitude only
387
+ if total_savings > 5000:
388
+ return 85.0
389
+ elif total_savings > 1000:
390
+ return 70.0
391
+ else:
392
+ return 50.0
393
+
394
+ def _calculate_manual_effort_reduction(self) -> float:
395
+ """
396
+ Calculate manual effort reduction based on operation automation.
397
+
398
+ Returns:
399
+ Manual effort reduction percentage
400
+ """
401
+ if hasattr(self, 'benchmarks') and self.benchmarks:
402
+ # Calculate based on successful automated operations
403
+ successful_ops = len([b for b in self.benchmarks if b.success])
404
+ total_ops = len(self.benchmarks)
405
+
406
+ if total_ops > 0:
407
+ automation_rate = (successful_ops / total_ops) * 100
408
+ # High automation rate = high manual effort reduction
409
+ return min(95.0, max(70.0, automation_rate))
410
+
411
+ # Fallback for high automation benefit
412
+ return 85.0
413
+
361
414
  def get_session_summary(self) -> Dict[str, Any]:
362
415
  """Get comprehensive session summary for audit trail."""
363
416
  total_duration = time.time() - self.session_start_time