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
+24 -11
View File
@@ -1,21 +1,34 @@
"""public-network API pool mapping and base URL."""
"""public-network API pool = compute pool (OS_REGION_NAME)."""
from gpu_rent.public_net import public_net_base, public_network_pool
from unittest.mock import MagicMock
from gpu_rent.public_net import (
public_net_base,
public_network_pool,
resolve_public_net_base,
)
def test_public_network_pool_ru6_maps_to_ru7():
assert public_network_pool("ru-6") == "ru-7"
def test_public_network_pool_passthrough():
def test_public_network_pool_is_compute_region():
assert public_network_pool("ru-6") == "ru-6"
assert public_network_pool("ru-7") == "ru-7"
assert public_network_pool("ru-3") == "ru-3"
def test_public_net_base_uses_public_network_path():
def test_public_net_base_uses_compute_pool():
assert public_net_base("ru-6") == (
"https://ru-6.cloud.api.selcloud.ru/public-network"
)
assert public_net_base("ru-7") == (
"https://ru-7.cloud.api.selcloud.ru/public-network"
)
assert public_net_base("ru-6") == (
"https://ru-7.cloud.api.selcloud.ru/public-network"
def test_resolve_public_net_base_from_keystone_catalog():
conn = MagicMock()
conn.session.get_endpoint.return_value = (
"https://ru-6.cloud.api.selcloud.ru/public-network/v1/"
)
assert resolve_public_net_base(conn, "ru-6") == (
"https://ru-6.cloud.api.selcloud.ru/public-network/v1"
)
conn.session.get_endpoint.assert_called()