This built contains the functionality to set hard quota on the website content folder. It requires FSRM to be installed on the File Server, Name of the share where the home folders are create should contain the drive name preceeded by _ e.g. SharedConfig_C. Quota is retrieved from OS disk space quota, quota unit is retrieved from quota description field in the quotas table, this info is fed to Dirquota command and the quota is set accordingly.

This commit is contained in:
Haya Nmeir 2012-09-16 02:22:05 +03:00
parent cfb58e3423
commit f7d7bcfafc
13 changed files with 347 additions and 22 deletions

View file

@ -912,5 +912,76 @@ namespace WebsitePanel.EnterpriseServer
return users.ToArray();
}
public static int SetFolderQuota(int packageId, string path)
{
// check account
int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);
if (accountCheck < 0) return accountCheck;
// check package
int packageCheck = SecurityContext.CheckPackage(packageId, DemandPackage.IsActive);
if (packageCheck < 0) return packageCheck;
// place log record
TaskManager.StartTask("FILES", "SET_QUOTA_ON_FOLDER", path);
TaskManager.ItemId = packageId;
try
{
// file server cluster name
string fileServerClusterName = String.Empty;
// Share Name where home folders are created
string shareName = String.Empty;
string[] splits = GetHomeFolder(packageId).Split('\\');
if (splits.Length > 4)
{
fileServerClusterName = splits[2];
shareName = splits[3];
}
// disk space quota
QuotaValueInfo diskSpaceQuota = PackageController.GetPackageQuota(packageId, Quotas.OS_DISKSPACE);
// bat file pat
string cmdFilePath = @"\\" + fileServerClusterName + @"\" + shareName + @"\" + "Process.bat";
#region figure Quota Unit
// Quota Unit
string unit = String.Empty;
if (diskSpaceQuota.QuotaDescription.ToLower().Contains("gb"))
unit = "GB";
else if (diskSpaceQuota.QuotaDescription.ToLower().Contains("mb"))
unit = "MB";
else
unit = "KB";
#endregion
OS.OperatingSystem os = GetOS(packageId);
os.SetQuotaLimitOnFolder(cmdFilePath, fileServerClusterName, path, diskSpaceQuota.QuotaAllocatedValue.ToString() + unit, 0, String.Empty, String.Empty);
return 0;
}
catch (Exception ex)
{
//Log and return a generic error rather than throwing an exception
TaskManager.WriteError(ex);
return BusinessErrorCodes.ERROR_FILE_GENERIC_LOGGED;
}
finally
{
TaskManager.CompleteTask();
}
}
}
}

View file

@ -377,6 +377,9 @@ namespace WebsitePanel.EnterpriseServer
// CREATE WEB SITE
siteId = web.CreateSite(site);
// Set hard quota on the website content folder
FilesController.SetFolderQuota(packageId, site.DataPath);
// register item
site.ServiceId = serviceId;
site.PackageId = packageId;

View file

@ -1,56 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3" />
<section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3"/>
</configSections>
<!-- Connection strings -->
<connectionStrings>
<add name="EnterpriseServer" connectionString="server=HSTPROV01;database=WebsitePanelMerge;uid=WebsitePanel;pwd=aj7ep6fyhmw3b5qeth7c;" providerName="System.Data.SqlClient" />
<add name="EnterpriseServer" connectionString="server=localhost\sqlexpress;database=WebsitePanelBeta;uid=WebsitePanel;pwd=bdeznsrsyce58m0bc61j;" providerName="System.Data.SqlClient"/>
</connectionStrings>
<appSettings>
<!-- Encryption util settings -->
<add key="WebsitePanel.CryptoKey" value="3x7eqt7zabc5n5afs6dg" />
<add key="WebsitePanel.CryptoKey" value="84lc71526qnp8mlqx0gk"/>
<!-- A1D4KDHUE83NKHddF -->
<add key="WebsitePanel.EncryptionEnabled" value="true" />
<add key="WebsitePanel.EncryptionEnabled" value="true"/>
<!-- Web Applications -->
<add key="WebsitePanel.EnterpriseServer.WebApplicationsPath" value="~/WebApplications" />
<add key="WebsitePanel.EnterpriseServer.WebApplicationsPath" value="~/WebApplications"/>
<!-- Communication settings -->
<!-- Maximum waiting time when sending request to the remote server
The value is in seconds. "-1" - infinite. -->
<add key="WebsitePanel.EnterpriseServer.ServerRequestTimeout" value="3600" />
<add key="WebsitePanel.EnterpriseServer.ServerRequestTimeout" value="3600"/>
</appSettings>
<system.web>
<!-- Disable any authentication -->
<authentication mode="None" />
<authentication mode="None"/>
<!-- Correct HTTP runtime settings -->
<httpRuntime executionTimeout="3600" maxRequestLength="16384" />
<httpRuntime executionTimeout="3600" maxRequestLength="16384"/>
<!-- Set globalization settings -->
<globalization culture="en-US" uiCulture="en" requestEncoding="UTF-8" responseEncoding="UTF-8" fileEncoding="UTF-8" />
<globalization culture="en-US" uiCulture="en" requestEncoding="UTF-8" responseEncoding="UTF-8" fileEncoding="UTF-8"/>
<!-- Web Services settings -->
<webServices>
<protocols>
<remove name="HttpPost" />
<remove name="HttpPostLocalhost" />
<remove name="HttpGet" />
<remove name="HttpPost"/>
<remove name="HttpPostLocalhost"/>
<remove name="HttpGet"/>
</protocols>
<soapServerProtocolFactory type="Microsoft.Web.Services3.WseProtocolFactory, Microsoft.Web.Services3" />
<soapServerProtocolFactory type="Microsoft.Web.Services3.WseProtocolFactory, Microsoft.Web.Services3"/>
</webServices>
<compilation targetFramework="4.0" />
<compilation targetFramework="4.0" debug="true"/>
</system.web>
<!-- WSE 3.0 settings -->
<microsoft.web.services3>
<diagnostics>
<trace enabled="false" input="InputTrace.webinfo" output="OutputTrace.webinfo" />
<trace enabled="false" input="InputTrace.webinfo" output="OutputTrace.webinfo"/>
</diagnostics>
<messaging>
<maxMessageLength value="-1" />
<mtom clientMode="On" />
<maxMessageLength value="-1"/>
<mtom clientMode="On"/>
</messaging>
<security>
<securityTokenManager>
<add type="WebsitePanel.EnterpriseServer.ServiceUsernameTokenManager, WebsitePanel.EnterpriseServer" namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" localName="UsernameToken" />
<add type="WebsitePanel.EnterpriseServer.ServiceUsernameTokenManager, WebsitePanel.EnterpriseServer" namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" localName="UsernameToken"/>
</securityTokenManager>
</security>
<policy fileName="WsePolicyCache.Config" />
<policy fileName="WsePolicyCache.Config"/>
</microsoft.web.services3>
</configuration>

View file

@ -19,6 +19,11 @@
</UpgradeBackupLocation>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile />
<UseIISExpress>false</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -410,6 +415,7 @@
<Content Include="esWebApplicationGallery.asmx" />
<EmbeddedResource Include="Images\logo.png" />
<Content Include="SystemEventHandlers.config" />
<None Include="Properties\PublishProfiles\Profile1.pubxml" />
<None Include="TaskEventHandlers.config" />
<None Include="WsePolicyCache.Config" />
</ItemGroup>