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
maproom/analyze/shape.py
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"""User-declared recommendation shape: attributes to modify or keep."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
from maproom.analyze.engine import Candidate, EngineResult
|
|
8
|
+
from maproom.analyze.specs import InstanceSpec, SpecCatalog
|
|
9
|
+
from maproom.plan.errors import PlanError
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass(frozen=True)
|
|
13
|
+
class ShapeAttribute:
|
|
14
|
+
name: str
|
|
15
|
+
summary: str
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
SHAPE_ATTRIBUTES: tuple[ShapeAttribute, ...] = (
|
|
19
|
+
ShapeAttribute(
|
|
20
|
+
"burstable",
|
|
21
|
+
"Whether the instance is a burstable CPU type.",
|
|
22
|
+
),
|
|
23
|
+
ShapeAttribute(
|
|
24
|
+
"has_instance_disks",
|
|
25
|
+
"Whether the instance has local instance-store disks.",
|
|
26
|
+
),
|
|
27
|
+
ShapeAttribute(
|
|
28
|
+
"instance_family",
|
|
29
|
+
"Family name, such as m5, c6i, or r6g.",
|
|
30
|
+
),
|
|
31
|
+
ShapeAttribute(
|
|
32
|
+
"instance_generation",
|
|
33
|
+
"Generation number inside the family, such as 5 in m5 or 6 in c6i.",
|
|
34
|
+
),
|
|
35
|
+
ShapeAttribute(
|
|
36
|
+
"instance_quantity",
|
|
37
|
+
"How many servers are in the VMSS or Auto Scaling group.",
|
|
38
|
+
),
|
|
39
|
+
ShapeAttribute(
|
|
40
|
+
"instance_size",
|
|
41
|
+
"Size suffix, such as large or 2xlarge.",
|
|
42
|
+
),
|
|
43
|
+
ShapeAttribute(
|
|
44
|
+
"processor_architecture",
|
|
45
|
+
"Processor architecture, such as x86_64 or arm64.",
|
|
46
|
+
),
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
_BY_NAME = {item.name: item for item in SHAPE_ATTRIBUTES}
|
|
51
|
+
_MODIFY = {f"modify_{item.name}" for item in SHAPE_ATTRIBUTES}
|
|
52
|
+
_KEEP = {f"keep_{item.name}" for item in SHAPE_ATTRIBUTES}
|
|
53
|
+
_ALL_TOKENS = _MODIFY | _KEEP
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@dataclass(frozen=True)
|
|
57
|
+
class ShapeConstraint:
|
|
58
|
+
"""Attributes the operator will allow to change, and attributes they want kept."""
|
|
59
|
+
|
|
60
|
+
modify: frozenset[str]
|
|
61
|
+
keep: frozenset[str]
|
|
62
|
+
|
|
63
|
+
def summary(self) -> str:
|
|
64
|
+
modify = ", ".join(sorted(self.modify)) or "(none)"
|
|
65
|
+
keep = ", ".join(sorted(self.keep)) or "(none)"
|
|
66
|
+
return f"modify {modify}; keep {keep}"
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def shape_in_effect(shape: ShapeConstraint | None) -> ShapeConstraint:
|
|
70
|
+
"""Every attribute except burstable may change until the operator names a list."""
|
|
71
|
+
if shape is None:
|
|
72
|
+
return ShapeConstraint(
|
|
73
|
+
modify=frozenset(
|
|
74
|
+
item.name for item in SHAPE_ATTRIBUTES if item.name != "burstable"
|
|
75
|
+
),
|
|
76
|
+
keep=frozenset({"burstable"}),
|
|
77
|
+
)
|
|
78
|
+
return shape
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def format_active_shapes(shape: ShapeConstraint | None) -> str:
|
|
82
|
+
"""List the shape settings in effect for this analyze run."""
|
|
83
|
+
lines = [
|
|
84
|
+
"Shape settings for this analyze run:",
|
|
85
|
+
"",
|
|
86
|
+
]
|
|
87
|
+
if shape is None:
|
|
88
|
+
for item in SHAPE_ATTRIBUTES:
|
|
89
|
+
if item.name == "burstable":
|
|
90
|
+
lines.append(f" keep_{item.name}")
|
|
91
|
+
else:
|
|
92
|
+
lines.append(f" modify_{item.name}")
|
|
93
|
+
lines.append(
|
|
94
|
+
"Pass --shape to name the attributes allowed to change. "
|
|
95
|
+
"Burstable stays fixed when --shape is omitted; name modify_burstable "
|
|
96
|
+
"to let burstable change."
|
|
97
|
+
)
|
|
98
|
+
return "\n".join(lines)
|
|
99
|
+
for item in SHAPE_ATTRIBUTES:
|
|
100
|
+
if item.name in shape.modify:
|
|
101
|
+
lines.append(f" modify_{item.name}")
|
|
102
|
+
elif item.name in shape.keep:
|
|
103
|
+
lines.append(f" keep_{item.name}")
|
|
104
|
+
return "\n".join(lines)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def format_shape_catalog() -> str:
|
|
108
|
+
"""Teach the modify_* and keep_* tokens."""
|
|
109
|
+
lines = [
|
|
110
|
+
"A shape is the set of instance attributes you will let a recommendation change,",
|
|
111
|
+
"and the set you want kept.",
|
|
112
|
+
"",
|
|
113
|
+
"With no --shape, every attribute except burstable may change.",
|
|
114
|
+
"Burstable stays fixed by default. Name modify_burstable to let it change.",
|
|
115
|
+
"Pass --shape to limit the lookup to the attributes you name.",
|
|
116
|
+
"Tokens are comma-separated and repeatable.",
|
|
117
|
+
"",
|
|
118
|
+
"Each attribute is one choice. Pass keep_<name> or modify_<name>.",
|
|
119
|
+
"Attributes you leave out stay fixed.",
|
|
120
|
+
"",
|
|
121
|
+
"Attributes:",
|
|
122
|
+
]
|
|
123
|
+
for item in SHAPE_ATTRIBUTES:
|
|
124
|
+
lines.append(f" {{keep|modify}}_{item.name}")
|
|
125
|
+
lines.append(f" {item.summary}")
|
|
126
|
+
lines.append("")
|
|
127
|
+
lines.append("modify_* and keep_* for the same attribute is treated as keep.")
|
|
128
|
+
lines.append("")
|
|
129
|
+
lines.append("Example:")
|
|
130
|
+
lines.append(
|
|
131
|
+
" maproom analyze aws --shape modify_instance_size,modify_processor_architecture"
|
|
132
|
+
)
|
|
133
|
+
lines.append(
|
|
134
|
+
" Fits the instance size to the most price-efficient Graviton or x86 type."
|
|
135
|
+
)
|
|
136
|
+
return "\n".join(lines) + "\n"
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def _normalize_token(token: str) -> str:
|
|
140
|
+
return token.strip().replace("-", "_").lower()
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def parse_shape_values(raw_values: list[str]) -> ShapeConstraint | PlanError:
|
|
144
|
+
modify: set[str] = set()
|
|
145
|
+
keep: set[str] = set()
|
|
146
|
+
for raw in raw_values:
|
|
147
|
+
for piece in raw.split(","):
|
|
148
|
+
token = _normalize_token(piece)
|
|
149
|
+
if not token:
|
|
150
|
+
continue
|
|
151
|
+
if token not in _ALL_TOKENS:
|
|
152
|
+
allowed = ", ".join(sorted(_ALL_TOKENS))
|
|
153
|
+
return PlanError(
|
|
154
|
+
f'unrecognized shape token "{piece.strip()}". '
|
|
155
|
+
f"Run `maproom analyze -h` for the list. Valid values: {allowed}"
|
|
156
|
+
)
|
|
157
|
+
name = token.split("_", 1)[1]
|
|
158
|
+
if token in _MODIFY:
|
|
159
|
+
if name not in keep:
|
|
160
|
+
modify.add(name)
|
|
161
|
+
else:
|
|
162
|
+
modify.discard(name)
|
|
163
|
+
keep.add(name)
|
|
164
|
+
if not modify and not keep:
|
|
165
|
+
return PlanError(
|
|
166
|
+
"at least one --shape value is required. Run `maproom analyze -h`."
|
|
167
|
+
)
|
|
168
|
+
return ShapeConstraint(modify=frozenset(modify), keep=frozenset(keep))
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def _same_architecture(current: InstanceSpec, candidate: InstanceSpec) -> bool:
|
|
172
|
+
if not current.architectures or not candidate.architectures:
|
|
173
|
+
return True
|
|
174
|
+
return bool(set(current.architectures) & set(candidate.architectures))
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def _changed_names(current: InstanceSpec, candidate: InstanceSpec) -> set[str]:
|
|
178
|
+
changed: set[str] = set()
|
|
179
|
+
if candidate.family != current.family:
|
|
180
|
+
changed.add("instance_family")
|
|
181
|
+
if candidate.generation != current.generation:
|
|
182
|
+
changed.add("instance_generation")
|
|
183
|
+
if candidate.size != current.size:
|
|
184
|
+
changed.add("instance_size")
|
|
185
|
+
if not _same_architecture(current, candidate):
|
|
186
|
+
changed.add("processor_architecture")
|
|
187
|
+
if candidate.instance_storage != current.instance_storage:
|
|
188
|
+
changed.add("has_instance_disks")
|
|
189
|
+
if candidate.burstable != current.burstable:
|
|
190
|
+
changed.add("burstable")
|
|
191
|
+
return changed
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def attribute_tokens(
|
|
195
|
+
current: InstanceSpec,
|
|
196
|
+
candidate: InstanceSpec,
|
|
197
|
+
) -> tuple[list[str], list[str]]:
|
|
198
|
+
"""Return (modify_* tokens, keep_* tokens) for one candidate versus current."""
|
|
199
|
+
changed = _changed_names(current, candidate)
|
|
200
|
+
modifies = [f"modify_{item.name}" for item in SHAPE_ATTRIBUTES if item.name in changed]
|
|
201
|
+
keeps = [f"keep_{item.name}" for item in SHAPE_ATTRIBUTES if item.name not in changed]
|
|
202
|
+
return modifies, keeps
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def shape_allows(
|
|
206
|
+
constraint: ShapeConstraint,
|
|
207
|
+
current: InstanceSpec,
|
|
208
|
+
candidate: InstanceSpec,
|
|
209
|
+
) -> bool:
|
|
210
|
+
"""True when every change is allowed and every requested keep still holds.
|
|
211
|
+
|
|
212
|
+
Attributes the operator did not list as modify_* are kept.
|
|
213
|
+
"""
|
|
214
|
+
changed = _changed_names(current, candidate)
|
|
215
|
+
if not changed <= constraint.modify:
|
|
216
|
+
return False
|
|
217
|
+
if not constraint.keep <= (set(_BY_NAME) - changed):
|
|
218
|
+
return False
|
|
219
|
+
return True
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def restrict_engine_result(
|
|
223
|
+
result: EngineResult,
|
|
224
|
+
*,
|
|
225
|
+
current: InstanceSpec,
|
|
226
|
+
catalog: SpecCatalog,
|
|
227
|
+
shape: ShapeConstraint,
|
|
228
|
+
) -> EngineResult:
|
|
229
|
+
"""Drop candidates that change an attribute the operator did not allow."""
|
|
230
|
+
|
|
231
|
+
def _keep(candidate: Candidate) -> bool:
|
|
232
|
+
spec = catalog.specs.get(candidate.instance_type)
|
|
233
|
+
if spec is None:
|
|
234
|
+
return False
|
|
235
|
+
return shape_allows(shape, current, spec)
|
|
236
|
+
|
|
237
|
+
recommendations = [item for item in result.recommendations if _keep(item)]
|
|
238
|
+
conditional = [item for item in result.conditional if _keep(item)]
|
|
239
|
+
dropped = (len(result.recommendations) - len(recommendations)) + (
|
|
240
|
+
len(result.conditional) - len(conditional)
|
|
241
|
+
)
|
|
242
|
+
rejected_by_reason = dict(result.rejected_by_reason)
|
|
243
|
+
if dropped:
|
|
244
|
+
rejected_by_reason["outside_shape"] = (
|
|
245
|
+
rejected_by_reason.get("outside_shape", 0) + dropped
|
|
246
|
+
)
|
|
247
|
+
return EngineResult(
|
|
248
|
+
recommendations=recommendations,
|
|
249
|
+
conditional=conditional,
|
|
250
|
+
rejected=result.rejected,
|
|
251
|
+
rejected_total=result.rejected_total + dropped,
|
|
252
|
+
rejected_by_reason=rejected_by_reason,
|
|
253
|
+
evaluated_total=result.evaluated_total,
|
|
254
|
+
)
|