Skip to content

Commit 5e5c951

Browse files
committed
fix(network): alignment subnet model field (#30)
1 parent 548cbd5 commit 5e5c951

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

src/openstack_mcp_server/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
# Transport protocol
7-
MCP_TRANSPORT: str = os.environ.get("TRANSPORT", "stdio")
7+
MCP_TRANSPORT: str = os.environ.get("TRANSPORT", "streamable-http")
88

99
# Openstack client settings
1010
MCP_CLOUD_NAME: str = os.environ.get("CLOUD_NAME", "openstack")

src/openstack_mcp_server/tools/network_tools.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,17 +383,19 @@ def _convert_to_subnet_model(self, openstack_subnet) -> Subnet:
383383
return Subnet(
384384
id=openstack_subnet.id,
385385
name=openstack_subnet.name,
386-
status=openstack_subnet.status,
386+
status=getattr(openstack_subnet, "status", None),
387387
description=openstack_subnet.description,
388388
project_id=openstack_subnet.project_id,
389389
network_id=openstack_subnet.network_id,
390390
cidr=openstack_subnet.cidr,
391391
ip_version=openstack_subnet.ip_version,
392392
gateway_ip=openstack_subnet.gateway_ip,
393-
is_dhcp_enabled=openstack_subnet.enable_dhcp,
394-
allocation_pools=openstack_subnet.allocation_pools,
395-
dns_nameservers=openstack_subnet.dns_nameservers,
396-
host_routes=openstack_subnet.host_routes,
393+
is_dhcp_enabled=openstack_subnet.is_dhcp_enabled,
394+
allocation_pools=getattr(
395+
openstack_subnet, "allocation_pools", None
396+
),
397+
dns_nameservers=getattr(openstack_subnet, "dns_nameservers", None),
398+
host_routes=getattr(openstack_subnet, "host_routes", None),
397399
)
398400

399401
def get_ports(

tests/tools/test_network_tools.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,7 @@ def test_get_subnets_filters_and_has_gateway_true(
815815
subnet1.ip_version = 4
816816
subnet1.gateway_ip = "10.0.0.1"
817817
subnet1.enable_dhcp = True
818+
subnet1.is_dhcp_enabled = True
818819
subnet1.allocation_pools = []
819820
subnet1.dns_nameservers = []
820821
subnet1.host_routes = []
@@ -830,6 +831,7 @@ def test_get_subnets_filters_and_has_gateway_true(
830831
subnet2.ip_version = 4
831832
subnet2.gateway_ip = None
832833
subnet2.enable_dhcp = False
834+
subnet2.is_dhcp_enabled = False
833835
subnet2.allocation_pools = []
834836
subnet2.dns_nameservers = []
835837
subnet2.host_routes = []
@@ -888,6 +890,7 @@ def test_get_subnets_has_gateway_false(
888890
subnet1.ip_version = 4
889891
subnet1.gateway_ip = "10.0.0.1"
890892
subnet1.enable_dhcp = True
893+
subnet1.is_dhcp_enabled = True
891894
subnet1.allocation_pools = []
892895
subnet1.dns_nameservers = []
893896
subnet1.host_routes = []
@@ -903,6 +906,7 @@ def test_get_subnets_has_gateway_false(
903906
subnet2.ip_version = 4
904907
subnet2.gateway_ip = None
905908
subnet2.enable_dhcp = False
909+
subnet2.is_dhcp_enabled = False
906910
subnet2.allocation_pools = []
907911
subnet2.dns_nameservers = []
908912
subnet2.host_routes = []
@@ -935,6 +939,7 @@ def test_create_subnet_success(
935939
subnet.ip_version = 4
936940
subnet.gateway_ip = "10.0.0.1"
937941
subnet.enable_dhcp = True
942+
subnet.is_dhcp_enabled = True
938943
subnet.allocation_pools = [{"start": "10.0.0.10", "end": "10.0.0.20"}]
939944
subnet.dns_nameservers = ["8.8.8.8"]
940945
subnet.host_routes = []
@@ -989,6 +994,7 @@ def test_get_subnet_detail_success(
989994
subnet.ip_version = 4
990995
subnet.gateway_ip = "10.0.0.1"
991996
subnet.enable_dhcp = True
997+
subnet.is_dhcp_enabled = True
992998
subnet.allocation_pools = []
993999
subnet.dns_nameservers = []
9941000
subnet.host_routes = []
@@ -1018,6 +1024,7 @@ def test_update_subnet_success(
10181024
subnet.ip_version = 4
10191025
subnet.gateway_ip = "10.0.0.254"
10201026
subnet.enable_dhcp = False
1027+
subnet.is_dhcp_enabled = False
10211028
subnet.allocation_pools = []
10221029
subnet.dns_nameservers = []
10231030
subnet.host_routes = []
@@ -1078,6 +1085,7 @@ def test_set_and_clear_subnet_gateway(
10781085
updated.ip_version = 4
10791086
updated.gateway_ip = "10.0.0.254"
10801087
updated.enable_dhcp = True
1088+
updated.is_dhcp_enabled = True
10811089
updated.allocation_pools = []
10821090
updated.dns_nameservers = []
10831091
updated.host_routes = []
@@ -1109,6 +1117,7 @@ def test_set_and_toggle_subnet_dhcp(
11091117
updated.ip_version = 4
11101118
updated.gateway_ip = "10.0.0.1"
11111119
updated.enable_dhcp = True
1120+
updated.is_dhcp_enabled = True
11121121
updated.allocation_pools = []
11131122
updated.dns_nameservers = []
11141123
updated.host_routes = []
@@ -1120,6 +1129,7 @@ def test_set_and_toggle_subnet_dhcp(
11201129
assert res1.is_dhcp_enabled is True
11211130

11221131
updated.enable_dhcp = False
1132+
updated.is_dhcp_enabled = False
11231133
res2 = tools.update_subnet("subnet-1", is_dhcp_enabled=False)
11241134
assert res2.is_dhcp_enabled is False
11251135

0 commit comments

Comments
 (0)