-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Add get_attachment_details tool #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ | |
|
|
||
| from openstack_mcp_server.tools.block_storage_tools import BlockStorageTools | ||
| from openstack_mcp_server.tools.response.block_storage import ( | ||
| Attachment, | ||
| ConnectionInfo, | ||
| Volume, | ||
| VolumeAttachment, | ||
| ) | ||
|
|
@@ -614,7 +616,7 @@ def test_register_tools(self): | |
| block_storage_tools.register_tools(mock_mcp) | ||
|
|
||
| # Verify mcp.tool() was called for each method | ||
| assert mock_mcp.tool.call_count == 5 | ||
| assert mock_mcp.tool.call_count == 6 | ||
|
||
|
|
||
| # Verify all methods were registered | ||
| registered_methods = [ | ||
|
|
@@ -683,3 +685,62 @@ def test_all_block_storage_methods_have_docstrings(self): | |
| assert len(docstring.strip()) > 0, ( | ||
| f"{method_name} docstring should not be empty" | ||
| ) | ||
|
|
||
| def test_get_attachment_details( | ||
| self, mock_get_openstack_conn_block_storage | ||
| ): | ||
| """Test getting attachment details.""" | ||
|
|
||
| # Set up the attachment mock object | ||
| mock_attachment = Mock() | ||
| mock_attachment.id = "attach-123" | ||
| mock_attachment.instance = "server-123" | ||
| mock_attachment.volume_id = "vol-123" | ||
| mock_attachment.attached_at = "2024-01-01T12:00:00Z" | ||
| mock_attachment.detached_at = None | ||
| mock_attachment.attach_mode = "attach" | ||
| mock_attachment.connection_info = { | ||
| "access_mode": "rw", | ||
| "cacheable": True, | ||
| "driver_volume_type": "iscsi", | ||
| "encrypted": False, | ||
| "qos_specs": None, | ||
| "target_discovered": True, | ||
| "target_iqn": "iqn.2024-01-01.com.example:volume-123", | ||
| "target_lun": 0, | ||
| "target_portal": "192.168.1.100:3260", | ||
| } | ||
| mock_attachment.connector = "connector-123" | ||
|
|
||
| # Configure the mock block_storage.get_attachment() | ||
| mock_conn = mock_get_openstack_conn_block_storage | ||
| mock_conn.block_storage.get_attachment.return_value = mock_attachment | ||
|
|
||
| block_storage_tools = BlockStorageTools() | ||
| result = block_storage_tools.get_attachment_details("attach-123") | ||
|
|
||
| # Verify the result | ||
| assert isinstance(result, Attachment) | ||
| assert result.id == "attach-123" | ||
| assert result.instance == "server-123" | ||
| assert result.attached_at == "2024-01-01T12:00:00Z" | ||
| assert result.detached_at is None | ||
| assert result.attach_mode == "attach" | ||
| assert result.connection_info == ConnectionInfo( | ||
| access_mode="rw", | ||
| cacheable=True, | ||
| driver_volume_type="iscsi", | ||
| encrypted=False, | ||
| qos_specs=None, | ||
| target_discovered=True, | ||
| target_iqn="iqn.2024-01-01.com.example:volume-123", | ||
| target_lun=0, | ||
| target_portal="192.168.1.100:3260", | ||
| ) | ||
| assert result.connector == "connector-123" | ||
| assert result.volume_id == "vol-123" | ||
|
|
||
| # Verify the mock calls | ||
| mock_conn.block_storage.get_attachment.assert_called_once_with( | ||
| "attach-123" | ||
| ) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auth 관련 필드정보가 필터링 되어야하는 이유가 있을까요?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@halucinor
auth_* 부분( auth_mehtod, auth_username, auth_password)을 필터링한 이유는 cinder에 접근하기 위한 중요한 인증 정보이기 때문입니다.
auth_method=CHAP인 경우를 예로 들자면 Cinder에서 볼륨을 attach할때 컴퓨트 노드는 해당 계정을 활용하여 target에 대한 로그인을 수행하고, target은 이를 검증하여 허용된 initiator만 세션을 주고받게 됩니다. (참고)
하지만 이러한 인증 정보가 노출되면 cinder에 대한 무단 접근이 가능해집니다. 이는 데이터 탈취와 같은 심각한 보안 문제가 발생할 수 있습니다.
개인적인 이유로, mcp서버가 관리자 등 다양한 사용자를 대상으로 한다고 할지라도 인증 정보 필터링등 최소한의 안전 장치는 마련해야 한다고 생각합니다.