PropertyList CMirDiskUIHandler::GetPropertyList(CDiskObjectPtr obj) const { PropertyList propList; PropertyListItem propItem; WTL::CString strBuffer; CMirDiskObjectPtr mirDisk = boost::dynamic_pointer_cast<CMirDiskObject>(obj); propItem.strName.LoadString( IDS_UIHANDLER_PROPERTY_DIRTY ); if ( mirDisk->IsDirty() ) propItem.strValue.LoadString( IDS_UIHANDLER_PROPERTY_DIRTY_TRUE ); else propItem.strValue.LoadString( IDS_UIHANDLER_PROPERTY_DIRTY_FALSE ); propItem.strToolTip.LoadString( IDS_UIHANDLER_PROPERTY_DIRTY_TOOLTIP ); propList.push_back( propItem ); return propList; }
CCommandSet CMirDiskUIHandler::GetCommandSet(CDiskObjectPtr obj) const { ATLASSERT( dynamic_cast<const CMirDiskObject*>(obj.get()) != NULL ); CCommandSet setCommand; BOOL bCanWrite; CMirDiskObjectPtr mirDisk = boost::dynamic_pointer_cast<CMirDiskObject>(obj); bCanWrite = mirDisk->GetAccessMask() & GENERIC_WRITE; setCommand.push_back( CCommand( IDM_TOOL_UNBIND, bCanWrite ) ); if(NMT_MIRROR == mirDisk->GetNDASMediaType()) { // migrate : mirror -> RAID 1 setCommand.push_back( CCommand( IDM_TOOL_MIGRATE, !mirDisk->IsBroken() && mirDisk->HasWriteAccess())); } else { // do not check IsDirty here (cause it takes some time) setCommand.push_back( CCommand( IDM_TOOL_SYNCHRONIZE, /* bCanWrite && */ mirDisk->IsDirty() && !mirDisk->IsBroken() && mirDisk->HasWriteAccess())); } return setCommand; }
WTL::CString CObjectUIHandler::GetFaultTolerance(CDiskObjectPtr obj) const { WTL::CString strTitle; strTitle = _T(""); if(obj->IsUnitDisk()) { if((dynamic_cast<CEmptyDiskObject*>(obj.get()) == NULL)) { CDiskObjectPtr parent; CUnitDiskObjectPtr pUnitDiskObject = boost::dynamic_pointer_cast<CUnitDiskObject>(obj); if(!(parent = pUnitDiskObject->GetParent())->IsRoot()) { CDiskObjectCompositePtr pDiskObjectComposite = boost::dynamic_pointer_cast<CDiskObjectComposite>(parent); if (NMT_RAID4 == pDiskObjectComposite->GetNDASMediaType()) { UINT8 child_status = pDiskObjectComposite->RMDUnitStatus(pUnitDiskObject->GetLocation()->GetUnitDiskLocation()); if(NDAS_UNIT_META_BIND_STATUS_FAULT & child_status) { strTitle.LoadString(IDS_FT_FAULT_CHILD); } else if(NDAS_UNIT_META_BIND_STATUS_SPARE & child_status) { strTitle.LoadString(IDS_FT_FAULT_SPARE); } } } else { strTitle.LoadString(IDS_FT_UNIT); } } } else { CDiskObjectCompositePtr pDiskObjectComposite = boost::dynamic_pointer_cast<CDiskObjectComposite>(obj); // check missing member if(pDiskObjectComposite->IsBroken()) { strTitle.LoadString(IDS_FT_MISSING); } else { switch(pDiskObjectComposite->GetNDASMediaType()) { case NMT_AGGREGATE: case NMT_RAID0: case NMT_MIRROR: if(pDiskObjectComposite->IsBroken()) strTitle.LoadString(IDS_FT_MISSING); else strTitle.LoadString(IDS_FT_NOT_FAULT_TOLERANT); break; case NMT_RAID1: { CMirDiskObjectPtr pMirDiskObject = boost::dynamic_pointer_cast<CMirDiskObject>(pDiskObjectComposite); if(pMirDiskObject->IsBroken()) strTitle.LoadString(IDS_FT_NEED_REPAIR); else if(pMirDiskObject->IsDirty()) strTitle.LoadString(IDS_FT_DIRTY); else strTitle.LoadString(IDS_FT_FAULT_TOLERANT); } break; case NMT_RAID4: { CRAID4DiskObjectPtr pRAID4DiskObject = boost::dynamic_pointer_cast<CRAID4DiskObject>(pDiskObjectComposite); if(pRAID4DiskObject->IsBroken()) { strTitle.LoadString(IDS_FT_NEED_REPAIR); } else { switch(pDiskObjectComposite->RMDStatus()) { case 0: strTitle.LoadString(IDS_FT_FAULT_TOLERANT); break; case 1: strTitle.LoadString(IDS_FT_DIRTY); break; case 2: strTitle.LoadString(IDS_FT_FAULT); break; case 3: strTitle.LoadString(IDS_FT_IN_SYNC); break; default: break; } } } break; default: break; } } } return strTitle; }
CCommandSet CUnitDiskUIHandler::GetCommandSet(CDiskObjectPtr obj) const { ATLASSERT( dynamic_cast<CUnitDiskObject*>(obj.get()) != NULL); CCommandSet setCommand; CUnitDiskObjectPtr unitDisk = boost::dynamic_pointer_cast<CUnitDiskObject>(obj); CUnitDiskInfoHandlerPtr handler = unitDisk->GetInfoHandler(); BOOL bCanWrite; if ( handler->IsBound() ) { CDiskObjectPtr aggrRoot = unitDisk->GetParent(); if ( aggrRoot->IsRoot() ) { // This can occur when the tree is updated just after // the disk is bound. // This additional if code prevents error. setCommand.push_back( CCommand(IDM_TOOL_UNBIND) ); } else { while ( !aggrRoot->GetParent()->IsRoot() ) aggrRoot = aggrRoot->GetParent(); // To Unbind, we should have write privilege to all the disks in bind setCommand.push_back( CCommand(IDM_TOOL_UNBIND, aggrRoot->GetAccessMask() & GENERIC_WRITE) ); } } else { bCanWrite = unitDisk->GetAccessMask() & GENERIC_WRITE; setCommand.push_back( CCommand(IDM_TOOL_ADDMIRROR, bCanWrite) ); } if ( handler->IsMirrored() ) { CMirDiskObjectPtr parent = boost::dynamic_pointer_cast<CMirDiskObject>(unitDisk->GetParent()); if ( parent.get() != NULL ) { // To synchronize, we have write privilege to the two disks in mirroring setCommand.push_back( CCommand(IDM_TOOL_SYNCHRONIZE, (parent->GetAccessMask() & GENERIC_WRITE) && parent->IsDirty() && !parent->IsBroken() && parent->HasWriteAccess() ) ); } CDiskObjectPtr aggrRoot = unitDisk->GetParent(); if ( aggrRoot->IsRoot() ) { // This can occur when the tree is updated just after // the disk is bound. // This additional if code prevents error. setCommand.push_back( CCommand(IDM_TOOL_UNBIND) ); } else { while ( !aggrRoot->GetParent()->IsRoot() ) aggrRoot = aggrRoot->GetParent(); } } else if(NMT_RAID4 == handler->GetNDASMediaType()) { CRAID4DiskObjectPtr parent = boost::dynamic_pointer_cast<CRAID4DiskObject>(unitDisk->GetParent()); if ( parent.get() != NULL ) { // To synchronize, we have write privilege to the two disks in mirroring setCommand.push_back( CCommand(IDM_TOOL_SYNCHRONIZE, (parent->GetAccessMask() & GENERIC_WRITE) && parent->IsDirty() && !parent->IsBroken() ) ); } } if(unitDisk->IsUnitDisk()) { setCommand.push_back( CCommand(IDM_TOOL_SINGLE) ); } return setCommand; }