maproom 0.2.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.
- maproom/__init__.py +14 -0
- maproom/__main__.py +10 -0
- maproom/analyze/__init__.py +1 -0
- maproom/analyze/accel_families.py +45 -0
- maproom/analyze/account_azure_activity.py +260 -0
- maproom/analyze/account_azure_quota_requests.py +177 -0
- maproom/analyze/account_cloudtrail.py +316 -0
- maproom/analyze/account_quota_requests.py +180 -0
- maproom/analyze/analyze_v1_orchestration.py +1194 -0
- maproom/analyze/catalog.py +353 -0
- maproom/analyze/change_detection.py +652 -0
- maproom/analyze/context_client.py +99 -0
- maproom/analyze/context_lookup.py +142 -0
- maproom/analyze/cover_analyze.py +344 -0
- maproom/analyze/cover_client.py +65 -0
- maproom/analyze/cover_lookup.py +242 -0
- maproom/analyze/engine.py +644 -0
- maproom/analyze/fleetfit_endpoints.py +217 -0
- maproom/analyze/fleetfit_policy.py +66 -0
- maproom/analyze/instance_price_analyze.py +221 -0
- maproom/analyze/instance_price_client.py +108 -0
- maproom/analyze/instance_price_lookup.py +60 -0
- maproom/analyze/local_reads.py +484 -0
- maproom/analyze/lookup_http.py +280 -0
- maproom/analyze/metric_format.py +20 -0
- maproom/analyze/migration_method.py +130 -0
- maproom/analyze/move_list.py +93 -0
- maproom/analyze/operator_context.py +156 -0
- maproom/analyze/performance_rank.py +97 -0
- maproom/analyze/primary_recommendation.py +422 -0
- maproom/analyze/provider_comparison.py +401 -0
- maproom/analyze/quota_analyze.py +481 -0
- maproom/analyze/quota_client.py +75 -0
- maproom/analyze/quota_lookup.py +110 -0
- maproom/analyze/quota_outcome_steer.py +105 -0
- maproom/analyze/recommend_batch.py +199 -0
- maproom/analyze/recommend_client.py +362 -0
- maproom/analyze/recommend_share.py +118 -0
- maproom/analyze/recommendation.py +591 -0
- maproom/analyze/reservation_pack.py +883 -0
- maproom/analyze/reservation_read.py +461 -0
- maproom/analyze/safe_analyze.py +1134 -0
- maproom/analyze/safe_move.py +195 -0
- maproom/analyze/safe_moves.py +571 -0
- maproom/analyze/safe_moves_catalog.py +127 -0
- maproom/analyze/safe_moves_client.py +70 -0
- maproom/analyze/series_analyze.py +491 -0
- maproom/analyze/series_client.py +106 -0
- maproom/analyze/series_lookup.py +663 -0
- maproom/analyze/shape.py +254 -0
- maproom/analyze/size_analyze.py +883 -0
- maproom/analyze/size_client.py +81 -0
- maproom/analyze/size_keep.py +409 -0
- maproom/analyze/size_lookup.py +368 -0
- maproom/analyze/specs.py +325 -0
- maproom/analyze/spot_analyze.py +392 -0
- maproom/analyze/spot_client.py +74 -0
- maproom/analyze/spot_lookup.py +213 -0
- maproom/analyze/token_client.py +97 -0
- maproom/analyze/utilization.py +190 -0
- maproom/analyze/workload.py +104 -0
- maproom/analyze/workset.py +762 -0
- maproom/aws_region.py +78 -0
- maproom/cache/__init__.py +1 -0
- maproom/cache/catalog.py +372 -0
- maproom/cache/commands.py +215 -0
- maproom/cache/instances.py +460 -0
- maproom/cli.py +2084 -0
- maproom/cli_argv.py +329 -0
- maproom/cli_floors.py +89 -0
- maproom/cliio/__init__.py +1 -0
- maproom/cliio/registry.py +377 -0
- maproom/cliio/runner.py +489 -0
- maproom/consent/__init__.py +33 -0
- maproom/consent/gate.py +238 -0
- maproom/consent/policy.py +20 -0
- maproom/consent/prompt.py +61 -0
- maproom/consent/service_upload_gate.py +318 -0
- maproom/consent/service_upload_prompt.py +62 -0
- maproom/consent/stdin.py +45 -0
- maproom/consent/storage.py +24 -0
- maproom/consent/write_token.py +29 -0
- maproom/contracts/__init__.py +6 -0
- maproom/contracts/schema_diff.py +119 -0
- maproom/contracts/validate.py +113 -0
- maproom/data/__init__.py +1 -0
- maproom/data/clear.py +76 -0
- maproom/data/commands.py +14 -0
- maproom/doctor/__init__.py +1 -0
- maproom/doctor/aws_session.py +226 -0
- maproom/doctor/checks.py +701 -0
- maproom/doctor/context.py +32 -0
- maproom/doctor/display.py +96 -0
- maproom/doctor/inventory_display.py +377 -0
- maproom/doctor/runner.py +1467 -0
- maproom/errors.py +43 -0
- maproom/exitcodes.py +70 -0
- maproom/inventory/__init__.py +1 -0
- maproom/inventory/account_identity.py +79 -0
- maproom/inventory/accounts.py +155 -0
- maproom/inventory/command.py +961 -0
- maproom/inventory/messages.py +264 -0
- maproom/inventory/reservations_refresh.py +37 -0
- maproom/mock_environment/__init__.py +28 -0
- maproom/mock_environment/load.py +241 -0
- maproom/mock_environment/runner.py +387 -0
- maproom/output/__init__.py +1 -0
- maproom/output/json_envelope.py +241 -0
- maproom/output/redact.py +11 -0
- maproom/output/terminal.py +129 -0
- maproom/parsers.py +284 -0
- maproom/paths.py +105 -0
- maproom/plan/__init__.py +1 -0
- maproom/plan/accept.py +59 -0
- maproom/plan/analysis_context.py +78 -0
- maproom/plan/analyze_selection.py +279 -0
- maproom/plan/commands.py +586 -0
- maproom/plan/current.py +59 -0
- maproom/plan/errors.py +10 -0
- maproom/plan/export.py +36 -0
- maproom/plan/formatting.py +91 -0
- maproom/plan/ids.py +13 -0
- maproom/plan/migration_options.py +75 -0
- maproom/plan/model.py +265 -0
- maproom/plan/names.py +24 -0
- maproom/plan/store.py +193 -0
- maproom/plan/tty.py +34 -0
- maproom/pricing/__init__.py +5 -0
- maproom/pricing/prices.py +119 -0
- maproom/privacy/__init__.py +6 -0
- maproom/privacy/commands.py +159 -0
- maproom/privacy/delete_uploads.py +204 -0
- maproom/privacy/fleetfit_policy.py +125 -0
- maproom/privacy/fleetfit_statement.py +104 -0
- maproom/privacy/format.py +76 -0
- maproom/privacy/manifests.py +342 -0
- maproom/privacy/statement.py +58 -0
- maproom/quotas/__init__.py +21 -0
- maproom/quotas/aws.py +204 -0
- maproom/quotas/azure.py +75 -0
- maproom/quotas/commands.py +240 -0
- maproom/quotas/family_coverage.py +122 -0
- maproom/quotas/fetch.py +124 -0
- maproom/quotas/load.py +41 -0
- maproom/quotas/model.py +178 -0
- maproom/quotas/outcome_ledger.py +245 -0
- maproom/quotas/quota_request_sync.py +221 -0
- maproom/quotas/show.py +73 -0
- maproom/quotas/status.py +206 -0
- maproom/quotas/store.py +161 -0
- maproom/redaction.py +157 -0
- maproom/reference_data/__init__.py +1 -0
- maproom/reference_data/aws/aws_prices.csv +25562 -0
- maproom/reference_data/aws/capabilities.csv +1346 -0
- maproom/reference_data/aws/instance_types.csv +1346 -0
- maproom/reference_data/azure/azure_prices.csv +1 -0
- maproom/reference_data/azure/vm_types.csv +1 -0
- maproom/reference_data/benchmarks/cpu-lscpu-v2-instances.json +27 -0
- maproom/reference_data/benchmarks/safe-moves-v1.json +328 -0
- maproom/reference_data/manifest.json +174 -0
- maproom/reference_data/manifest.py +69 -0
- maproom/reservations/__init__.py +17 -0
- maproom/reservations/aws.py +76 -0
- maproom/reservations/azure.py +36 -0
- maproom/reservations/commands.py +149 -0
- maproom/reservations/load.py +41 -0
- maproom/reservations/model.py +316 -0
- maproom/reservations/show.py +64 -0
- maproom/reservations/status.py +181 -0
- maproom/reservations/store.py +391 -0
- maproom/resources.py +54 -0
- maproom/root_help.py +251 -0
- maproom/saving_plans/__init__.py +15 -0
- maproom/saving_plans/aws.py +73 -0
- maproom/saving_plans/commands.py +122 -0
- maproom/saving_plans/load.py +41 -0
- maproom/saving_plans/model.py +101 -0
- maproom/saving_plans/show.py +64 -0
- maproom/saving_plans/status.py +118 -0
- maproom/saving_plans/store.py +173 -0
- maproom/secret_egress_gate.py +108 -0
- maproom/service/install_id.py +60 -0
- maproom/settings/__init__.py +1 -0
- maproom/settings/defaults.py +73 -0
- maproom/settings/init.py +143 -0
- maproom/settings/model.py +105 -0
- maproom/settings/product_version_change.py +343 -0
- maproom/settings/product_versions.py +68 -0
- maproom/settings/set.py +347 -0
- maproom/settings/show.py +227 -0
- maproom/settings/write.py +273 -0
- maproom/snapshot_time.py +27 -0
- maproom-0.2.0.dist-info/METADATA +263 -0
- maproom-0.2.0.dist-info/RECORD +199 -0
- maproom-0.2.0.dist-info/WHEEL +5 -0
- maproom-0.2.0.dist-info/entry_points.txt +2 -0
- maproom-0.2.0.dist-info/licenses/LICENSE +201 -0
- maproom-0.2.0.dist-info/licenses/NOTICE +72 -0
- maproom-0.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"""Completely-safe type search. One named target, or none."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from decimal import Decimal
|
|
7
|
+
|
|
8
|
+
from maproom.analyze.catalog import SpecRow, published_network_rank
|
|
9
|
+
|
|
10
|
+
_DISK_RANK = {"none": 0, "hdd": 1, "ssd": 2, "nvme": 3}
|
|
11
|
+
|
|
12
|
+
UNCHECKED_COVERAGE = "Reservation coverage was not checked."
|
|
13
|
+
UNCHECKED_AZ = "AZ capacity was not checked."
|
|
14
|
+
UNCHECKED_QUOTA = "vCPU quota was not checked."
|
|
15
|
+
SIZE_UNCHECKED_LINES = (
|
|
16
|
+
UNCHECKED_COVERAGE,
|
|
17
|
+
UNCHECKED_AZ,
|
|
18
|
+
UNCHECKED_QUOTA,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def size_move_unchecked_footer(*, extra: tuple[str, ...] = ()) -> str:
|
|
23
|
+
lines = [*SIZE_UNCHECKED_LINES, *extra]
|
|
24
|
+
return "\n".join(lines)
|
|
25
|
+
PRICE_ASSUMPTION = (
|
|
26
|
+
"The shipped Linux price file can be out of date and wrong for Windows; "
|
|
27
|
+
"a fleetfit price call uses the latest prices."
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass(frozen=True)
|
|
32
|
+
class BootFacts:
|
|
33
|
+
"""Boot facts for the running instance. An unread fact fails closed."""
|
|
34
|
+
|
|
35
|
+
virtualization_type: str
|
|
36
|
+
ena_enabled: bool | None
|
|
37
|
+
ena_read_failed: bool = False
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def choose_target(
|
|
41
|
+
current: SpecRow,
|
|
42
|
+
candidates: list[SpecRow],
|
|
43
|
+
prices: dict[str, Decimal],
|
|
44
|
+
offered: set[str],
|
|
45
|
+
safe_move_types: set[str],
|
|
46
|
+
boot: BootFacts,
|
|
47
|
+
*,
|
|
48
|
+
same_family: bool = True,
|
|
49
|
+
require_safe_move: bool = True,
|
|
50
|
+
) -> SpecRow | None:
|
|
51
|
+
"""Return the cheapest passing row, or none.
|
|
52
|
+
|
|
53
|
+
The current type must already be on the safe-move type list unless
|
|
54
|
+
``require_safe_move`` is false. An empty list names nothing. The target
|
|
55
|
+
stays in the same family and processor vendor unless ``same_family`` is
|
|
56
|
+
false. vCPU, memory, GB per vCPU, CPU rank, and ephemeral disk must be at least
|
|
57
|
+
as strong. The shipped hourly price must be lower, or the same price when
|
|
58
|
+
the generation is newer. Network performance is not compared. The
|
|
59
|
+
target type is HVM, the instance is HVM, ENA is on when the target
|
|
60
|
+
requires it, and NVMe boot is already true on the current type when the
|
|
61
|
+
target uses NVMe. Quota family is not compared.
|
|
62
|
+
"""
|
|
63
|
+
if require_safe_move and current.instance_type not in safe_move_types:
|
|
64
|
+
return None
|
|
65
|
+
if current.cpu_performance_rank is None:
|
|
66
|
+
return None
|
|
67
|
+
if current.gb_per_vcpu is None:
|
|
68
|
+
return None
|
|
69
|
+
|
|
70
|
+
passing: list[SpecRow] = []
|
|
71
|
+
current_price = prices.get(current.instance_type)
|
|
72
|
+
for candidate in candidates:
|
|
73
|
+
if candidate.instance_type == current.instance_type:
|
|
74
|
+
continue
|
|
75
|
+
if candidate.cloud != current.cloud:
|
|
76
|
+
continue
|
|
77
|
+
if not _passes(
|
|
78
|
+
current,
|
|
79
|
+
candidate,
|
|
80
|
+
prices,
|
|
81
|
+
offered,
|
|
82
|
+
current_price,
|
|
83
|
+
boot,
|
|
84
|
+
same_family=same_family,
|
|
85
|
+
):
|
|
86
|
+
continue
|
|
87
|
+
passing.append(candidate)
|
|
88
|
+
if not passing:
|
|
89
|
+
return None
|
|
90
|
+
passing.sort(key=lambda row: _sort_key(row, prices))
|
|
91
|
+
return passing[0]
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _passes(
|
|
95
|
+
current: SpecRow,
|
|
96
|
+
candidate: SpecRow,
|
|
97
|
+
prices: dict[str, Decimal],
|
|
98
|
+
offered: set[str],
|
|
99
|
+
current_price: Decimal | None,
|
|
100
|
+
boot: BootFacts,
|
|
101
|
+
*,
|
|
102
|
+
same_family: bool = True,
|
|
103
|
+
) -> bool:
|
|
104
|
+
if candidate.instance_type not in offered:
|
|
105
|
+
return False
|
|
106
|
+
if same_family and not _same_line(current, candidate):
|
|
107
|
+
return False
|
|
108
|
+
if candidate.vcpu < current.vcpu:
|
|
109
|
+
return False
|
|
110
|
+
if candidate.memory_gib < current.memory_gib:
|
|
111
|
+
return False
|
|
112
|
+
if not _ratio_ok(current, candidate):
|
|
113
|
+
return False
|
|
114
|
+
if candidate.cpu_performance_rank is None or current.cpu_performance_rank is None:
|
|
115
|
+
return False
|
|
116
|
+
if candidate.cpu_performance_rank < current.cpu_performance_rank:
|
|
117
|
+
return False
|
|
118
|
+
if not _disks_ok(current, candidate):
|
|
119
|
+
return False
|
|
120
|
+
if not _boot_ok(current, candidate, boot):
|
|
121
|
+
return False
|
|
122
|
+
candidate_price = prices.get(candidate.instance_type)
|
|
123
|
+
if current_price is None or candidate_price is None:
|
|
124
|
+
return False
|
|
125
|
+
return passes_price_bar(current, candidate, current_price, candidate_price)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def passes_price_bar(
|
|
129
|
+
current: SpecRow,
|
|
130
|
+
candidate: SpecRow,
|
|
131
|
+
current_price: Decimal,
|
|
132
|
+
candidate_price: Decimal,
|
|
133
|
+
) -> bool:
|
|
134
|
+
if candidate_price < current_price:
|
|
135
|
+
return True
|
|
136
|
+
if candidate_price > current_price:
|
|
137
|
+
return False
|
|
138
|
+
current_gen = current.generation or 0
|
|
139
|
+
candidate_gen = candidate.generation or 0
|
|
140
|
+
return candidate_gen > current_gen
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _same_line(current: SpecRow, candidate: SpecRow) -> bool:
|
|
144
|
+
family = current.family.strip().lower()
|
|
145
|
+
vendor = current.processor_vendor.strip().lower()
|
|
146
|
+
if not family or not vendor:
|
|
147
|
+
return False
|
|
148
|
+
return (
|
|
149
|
+
candidate.family.strip().lower() == family
|
|
150
|
+
and candidate.processor_vendor.strip().lower() == vendor
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def _ratio_ok(current: SpecRow, candidate: SpecRow) -> bool:
|
|
155
|
+
if current.gb_per_vcpu is None or candidate.gb_per_vcpu is None:
|
|
156
|
+
return False
|
|
157
|
+
return candidate.gb_per_vcpu >= current.gb_per_vcpu
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def _network_ok(current: SpecRow, candidate: SpecRow) -> bool:
|
|
161
|
+
current_network = published_network_rank(current.network_performance)
|
|
162
|
+
candidate_network = published_network_rank(candidate.network_performance)
|
|
163
|
+
if current_network is None or candidate_network is None:
|
|
164
|
+
return False
|
|
165
|
+
return candidate_network >= current_network
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def _boot_ok(current: SpecRow, candidate: SpecRow, boot: BootFacts) -> bool:
|
|
169
|
+
if (candidate.virtualization or "").strip().lower() != "hvm":
|
|
170
|
+
return False
|
|
171
|
+
if (boot.virtualization_type or "").strip().lower() != "hvm":
|
|
172
|
+
return False
|
|
173
|
+
if candidate.ena_required and (boot.ena_read_failed or boot.ena_enabled is not True):
|
|
174
|
+
return False
|
|
175
|
+
if candidate.nvme_boot and not current.nvme_boot:
|
|
176
|
+
return False
|
|
177
|
+
return True
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def _disks_ok(current: SpecRow, candidate: SpecRow) -> bool:
|
|
181
|
+
current_disk = current.ephemeral_disk_type or "none"
|
|
182
|
+
if current_disk == "none":
|
|
183
|
+
return True
|
|
184
|
+
candidate_disk = candidate.ephemeral_disk_type or "none"
|
|
185
|
+
if candidate_disk == "none":
|
|
186
|
+
return False
|
|
187
|
+
if candidate.ephemeral_disk_total_gb < current.ephemeral_disk_total_gb:
|
|
188
|
+
return False
|
|
189
|
+
return _DISK_RANK.get(candidate_disk, 0) >= _DISK_RANK.get(current_disk, 0)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def _sort_key(row: SpecRow, prices: dict[str, Decimal]) -> tuple[Decimal, Decimal, str]:
|
|
193
|
+
price = prices[row.instance_type]
|
|
194
|
+
rank = -(row.cpu_performance_rank or Decimal("0"))
|
|
195
|
+
return (price, rank, row.instance_type)
|