Refactor public network API handling and enhance connectivity checks

- Updated the public network handling to resolve the base URL dynamically based on Keystone catalog.
- Simplified the public network pool function to directly return the compute region.
- Enhanced error messages in the doctor command for better clarity on public network status.
- Introduced new functions for managing security groups and ensuring visibility of public ports in Neutron.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-23 18:55:19 +03:00
co-authored by Cursor
parent eb459dcccf
commit 9e9f72c1ac
6 changed files with 123 additions and 37 deletions
+21
View File
@@ -0,0 +1,21 @@
"""SG for direct public IP uses compute-pool Neutron (openstacksdk)."""
from unittest.mock import MagicMock
from gpu_rent.public_net import SecurityGroupRef, ensure_public_network_security_group
def test_public_network_sg_uses_sdk(monkeypatch):
main_conn = MagicMock()
def fake_ensure_sg(conn, cidr, log):
assert conn is main_conn
assert cidr == "0.0.0.0/0"
return MagicMock(id="sg-ru6")
monkeypatch.setattr("gpu_rent.cloud.ensure_security_group", fake_ensure_sg)
sg = ensure_public_network_security_group(
main_conn, "0.0.0.0/0", "ru-6", lambda _m: None
)
assert sg == SecurityGroupRef(id="sg-ru6")