wsp-10327 Add Dynamic Memory to VPS - Enterprise Part.

This commit is contained in:
Alexander Trofimov 2015-04-07 21:49:03 +03:00
parent 53f6190981
commit 88681f444e
19 changed files with 364 additions and 178 deletions

View file

@ -21,7 +21,10 @@ DELETE FROM HostingPlanQuotas WHERE QuotaID = 342
GO
DELETE FROM HostingPlanQuotas WHERE QuotaID = 343
GO
IF NOT EXISTS (SELECT * FROM [dbo].[ResourceGroups] WHERE GroupID = 33 AND [GroupName] = 'VPS2012')
BEGIN
DELETE FROM HostingPlanResources WHERE GroupID = 33
END
GO
@ -8218,17 +8221,23 @@ AS
INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID
INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID
WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3)
ELSE IF @QuotaID = 558 -- RAM of VPS
SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP
ELSE IF @QuotaID = 558 BEGIN -- RAM of VPS2012
DECLARE @Result1 int = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP
INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID
INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID
WHERE SIP.PropertyName = 'RamSize' AND PT.ParentPackageID = @PackageID)
ELSE IF @QuotaID = 559 -- HDD of VPS
DECLARE @Result2 int = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP
INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID
INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID
WHERE SIP.PropertyName = 'DynamicMemory.Maximum' AND PT.ParentPackageID = @PackageID)
SET @Result = CASE WHEN isnull(@Result1,0) > isnull(@Result2,0) THEN @Result1 ELSE @Result2 END
END
ELSE IF @QuotaID = 559 -- HDD of VPS2012
SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP
INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID
INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID
WHERE SIP.PropertyName = 'HddSize' AND PT.ParentPackageID = @PackageID)
ELSE IF @QuotaID = 562 -- External IP addresses of VPS
ELSE IF @QuotaID = 562 -- External IP addresses of VPS2012
SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP
INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID
INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID

View file

@ -39,6 +39,7 @@
public const string QUOTA_EXCEEDED_CPU = "VPS_QUOTA_EXCEEDED_CPU";
public const string QUOTA_EXCEEDED_RAM = "VPS_QUOTA_EXCEEDED_RAM";
public const string QUOTA_WRONG_RAM = "VPS_QUOTA_WRONG_RAM";
public const string QUOTA_NOT_IN_DYNAMIC_RAM = "VPS_QUOTA_NOT_IN_DYNAMIC_RAM";
public const string QUOTA_EXCEEDED_HDD = "VPS_QUOTA_EXCEEDED_HDD";
public const string QUOTA_WRONG_HDD = "VPS_QUOTA_WRONG_HDD";
public const string QUOTA_EXCEEDED_SNAPSHOTS = "VPS_QUOTA_EXCEEDED_SNAPSHOTS";

View file

@ -23,7 +23,6 @@ namespace WebsitePanel.EnterpriseServer {
using WebsitePanel.Providers.Virtualization;
using WebsitePanel.Providers.ResultObjects;
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
@ -1105,65 +1104,6 @@ namespace WebsitePanel.EnterpriseServer {
string osTemplateFile,
string password,
string summaryLetterEmail,
int generation,
int cpuCores,
int ramMB,
int hddGB,
int snapshots,
bool dvdInstalled,
bool bootFromCD,
bool numLock,
bool startShutdownAllowed,
bool pauseResumeAllowed,
bool rebootAllowed,
bool resetAllowed,
bool reinstallAllowed,
bool externalNetworkEnabled,
int externalAddressesNumber,
bool randomExternalAddresses,
int[] externalAddresses,
bool privateNetworkEnabled,
int privateAddressesNumber,
bool randomPrivateAddresses,
string[] privateAddresses) {
object[] results = this.Invoke("CreateVirtualMachine", new object[] {
packageId,
hostname,
osTemplateFile,
password,
summaryLetterEmail,
generation,
cpuCores,
ramMB,
hddGB,
snapshots,
dvdInstalled,
bootFromCD,
numLock,
startShutdownAllowed,
pauseResumeAllowed,
rebootAllowed,
resetAllowed,
reinstallAllowed,
externalNetworkEnabled,
externalAddressesNumber,
randomExternalAddresses,
externalAddresses,
privateNetworkEnabled,
privateAddressesNumber,
randomPrivateAddresses,
privateAddresses});
return ((IntResult)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginCreateVirtualMachine(
int packageId,
string hostname,
string osTemplateFile,
string password,
string summaryLetterEmail,
int generation,
int cpuCores,
int ramMB,
int hddGB,
@ -1184,15 +1124,13 @@ namespace WebsitePanel.EnterpriseServer {
int privateAddressesNumber,
bool randomPrivateAddresses,
string[] privateAddresses,
System.AsyncCallback callback,
object asyncState) {
return this.BeginInvoke("CreateVirtualMachine", new object[] {
VirtualMachine otherSettings) {
object[] results = this.Invoke("CreateVirtualMachine", new object[] {
packageId,
hostname,
osTemplateFile,
password,
summaryLetterEmail,
generation,
cpuCores,
ramMB,
hddGB,
@ -1212,7 +1150,68 @@ namespace WebsitePanel.EnterpriseServer {
privateNetworkEnabled,
privateAddressesNumber,
randomPrivateAddresses,
privateAddresses}, callback, asyncState);
privateAddresses,
otherSettings});
return ((IntResult)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginCreateVirtualMachine(
int packageId,
string hostname,
string osTemplateFile,
string password,
string summaryLetterEmail,
int cpuCores,
int ramMB,
int hddGB,
int snapshots,
bool dvdInstalled,
bool bootFromCD,
bool numLock,
bool startShutdownAllowed,
bool pauseResumeAllowed,
bool rebootAllowed,
bool resetAllowed,
bool reinstallAllowed,
bool externalNetworkEnabled,
int externalAddressesNumber,
bool randomExternalAddresses,
int[] externalAddresses,
bool privateNetworkEnabled,
int privateAddressesNumber,
bool randomPrivateAddresses,
string[] privateAddresses,
VirtualMachine otherSettings,
System.AsyncCallback callback,
object asyncState) {
return this.BeginInvoke("CreateVirtualMachine", new object[] {
packageId,
hostname,
osTemplateFile,
password,
summaryLetterEmail,
cpuCores,
ramMB,
hddGB,
snapshots,
dvdInstalled,
bootFromCD,
numLock,
startShutdownAllowed,
pauseResumeAllowed,
rebootAllowed,
resetAllowed,
reinstallAllowed,
externalNetworkEnabled,
externalAddressesNumber,
randomExternalAddresses,
externalAddresses,
privateNetworkEnabled,
privateAddressesNumber,
randomPrivateAddresses,
privateAddresses,
otherSettings}, callback, asyncState);
}
/// <remarks/>
@ -1228,38 +1227,6 @@ namespace WebsitePanel.EnterpriseServer {
string osTemplateFile,
string password,
string summaryLetterEmail,
int generation,
int cpuCores,
int ramMB,
int hddGB,
int snapshots,
bool dvdInstalled,
bool bootFromCD,
bool numLock,
bool startShutdownAllowed,
bool pauseResumeAllowed,
bool rebootAllowed,
bool resetAllowed,
bool reinstallAllowed,
bool externalNetworkEnabled,
int externalAddressesNumber,
bool randomExternalAddresses,
int[] externalAddresses,
bool privateNetworkEnabled,
int privateAddressesNumber,
bool randomPrivateAddresses,
string[] privateAddresses) {
this.CreateVirtualMachineAsync(packageId, hostname, osTemplateFile, password, summaryLetterEmail, generation, cpuCores, ramMB, hddGB, snapshots, dvdInstalled, bootFromCD, numLock, startShutdownAllowed, pauseResumeAllowed, rebootAllowed, resetAllowed, reinstallAllowed, externalNetworkEnabled, externalAddressesNumber, randomExternalAddresses, externalAddresses, privateNetworkEnabled, privateAddressesNumber, randomPrivateAddresses, privateAddresses, null);
}
/// <remarks/>
public void CreateVirtualMachineAsync(
int packageId,
string hostname,
string osTemplateFile,
string password,
string summaryLetterEmail,
int generation,
int cpuCores,
int ramMB,
int hddGB,
@ -1280,6 +1247,38 @@ namespace WebsitePanel.EnterpriseServer {
int privateAddressesNumber,
bool randomPrivateAddresses,
string[] privateAddresses,
VirtualMachine otherSettings) {
this.CreateVirtualMachineAsync(packageId, hostname, osTemplateFile, password, summaryLetterEmail, cpuCores, ramMB, hddGB, snapshots, dvdInstalled, bootFromCD, numLock, startShutdownAllowed, pauseResumeAllowed, rebootAllowed, resetAllowed, reinstallAllowed, externalNetworkEnabled, externalAddressesNumber, randomExternalAddresses, externalAddresses, privateNetworkEnabled, privateAddressesNumber, randomPrivateAddresses, privateAddresses, otherSettings, null);
}
/// <remarks/>
public void CreateVirtualMachineAsync(
int packageId,
string hostname,
string osTemplateFile,
string password,
string summaryLetterEmail,
int cpuCores,
int ramMB,
int hddGB,
int snapshots,
bool dvdInstalled,
bool bootFromCD,
bool numLock,
bool startShutdownAllowed,
bool pauseResumeAllowed,
bool rebootAllowed,
bool resetAllowed,
bool reinstallAllowed,
bool externalNetworkEnabled,
int externalAddressesNumber,
bool randomExternalAddresses,
int[] externalAddresses,
bool privateNetworkEnabled,
int privateAddressesNumber,
bool randomPrivateAddresses,
string[] privateAddresses,
VirtualMachine otherSettings,
object userState) {
if ((this.CreateVirtualMachineOperationCompleted == null)) {
this.CreateVirtualMachineOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateVirtualMachineOperationCompleted);
@ -1290,7 +1289,6 @@ namespace WebsitePanel.EnterpriseServer {
osTemplateFile,
password,
summaryLetterEmail,
generation,
cpuCores,
ramMB,
hddGB,
@ -1310,7 +1308,8 @@ namespace WebsitePanel.EnterpriseServer {
privateNetworkEnabled,
privateAddressesNumber,
randomPrivateAddresses,
privateAddresses}, this.CreateVirtualMachineOperationCompleted, userState);
privateAddresses,
otherSettings}, this.CreateVirtualMachineOperationCompleted, userState);
}
private void OnCreateVirtualMachineOperationCompleted(object arg) {
@ -1765,7 +1764,23 @@ namespace WebsitePanel.EnterpriseServer {
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/UpdateVirtualMachineConfiguration", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public ResultObject UpdateVirtualMachineConfiguration(int itemId, int cpuCores, int ramMB, int hddGB, int snapshots, bool dvdInstalled, bool bootFromCD, bool numLock, bool startShutdownAllowed, bool pauseResumeAllowed, bool rebootAllowed, bool resetAllowed, bool reinstallAllowed, bool externalNetworkEnabled, bool privateNetworkEnabled) {
public ResultObject UpdateVirtualMachineConfiguration(
int itemId,
int cpuCores,
int ramMB,
int hddGB,
int snapshots,
bool dvdInstalled,
bool bootFromCD,
bool numLock,
bool startShutdownAllowed,
bool pauseResumeAllowed,
bool rebootAllowed,
bool resetAllowed,
bool reinstallAllowed,
bool externalNetworkEnabled,
bool privateNetworkEnabled,
VirtualMachine otherSettings) {
object[] results = this.Invoke("UpdateVirtualMachineConfiguration", new object[] {
itemId,
cpuCores,
@ -1781,7 +1796,8 @@ namespace WebsitePanel.EnterpriseServer {
resetAllowed,
reinstallAllowed,
externalNetworkEnabled,
privateNetworkEnabled});
privateNetworkEnabled,
otherSettings});
return ((ResultObject)(results[0]));
}
@ -1802,6 +1818,7 @@ namespace WebsitePanel.EnterpriseServer {
bool reinstallAllowed,
bool externalNetworkEnabled,
bool privateNetworkEnabled,
VirtualMachine otherSettings,
System.AsyncCallback callback,
object asyncState) {
return this.BeginInvoke("UpdateVirtualMachineConfiguration", new object[] {
@ -1819,7 +1836,8 @@ namespace WebsitePanel.EnterpriseServer {
resetAllowed,
reinstallAllowed,
externalNetworkEnabled,
privateNetworkEnabled}, callback, asyncState);
privateNetworkEnabled,
otherSettings}, callback, asyncState);
}
/// <remarks/>
@ -1828,11 +1846,6 @@ namespace WebsitePanel.EnterpriseServer {
return ((ResultObject)(results[0]));
}
/// <remarks/>
public void UpdateVirtualMachineConfigurationAsync(int itemId, int cpuCores, int ramMB, int hddGB, int snapshots, bool dvdInstalled, bool bootFromCD, bool numLock, bool startShutdownAllowed, bool pauseResumeAllowed, bool rebootAllowed, bool resetAllowed, bool reinstallAllowed, bool externalNetworkEnabled, bool privateNetworkEnabled) {
this.UpdateVirtualMachineConfigurationAsync(itemId, cpuCores, ramMB, hddGB, snapshots, dvdInstalled, bootFromCD, numLock, startShutdownAllowed, pauseResumeAllowed, rebootAllowed, resetAllowed, reinstallAllowed, externalNetworkEnabled, privateNetworkEnabled, null);
}
/// <remarks/>
public void UpdateVirtualMachineConfigurationAsync(
int itemId,
@ -1850,6 +1863,28 @@ namespace WebsitePanel.EnterpriseServer {
bool reinstallAllowed,
bool externalNetworkEnabled,
bool privateNetworkEnabled,
VirtualMachine otherSettings) {
this.UpdateVirtualMachineConfigurationAsync(itemId, cpuCores, ramMB, hddGB, snapshots, dvdInstalled, bootFromCD, numLock, startShutdownAllowed, pauseResumeAllowed, rebootAllowed, resetAllowed, reinstallAllowed, externalNetworkEnabled, privateNetworkEnabled, otherSettings, null);
}
/// <remarks/>
public void UpdateVirtualMachineConfigurationAsync(
int itemId,
int cpuCores,
int ramMB,
int hddGB,
int snapshots,
bool dvdInstalled,
bool bootFromCD,
bool numLock,
bool startShutdownAllowed,
bool pauseResumeAllowed,
bool rebootAllowed,
bool resetAllowed,
bool reinstallAllowed,
bool externalNetworkEnabled,
bool privateNetworkEnabled,
VirtualMachine otherSettings,
object userState) {
if ((this.UpdateVirtualMachineConfigurationOperationCompleted == null)) {
this.UpdateVirtualMachineConfigurationOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateVirtualMachineConfigurationOperationCompleted);
@ -1869,7 +1904,8 @@ namespace WebsitePanel.EnterpriseServer {
resetAllowed,
reinstallAllowed,
externalNetworkEnabled,
privateNetworkEnabled}, this.UpdateVirtualMachineConfigurationOperationCompleted, userState);
privateNetworkEnabled,
otherSettings}, this.UpdateVirtualMachineConfigurationOperationCompleted, userState);
}
private void OnUpdateVirtualMachineConfigurationOperationCompleted(object arg) {

View file

@ -98,6 +98,19 @@ namespace WebsitePanel.EnterpriseServer
svals[i] = ivals[i].ToString();
s = String.Join(";", svals);
}
// when property is custom class with Persistent attribute
else if (prop.PropertyType.GetCustomAttributes(typeof(PersistentAttribute), false).Length > 0)
{
// add sub-class properties to hash
var childHash = GetObjectProperties(val, persistentOnly);
foreach (var hashKey in childHash.Keys)
{
var value = childHash[hashKey];
hash.Add(prop.Name + "." + hashKey, value);
}
// exit
continue;
}
else
s = val.ToString();
}
@ -476,6 +489,41 @@ namespace WebsitePanel.EnterpriseServer
}
}
private static Hashtable GetPropertiesForCache(Type type, bool persistentOnly)
{
// create properties cache
var props = new Hashtable();
PropertyInfo[] objProps = type.GetProperties(BindingFlags.Instance
//| BindingFlags.DeclaredOnly
| BindingFlags.Public);
foreach (PropertyInfo prop in objProps)
{
// check for persistent attribute
object[] attrs = prop.GetCustomAttributes(typeof(PersistentAttribute), false);
if (!persistentOnly || (persistentOnly && attrs.Length > 0) && !props.ContainsKey(prop.Name))
{
// when property is custom class with Persistent attribute
if (prop.PropertyType.GetCustomAttributes(typeof (PersistentAttribute), false).Length > 0)
{
// add sub-class properties to hash
var childHash = GetPropertiesForCache(prop.PropertyType, persistentOnly);
foreach (var hashKey in childHash.Keys)
{
var value = childHash[hashKey];
props.Add(prop.Name + "." + hashKey, value);
}
// exit
continue;
}
// add property to hash
props.Add(prop.Name, prop);
}
}
return props;
}
public static void CreateObjectFromHash(object obj, Hashtable propValues, bool persistentOnly)
{
Type type = obj.GetType();
@ -489,21 +537,7 @@ namespace WebsitePanel.EnterpriseServer
}
else
{
// create properties cache
props = new Hashtable();
PropertyInfo[] objProps = type.GetProperties(BindingFlags.Instance
//| BindingFlags.DeclaredOnly
| BindingFlags.Public);
foreach (PropertyInfo prop in objProps)
{
// check for persistent attribute
object[] attrs = prop.GetCustomAttributes(typeof(PersistentAttribute), false);
if (!persistentOnly || (persistentOnly && attrs.Length > 0) && !props.ContainsKey(prop.Name))
{
// add property to hash
props.Add(prop.Name, prop);
}
}
props = GetPropertiesForCache(type, persistentOnly);
if (!propertiesCache.ContainsKey(type.Name))
{
@ -518,38 +552,63 @@ namespace WebsitePanel.EnterpriseServer
// try to locate specified property
if (props[propName] != null)
{
PropertyInfo prop = (PropertyInfo)props[propName];
string val = propValues[propName].ToString();
var currentObj = obj;
// when property is custom class with Persistent attribute
if (propName.Contains("."))
{
var mainPropertyName = propName.Split('.')[0];
var childPropertyName = propName.Split('.')[1];
var mainProperty = type.GetProperty(mainPropertyName);
if (mainProperty == null) continue;
var mainVal = mainProperty.GetValue(obj, null);
if (mainVal == null)
{
mainVal = Activator.CreateInstance(mainProperty.PropertyType);
mainProperty.SetValue(obj, mainVal, null);
}
currentObj = mainVal;
var childProperty = mainProperty.PropertyType.GetProperty(childPropertyName);
if (childProperty == null) continue;
prop = childProperty;
}
// set property
// we support:
// String
// Int32
// Boolean
// Float
PropertyInfo prop = (PropertyInfo)props[propName];
string val = propValues[propName].ToString();
if (prop.PropertyType == typeof(String))
prop.SetValue(obj, val, null);
prop.SetValue(currentObj, val, null);
else if (prop.PropertyType == typeof(Int32))
prop.SetValue(obj, Int32.Parse(val), null);
prop.SetValue(currentObj, Int32.Parse(val), null);
else
if (prop.PropertyType == typeof(long))
prop.SetValue(obj, long.Parse(val), null);
prop.SetValue(currentObj, long.Parse(val), null);
else
if (prop.PropertyType == typeof(Boolean))
prop.SetValue(obj, Boolean.Parse(val), null);
prop.SetValue(currentObj, Boolean.Parse(val), null);
else if (prop.PropertyType == typeof(Single))
prop.SetValue(obj, Single.Parse(val), null);
prop.SetValue(currentObj, Single.Parse(val), null);
else if (prop.PropertyType.IsEnum)
prop.SetValue(obj, Enum.Parse(prop.PropertyType, val, true), null);
prop.SetValue(currentObj, Enum.Parse(prop.PropertyType, val, true), null);
else
if (prop.PropertyType == typeof(Guid))
prop.SetValue(obj, new Guid(val), null);
prop.SetValue(currentObj, new Guid(val), null);
else
if (prop.PropertyType == typeof(string[]))
{
if (val == "")
prop.SetValue(obj, new string[0], null);
prop.SetValue(currentObj, new string[0], null);
else
prop.SetValue(obj, val.Split(';'), null);
prop.SetValue(currentObj, val.Split(';'), null);
}
else if (prop.PropertyType == typeof(int[]))
{
@ -562,7 +621,7 @@ namespace WebsitePanel.EnterpriseServer
if (val == "")
ivals = new int[0];
prop.SetValue(obj, ivals, null);
prop.SetValue(currentObj, ivals, null);
}
}
}

View file

@ -254,8 +254,6 @@ namespace WebsitePanel.EnterpriseServer
return res;
}
int generation = 1;
// CPU cores
int cpuCores = cntx.Quotas[Quotas.VPS2012_CPU_NUMBER].QuotaAllocatedValue;
if (cpuCores == -1) // unlimited is not possible
@ -309,20 +307,20 @@ namespace WebsitePanel.EnterpriseServer
// create server and return result
return CreateVirtualMachine(packageId, hostname, osTemplate, password, summaryLetterEmail,
generation, cpuCores, ramMB, hddGB, snapshots,
cpuCores, ramMB, hddGB, snapshots,
dvdInstalled, bootFromCD, numLock,
startShutdownAllowed, pauseResumeAllowed, rebootAllowed, resetAllowed, reinstallAllowed,
externalNetworkEnabled, externalAddressesNumber, randomExternalAddresses, externalAddresses,
privateNetworkEnabled, privateAddressesNumber, randomPrivateAddresses, privateAddresses);
privateNetworkEnabled, privateAddressesNumber, randomPrivateAddresses, privateAddresses, new VirtualMachine());
}
public static IntResult CreateVirtualMachine(int packageId,
string hostname, string osTemplateFile, string password, string summaryLetterEmail,
int generation, int cpuCores, int ramMB, int hddGB, int snapshots,
int cpuCores, int ramMB, int hddGB, int snapshots,
bool dvdInstalled, bool bootFromCD, bool numLock,
bool startShutdownAllowed, bool pauseResumeAllowed, bool rebootAllowed, bool resetAllowed, bool reinstallAllowed,
bool externalNetworkEnabled, int externalAddressesNumber, bool randomExternalAddresses, int[] externalAddresses,
bool privateNetworkEnabled, int privateAddressesNumber, bool randomPrivateAddresses, string[] privateAddresses)
bool privateNetworkEnabled, int privateAddressesNumber, bool randomPrivateAddresses, string[] privateAddresses, VirtualMachine otherSettings)
{
// result object
IntResult res = new IntResult();
@ -368,10 +366,20 @@ namespace WebsitePanel.EnterpriseServer
List<string> quotaResults = new List<string>();
PackageContext cntx = PackageController.GetPackageContext(packageId);
// dynamic memory
var newRam = ramMB;
if (otherSettings.DynamicMemory != null && otherSettings.DynamicMemory.Enabled)
{
newRam = otherSettings.DynamicMemory.Maximum;
if (ramMB > otherSettings.DynamicMemory.Maximum || ramMB < otherSettings.DynamicMemory.Minimum)
quotaResults.Add(VirtualizationErrorCodes.QUOTA_NOT_IN_DYNAMIC_RAM);
}
CheckListsQuota(cntx, quotaResults, Quotas.VPS2012_SERVERS_NUMBER, VirtualizationErrorCodes.QUOTA_EXCEEDED_SERVERS_NUMBER);
CheckNumericQuota(cntx, quotaResults, Quotas.VPS2012_CPU_NUMBER, cpuCores, VirtualizationErrorCodes.QUOTA_EXCEEDED_CPU);
CheckNumericQuota(cntx, quotaResults, Quotas.VPS2012_RAM, ramMB, VirtualizationErrorCodes.QUOTA_EXCEEDED_RAM);
CheckNumericQuota(cntx, quotaResults, Quotas.VPS2012_RAM, newRam, VirtualizationErrorCodes.QUOTA_EXCEEDED_RAM);
CheckNumericQuota(cntx, quotaResults, Quotas.VPS2012_HDD, hddGB, VirtualizationErrorCodes.QUOTA_EXCEEDED_HDD);
CheckNumericQuota(cntx, quotaResults, Quotas.VPS2012_SNAPSHOTS_NUMBER, snapshots, VirtualizationErrorCodes.QUOTA_EXCEEDED_SNAPSHOTS);
@ -458,7 +466,7 @@ namespace WebsitePanel.EnterpriseServer
vm.CurrentTaskId = Guid.NewGuid().ToString("N"); // generate creation task id
vm.ProvisioningStatus = VirtualMachineProvisioningStatus.InProgress;
vm.Generation = generation;
vm.Generation = otherSettings.Generation;
vm.CpuCores = cpuCores;
vm.RamSize = ramMB;
vm.HddSize = hddGB;
@ -472,6 +480,12 @@ namespace WebsitePanel.EnterpriseServer
vm.ResetAllowed = resetAllowed;
vm.ReinstallAllowed = reinstallAllowed;
// dynamic memory
if (otherSettings.DynamicMemory != null && otherSettings.DynamicMemory.Enabled)
vm.DynamicMemory = otherSettings.DynamicMemory;
else
vm.DynamicMemory = null;
// networking
vm.ExternalNetworkEnabled = externalNetworkEnabled;
vm.PrivateNetworkEnabled = privateNetworkEnabled;
@ -1192,8 +1206,10 @@ namespace WebsitePanel.EnterpriseServer
item.Name = vm.Name;
item.ProvisioningStatus = VirtualMachineProvisioningStatus.OK;
item.Generation = vm.Generation;
item.CpuCores = vm.CpuCores;
item.RamSize = vm.RamSize;
item.DynamicMemory = vm.DynamicMemory;
item.HddSize = vm.HddSize;
item.VirtualHardDrivePath = vm.VirtualHardDrivePath;
item.RootFolderPath = Path.GetDirectoryName(vm.VirtualHardDrivePath);
@ -1947,11 +1963,7 @@ namespace WebsitePanel.EnterpriseServer
#endregion
#region VPS Edit Configuration
public static ResultObject UpdateVirtualMachineConfiguration(int itemId, int cpuCores, int ramMB, int hddGB, int snapshots,
bool dvdInstalled, bool bootFromCD, bool numLock,
bool startShutdownAllowed, bool pauseResumeAllowed, bool rebootAllowed, bool resetAllowed, bool reinstallAllowed,
bool externalNetworkEnabled,
bool privateNetworkEnabled)
public static ResultObject UpdateVirtualMachineConfiguration(int itemId, int cpuCores, int ramMB, int hddGB, int snapshots, bool dvdInstalled, bool bootFromCD, bool numLock, bool startShutdownAllowed, bool pauseResumeAllowed, bool rebootAllowed, bool resetAllowed, bool reinstallAllowed, bool externalNetworkEnabled, bool privateNetworkEnabled, VirtualMachine otherSettings)
{
ResultObject res = new ResultObject();
@ -1978,8 +1990,22 @@ namespace WebsitePanel.EnterpriseServer
List<string> quotaResults = new List<string>();
PackageContext cntx = PackageController.GetPackageContext(vm.PackageId);
var currentRam = vm.RamSize;
var newRam = ramMB;
// dynamic memory
if (vm.DynamicMemory != null && vm.DynamicMemory.Enabled)
currentRam = vm.DynamicMemory.Maximum;
if (otherSettings.DynamicMemory != null && otherSettings.DynamicMemory.Enabled)
{
newRam = otherSettings.DynamicMemory.Maximum;
if (ramMB > otherSettings.DynamicMemory.Maximum || ramMB < otherSettings.DynamicMemory.Minimum)
quotaResults.Add(VirtualizationErrorCodes.QUOTA_NOT_IN_DYNAMIC_RAM);
}
CheckNumericQuota(cntx, quotaResults, Quotas.VPS2012_CPU_NUMBER, cpuCores, VirtualizationErrorCodes.QUOTA_EXCEEDED_CPU);
CheckNumericQuota(cntx, quotaResults, Quotas.VPS2012_RAM, vm.RamSize, ramMB, VirtualizationErrorCodes.QUOTA_EXCEEDED_RAM);
CheckNumericQuota(cntx, quotaResults, Quotas.VPS2012_RAM, currentRam, newRam, VirtualizationErrorCodes.QUOTA_EXCEEDED_RAM);
CheckNumericQuota(cntx, quotaResults, Quotas.VPS2012_HDD, vm.HddSize, hddGB, VirtualizationErrorCodes.QUOTA_EXCEEDED_HDD);
CheckNumericQuota(cntx, quotaResults, Quotas.VPS2012_SNAPSHOTS_NUMBER, snapshots, VirtualizationErrorCodes.QUOTA_EXCEEDED_SNAPSHOTS);
@ -2072,6 +2098,12 @@ namespace WebsitePanel.EnterpriseServer
vm.ExternalNetworkEnabled = externalNetworkEnabled;
vm.PrivateNetworkEnabled = privateNetworkEnabled;
// dynamic memory
if (otherSettings.DynamicMemory != null && otherSettings.DynamicMemory.Enabled)
vm.DynamicMemory = otherSettings.DynamicMemory;
else
vm.DynamicMemory = null;
// load service settings
StringDictionary settings = ServerController.GetServiceSettings(vm.ServiceId);

View file

@ -186,17 +186,17 @@ namespace WebsitePanel.EnterpriseServer
[WebMethod]
public IntResult CreateVirtualMachine(int packageId,
string hostname, string osTemplateFile, string password, string summaryLetterEmail,
int generation, int cpuCores, int ramMB, int hddGB, int snapshots, bool dvdInstalled, bool bootFromCD, bool numLock,
int cpuCores, int ramMB, int hddGB, int snapshots, bool dvdInstalled, bool bootFromCD, bool numLock,
bool startShutdownAllowed, bool pauseResumeAllowed, bool rebootAllowed, bool resetAllowed, bool reinstallAllowed,
bool externalNetworkEnabled, int externalAddressesNumber, bool randomExternalAddresses, int[] externalAddresses,
bool privateNetworkEnabled, int privateAddressesNumber, bool randomPrivateAddresses, string[] privateAddresses)
bool privateNetworkEnabled, int privateAddressesNumber, bool randomPrivateAddresses, string[] privateAddresses, VirtualMachine otherSettings)
{
return VirtualizationServerController2012.CreateVirtualMachine(packageId,
hostname, osTemplateFile, password, summaryLetterEmail,
generation, cpuCores, ramMB, hddGB, snapshots, dvdInstalled, bootFromCD, numLock,
cpuCores, ramMB, hddGB, snapshots, dvdInstalled, bootFromCD, numLock,
startShutdownAllowed, pauseResumeAllowed, rebootAllowed, resetAllowed, reinstallAllowed,
externalNetworkEnabled, externalAddressesNumber, randomExternalAddresses, externalAddresses,
privateNetworkEnabled, privateAddressesNumber, randomPrivateAddresses, privateAddresses);
privateNetworkEnabled, privateAddressesNumber, randomPrivateAddresses, privateAddresses, otherSettings);
}
#endregion
@ -278,14 +278,14 @@ namespace WebsitePanel.EnterpriseServer
bool dvdInstalled, bool bootFromCD, bool numLock,
bool startShutdownAllowed, bool pauseResumeAllowed, bool rebootAllowed, bool resetAllowed, bool reinstallAllowed,
bool externalNetworkEnabled,
bool privateNetworkEnabled)
bool privateNetworkEnabled, VirtualMachine otherSettings)
{
return VirtualizationServerController2012.UpdateVirtualMachineConfiguration(
itemId, cpuCores, ramMB, hddGB, snapshots,
dvdInstalled, bootFromCD, numLock,
startShutdownAllowed, pauseResumeAllowed, rebootAllowed, resetAllowed, reinstallAllowed,
externalNetworkEnabled,
privateNetworkEnabled);
externalNetworkEnabled, privateNetworkEnabled,
otherSettings);
}
#endregion

View file

@ -30,7 +30,7 @@ using System;
namespace WebsitePanel.Providers
{
[AttributeUsage(AttributeTargets.Property)]
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class)]
public class PersistentAttribute : Attribute
{
public PersistentAttribute()

View file

@ -31,16 +31,22 @@
namespace WebsitePanel.Providers.Virtualization
{
[Persistent]
public class DynamicMemory
{
[Persistent]
public bool Enabled { get; set; }
[Persistent]
public int Minimum { get; set; }
[Persistent]
public int Maximum { get; set; }
[Persistent]
public int Buffer { get; set; }
[Persistent]
public int Priority { get; set; } // Weight
}
}

View file

@ -25,8 +25,8 @@ namespace WebsitePanel.Providers.Virtualization
info.Enabled = result[0].GetBool("DynamicMemoryEnabled");
info.Minimum = Convert.ToInt32(result[0].GetLong("Minimum") / Constants.Size1M);
info.Maximum = Convert.ToInt32(result[0].GetLong("Maximum") / Constants.Size1M);
info.Buffer = Convert.ToInt32(result[0].GetInt("Buffer") / Constants.Size1M);
info.Priority = Convert.ToInt32(result[0].GetInt("Priority") / Constants.Size1M);
info.Buffer = Convert.ToInt32(result[0].GetInt("Buffer"));
info.Priority = Convert.ToInt32(result[0].GetInt("Priority"));
}
return info;

View file

@ -4262,6 +4262,9 @@
<data name="VPS.VPS_QUOTA_WRONG_RAM" xml:space="preserve">
<value>RAM size must be a positive number and greater than zero</value>
</data>
<data name="VPS.VPS_QUOTA_NOT_IN_DYNAMIC_RAM" xml:space="preserve">
<value>RAM size must be between the minimum and maximum of the dynamic memory</value>
</data>
<data name="VPS.VPS_QUOTA_WRONG_SNAPSHOTS" xml:space="preserve">
<value>Snapshots must be a positive number and greater than zero</value>
</data>

View file

@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="locMinimum.Text" xml:space="preserve">
<value>Minimum RAM:</value>
<value>Minimum RAM, Mb:</value>
</data>
<data name="MinimumCompareValidator.ErrorMessage" xml:space="preserve">
<value>Minimum memory must be a whole number</value>
@ -145,10 +145,10 @@
<value>Enter the buffer</value>
</data>
<data name="locBuffer.Text" xml:space="preserve">
<value>Buffer (%):</value>
<value>Buffer, %:</value>
</data>
<data name="locMaximum.Text" xml:space="preserve">
<value>Maximum RAM:</value>
<value>Maximum RAM, Mb:</value>
</data>
<data name="locPriority.Text" xml:space="preserve">
<value>Weight (Priority):</value>

View file

@ -82,7 +82,7 @@ namespace WebsitePanel.Portal.VPS2012.UserControls
if (string.IsNullOrEmpty(text))
return 0;
return Int32.Parse(txtMinimum.Text);
return Int32.Parse(text);
}
}
}

View file

@ -193,7 +193,7 @@
</table>
</asp:Panel>
<wsp:DynamicMemoryControl ruVpsnat="server" ID="DynamicMemorySetting" Mode="Edit"/>
<wsp:DynamicMemoryControl runat="server" ID="DynamicMemorySetting" Mode="Edit"/>
<wsp:CollapsiblePanel id="secSnapshots" runat="server"
TargetControlID="SnapshotsPanel" meta:resourcekey="secSnapshots" Text="Snapshots">

View file

@ -338,12 +338,13 @@ namespace WebsitePanel.Portal.VPS2012
// create virtual machine
IntResult res = ES.Services.VPS2012.CreateVirtualMachine(PanelSecurity.PackageId,
hostname, listOperatingSystems.SelectedValue, adminPassword, summaryEmail,
virtualMachine.Generation, Utils.ParseInt(ddlCpu.SelectedValue), Utils.ParseInt(txtRam.Text.Trim()),
Utils.ParseInt(ddlCpu.SelectedValue), Utils.ParseInt(txtRam.Text.Trim()),
Utils.ParseInt(txtHdd.Text.Trim()), Utils.ParseInt(txtSnapshots.Text.Trim()),
chkDvdInstalled.Checked, chkBootFromCd.Checked, chkNumLock.Checked,
chkStartShutdown.Checked, chkPauseResume.Checked, chkReboot.Checked, chkReset.Checked, chkReinstall.Checked,
chkExternalNetworkEnabled.Checked, Utils.ParseInt(txtExternalAddressesNumber.Text.Trim()), radioExternalRandom.Checked, extIps.ToArray(),
chkPrivateNetworkEnabled.Checked, Utils.ParseInt(txtPrivateAddressesNumber.Text.Trim()), radioPrivateRandom.Checked, privIps);
chkPrivateNetworkEnabled.Checked, Utils.ParseInt(txtPrivateAddressesNumber.Text.Trim()), radioPrivateRandom.Checked, privIps,
virtualMachine);
if (res.IsSuccess)
{

View file

@ -381,6 +381,15 @@ namespace WebsitePanel.Portal.VPS2012 {
/// </remarks>
protected global::System.Web.UI.WebControls.Localize locGB;
/// <summary>
/// DynamicMemorySetting control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.VPS2012.UserControls.DynamicMemoryControl DynamicMemorySetting;
/// <summary>
/// secSnapshots control.
/// </summary>

View file

@ -6,6 +6,8 @@
<%@ Register Src="../UserControls/CollapsiblePanel.ascx" TagName="CollapsiblePanel" TagPrefix="wsp" %>
<%@ Register Src="../UserControls/CheckBoxOption.ascx" TagName="CheckBoxOption" TagPrefix="wsp" %>
<%@ Register Src="../UserControls/EnableAsyncTasksSupport.ascx" TagName="EnableAsyncTasksSupport" TagPrefix="wsp" %>
<%@ Register TagPrefix="wsp" TagName="Generation" Src="UserControls/Generation.ascx" %>
<%@ Register TagPrefix="wsp" TagName="DynamicMemoryControl" Src="UserControls/DynamicMemoryControl.ascx" %>
<wsp:EnableAsyncTasksSupport id="asyncTasks" runat="server"/>
@ -114,11 +116,12 @@
</wsp:CollapsiblePanel>
<asp:Panel ID="ConfigurationPanel" runat="server" Height="0" style="overflow:hidden;padding:5px;">
<table cellpadding="4">
<wsp:Generation runat="server" ID="GenerationSetting" Mode="Summary"/>
<tr>
<td class="FormLabel150">
<td>
<asp:Localize ID="locCPU" runat="server" meta:resourcekey="locCPU" Text="CPU:"></asp:Localize>
</td>
<td class="NormalBold">
<td>
<asp:Literal ID="CpuCores" runat="server" Text="0"></asp:Literal>
</td>
</tr>
@ -126,7 +129,7 @@
<td>
<asp:Localize ID="locRAM" runat="server" meta:resourcekey="locRAM" Text="RAM:"></asp:Localize>
</td>
<td class="NormalBold">
<td>
<asp:Literal ID="RamSize" runat="server" Text="0"></asp:Literal>
</td>
</tr>
@ -134,7 +137,7 @@
<td>
<asp:Localize ID="locHDD" runat="server" meta:resourcekey="locHDD" Text="HDD:"></asp:Localize>
</td>
<td class="NormalBold">
<td>
<asp:Literal ID="HddSize" runat="server" Text="0"></asp:Literal>
</td>
</tr>
@ -142,13 +145,15 @@
<td>
<asp:Localize ID="locVhdPath" runat="server" meta:resourcekey="locVhdPath" Text="VHD location:"></asp:Localize>
</td>
<td class="NormalBold">
<td>
<asp:Literal ID="VhdPath" runat="server" Text="0"></asp:Literal>
</td>
</tr>
</table>
</asp:Panel>
<wsp:DynamicMemoryControl runat="server" ID="DynamicMemorySetting" Mode="Display"/>
<wsp:CollapsiblePanel id="secBios" runat="server"
TargetControlID="BiosPanel" meta:resourcekey="secBios" Text="BIOS">
</wsp:CollapsiblePanel>

View file

@ -33,7 +33,8 @@ using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using WebsitePanel.EnterpriseServer;
using WebsitePanel.Providers.Virtualization;
using WebsitePanel.Portal.Code.Helpers;
using WebsitePanel.Providers.Virtualization;
using WebsitePanel.Providers.ResultObjects;
namespace WebsitePanel.Portal.VPS2012
@ -126,6 +127,8 @@ namespace WebsitePanel.Portal.VPS2012
HddSize.Text = vm.HddSize.ToString();
VhdPath.Text = vm.VirtualHardDrivePath;
this.BindSettingsControls(vm);
// other settings
NumLockEnabled.Value = vm.NumLockEnabled;
BootFromCd.Value = vm.BootFromCD;

View file

@ -246,6 +246,15 @@ namespace WebsitePanel.Portal.VPS2012 {
/// </remarks>
protected global::System.Web.UI.WebControls.Panel ConfigurationPanel;
/// <summary>
/// GenerationSetting control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.VPS2012.UserControls.Generation GenerationSetting;
/// <summary>
/// locCPU control.
/// </summary>
@ -318,6 +327,15 @@ namespace WebsitePanel.Portal.VPS2012 {
/// </remarks>
protected global::System.Web.UI.WebControls.Literal VhdPath;
/// <summary>
/// DynamicMemorySetting control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.VPS2012.UserControls.DynamicMemoryControl DynamicMemorySetting;
/// <summary>
/// secBios control.
/// </summary>

View file

@ -137,6 +137,9 @@ namespace WebsitePanel.Portal.VPS2012
protected void btnUpdate_Click(object sender, EventArgs e)
{
if (!Page.IsValid)
return;
try
{
// check rights
@ -165,7 +168,8 @@ namespace WebsitePanel.Portal.VPS2012
chkReset.Checked,
chkReinstall.Checked,
chkExternalNetworkEnabled.Checked,
chkPrivateNetworkEnabled.Checked);
chkPrivateNetworkEnabled.Checked,
virtualMachine);
if (res.IsSuccess)
{