multicloud-cli 0.7.0__tar.gz → 0.7.1__tar.gz
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.
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/PKG-INFO +1 -1
- multicloud_cli-0.7.1/multicloud_cli/__init__.py +1 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/cloud_account.py +25 -4
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/pool.py +12 -1
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/tests/test_cloud_account.py +36 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/tests/test_conventions.py +2 -1
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/tests/test_pool.py +42 -0
- multicloud_cli-0.7.0/multicloud_cli/__init__.py +0 -1
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/.gitignore +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/LICENSE +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/README.md +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/account.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/api.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/auth.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/catalog.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/config.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/duration.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/exitcodes.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/extend.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/main.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/net.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/node.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/orgopt.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/output.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/ssh.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/ssh_cert.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/multicloud_cli/sso.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/pyproject.toml +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/tests/__init__.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/tests/conftest.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/tests/helpers.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/tests/test_account_extend.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/tests/test_apply.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/tests/test_auth.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/tests/test_catalog.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/tests/test_net.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/tests/test_ssh.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/tests/test_ssh_cert.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/tests/test_sso.py +0 -0
- {multicloud_cli-0.7.0 → multicloud_cli-0.7.1}/tests/test_sso_session.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: multicloud-cli
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.1
|
|
4
4
|
Summary: mctl: the Multicloud command line: sign in, connect your cloud account, run pools
|
|
5
5
|
Project-URL: Homepage, https://multicloud.io
|
|
6
6
|
Author-email: Multicloud Team <info@multicloud.io>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.7.1"
|
|
@@ -60,6 +60,14 @@ def call(method: str, org: Optional[str], tail: str = "", *, body: Optional[Dict
|
|
|
60
60
|
_NOUN = {"AWS": "AWS account", "GCE": "GCP project", "AZURE": "Azure subscription"}
|
|
61
61
|
|
|
62
62
|
|
|
63
|
+
# The cloud's own id of an account (what accept-shared-account wants typed), and what it looks like.
|
|
64
|
+
_NATIVE_ID = {
|
|
65
|
+
"AWS": ("AWS account ID", "12 digits, for example 123456789012"),
|
|
66
|
+
"GCE": ("GCP project ID", "lower-case letters, digits and hyphens, for example my-project-123"),
|
|
67
|
+
"AZURE": ("Azure subscription ID", "a GUID, for example 0f1e2d3c-4b5a-6978-8796-a5b4c3d2e1f0"),
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
63
71
|
def noun_of(cloud: Optional[str]) -> str:
|
|
64
72
|
return _NOUN.get(str(cloud or "").upper(), "cloud account")
|
|
65
73
|
|
|
@@ -261,7 +269,8 @@ def _file_exists(name: str):
|
|
|
261
269
|
|
|
262
270
|
|
|
263
271
|
@cloud_account.command()
|
|
264
|
-
@click.option("--cloud", required=True, type=click.Choice(["AWS", "GCE"], case_sensitive=False)
|
|
272
|
+
@click.option("--cloud", required=True, type=click.Choice(["AWS", "GCE"], case_sensitive=False),
|
|
273
|
+
help="AWS or GCE (Google Cloud). Azure: not available in mctl yet")
|
|
265
274
|
@click.option("--account", help="AWS: pin the 12-digit AWS account id (optional; not allowed for GCE)")
|
|
266
275
|
@click.option("--new-account-email", "new_email", metavar="EMAIL",
|
|
267
276
|
help="AWS: create a new AWS account for Multicloud in your AWS Organizations, with this email "
|
|
@@ -601,6 +610,10 @@ def accept_shared_account(ctx, account_id):
|
|
|
601
610
|
click.echo(f"Error: cloud account {account_id} needs no approval ({describe_verify(data)}; "
|
|
602
611
|
f"dedicated: {dedicated_label(data)}).", err=True)
|
|
603
612
|
sys.exit(exitcodes.ERROR)
|
|
613
|
+
if not native:
|
|
614
|
+
click.echo(f"Error: cloud account {account_id} has no cloud id yet, so there is nothing to approve. "
|
|
615
|
+
f"Run: mctl cloud-account verify {account_id}", err=True)
|
|
616
|
+
sys.exit(exitcodes.ERROR)
|
|
604
617
|
noun = noun_of(cloud)
|
|
605
618
|
for line in shared_warning(cloud):
|
|
606
619
|
click.echo(line)
|
|
@@ -608,9 +621,17 @@ def accept_shared_account(ctx, account_id):
|
|
|
608
621
|
if not _stdin_is_tty():
|
|
609
622
|
click.echo("Error: the approval needs a person at a terminal: type the id when asked.", err=True)
|
|
610
623
|
sys.exit(exitcodes.ERROR)
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
624
|
+
kind, example = _NATIVE_ID.get(str(cloud or "").upper(), ("cloud id", "the id your cloud shows"))
|
|
625
|
+
click.echo(f"To connect it anyway, type the {kind} ({native}). The {kind} is {example}. "
|
|
626
|
+
f"It is not the Multicloud cloud account id {account_id}.")
|
|
627
|
+
typed = click.prompt(kind, default="", show_default=False).strip()
|
|
628
|
+
if not native or not typed or typed.lower() != str(native).lower():
|
|
629
|
+
if typed == str(account_id):
|
|
630
|
+
click.echo(f"You typed the Multicloud cloud account id {account_id}. Type the {kind} {native} "
|
|
631
|
+
f"instead.", err=True)
|
|
632
|
+
else:
|
|
633
|
+
click.echo(f"The id does not match the {kind} {native}.", err=True)
|
|
634
|
+
click.echo("Nothing approved.", err=True)
|
|
614
635
|
sys.exit(exitcodes.ERROR)
|
|
615
636
|
answer = _run(ctx, lambda org: call("POST", org, f"/{account_id}/accept-shared-account",
|
|
616
637
|
body={"account_id": typed.strip()}, prefer_sso=True))
|
|
@@ -285,7 +285,18 @@ def create(ctx, name, github_org, clouds, cloud_accounts, classes_, max_cost_per
|
|
|
285
285
|
made = _run(ctx, go)
|
|
286
286
|
if as_json:
|
|
287
287
|
return _dump(made)
|
|
288
|
-
|
|
288
|
+
pool_id = made.get("pool_id")
|
|
289
|
+
|
|
290
|
+
def view(org):
|
|
291
|
+
# The 201 body has no name and no status: read them from the pool. The pool exists either way.
|
|
292
|
+
try:
|
|
293
|
+
return api.call("GET", org, f"/pools/{pool_id}", scope=READ)
|
|
294
|
+
except api.ApiError:
|
|
295
|
+
return None
|
|
296
|
+
shown = _run(ctx, view) if pool_id is not None else None
|
|
297
|
+
text = f"Pool {pool_id} ({(shown or {}).get('name') or body['name']}) created."
|
|
298
|
+
click.echo(text + (f" Status: {_status(shown)}" if shown and shown.get("status")
|
|
299
|
+
else " Status: not read yet (see the next command)."))
|
|
289
300
|
for line in quota_lines(made.get("quota")) if "cloud_accounts" in body else ():
|
|
290
301
|
click.echo(line)
|
|
291
302
|
click.echo(f"Next: mctl pool show {made.get('pool_id')}")
|
|
@@ -535,6 +535,42 @@ def test_accept_shared_account_wrong_id_approves_nothing():
|
|
|
535
535
|
assert "Nothing approved" in r.stderr
|
|
536
536
|
|
|
537
537
|
|
|
538
|
+
@pytest.mark.parametrize("cloud,native,kind,example", [
|
|
539
|
+
("AWS", "123456789012", "AWS account ID", "12 digits"),
|
|
540
|
+
("GCE", "mc-acme-1a2b", "GCP project ID", "my-project-123"),
|
|
541
|
+
("AZURE", SUB, "Azure subscription ID", "GUID"),
|
|
542
|
+
])
|
|
543
|
+
def test_accept_shared_account_prompt_names_the_native_id_not_the_row_id(cloud, native, kind, example):
|
|
544
|
+
# Live run 2026-11-12: the operator typed the Multicloud row id at "type its id".
|
|
545
|
+
shared = {**SHARED, "cloud": cloud, "expected_native_id": native}
|
|
546
|
+
r, req = invoke_seq(["cloud-account", "accept-shared-account", "7"], [reply(200, shared)], input="7\n")
|
|
547
|
+
assert r.exit_code == 1 and req.call_count == 1 # nothing posted
|
|
548
|
+
assert f"type the {kind} ({native})" in r.output and example in r.output
|
|
549
|
+
assert "not the Multicloud cloud account id 7" in r.output
|
|
550
|
+
assert "You typed the Multicloud cloud account id 7" in r.stderr
|
|
551
|
+
assert "Nothing approved" in r.stderr
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
def test_accept_shared_account_without_a_cloud_id_stops_before_the_prompt():
|
|
555
|
+
bare = {**SHARED, "expected_native_id": None, "native_id": None}
|
|
556
|
+
r, req = invoke_seq(["cloud-account", "accept-shared-account", "7"], [reply(200, bare)], input="x\n")
|
|
557
|
+
assert r.exit_code == 1 and req.call_count == 1
|
|
558
|
+
assert "has no cloud id yet" in r.stderr and "This Azure subscription" not in r.output
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
def test_accept_shared_account_wrong_id_says_what_was_expected():
|
|
562
|
+
r, _ = invoke_seq(["cloud-account", "accept-shared-account", "7"], [reply(200, SHARED)], input="nope\n")
|
|
563
|
+
assert r.exit_code == 1
|
|
564
|
+
assert f"does not match the Azure subscription ID {SUB}" in r.stderr
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
def test_create_cloud_choice_says_azure_is_not_available_yet():
|
|
568
|
+
r, req = invoke(["cloud-account", "create", "--cloud", "AZURE"], reply(200, {}))
|
|
569
|
+
assert r.exit_code == 2 and not req.called
|
|
570
|
+
r, _ = invoke(["cloud-account", "create", "--help"], reply(200, {}))
|
|
571
|
+
assert "Azure: not available in mctl yet" in " ".join(r.output.split())
|
|
572
|
+
|
|
573
|
+
|
|
538
574
|
def test_accept_shared_account_has_no_yes_and_needs_a_terminal():
|
|
539
575
|
r, _ = invoke_seq(["cloud-account", "accept-shared-account", "7", "--yes"], [])
|
|
540
576
|
assert r.exit_code == 2
|
|
@@ -239,7 +239,8 @@ def test_create_from_stdin_and_json_option_from_stdin(net):
|
|
|
239
239
|
r = runner().invoke(mctl, ["pool", "create", "ci", "--github-org", "g", "--clouds", "@-", "--classes", "cpu-4",
|
|
240
240
|
"--max-cost-per-hour", "2"], input=json.dumps([{"type": "AWS"}]))
|
|
241
241
|
assert r.exit_code == 0, r.stderr
|
|
242
|
-
|
|
242
|
+
posts = [c for c in net["calls"] if c[0] == "POST"] # each create also reads the new pool (GET)
|
|
243
|
+
assert posts[1][2]["json"]["clouds"] == [{"type": "AWS"}]
|
|
243
244
|
|
|
244
245
|
|
|
245
246
|
def test_rotation_status_and_deprecated_flag(net):
|
|
@@ -132,6 +132,48 @@ def test_pool_create_cloud_account_option_builds_body(monkeypatch):
|
|
|
132
132
|
assert "quota NOTE" in r.stdout and "quota FILED" not in r.stdout
|
|
133
133
|
|
|
134
134
|
|
|
135
|
+
def created_body(pool_id=7):
|
|
136
|
+
"""The 201 body of POST /pools (pools_service.onboard): no name and no status, unlike a PoolView."""
|
|
137
|
+
return {"pool_id": pool_id, "cluster_slug": "acme-ci", "github_app_manifest_url": "https://github.test/m",
|
|
138
|
+
"github_app_manifest": {}, "cache_bucket": {}, "clouds": [],
|
|
139
|
+
"quota": {"filed": [], "notes": ["spot quota is not checked or filed for pools on connected "
|
|
140
|
+
"cloud accounts"]},
|
|
141
|
+
"cloud_accounts": [{"id": 9, "cloud": "AWS", "regions": [], "via": "own"}], "grants": [], "notes": []}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def test_pool_create_prints_name_and_status_from_the_pool(monkeypatch):
|
|
145
|
+
# Live run 2026-11-12 printed "Pool 7 (None) created. Status: unknown".
|
|
146
|
+
r, calls, _ = run(["create", "ci", "--github-org", "acme-gh", "--cloud-account", "9", "--classes", "cpu-4",
|
|
147
|
+
"--max-cost-per-hour", "0.05"],
|
|
148
|
+
[reply(201, created_body()), reply(200, pool_view(7, "ci", status="provisioning",
|
|
149
|
+
status_message="TCP_NOT_READY"))],
|
|
150
|
+
monkeypatch)
|
|
151
|
+
assert r.exit_code == 0, r.output
|
|
152
|
+
assert [c[:2] for c in calls] == [("POST", f"{BASE}/pools"), ("GET", f"{BASE}/pools/7")]
|
|
153
|
+
assert "Pool 7 (ci) created. Status: provisioning (TCP_NOT_READY)" in r.stdout
|
|
154
|
+
assert "None" not in r.stdout and "unknown" not in r.stdout
|
|
155
|
+
assert "quota NOTE" in r.stdout
|
|
156
|
+
assert "Next: mctl pool show 7" in r.stdout
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def test_pool_create_still_succeeds_when_the_status_read_fails(monkeypatch):
|
|
160
|
+
r, calls, _ = run(["create", "ci", "--github-org", "acme-gh", "--cloud-account", "9", "--classes", "cpu-4",
|
|
161
|
+
"--max-cost-per-hour", "0.05"],
|
|
162
|
+
[reply(201, created_body()), reply(503, {"detail": "busy"})], monkeypatch)
|
|
163
|
+
assert r.exit_code == 0, r.output
|
|
164
|
+
assert len(calls) == 2
|
|
165
|
+
assert "Pool 7 (ci) created." in r.stdout and "None" not in r.stdout
|
|
166
|
+
assert "Status: unknown" not in r.stdout and "Status: not read yet" in r.stdout
|
|
167
|
+
assert "Next: mctl pool show 7" in r.stdout
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def test_pool_create_json_is_the_raw_create_body(monkeypatch):
|
|
171
|
+
r, calls, _ = run(["create", "ci", "--github-org", "acme-gh", "--cloud-account", "9", "--classes", "cpu-4",
|
|
172
|
+
"--max-cost-per-hour", "0.05", "--json"], [reply(201, created_body())], monkeypatch)
|
|
173
|
+
assert r.exit_code == 0, r.output
|
|
174
|
+
assert len(calls) == 1 and json.loads(r.stdout) == created_body()
|
|
175
|
+
|
|
176
|
+
|
|
135
177
|
def test_pool_create_cloud_account_and_clouds_are_exclusive(monkeypatch, tmp_path):
|
|
136
178
|
base = ["create", "ci", "--github-org", "g", "--classes", "cpu-4", "--max-cost-per-hour", "1"]
|
|
137
179
|
r, calls, _ = run(base + ["--cloud-account", "7", "--clouds", '[{"type":"AWS"}]'],
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.7.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|