Skip to content

Commit 4bdb73f

Browse files
committed
cluster_status() 정보 강화
✅ Volume backup 정보 (백업 개수, 상태, 크기) ✅ Volume snapshots 모니터링 (스냅샷 상태별 분류) ✅ Volume 특성 분석 (bootable, encrypted, multiattach) ✅ Volume types 현황 (스토리지 성능 정보) ✅ 통합 스토리지 요약 (전체 스토리지 사용량) ✅ Attachment 세부 현황 (연결 상태 분석)
1 parent cac4608 commit 4bdb73f

File tree

1 file changed

+88
-3
lines changed
  • src/mcp_openstack_ops/services

1 file changed

+88
-3
lines changed

src/mcp_openstack_ops/services/core.py

Lines changed: 88 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,23 +225,99 @@ def get_cluster_status() -> Dict[str, Any]:
225225
'port_states': port_states
226226
}
227227

228-
# Volume resources
228+
# Volume resources (enhanced with backup information and detailed volume analysis)
229229
volumes = list(conn.volume.volumes())
230230
snapshots = list(conn.volume.snapshots())
231231

232-
# Analyze volume states
232+
# Analyze volume states and characteristics
233233
volume_states = {}
234234
total_volume_size = 0
235+
bootable_volumes = 0
236+
encrypted_volumes = 0
237+
multiattach_volumes = 0
238+
attached_volumes = 0
239+
volume_attachments = []
240+
235241
for volume in volumes:
236242
state = getattr(volume, 'status', 'UNKNOWN').upper()
237243
volume_states[state] = volume_states.get(state, 0) + 1
238244
total_volume_size += getattr(volume, 'size', 0)
245+
246+
# Track volume characteristics
247+
if getattr(volume, 'is_bootable', False):
248+
bootable_volumes += 1
249+
if getattr(volume, 'encrypted', False):
250+
encrypted_volumes += 1
251+
if getattr(volume, 'multiattach', False):
252+
multiattach_volumes += 1
253+
254+
# Track attachments
255+
attachments = getattr(volume, 'attachments', [])
256+
if attachments:
257+
attached_volumes += 1
258+
volume_attachments.extend(attachments)
259+
260+
# Get volume snapshots with state analysis
261+
snapshot_states = {}
262+
total_snapshot_size = 0
263+
for snapshot in snapshots:
264+
state = getattr(snapshot, 'status', 'UNKNOWN').upper()
265+
snapshot_states[state] = snapshot_states.get(state, 0) + 1
266+
total_snapshot_size += getattr(snapshot, 'size', 0)
267+
268+
# Get volume types information
269+
volume_types = []
270+
try:
271+
from ..services.storage import get_volume_types
272+
volume_types = get_volume_types()
273+
except Exception as e:
274+
logger.warning(f"Could not retrieve volume types: {e}")
275+
276+
# Get volume backup information
277+
backups = []
278+
backup_states = {}
279+
total_backup_size = 0
280+
try:
281+
from ..services.storage import set_volume_backups
282+
backup_result = set_volume_backups('list')
283+
if backup_result.get('success'):
284+
backups = backup_result.get('backups', [])
285+
# Analyze backup states and sizes
286+
for backup in backups:
287+
state = backup.get('status', 'UNKNOWN').upper()
288+
backup_states[state] = backup_states.get(state, 0) + 1
289+
total_backup_size += backup.get('size', 0)
290+
else:
291+
logger.warning("Volume backup service not available")
292+
except Exception as e:
293+
logger.warning(f"Could not retrieve backup information: {e}")
239294

240295
status_data['resources']['volume'] = {
241296
'volumes': len(volumes),
242297
'snapshots': len(snapshots),
243298
'volume_states': volume_states,
244-
'total_size_gb': total_volume_size
299+
'snapshot_states': snapshot_states,
300+
'total_size_gb': total_volume_size,
301+
'total_snapshot_size_gb': total_snapshot_size,
302+
'backups': len(backups),
303+
'backup_states': backup_states,
304+
'total_backup_size_gb': total_backup_size,
305+
'volume_characteristics': {
306+
'bootable_volumes': bootable_volumes,
307+
'encrypted_volumes': encrypted_volumes,
308+
'multiattach_volumes': multiattach_volumes,
309+
'attached_volumes': attached_volumes,
310+
'available_volumes': volume_states.get('AVAILABLE', 0),
311+
'in_use_volumes': volume_states.get('IN-USE', 0),
312+
'total_attachments': len(volume_attachments)
313+
},
314+
'volume_types_available': len(volume_types),
315+
'storage_summary': {
316+
'total_storage_gb': total_volume_size + total_snapshot_size + total_backup_size,
317+
'volumes_gb': total_volume_size,
318+
'snapshots_gb': total_snapshot_size,
319+
'backups_gb': total_backup_size
320+
}
245321
}
246322

247323
# Image resources (enhanced)
@@ -657,6 +733,14 @@ def get_cluster_status() -> Dict[str, Any]:
657733
'gigabytes': {
658734
'used': total_volume_size,
659735
'limit': getattr(volume_quotas, 'gigabytes', -1)
736+
},
737+
'backups': {
738+
'used': len(backups),
739+
'limit': getattr(volume_quotas, 'backups', -1)
740+
},
741+
'backup_gigabytes': {
742+
'used': total_backup_size,
743+
'limit': getattr(volume_quotas, 'backup_gigabytes', -1)
660744
}
661745
}
662746
}
@@ -822,6 +906,7 @@ def get_cluster_status() -> Dict[str, Any]:
822906
'total_instances': status_data['resources']['compute'].get('instances', 0),
823907
'total_networks': status_data['resources']['network'].get('networks', 0),
824908
'total_volumes': status_data['resources']['volume'].get('volumes', 0),
909+
'total_backups': status_data['resources']['volume'].get('backups', 0),
825910
'total_images': status_data['resources']['image'].get('images', 0),
826911
'total_floating_ips': status_data['resources']['network'].get('floating_ips', 0),
827912
'health_status': overall_health,

0 commit comments

Comments
 (0)