Exemple #1
0
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;
}
Exemple #2
0
///////////////////////////////////////////////////////////////////////////////
// CMirDiskUIHandler
///////////////////////////////////////////////////////////////////////////////
UINT CMirDiskUIHandler::GetIconID(CDiskObjectPtr obj) const
{
	ATLASSERT( dynamic_cast<const CMirDiskObject*>(obj.get()) != NULL );
	CMirDiskObjectPtr mirDisk = 
		boost::dynamic_pointer_cast<CMirDiskObject>(obj);

	if ( mirDisk->IsBroken() )
	{
		return IDI_NDMIRR_BROKEN;
	}
	else
	{
		return IDI_NDMIRR_OK;
	}
}
Exemple #3
0
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;
}
Exemple #4
0
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;
}