Beispiel #1
0
void CMainFrame::OnSpareAdd(UINT wNotifyCode, int wID, HWND hwndCtl)
{
	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	if(!pDevice->GetCommandAbility(wID))
		return;

	CNBLogicalDevice *pLogicalDevice = dynamic_cast<CNBLogicalDevice *>(pDevice);
	if(!pLogicalDevice || !pLogicalDevice->IsOperatableAll())
		return;

	CNBSelectDeviceDlg dlgSelectDevice(
		IDD_DEVICE_LIST, 
		IDS_SPARE_ADD_DLG_CAPTION, 
		IDS_SPARE_ADD_DLG_MESSAGE, 
		GetOperatableSingleDevices(), 
		1, 
		CheckCapacityForSpare, 
		pLogicalDevice);

	if(dlgSelectDevice.DoModal() != IDOK)
		return;

	CNBUnitDevice *pUnitDevice = dlgSelectDevice.GetSelectedDevice();

	// Bind & Synchronize 
	NDASCOMM_CONNECTION_INFO ci, ci_spare;
	(*pLogicalDevice)[0]->InitConnectionInfo(&ci, TRUE);
	pUnitDevice->InitConnectionInfo(&ci_spare, TRUE);

	AutoCursor l_auto_cursor(IDC_WAIT);
	BOOL bResults = NdasOpSpareAdd(
		&ci, &ci_spare);
	l_auto_cursor.Release();

	pLogicalDevice->HixChangeNotify(pGetNdasHostGuid());
	pUnitDevice->HixChangeNotify(pGetNdasHostGuid());

	if(!bResults)
	{
		CString strMsg;

		DWORD dwLastError = ::GetLastError();

		strMsg.LoadString(IDS_OPERATION_FAIL);

		ShowErrorMessageBox(strMsg);

		return;
	}

	OnRefreshStatus(NULL, NULL, NULL);
}
Beispiel #2
0
void CMainFrame::OnSpareRemove(UINT wNotifyCode, int wID, HWND hwndCtl)
{
	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	if(!pDevice->GetCommandAbility(wID))
		return;

	CNBUnitDevice *pUnitDevice = dynamic_cast<CNBUnitDevice *>(pDevice);
	if(!pUnitDevice || !pUnitDevice->GetLogicalDevice()->IsOperatableAll())
		return;

	NBUnitDevicePtrList listUnitDevices;
	listUnitDevices.push_back(pUnitDevice);

	CNBSelectDeviceDlg dlgSelectDevice(
		IDD_DEVICE_LIST, 
		IDS_SPARE_REMOVE_DLG_CAPTION, 
		IDS_SPARE_REMOVE_DLG_MESSAGE, 
		listUnitDevices, 
		0, 
		NULL, 
		NULL);

	if(dlgSelectDevice.DoModal() != IDOK)
		return;

	NDASCOMM_CONNECTION_INFO ci;
	pUnitDevice->InitConnectionInfo(&ci, TRUE);

	AutoCursor l_auto_cursor(IDC_WAIT);
	BOOL bResults = NdasOpSpareRemove(&ci);
	l_auto_cursor.Release();

	pUnitDevice->GetLogicalDevice()->HixChangeNotify(pGetNdasHostGuid());

	if(!bResults)
	{
		CString strMsg;

		DWORD dwLastError = ::GetLastError();

		strMsg.LoadString(IDS_OPERATION_FAIL);

		ShowErrorMessageBox(strMsg);

		return;
	}

	OnRefreshStatus(NULL, NULL, NULL);
}
Beispiel #3
0
void CMainFrame::OnRepair(UINT /*wNotifyCode*/, int /*wID*/, HWND /*hwndCtl*/)
{
#ifdef __NEVER_DEFINED__
	BOOL bResults;
	BOOL bReturn = FALSE;

	int iItemSelected = m_viewTreeList.GetSelectedItemData();
	if (-1 == iItemSelected)
	{
		
		return;
	}
	
	CDiskObjectPtr obj = m_mapObject[iItemSelected];


	if( dynamic_cast<CDiskObjectComposite *>(obj.get()) == NULL )
	{
		
		return;
	}

	CDiskObjectCompositePtr DiskObjectComposite =
		boost::dynamic_pointer_cast<CDiskObjectComposite>(obj);

	if(!((NMT_RAID1 == DiskObjectComposite->GetNDASMediaType() ||
		NMT_RAID4 == DiskObjectComposite->GetNDASMediaType()) &&
		1 == DiskObjectComposite->GetMissingMemberCount()))
	{
		
		// TODO : No disk is available
		CString strMsg;
		strMsg.LoadString( IDS_MAINFRAME_NOT_READY_REPAIR );
		CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox(
			strMsg,
			strTitle, 
			MB_OK | MB_ICONERROR
			);
		return;
	}		


	CSelectDiskDlg dlgSelect(IDD_REPAIR);
	CDiskObjectList singleDisks;
	CFindIfVisitor<FALSE> singleDiskFinder;
	singleDisks = singleDiskFinder.FindIf(m_pRoot, IsWritableUnitDisk);

	if ( singleDisks.size() == 0 )
	{
		
		// TODO : No disk is available
		CString strMsg;
		strMsg.LoadString( IDS_MAINFRAME_NO_DISK_REPAIR );
		CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox(
			strMsg,
			strTitle, 
			MB_OK | MB_ICONWARNING
			);
		return;
	}

	dlgSelect.SetSingleDisks(singleDisks);

	if ( dlgSelect.DoModal() != IDOK )
		return;

	CUnitDiskObjectPtr replaceDisk, sourceDisk;
	sourceDisk = DiskObjectComposite->GetAvailableUnitDisk();
	replaceDisk = dlgSelect.GetSelectedDisk();

	if(NULL == sourceDisk.get())
		return;
	
	NDASCOMM_CONNECTION_INFO ci, ciReplace;

	ZeroMemory(&ci, sizeof(NDASCOMM_CONNECTION_INFO));
	ci.Size = sizeof(NDASCOMM_CONNECTION_INFO);
	ci.AddressType = NDASCOMM_CIT_DEVICE_ID;
	ci.LoginType = NDASCOMM_LOGIN_TYPE_NORMAL;
	ci.UnitNo = sourceDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
	ci.WriteAccess = TRUE;
	ci.Protocol = NDASCOMM_TRANSPORT_LPX;
	CopyMemory(
		ci.DeviceId.Node, 
		sourceDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
		sizeof(ci.DeviceId.Node));

	ZeroMemory(&ciReplace, sizeof(NDASCOMM_CONNECTION_INFO));
	ciReplace.Size = sizeof(NDASCOMM_CONNECTION_INFO);
	ciReplace.AddressType = NDASCOMM_CIT_DEVICE_ID;
	ciReplace.LoginType = NDASCOMM_LOGIN_TYPE_NORMAL;
	ciReplace.UnitNo = replaceDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
	ciReplace.WriteAccess = TRUE;
	ciReplace.Protocol = NDASCOMM_TRANSPORT_LPX;
	CopyMemory(
		ciReplace.DeviceId.Node,
		replaceDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
		sizeof(ciReplace.DeviceId.Node));

	AutoCursor l_auto_cursor(IDC_WAIT);
	bResults = NdasOpRepair(&ci, &ciReplace);
	l_auto_cursor.Release();

	if(!bResults)
	{
		CString strMsg;

		DWORD dwLastError = ::GetLastError();
		strMsg.LoadString(IDS_REPAIR_FAIL);

		ShowErrorMessageBox(strMsg);

		return;
	}

	CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid());
	bResults = HixChangeNotify.Initialize();
	if(bResults)
	{
		CUnitDiskObjectPtr UnitDiskObjectPtr;
		NDAS_UNITDEVICE_ID unitDeviceId;

		CDiskObjectComposite::const_iterator itr;
		for ( itr = DiskObjectComposite->begin(); itr != DiskObjectComposite->end(); ++itr )
		{
			if((dynamic_cast<CEmptyDiskObject*>((*itr).get()) != NULL))
				continue;

			UnitDiskObjectPtr = 
				boost::dynamic_pointer_cast<CUnitDiskObject>(*itr);

			CopyMemory(unitDeviceId.DeviceId.Node, 
				UnitDiskObjectPtr->GetLocation()->GetUnitDiskLocation()->MACAddr, 
				sizeof(unitDeviceId.DeviceId.Node));
			unitDeviceId.UnitNo = 
				UnitDiskObjectPtr->GetLocation()->GetUnitDiskLocation()->UnitNumber;
			HixChangeNotify.Notify(unitDeviceId);
		}

		CopyMemory(unitDeviceId.DeviceId.Node, 
			replaceDisk->GetLocation()->GetUnitDiskLocation()->MACAddr, 
			sizeof(unitDeviceId.DeviceId.Node));
		unitDeviceId.UnitNo = 
			replaceDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
		HixChangeNotify.Notify(unitDeviceId);
	}


	CRecoverDlg dlgRecover(
		TRUE, 
        (NMT_RAID1 == DiskObjectComposite->GetNDASMediaType()) ?
		IDS_LOGDEV_TYPE_DISK_RAID1 : IDS_LOGDEV_TYPE_DISK_RAID4,
		IDS_RECOVERDLG_TASK_REPAIR);

	dlgRecover.SetMemberDevice(sourceDisk);
	dlgRecover.DoModal();

	OnRefreshStatus(NULL, NULL, NULL);
#endif
	
	return;
}
Beispiel #4
0
void CMainFrame::OnUnBind(UINT wNotifyCode, int wID, HWND hwndCtl)
{
	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	if(!pDevice->GetCommandAbility(wID))
		return;

	CNBLogicalDevice *pLogicalDevice = dynamic_cast<CNBLogicalDevice *>(pDevice);
	if(!pLogicalDevice)
		return;

	BOOL bUnbindMirror = 
		(NMT_RAID1 == pLogicalDevice->GetType() ||
		NMT_RAID1R == pLogicalDevice->GetType() ||
		NMT_MIRROR == pLogicalDevice->GetType());

	// warning message
	CString strMsg;

	NBUnitDevicePtrList listUnitDevices = pLogicalDevice->GetOperatableDevices();
	CNBSelectDeviceDlg dlgSelectDevice(
		IDD_DEVICE_LIST, 
		IDS_UNBIND_DLG_CAPTION, 
		(bUnbindMirror) ? IDS_WARNING_UNBIND_MIR : IDS_WARNING_UNBIND, 
		listUnitDevices, 
		0, 
		NULL, 
		NULL);

	if(dlgSelectDevice.DoModal() != IDOK)
		return;

	NDASCOMM_CONNECTION_INFO *ci = new NDASCOMM_CONNECTION_INFO[listUnitDevices.size()];

	UINT32 i = 0;

	for(NBUnitDevicePtrList::iterator itUnitDevice = listUnitDevices.begin();
		itUnitDevice != listUnitDevices.end(); i++, itUnitDevice++)
	{
		(*itUnitDevice)->InitConnectionInfo(&ci[i], TRUE);
	}


	AutoCursor l_auto_cursor(IDC_WAIT);
	UINT32 BindResult = NdasOpBind(listUnitDevices.size(), ci, NMT_SINGLE, 0);
	l_auto_cursor.Release();

	DWORD dwLastError = ::GetLastError();

	if(i == BindResult)
	{
		CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);

		strMsg.LoadString(
			(bUnbindMirror) ? IDS_WARNING_UNBIND_AFTER_MIR : 
		IDS_WARNING_UNBIND_AFTER);

		MessageBox(
			strMsg,
			strTitle,
			MB_OK|MB_ICONINFORMATION
			);
	}
	else
	{

		::SetLastError(dwLastError);

		switch(dwLastError)
		{
		case NDASCOMM_ERROR_RW_USER_EXIST:
		case NDASOP_ERROR_ALREADY_USED:
		case NDASOP_ERROR_DEVICE_FAIL:
		case NDASOP_ERROR_NOT_SINGLE_DISK:
		case NDASOP_ERROR_DEVICE_UNSUPPORTED:
		case NDASOP_ERROR_NOT_BOUND_DISK: // does not return this error
			if(BindResult < listUnitDevices.size())
			{
				i = 0;
				for(NBUnitDevicePtrList::iterator itUnitDevice = listUnitDevices.begin();
					itUnitDevice != listUnitDevices.end(); i++, itUnitDevice++)
				{
					if(i == BindResult)
						strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT, (*itUnitDevice)->GetName());
				}
				
			}
			else
				strMsg.LoadString(IDS_BIND_FAIL);
			break;
		default:
			strMsg.LoadString(IDS_BIND_FAIL);
			break;
		}
		ShowErrorMessageBox(IDS_MAINFRAME_SINGLE_ACCESS_FAIL);
	}

	for(NBUnitDevicePtrList::iterator itUnitDevice = listUnitDevices.begin();
		itUnitDevice != listUnitDevices.end(); i++, itUnitDevice++)
	{
		(*itUnitDevice)->HixChangeNotify(pGetNdasHostGuid());
	}

	delete [] ci;

	OnRefreshStatus(NULL, NULL, NULL);

	return;
}
Beispiel #5
0
void CMainFrame::OnSingle(UINT wNotifyCode, int wID, HWND hwndCtl)
{
	CString strMsg;

	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	if(!pDevice->GetCommandAbility(wID))
		return;

	CNBUnitDevice *pUnitDevice;
	if(dynamic_cast<CNBLogicalDevice *>(pDevice))
	{
		CNBLogicalDevice *pLogicalDevice = dynamic_cast<CNBLogicalDevice *>(pDevice);
		if(!pLogicalDevice || !pLogicalDevice->IsOperatableAll())
			return;

		pUnitDevice = (*pLogicalDevice)[0];
	}
	else
	{
		pUnitDevice = dynamic_cast<CNBUnitDevice *>(pDevice);
		if(!pUnitDevice || !pUnitDevice->IsOperatable())
			return;
	}

	if(!pUnitDevice)
		return;

	NBUnitDevicePtrList listUnitDevices;
	listUnitDevices.push_back(pUnitDevice);

	CNBSelectDeviceDlg dlgSelectDevice(
		IDD_DEVICE_LIST, 
		IDS_SINGLE_DLG_CAPTION, 
		IDS_SINGLE_DLG_MESSAGE, 
		listUnitDevices, 
		0, 
		NULL, 
		NULL);

	if(dlgSelectDevice.DoModal() != IDOK)
		return;


	NDASCOMM_CONNECTION_INFO ConnectionInfo;
	if(!pUnitDevice->InitConnectionInfo(&ConnectionInfo, TRUE))
	{
		
		// "%1!s! does not have a write access privilege. You need to set write key to this NDAS device before this action."
		strMsg.FormatMessage(IDS_ERROR_NOT_REGISTERD_WRITE_FMT,
			pUnitDevice->GetName()
			);
		CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox(
			strMsg,
			strTitle,
			MB_OK|MB_ICONERROR
			);

		return;
	}

	AutoCursor l_auto_cursor(IDC_WAIT);
	UINT32 BindResult = NdasOpBind(
		1,
		&ConnectionInfo,
		NMT_SINGLE,
		0);
	l_auto_cursor.Release();

	if(1 != BindResult)
	{
		DWORD dwLastError = ::GetLastError();

		switch(dwLastError)
		{
		case NDASCOMM_ERROR_RW_USER_EXIST:
		case NDASOP_ERROR_ALREADY_USED:
		case NDASOP_ERROR_DEVICE_FAIL:
		case NDASOP_ERROR_NOT_SINGLE_DISK:
		case NDASOP_ERROR_DEVICE_UNSUPPORTED:
		case NDASOP_ERROR_NOT_BOUND_DISK: // does not return this error
			strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT, pUnitDevice->GetName());
			break;
		default:
			strMsg.LoadString(IDS_BIND_FAIL);
			break;
		}

		ShowErrorMessageBox(strMsg);
	}

	pUnitDevice->HixChangeNotify(pGetNdasHostGuid());

	OnRefreshStatus(NULL, NULL, NULL);
}
Beispiel #6
0
void CMainFrame::OnMigrate(UINT wNotifyCode, int wID, HWND hwndCtl)
{
	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	if(!pDevice->GetCommandAbility(wID))
		return;

	CNBLogicalDevice *pLogicalDevice = dynamic_cast<CNBLogicalDevice *>(pDevice);
	if(!pLogicalDevice)
		return;

	if (NMT_MIRROR != pLogicalDevice->GetType() &&
		NMT_RAID1 != pLogicalDevice->GetType() &&
		NMT_RAID4 != pLogicalDevice->GetType())
		return;

	// warning message
	CString strMsg;

	NBUnitDevicePtrList listUnitDevices = pLogicalDevice->GetOperatableDevices();
	CNBSelectDeviceDlg dlgSelectDevice(
		IDD_DEVICE_LIST, 
		IDS_MIGRATE_DLG_CAPTION, 
		IDS_MIGRATE_DLG_MESSAGE, 
		listUnitDevices, 
		0, 
		NULL, 
		NULL);

	if(dlgSelectDevice.DoModal() != IDOK)
		return;

	NDASCOMM_CONNECTION_INFO *ci = new NDASCOMM_CONNECTION_INFO[listUnitDevices.size()];

	UINT32 i = 0;

	for(NBUnitDevicePtrList::iterator itUnitDevice = listUnitDevices.begin();
		itUnitDevice != listUnitDevices.end(); i++, itUnitDevice++)
	{
		(*itUnitDevice)->InitConnectionInfo(&ci[i], TRUE);
	}


	AutoCursor l_auto_cursor(IDC_WAIT);
	BOOL bResult = NdasOpMigrate(&ci[0]);
	l_auto_cursor.Release();

	DWORD dwLastError = ::GetLastError();

	if(!bResult)
	{
		ShowErrorMessageBox(IDS_MAINFRAME_SINGLE_ACCESS_FAIL);
	}

	for(NBUnitDevicePtrList::iterator itUnitDevice = listUnitDevices.begin();
		itUnitDevice != listUnitDevices.end(); i++, itUnitDevice++)
	{
		(*itUnitDevice)->HixChangeNotify(pGetNdasHostGuid());
	}

	delete [] ci;

	OnRefreshStatus(NULL, NULL, NULL);

	return;
}
Beispiel #7
0
BOOL CMainFrame::RefreshStatus()
{
	AutoCursor l_auto_cursor(IDC_WAIT);

	m_viewTreeList.GetTreeControl().DeleteAllItems();
	ClearDevices();

	// Initially, no commands are enabled
	//	UIEnableForDevice(pDevice, IDM_TOOL_BIND);
	UIEnableForDevice(NULL, IDM_TOOL_UNBIND);
	UIEnableForDevice(NULL, IDM_TOOL_ADDMIRROR);
	UIEnableForDevice(NULL, IDM_TOOL_MIGRATE);
	UIEnableForDevice(NULL, IDM_TOOL_REPLACE_DEVICE);
	UIEnableForDevice(NULL, IDM_TOOL_REPLACE_UNIT_DEVICE);
	UIEnableForDevice(NULL, IDM_TOOL_SINGLE);
	UIEnableForDevice(NULL, IDM_TOOL_SPAREADD);
	UIEnableForDevice(NULL, IDM_TOOL_SPAREREMOVE);

	UpdateWindow();

	// retrieve all the device & unit device information
	if(!NdasEnumDevices( EnumDevicesCallBack, reinterpret_cast<LPVOID>(&m_listDevices)))
	{
		return FALSE;
	}

	m_wndRefreshProgress.ShowWindow(SW_SHOW);
	m_wndRefreshProgress.SetRange32(0, m_listDevices.size());
	m_wndRefreshProgress.SetStep(1);
	m_wndRefreshProgress.SetPos(0);


	// initialize all the unit devices
	for(NBNdasDevicePtrList::iterator itDevice = m_listDevices.begin();
		itDevice != m_listDevices.end(); itDevice++)
	{
		if(!(*itDevice)->UnitDevicesInitialize())
		{
			// add single empty device
			ATLTRACE(_T("Device not connected : %s\n"), (*itDevice)->GetName());
//			m_wndRefreshProgress.ShowWindow(SW_HIDE);
//			return FALSE;
		}
		m_wndRefreshProgress.StepIt();
	}

	// create logical devices
	CNBUnitDevice *pUnitDevice;
	CNBLogicalDevice *pLogicalDevice;

	m_wndRefreshProgress.SetPos(0);
	for(NBNdasDevicePtrList::iterator itDevice = m_listDevices.begin();
		itDevice != m_listDevices.end(); itDevice++)
	{
		for(UINT32 i = 0; i < (*itDevice)->UnitDevicesCount(); i++)
		{
			// find logical device which has this unit device as member
			pLogicalDevice = NULL;
			pUnitDevice = (*(*itDevice))[i];
			ATLASSERT(pUnitDevice);
			if(!pUnitDevice)
				return FALSE;

			for(NBLogicalDevicePtrList::iterator itLogicalDevice = m_listLogicalDevices.begin();
				itLogicalDevice != m_listLogicalDevices.end(); itLogicalDevice++)
			{
				if((*itLogicalDevice)->IsMember(pUnitDevice))
				{
					// add to this logical device
					pLogicalDevice = *itLogicalDevice;
					ATLTRACE(_T("use CNBLogicalDevice(%p) : %s\n"), pLogicalDevice, pUnitDevice->GetName());
					break;
				}
			}

			if(NULL == pLogicalDevice)
			{
				// create new logical device
				pLogicalDevice = new CNBLogicalDevice();
				m_listLogicalDevices.push_back(pLogicalDevice);
				ATLTRACE(_T("new CNBLogicalDevice(%p) : %s\n"), pLogicalDevice, pUnitDevice->GetName());
			}

			if(!pLogicalDevice->UnitDeviceAdd(pUnitDevice))
			{
				m_wndRefreshProgress.ShowWindow(SW_HIDE);
				return FALSE;			
			}
		}

		m_wndRefreshProgress.StepIt();
	}

	m_viewTreeList.SetDevices(&m_listLogicalDevices);
	m_wndRefreshProgress.ShowWindow(SW_HIDE);
	
	return TRUE;
}
Beispiel #8
0
void CMainFrame::OnAddMirror(UINT wNotifyCode, int wID, HWND hwndCtl)
{
	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	if(!pDevice->GetCommandAbility(wID))
		return;

	CNBLogicalDevice *pLogicalDevice = dynamic_cast<CNBLogicalDevice *>(pDevice);
	if(!pLogicalDevice || pLogicalDevice->IsGroup())
		return;

	NBUnitDevicePtrList listUnitDevices = GetOperatableSingleDevices();
	// remove self
	listUnitDevices.remove((*pLogicalDevice)[0]);

	CNBSelectDeviceDlg dlgSelectDevice(
		IDD_DEVICE_LIST, 
		IDS_MIRROR_ADD_DLG_CAPTION, 
		IDS_MIRROR_ADD_DLG_MESSAGE, 
		listUnitDevices, 
		1, 
		CheckCapacityForMirror, 
		pLogicalDevice);

	if(dlgSelectDevice.DoModal() != IDOK)
		return;

	CNBUnitDevice *pUnitDeviceAdd = dlgSelectDevice.GetSelectedDevice();
	CNBUnitDevice *pUnitDevice = pUnitDevice = (*pLogicalDevice)[0];

	// Bind & Synchronize 
	NDASCOMM_CONNECTION_INFO ConnectionInfo[2];
	pUnitDevice->InitConnectionInfo(&ConnectionInfo[0], TRUE);
	pUnitDeviceAdd->InitConnectionInfo(&ConnectionInfo[1], TRUE);

	AutoCursor l_auto_cursor(IDC_WAIT);
	UINT32 BindResult = NdasOpBind(
		2,
		ConnectionInfo,
		NMT_SAFE_RAID1,
		0);
	l_auto_cursor.Release();

	if(2 != BindResult)
	{


		CString strMsg;

		DWORD dwLastError = ::GetLastError();

		switch(dwLastError)
		{
		case NDASCOMM_ERROR_RW_USER_EXIST:
		case NDASOP_ERROR_ALREADY_USED:
		case NDASOP_ERROR_DEVICE_FAIL:
		case NDASOP_ERROR_NOT_SINGLE_DISK:
		case NDASOP_ERROR_DEVICE_UNSUPPORTED:
			strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT, 
				(BindResult == 0) ? pUnitDevice->GetName() : pUnitDeviceAdd->GetName());
			break;
		default:
			strMsg.LoadString(IDS_BIND_FAIL);
			break;
		}

		ShowErrorMessageBox(strMsg);

		return;
	}

	pUnitDevice->HixChangeNotify(pGetNdasHostGuid());
	pUnitDeviceAdd->HixChangeNotify(pGetNdasHostGuid());

/*
	CRecoverDlg dlgRecover(FALSE, IDS_LOGDEV_TYPE_DISK_RAID1, IDS_RECOVERDLG_TASK_ADD_MIRROR);

	ATLASSERT(FALSE);
//		dlgRecover.SetMemberDevice(pUnitDeviceAdd);
	dlgRecover.DoModal();
*/

	OnRefreshStatus(NULL, NULL, NULL);
}
Beispiel #9
0
void CMainFrame::OnReplaceUnitDevice(UINT wNotifyCode, int wID, HWND hwndCtl)
{
	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	if(!pDevice->GetCommandAbility(wID))
		return;

	CNBLogicalDevice *pLogicalDevice = dynamic_cast<CNBLogicalDevice *>(pDevice);
	if(!pLogicalDevice)
		return;

	// find the missing device

	CNBLogicalDevice *pLogicalDeviceReplace = NULL;
	CNBUnitDevice *pUnitDeviceReplace = NULL;
	NBUnitDevicePtrList listUnitDevicesReplace;
	NBLogicalDevicePtrList::iterator itLogicalDevice;
	for(UINT32 i = 0; i < pLogicalDevice->DevicesTotal(); i++)
	{
		if(!(*pLogicalDevice)[i])
		{
			for(itLogicalDevice = m_listLogicalDevices.begin(); 
				itLogicalDevice != m_listLogicalDevices.end(); 
				++itLogicalDevice)
			{
				pLogicalDeviceReplace = *itLogicalDevice;
				if(pLogicalDeviceReplace)
				{
					if (pLogicalDeviceReplace->IsHDD() &&
						!pLogicalDeviceReplace->IsGroup() &&
						pLogicalDeviceReplace->IsOperatable())
					{
						pUnitDeviceReplace = (*pLogicalDeviceReplace)[0];
						if (pUnitDeviceReplace->IsThis(
							pLogicalDevice->DIB()->UnitDisks[i].MACAddr,
							pLogicalDevice->DIB()->UnitDisks[i].UnitNumber))
						{
							// ok we found replacable HDD
							listUnitDevicesReplace.push_back(pUnitDeviceReplace);

						}
					}
				}
			}
		}
	}

	if(!listUnitDevicesReplace.size())
		return;

	CNBSelectDeviceDlg dlgSelectDevice(
		IDD_DEVICE_LIST, 
		IDS_REPLACE_UNIT_DEVICE_DLG_CAPTION, 
		IDS_REPLACE_UNIT_DEVICE_DLG_MESSAGE, 
		listUnitDevicesReplace, 
		0, 
		CheckCapacityForSpare, 
		pLogicalDevice);

	if(dlgSelectDevice.DoModal() != IDOK)
		return;

	// dlgSelectDevice is not selective dialog. get unit device from listUnitDevicesReplace
	CNBUnitDevice *pUnitDevice = *(listUnitDevicesReplace.begin());

	// Bind & Synchronize 
	NDASCOMM_CONNECTION_INFO ci, ci_replace;
	pLogicalDevice->InitConnectionInfo(&ci, TRUE); // use write access. this function does not support run time replace yet.
	pUnitDevice->InitConnectionInfo(&ci_replace, TRUE);

	for(UINT32 i = 0; i < pLogicalDevice->DevicesTotal(); i++)
	{
		if (!(*pLogicalDevice)[i])
		{
			break;
		}
	}

	if(pLogicalDevice->DevicesTotal() == i)
	{
		// failed to find missing device
		return;
	}

	AutoCursor l_auto_cursor(IDC_WAIT);

	BOOL bResults = NdasOpReplaceUnitDevice(
		&ci, &ci_replace, i);
	l_auto_cursor.Release();

	pLogicalDevice->HixChangeNotify(pGetNdasHostGuid());
	pUnitDevice->HixChangeNotify(pGetNdasHostGuid());

	if(!bResults)
	{
		CString strMsg;

		DWORD dwLastError = ::GetLastError();

		strMsg.LoadString(IDS_OPERATION_FAIL);

		ShowErrorMessageBox(strMsg);

		return;
	}

	OnRefreshStatus(NULL, NULL, NULL);
}
Beispiel #10
0
// 0 to automatically advance to the next page
// -1 to prevent the page from changing
INT 
CSelectDiskPage::OnWizardNext()
{
	ATLASSERT( m_wndListBind.GetItemCount() == (int)m_pWizData->m_nDiskCount);
	ATLASSERT( 
		NMT_AGGREGATE == m_pWizData->m_nBindType || 
		NMT_RAID0 == m_pWizData->m_nBindType || 
		NMT_RAID1 == m_pWizData->m_nBindType || 
		NMT_RAID4 == m_pWizData->m_nBindType);

	NBUnitDevicePtrList listBind;
	unsigned int i;
	UINT32 BindResult;
	WTL::CString strMsg;

	// warning message
	{
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		strMsg.LoadString(IDS_WARNING_BIND);
		int id = MessageBox(
			strMsg,
			strTitle,
			MB_YESNO|MB_ICONEXCLAMATION
			);
		if(IDYES != id)
			return -1;
	}

	m_pWizData->listUnitDevicesBind = m_wndListBind.GetDiskObjectList();

	NDASCOMM_CONNECTION_INFO *pConnectionInfo;
	pConnectionInfo = new NDASCOMM_CONNECTION_INFO[m_pWizData->m_nDiskCount];
	ZeroMemory(pConnectionInfo, sizeof(NDASCOMM_CONNECTION_INFO) * m_pWizData->m_nDiskCount);

	listBind = m_wndListBind.GetDiskObjectList();
	WTL::CString strTitle;
	CNBUnitDevice *UnitDiskObject;
	NBUnitDevicePtrList::const_iterator itr;
	
	for (i = 0, itr = listBind.begin(); itr != listBind.end(); ++itr, i++ )
	{
		UnitDiskObject = *itr;
		
		if(!UnitDiskObject->InitConnectionInfo(&pConnectionInfo[i], TRUE))
//		if(!((*itr)->GetAccessMask() & GENERIC_WRITE))
		{
			// "%1!s! does not have a write access privilege. You need to set write key to this NDAS device before this action."
			strMsg.FormatMessage(IDS_ERROR_NOT_REGISTERD_WRITE_FMT,
				(*itr)->GetName()
				);
			strTitle.LoadString(IDS_APPLICATION);
			MessageBox(
				strMsg,
				strTitle,
				MB_OK|MB_ICONERROR
				);

			delete [] pConnectionInfo;
			return -1;
		}
	}

	DWORD dwUserSpace = 0;
	if(!pGetAppConfigValue(_T("UserSpace"), &dwUserSpace))
	{
		dwUserSpace = 0;
	}


	AutoCursor l_auto_cursor(IDC_WAIT);
	m_pWizData->m_BindResult = NdasOpBind(
		m_pWizData->m_nDiskCount, pConnectionInfo, m_pWizData->m_nBindType, dwUserSpace);
	l_auto_cursor.Release();


	if(m_pWizData->m_BindResult != m_pWizData->m_nDiskCount) // error
		m_pWizData->dwBindLastError = ::GetLastError();		

	CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid());
	BOOL bResults = HixChangeNotify.Initialize();
	if(bResults)
	{
		for (i = 0; i < m_pWizData->m_nDiskCount; i++ )
		{
			NDAS_UNITDEVICE_ID unitDeviceId;
			CopyMemory(unitDeviceId.DeviceId.Node, pConnectionInfo[i].AddressLPX, 
				sizeof(unitDeviceId.DeviceId.Node));
			unitDeviceId.UnitNo = pConnectionInfo[i].UnitNo;
			HixChangeNotify.Notify(unitDeviceId);
		}
	}

	delete [] pConnectionInfo;

	return 0;
}
Beispiel #11
0
// 0 to automatically advance to the next page
// -1 to prevent the page from changing
INT 
CSelectDiskPage::OnWizardNext()
{
	ATLASSERT( m_wndListBind.GetItemCount() == (int)m_pWizData->m_nDiskCount);
	ATLASSERT( 
		NMT_AGGREGATE == m_pWizData->m_nBindType || 
		NMT_RAID0 == m_pWizData->m_nBindType || 
		NMT_RAID1R3 == m_pWizData->m_nBindType || 
		NMT_RAID4R3 == m_pWizData->m_nBindType ||
		NMT_RAID5 == m_pWizData->m_nBindType
		);

	NBUnitDevicePtrList listBind;
	unsigned int i;
	CString strMsg;

	// Warning message if disk is over 2T.
	{
		UINT64 nSize = pGetBoundDiskSize(
			m_pWizData->m_nBindType, 
			m_pWizData->m_nDiskCount, 
			m_wndListBind.GetDiskObjectList());
		if (nSize >= 2LL * 1024 * 1024 * 1024 * 1024) { // 2 Tera.
			CString strTitle;
			strTitle.LoadString(IDS_APPLICATION);
			strMsg.LoadString(IDS_WARNING_BIND_SIZE);
			int id = MessageBox(
				strMsg,
				strTitle,
				MB_YESNO|MB_ICONEXCLAMATION
				);
			if(IDYES != id)
				return -1;
		}
			
	}
	// warning message
	{
		CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		strMsg.LoadString(IDS_WARNING_BIND);
		int id = MessageBox(
			strMsg,
			strTitle,
			MB_YESNO|MB_ICONEXCLAMATION
			);
		if(IDYES != id)
			return -1;
	}

	m_pWizData->listUnitDevicesBind = m_wndListBind.GetDiskObjectList();

	NDASCOMM_CONNECTION_INFO *pConnectionInfo;
	pConnectionInfo = new NDASCOMM_CONNECTION_INFO[m_pWizData->m_nDiskCount];
	ZeroMemory(pConnectionInfo, sizeof(NDASCOMM_CONNECTION_INFO) * m_pWizData->m_nDiskCount);

	listBind = m_wndListBind.GetDiskObjectList();
	CString strTitle;
	CNBUnitDevice *UnitDiskObject;
	NBUnitDevicePtrList::const_iterator itr;
	
	for (i = 0, itr = listBind.begin(); itr != listBind.end(); ++itr, i++ )
	{
		UnitDiskObject = *itr;
		
		if(!UnitDiskObject->InitConnectionInfo(&pConnectionInfo[i], TRUE))
//		if(!((*itr)->GetAccessMask() & GENERIC_WRITE))
		{
			// "%1!s! does not have a write access privilege. You need to set write key to this NDAS device before this action."
			strMsg.FormatMessage(IDS_ERROR_NOT_REGISTERD_WRITE_FMT,
				(*itr)->GetName()
				);
			strTitle.LoadString(IDS_APPLICATION);
			MessageBox(
				strMsg,
				strTitle,
				MB_OK|MB_ICONERROR);

			delete [] pConnectionInfo;
			return -1;
		}
	}

	DWORD dwUserSpace = 0;
	if(!pGetAppConfigValue(_T("UserSpace"), &dwUserSpace))
	{
		dwUserSpace = 0;
	}


	AutoCursor l_auto_cursor(IDC_WAIT);
	m_pWizData->m_BindResult = NdasOpBind(
		m_pWizData->m_nDiskCount, pConnectionInfo, m_pWizData->m_nBindType, dwUserSpace);
	l_auto_cursor.Release();


	if(m_pWizData->m_BindResult != m_pWizData->m_nDiskCount) // error
		m_pWizData->dwBindLastError = ::GetLastError();		

	LPCGUID hostGuid = pGetNdasHostGuid();

	for (i = 0; i < m_pWizData->m_nDiskCount; i++ )
	{
		BOOL success = NdasCommNotifyUnitDeviceChange(
			NDAS_DIC_NDAS_ID,
			pConnectionInfo[i].Address.NdasId.Id,
			pConnectionInfo[i].UnitNo,
			hostGuid);

		if (!success)
		{
			ATLTRACE("NdasCommNotifyUnitDeviceChange failed, error=0x%X\n",
				GetLastError());
		}
	}

	delete [] pConnectionInfo;

	return 0;
}