////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 1999-2003 Microsoft Corporation // // Module Name: // VdsNasClasses.h // // Implementation File: // VdsNasClasses.cpp // // Description: // Definition of the VDS NAS WMI Provider classes. // // // Notes: // ////////////////////////////////////////////////////////////////////////////// #pragma once ////////////////////////////////////////////////////////////////////////////// // Include Files ////////////////////////////////////////////////////////////////////////////// #include "ProvBase.h" #include "vds.h" #include "vdsholder.h" #include #define SAFE_FREE(x) if (x) { CoTaskMemFree(x); x = NULL; } #define SAFE_RELEASE(x) if (x) { x->Release(); x = NULL; } #define SAFE_FREE_DISK_PROP(x) if (x) { SAFE_FREE((x)->pwszDiskAddress); \ SAFE_FREE((x)->pwszName); \ SAFE_FREE((x)->pwszFriendlyName); \ SAFE_FREE((x)->pwszAdaptorName); \ SAFE_FREE((x)->pwszDevicePath);\ }\ #define SAFE_FREE_VOLUME_PROP(x) if (x) { SAFE_FREE((x)->pwszName); } #define SAFE_FREE_PROVIDER_PROP(x) if (x) { SAFE_FREE((x)->pwszName); \ SAFE_FREE((x)->pwszVersion); \ }\ #define SAFE_FREE_PACK_PROP(x) if (x) { SAFE_FREE((x)->pwszName); } HRESULT g_LoadService( IVdsService **ppService ); HRESULT g_GetDiskSize( IVdsDisk *pDisk, BOOL bFree, ULONGLONG &ullSize ); BOOL g_IsDynamicDisk( IVdsDisk *pDisk ); BOOL g_IsDynamicVolume( IVdsVolume *pVolume ); // Struct to hold volume info on the extent level typedef struct VolumeExtent { CComPtr spVolume; VDS_OBJECT_ID plexId; VDS_VOLUME_TYPE type; ULONGLONG ullSize; } VolumeExtent; ////////////////////////////////////////////////////////////////////////////// //++ // // class CDisk // // Description: // Provider Implementation for Disk // //-- ////////////////////////////////////////////////////////////////////////////// class CNasDisk : public CProvBase { // // constructor // public: CNasDisk( LPCWSTR pwszNameIn, CWbemServices* pNamespaceIn ); ~CNasDisk(){} // // methods // public: virtual HRESULT EnumInstance( long lFlagsIn, IWbemContext* pCtxIn, IWbemObjectSink* pHandlerIn ); virtual HRESULT GetObject( CObjPath& rObjPathIn, long lFlagsIn, IWbemContext* pCtxIn, IWbemObjectSink* pHandlerIn ); virtual HRESULT ExecuteMethod( BSTR bstrObjPathIn, WCHAR* pwszMethodNameIn, long lFlagIn, IWbemClassObject* pParamsIn, IWbemObjectSink* pHandlerIn ); virtual HRESULT PutInstance( CWbemClassObject& rInstToPutIn, long lFlagIn, IWbemContext* pCtxIn, IWbemObjectSink* pHandlerIn ) { return WBEM_E_NOT_SUPPORTED; }; virtual HRESULT DeleteInstance( CObjPath& rObjPathIn, long lFlagIn, IWbemContext* pCtxIn, IWbemObjectSink* pHandlerIn ) { return WBEM_E_NOT_SUPPORTED; }; static CProvBase* S_CreateThis( LPCWSTR pwszNameIn, CWbemServices* pNamespaceIn ); HRESULT Initialize( ); private: CComPtr m_spService; HRESULT m_LoadInstance( IN IVdsDisk* pDisk, OUT IWbemClassObject* pObject); HRESULT m_GetDiskSize( IN IVdsDisk *pDisk, IN BOOL bFree, OUT ULONGLONG &ullSize ); BOOL m_IsDynamicDisk( IN IVdsDisk *pDisk ); HRESULT m_GetObject( IN CObjPath& rObjPath, OUT IVdsDisk **ppDisk ); HRESULT m_ExecClean( IN BSTR bstrObjPath, IN IWbemClassObject* pParams, IN OUT IWbemClassObject* pOutParams ); HRESULT m_ExecConvert( IN BSTR bstrObjPath, IN IWbemClassObject* pParams, IN OUT IWbemClassObject* pOutParams ); HRESULT m_ExecReplace( IN BSTR bstrObjPath, IN IWbemClassObject* pParams, IN OUT IWbemClassObject* pOutParams ); HRESULT m_ExecRescan( IN BSTR bstrObjPath, IN IWbemClassObject* pParams, IN OUT IWbemClassObject* pOutParams ); DWORD m_Clean( IN IVdsDisk *pDisk ); DWORD m_Convert( IN IVdsDisk *pDisk, IN DWORD convertType ); DWORD m_Replace( IN IVdsDisk *pDisk ); DWORD m_Rescan( ); HRESULT m_GetMissingDisk( OUT IVdsDisk **ppMissingDisk ); HRESULT m_ReplaceMirror( IN VolumeExtent *pFtVolume, IN VDS_OBJECT_ID &diskId ); HRESULT m_ReplaceRaid5( IN VolumeExtent *pFtVolume, IN VDS_OBJECT_ID &diskId ); HRESULT m_CreatePack( IN VDS_PROVIDER_FLAG providerFlag, OUT IVdsPack **ppActivePack ); HRESULT m_GetOnlinePack( OUT IVdsPack **ppPack ); HRESULT m_ConvertDynamic( IN IVdsDisk *pDisk ); HRESULT m_ConvertBasic( IN IVdsDisk *pDisk ); }; ////////////////////////////////////////////////////////////////////////////// //++ // // class CNasVolume // // Description: // Provider Implementation for volume on NAS appliance // //-- ////////////////////////////////////////////////////////////////////////////// class CNasVolume : public CProvBase { // // constructor // public: CNasVolume( LPCWSTR pwszNameIn, CWbemServices* pNamespaceIn ); ~CNasVolume(){} // // methods // public: virtual HRESULT EnumInstance( long lFlagsIn, IWbemContext* pCtxIn, IWbemObjectSink* pHandlerIn ); virtual HRESULT GetObject( CObjPath& rObjPathIn, long lFlagsIn, IWbemContext* pCtxIn, IWbemObjectSink* pHandlerIn ); virtual HRESULT ExecuteMethod( BSTR bstrObjPathIn, WCHAR* pwszMethodNameIn, long lFlagIn, IWbemClassObject* pParamsIn, IWbemObjectSink* pHandlerIn ); virtual HRESULT PutInstance( CWbemClassObject& rInstToPutIn, long lFlagIn, IWbemContext* pCtxIn, IWbemObjectSink* pHandlerIn ) { return WBEM_E_NOT_SUPPORTED; }; virtual HRESULT DeleteInstance( CObjPath& rObjPathIn, long lFlagIn, IWbemContext* pCtxIn, IWbemObjectSink* pHandlerIn ) { return WBEM_E_NOT_SUPPORTED; }; static CProvBase* S_CreateThis( LPCWSTR pwszNameIn, CWbemServices* pNamespaceIn ); HRESULT Initialize( ); private: CComPtr m_spService; HRESULT m_LoadInstance( IVdsVolume* pVolume, IWbemClassObject* pObject); HRESULT m_GetObject( CObjPath& rObjPath, IVdsVolume **ppVolume ); HRESULT m_ExecReactivate( IN BSTR bstrObjPath, IN IWbemClassObject* pParams, IN OUT IWbemClassObject* pOutParams ); HRESULT m_ExecExtend( IN BSTR bstrObjPath, IN IWbemClassObject* pParams, IN OUT IWbemClassObject* pOutParams ); HRESULT m_ExecCreate( IN BSTR bstrObjPath, IN IWbemClassObject* pParams, IN OUT IWbemClassObject* pOutParams ); HRESULT m_ExecDelete( IN BSTR bstrObjPath, IN IWbemClassObject* pParams, IN OUT IWbemClassObject* pOutParams ); DWORD m_Reactivate( IVdsVolume *pVolume); DWORD m_Extend( IVdsVolume *pVolume, VDS_OBJECT_ID diskId, ULONGLONG ullSize); DWORD m_Create( DWORD dwVolumeType, _bstr_t bstrVolumeLable, _bstr_t *pDisks, DWORD dwNumDisks, ULONGLONG ullSize); DWORD m_Delete( IVdsVolume *pVolume, BOOL bForce); HRESULT m_GetExtendedPart( IVdsDisk *pDisk, ULONGLONG *ullExtendedOffset, ULONGLONG *ullExtendedSize); HRESULT m_GetNextAvailableDriveLetter( WCHAR &DriveLetter); HRESULT m_AssignDriveLetter( IVdsVolume *pVolume, WCHAR DriveLetter); HRESULT m_Format( IVdsVolume *pVolume, VDS_FILE_SYSTEM_TYPE type, LPWSTR pwszLabel, DWORD dwUnitAllocationSize, BOOL bForce, BOOL bQuickFormat, BOOL bEnableCompression); }; ////////////////////////////////////////////////////////////////////////////// //++ // // class CVolumeOn // // Description: // Provider Implementation for volume on NAS appliance // //-- ////////////////////////////////////////////////////////////////////////////// class CVolumeOn : public CProvBase { // // constructor // public: CVolumeOn( LPCWSTR pwszNameIn, CWbemServices* pNamespaceIn ); ~CVolumeOn(){} // // methods // public: virtual HRESULT EnumInstance( long lFlagsIn, IWbemContext* pCtxIn, IWbemObjectSink* pHandlerIn ); virtual HRESULT GetObject( CObjPath& rObjPathIn, long lFlagsIn, IWbemContext* pCtxIn, IWbemObjectSink* pHandlerIn ); virtual HRESULT ExecuteMethod( BSTR bstrObjPathIn, WCHAR* pwszMethodNameIn, long lFlagIn, IWbemClassObject* pParamsIn, IWbemObjectSink* pHandlerIn ) { return WBEM_E_NOT_SUPPORTED; }; virtual HRESULT PutInstance( CWbemClassObject& rInstToPutIn, long lFlagIn, IWbemContext* pCtxIn, IWbemObjectSink* pHandlerIn ) { return WBEM_E_NOT_SUPPORTED; }; virtual HRESULT DeleteInstance( CObjPath& rObjPathIn, long lFlagIn, IWbemContext* pCtxIn, IWbemObjectSink* pHandlerIn ) { return WBEM_E_NOT_SUPPORTED; }; static CProvBase* S_CreateThis( LPCWSTR pwszNameIn, CWbemServices* pNamespaceIn ); HRESULT Initialize(); private: CComPtr m_spService; HRESULT m_LoadInstance( VDS_DISK_EXTENT* pExtent, IWbemClassObject* pObject); };