multicloud-cli 0.9.2__tar.gz → 0.10.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.
Files changed (42) hide show
  1. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/PKG-INFO +1 -1
  2. multicloud_cli-0.10.1/multicloud_cli/__init__.py +1 -0
  3. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/cloud_account.py +107 -15
  4. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/tests/test_cloud_account.py +79 -1
  5. multicloud_cli-0.9.2/multicloud_cli/__init__.py +0 -1
  6. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/.gitignore +0 -0
  7. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/LICENSE +0 -0
  8. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/README.md +0 -0
  9. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/account.py +0 -0
  10. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/api.py +0 -0
  11. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/auth.py +0 -0
  12. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/catalog.py +0 -0
  13. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/config.py +0 -0
  14. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/duration.py +0 -0
  15. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/exitcodes.py +0 -0
  16. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/extend.py +0 -0
  17. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/main.py +0 -0
  18. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/net.py +0 -0
  19. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/node.py +0 -0
  20. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/orgopt.py +0 -0
  21. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/output.py +0 -0
  22. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/pool.py +0 -0
  23. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/ssh.py +0 -0
  24. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/ssh_cert.py +0 -0
  25. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/sso.py +0 -0
  26. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/multicloud_cli/version_check.py +0 -0
  27. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/pyproject.toml +0 -0
  28. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/tests/__init__.py +0 -0
  29. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/tests/conftest.py +0 -0
  30. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/tests/helpers.py +0 -0
  31. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/tests/test_account_extend.py +0 -0
  32. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/tests/test_apply.py +0 -0
  33. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/tests/test_auth.py +0 -0
  34. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/tests/test_catalog.py +0 -0
  35. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/tests/test_conventions.py +0 -0
  36. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/tests/test_net.py +0 -0
  37. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/tests/test_pool.py +0 -0
  38. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/tests/test_ssh.py +0 -0
  39. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/tests/test_ssh_cert.py +0 -0
  40. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/tests/test_sso.py +0 -0
  41. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/tests/test_sso_session.py +0 -0
  42. {multicloud_cli-0.9.2 → multicloud_cli-0.10.1}/tests/test_version_check.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: multicloud-cli
3
- Version: 0.9.2
3
+ Version: 0.10.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.10.1"
@@ -77,12 +77,12 @@ class CloudAccountError(exitcodes.CliError):
77
77
 
78
78
  def call(method: str, org: Optional[str], tail: str = "", *, body: Optional[Dict[str, Any]] = None,
79
79
  headers: Optional[Dict[str, str]] = None, accept=(200, 201, 202),
80
- prefer_sso: bool = False) -> Dict[str, Any]:
80
+ prefer_sso: bool = False, params: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
81
81
  """One API call. Returns the JSON body with ``_status`` added; raises on other statuses.
82
82
  ``prefer_sso`` uses the sign-in even when ``MULTICLOUD_API_KEY`` is set (the owner-only routes)."""
83
83
  try:
84
84
  return api.call(method, org, "/cloud-accounts" + tail, body=body, headers=headers, accept=accept,
85
- pass_codes=("VERIFY_FAILED",), prefer_sso=prefer_sso)
85
+ pass_codes=("VERIFY_FAILED",), prefer_sso=prefer_sso, params=params)
86
86
  except api.ApiError as ex:
87
87
  raise CloudAccountError(str(ex), ex.exit_code)
88
88
 
@@ -149,7 +149,7 @@ def _num(value):
149
149
 
150
150
 
151
151
  #: Onboarding decision 28: the question ``create`` asks, default No.
152
- QUOTA_QUESTION = "Allow Multicloud to request higher quotas in this account?"
152
+ QUOTA_QUESTION = "Allow Multicloud to request higher quotas in this account later?"
153
153
  ALLOW_QUOTA_COMMAND = "mctl cloud-account allow-quota-requests {id}"
154
154
 
155
155
 
@@ -341,9 +341,9 @@ def create(ctx, cloud, account, location, new_email, regions, force, opt_in, all
341
341
  --region stays the list of locations Multicloud may use. Run apply after 'az login' as an Owner of the
342
342
  subscription.
343
343
 
344
- Quota requests: Multicloud files a quota increase request in the account only when you allow it
345
- (--allow-quota-requests, or 'y' at the question). Without it, verify only reads the quotas and tells
346
- you what to request. Change it later with allow-quota-requests or revoke-quota-requests."""
344
+ Quota requests: verify only reads the quotas and tells you what is low; it requests none. Requests are
345
+ made later through the quota dialogue, and only when you allow it (--allow-quota-requests, or 'y' at
346
+ the question). Change it later with allow-quota-requests or revoke-quota-requests."""
347
347
  cloud = cloud.upper()
348
348
  gce, azure = cloud == "GCE", cloud == "AZURE"
349
349
  if location and not azure:
@@ -462,9 +462,9 @@ def _ask_quota(cloud: str) -> bool:
462
462
  if not _stdin_is_tty():
463
463
  return False
464
464
  service = "Azure Microsoft.Quota" if cloud == "AZURE" else "AWS Service Quotas"
465
- click.echo(f"Multicloud can request higher spot quotas in this account ({service}) when they are too low "
466
- "for your pools. Without it, Multicloud only reads the quotas and tells you what to request.",
467
- err=True)
465
+ click.echo(f"Verify only reads the quotas in this account ({service}); it requests none. Requests are made "
466
+ "later through the quota dialogue and need your consent. Until then, request higher quotas "
467
+ "yourself where verify shows quota LOW.", err=True)
468
468
  return click.confirm(QUOTA_QUESTION, default=False, err=True)
469
469
 
470
470
 
@@ -485,7 +485,7 @@ def _create_quota_consent(ctx, acct_id, allow: bool, say) -> Optional[Dict[str,
485
485
  A refusal (no owner sign-in) keeps the account and says so on stderr."""
486
486
  command = ALLOW_QUOTA_COMMAND.format(id=acct_id)
487
487
  if not allow:
488
- say(f"Quota requests: not allowed. To allow them later: {command}")
488
+ say(f"Quota requests: not allowed (verify requests none). To allow the quota dialogue to request later: {command}")
489
489
  return None
490
490
  try:
491
491
  answer = call("PUT", ctx.obj.get("cloud_account_org"), f"/{acct_id}/quota-consent", prefer_sso=True)
@@ -494,7 +494,7 @@ def _create_quota_consent(ctx, acct_id, allow: bool, say) -> Optional[Dict[str,
494
494
  f"allows them with: {command}", err=True)
495
495
  return None
496
496
  answer.pop("_status", None)
497
- say(f"Quota requests allowed (by {answer.get('quota_consent_by')}).")
497
+ say(f"Quota requests allowed (by {answer.get('quota_consent_by')}). Verify still requests none; the quota dialogue uses this consent.")
498
498
  return answer
499
499
 
500
500
 
@@ -749,13 +749,13 @@ def accept_shared_account(ctx, account_id):
749
749
  def allow_quota_requests(ctx, account_id):
750
750
  """Allow Multicloud to request higher quotas in this account (organization owners only).
751
751
 
752
- Multicloud then files quota increase requests (AWS Service Quotas, Azure Microsoft.Quota) when the spot
753
- quota is too low for your pools, at most a few per day. Needs a sign-in (mctl auth login), not an API key.
752
+ Multicloud then files the quota increase requests that you ask for through the quota dialogue or
753
+ 'quota-request' (AWS Service Quotas). 'verify' files none. Needs a sign-in (mctl auth login), not an API key.
754
754
  Undo with revoke-quota-requests."""
755
755
  answer = _run(ctx, lambda org: call("PUT", org, f"/{account_id}/quota-consent", prefer_sso=True))
756
756
  click.echo(f"Multicloud may now request higher quotas in cloud account {account_id} "
757
- f"({quota_consent_label(answer)}). The next verify files what is needed: "
758
- f"mctl cloud-account verify {account_id}")
757
+ f"({quota_consent_label(answer)}). verify files nothing. File a request with: "
758
+ f"mctl cloud-account quota-request {account_id} --region R --code C --desired N")
759
759
 
760
760
 
761
761
  @cloud_account.command(name="revoke-quota-requests")
@@ -770,6 +770,98 @@ def revoke_quota_requests(ctx, account_id):
770
770
  f"filed stay open in the cloud.")
771
771
 
772
772
 
773
+ def quota_plan_lines(data: Dict[str, Any]) -> list:
774
+ """Readable lines for the answer of ``GET .../quota-plan-data``."""
775
+ lines = []
776
+ budget = data.get("budget") or {}
777
+ if budget:
778
+ lines.append("request budget: " + ", ".join(f"{k}={v}" for k, v in sorted(budget.items())))
779
+ lines.append("quota requests: " + ("allowed" if data.get("consent") else "NOT allowed (allow-quota-requests)"))
780
+ for region in data.get("regions") or []:
781
+ lines.append(f"{region.get('region')}:")
782
+ if region.get("history_error"):
783
+ lines.append(f" history unreadable: {region['history_error']}")
784
+ for q in region.get("quotas") or []:
785
+ head = f" {q.get('key')} ({q.get('code')}): "
786
+ lines.append(head + (f"limit {_num(q.get('current_limit'))}" if q.get("error") is None
787
+ else f"unreadable: {q['error']}"))
788
+ o = q.get("open_request")
789
+ if o:
790
+ lines.append(f" OPEN request {o.get('id')}: {_num(o.get('desired'))} ({o.get('status')})")
791
+ d = q.get("latest_denial")
792
+ if d:
793
+ state = (f"wait until {d.get('cooldown_until')}; confirm with --confirm-denied {d.get('request_id')}"
794
+ if d.get("cooldown_active") else "wait is over")
795
+ reason = f" ({d['reason']})" if d.get("reason") else ""
796
+ lines.append(f" DENIED {d.get('date')}, request {d.get('request_id')}{reason}: {state}")
797
+ return lines
798
+
799
+
800
+ @cloud_account.command(name="quota-plan")
801
+ @click.argument("account_id", type=int)
802
+ @click.option("--region", "regions", multiple=True, help="Region to read (repeat; at most 10). Required")
803
+ @click.option("--code", "codes", multiple=True, help="Quota code to read (repeat). Default: the four spot and on-demand codes")
804
+ @json_option
805
+ @click.pass_context
806
+ def quota_plan(ctx, account_id, regions, codes, as_json):
807
+ """Read the quota data for the quota dialogue: limits, open requests, denials, request budget (AWS).
808
+
809
+ Files nothing. Output per region and quota: current limit, an open request, the latest denial and
810
+ the end of its 30-day wait."""
811
+ regions = list(dict.fromkeys(r.strip() for r in regions if r.strip()))
812
+ if not regions:
813
+ raise click.UsageError("Name at least one --region, for example --region us-east-1.")
814
+ if len(regions) > 10:
815
+ raise click.UsageError("At most 10 regions per call.")
816
+ params = {"regions": ",".join(regions)}
817
+ codes = list(dict.fromkeys(c.strip() for c in codes if c.strip()))
818
+ if codes:
819
+ params["codes"] = ",".join(codes)
820
+ answer = _run(ctx, lambda org: call("GET", org, f"/{account_id}/quota-plan-data", params=params))
821
+ if as_json:
822
+ _dump(answer)
823
+ return
824
+ click.echo("\n".join(quota_plan_lines(answer)))
825
+
826
+
827
+ @cloud_account.command(name="quota-request")
828
+ @click.argument("account_id", type=int)
829
+ @click.option("--region", required=True, help="Region to file in, for example us-east-1")
830
+ @click.option("--code", required=True, help="Quota code, for example L-3819A6DF (spot G and VT vCPUs)")
831
+ @click.option("--desired", required=True, type=click.FloatRange(min=0, min_open=True, max=10_000_000),
832
+ help="New limit to ask for (above 0, at most 10000000)")
833
+ @click.option("--confirm-denied", "confirm_denied", default=None,
834
+ help="Request id of the denial shown by quota-plan: files again although AWS denied this quota in the last 30 days")
835
+ @json_option
836
+ @click.pass_context
837
+ def quota_request(ctx, account_id, region, code, desired, confirm_denied, as_json):
838
+ """File one quota increase (AWS). Needs consent: mctl cloud-account allow-quota-requests ID.
839
+
840
+ A quota AWS denied in the last 30 days is not filed again until you pass --confirm-denied with the
841
+ denial's request id (shown by quota-plan and in the answer)."""
842
+ item = {"region": region, "code": code, "desired": desired}
843
+ if confirm_denied and confirm_denied.strip():
844
+ item["confirm_denied"] = confirm_denied.strip()
845
+ answer = _run(ctx, lambda org: call("POST", org, f"/{account_id}/quota-requests", body={"requests": [item]}))
846
+ if as_json:
847
+ _dump(answer)
848
+ return
849
+ lines = quota_lines(answer)
850
+ for d in answer.get("deferred") or []:
851
+ denial = d.get("denial") or {}
852
+ if denial.get("request_id"):
853
+ lines.append(f"quota NOTE denied {denial.get('date')} (request {denial['request_id']}); "
854
+ f"to file anyway add: --confirm-denied {denial['request_id']}")
855
+ for u in answer.get("unmatched_confirmations") or []:
856
+ lines.append(f"quota NOTE --confirm-denied {u.get('confirm_denied')} lifted nothing: {u.get('reason')}")
857
+ if answer.get("consent") is False:
858
+ lines.append("quota NOTE NOTHING FILED: quota requests are not allowed. Run: "
859
+ + ALLOW_QUOTA_COMMAND.format(id=account_id))
860
+ click.echo("\n".join(lines) if lines else "Nothing filed.")
861
+ if answer.get("consent") is False:
862
+ sys.exit(exitcodes.ERROR)
863
+
864
+
773
865
  WAIT_DEFAULT = "130m" # the cleanup job gives up after about two hours
774
866
  WAIT_INTERVAL = 30
775
867
 
@@ -1251,7 +1251,7 @@ def test_create_asks_about_quota_requests_and_defaults_to_no(tmp_path, monkeypat
1251
1251
  monkeypatch.chdir(tmp_path)
1252
1252
  r, calls = _run_create([], monkeypatch, tty=True, stdin="\n")
1253
1253
  assert r.exit_code == 0, r.output
1254
- assert "Allow Multicloud to request higher quotas in this account? [y/N]" in r.stderr
1254
+ assert "Allow Multicloud to request higher quotas in this account later? [y/N]" in r.stderr
1255
1255
  assert [c[0] for c in calls] == ["POST"]
1256
1256
  assert "mctl cloud-account allow-quota-requests 5" in r.stdout
1257
1257
 
@@ -1330,3 +1330,81 @@ def test_create_json_prints_the_account_after_the_consent(tmp_path, monkeypatch)
1330
1330
  assert r.exit_code == 0, r.output
1331
1331
  printed = json.loads(r.stdout)
1332
1332
  assert printed["quota_consent_on"] == "2026-11-12T10:00:00Z" and "_status" not in printed
1333
+
1334
+
1335
+ # --- quota-plan and quota-request (the quota dialogue's data and filing calls) ---
1336
+
1337
+ PLAN = {"consent": True, "budget": {"account_active": 3, "account_cap": 20},
1338
+ "regions": [{"region": "us-east-1", "quotas": [
1339
+ {"key": "spot-g", "code": "L-3819A6DF", "current_limit": 0.0,
1340
+ "open_request": {"id": "r-1", "desired": 8, "status": "PENDING"}},
1341
+ {"key": "spot-standard", "code": "L-34B43A08", "current_limit": 64.0,
1342
+ "latest_denial": {"request_id": "d-9", "status": "DENIED", "date": "2026-11-01",
1343
+ "cooldown_until": "2026-12-01", "cooldown_active": True}},
1344
+ {"key": "ondemand-g", "code": "L-DB2E81BA", "error": "ClientError: AccessDenied"}]},
1345
+ {"region": "eu-west-1", "quotas": [], "history_error": "ClientError: AccessDenied"}]}
1346
+
1347
+
1348
+ def test_quota_plan_prints_limits_open_requests_and_denials():
1349
+ r, req = invoke(["cloud-account", "quota-plan", "5", "--region", "us-east-1", "--region", "eu-west-1"],
1350
+ reply(200, PLAN))
1351
+ assert r.exit_code == 0, r.output
1352
+ method, url = req.call_args[0][:2]
1353
+ assert (method, url) == ("GET", "https://api.multicloud.io/api/v1/orgs/acme/cloud-accounts/5/quota-plan-data")
1354
+ assert req.call_args[1]["params"] == {"regions": "us-east-1,eu-west-1"} or "regions=us-east-1%2Ceu-west-1" in str(req.call_args)
1355
+ out = r.stdout
1356
+ assert "us-east-1" in out and "spot-g" in out and "L-3819A6DF" in out
1357
+ assert "OPEN" in out and "r-1" in out
1358
+ assert "DENIED" in out and "d-9" in out and "2026-12-01" in out
1359
+ assert "AccessDenied" in out
1360
+ assert "eu-west-1" in out and "history" in out.lower()
1361
+
1362
+
1363
+ def test_quota_plan_json_prints_the_raw_answer():
1364
+ r, _ = invoke(["cloud-account", "quota-plan", "5", "--region", "us-east-1", "--json"], reply(200, PLAN))
1365
+ assert json.loads(r.stdout)["budget"]["account_cap"] == 20
1366
+
1367
+
1368
+ def test_quota_request_sends_one_item_and_prints_the_outcome():
1369
+ answer = {"filed": [{"quota": "AWS/us-east-1/spot-g", "desired": 8, "request_id": "r-7"}],
1370
+ "deferred": [], "refused": [], "already_open": [], "unmatched_confirmations": []}
1371
+ r, req = invoke(["cloud-account", "quota-request", "5", "--region", "us-east-1", "--code", "L-3819A6DF",
1372
+ "--desired", "8"], reply(200, answer))
1373
+ assert r.exit_code == 0, r.output
1374
+ assert req.call_args[0][:2] == ("POST", "https://api.multicloud.io/api/v1/orgs/acme/cloud-accounts/5/quota-requests")
1375
+ assert req.call_args[1]["json"] == {"requests": [{"region": "us-east-1", "code": "L-3819A6DF", "desired": 8.0}]}
1376
+ assert "quota FILED" in r.stdout and "r-7" in r.stdout
1377
+
1378
+
1379
+ def test_quota_request_confirm_denied_is_sent_and_a_denial_is_shown():
1380
+ answer = {"deferred": [{"quota": "AWS/us-east-1/spot-g", "reason": "denied 2026-11-01",
1381
+ "denial": {"request_id": "d-9", "status": "DENIED", "date": "2026-11-01"}}],
1382
+ "unmatched_confirmations": [{"region": "us-east-1", "code": "L-3819A6DF", "confirm_denied": "x",
1383
+ "reason": "not the latest denial"}]}
1384
+ r, req = invoke(["cloud-account", "quota-request", "5", "--region", "us-east-1", "--code", "L-3819A6DF",
1385
+ "--desired", "8", "--confirm-denied", "x"], reply(200, answer))
1386
+ assert req.call_args[1]["json"]["requests"][0]["confirm_denied"] == "x"
1387
+ assert "quota LATER" in r.stdout and "d-9" in r.stdout and "--confirm-denied d-9" in r.stdout
1388
+ assert "not the latest denial" in r.stdout
1389
+
1390
+
1391
+ def test_quota_request_without_consent_names_the_allow_command():
1392
+ answer = {"consent": False, "filed": [], "planned": [{"quota": "AWS/us-east-1/spot-g", "current": 0, "required": 8}]}
1393
+ r, _ = invoke(["cloud-account", "quota-request", "5", "--region", "us-east-1", "--code", "L-3819A6DF",
1394
+ "--desired", "8"], reply(200, answer))
1395
+ assert "mctl cloud-account allow-quota-requests 5" in r.stdout
1396
+
1397
+
1398
+ def test_quota_request_refuses_a_bad_desired_and_exits_nonzero_without_consent():
1399
+ r, req = invoke(["cloud-account", "quota-request", "5", "--region", "us-east-1", "--code", "C", "--desired", "0"],
1400
+ reply(200, {}))
1401
+ assert r.exit_code != 0 and not req.called
1402
+ r, _ = invoke(["cloud-account", "quota-request", "5", "--region", "us-east-1", "--code", "C", "--desired", "8"],
1403
+ reply(200, {"consent": False, "planned": []}))
1404
+ assert r.exit_code != 0 and "NOTHING FILED" in r.stdout
1405
+
1406
+
1407
+ def test_quota_plan_refuses_more_than_ten_regions():
1408
+ args = ["cloud-account", "quota-plan", "5"] + [a for i in range(11) for a in ("--region", f"r{i}")]
1409
+ r, req = invoke(args, reply(200, {}))
1410
+ assert r.exit_code != 0 and not req.called
@@ -1 +0,0 @@
1
- __version__ = "0.9.2"
File without changes