Skip to content

Commit a2394d3

Browse files
committed
fix(block): Change response object to Attachment in a get_attchments tool(#84)
1 parent ff266b0 commit a2394d3

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/openstack_mcp_server/tools/block_storage_tools.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from .base import get_openstack_conn
44
from .response.block_storage import (
55
Attachment,
6-
AttachmentSummary,
76
ConnectionInfo,
87
Volume,
98
VolumeAttachment,
@@ -251,11 +250,16 @@ def get_attachments(
251250
attachments = []
252251
for attachment in conn.block_storage.attachments(**filter):
253252
attachments.append(
254-
AttachmentSummary(
253+
Attachment(
255254
id=attachment.id,
256255
instance=attachment.instance,
257256
volume_id=attachment.volume_id,
258257
status=attachment.status,
258+
connection_info=attachment.connection_info,
259+
attach_mode=attachment.attach_mode,
260+
connector=attachment.connector,
261+
attached_at=attachment.attached_at,
262+
detached_at=attachment.detached_at,
259263
)
260264
)
261265

src/openstack_mcp_server/tools/response/block_storage.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,3 @@ class Attachment(BaseModel):
4242
attach_mode: str | None = None
4343
connection_info: ConnectionInfo | None = None
4444
connector: str | None = None
45-
46-
47-
class AttachmentSummary(BaseModel):
48-
id: str
49-
instance: str
50-
volume_id: str
51-
status: str

tests/tools/test_block_storage_tools.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,11 @@ def test_get_attachments(self, mock_get_openstack_conn_block_storage):
752752
mock_attachment.instance = "server-123"
753753
mock_attachment.volume_id = "vol-123"
754754
mock_attachment.status = "attached"
755+
mock_attachment.connection_info = None
756+
mock_attachment.connector = None
757+
mock_attachment.attach_mode = None
758+
mock_attachment.attached_at = None
759+
mock_attachment.detached_at = None
755760

756761
mock_conn.block_storage.attachments.return_value = [mock_attachment]
757762

@@ -770,7 +775,11 @@ def test_get_attachments(self, mock_get_openstack_conn_block_storage):
770775
assert result[0].id == "attach-123"
771776
assert result[0].instance == "server-123"
772777
assert result[0].volume_id == "vol-123"
773-
assert result[0].status == "attached"
778+
assert result[0].attached_at is None
779+
assert result[0].detached_at is None
780+
assert result[0].attach_mode is None
781+
assert result[0].connection_info is None
782+
assert result[0].connector is None
774783

775784
# Verify the mock calls
776785
mock_conn.block_storage.attachments.assert_called_once_with(**filter)

0 commit comments

Comments
 (0)