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 GO
DELETE FROM HostingPlanQuotas WHERE QuotaID = 343 DELETE FROM HostingPlanQuotas WHERE QuotaID = 343
GO GO
IF NOT EXISTS (SELECT * FROM [dbo].[ResourceGroups] WHERE GroupID = 33 AND [GroupName] = 'VPS2012')
BEGIN
DELETE FROM HostingPlanResources WHERE GroupID = 33 DELETE FROM HostingPlanResources WHERE GroupID = 33
END
GO GO
@ -8218,17 +8221,23 @@ AS
INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID
INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID
WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3)
ELSE IF @QuotaID = 558 -- RAM of VPS ELSE IF @QuotaID = 558 BEGIN -- RAM of VPS2012
SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP 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 ServiceItems AS SI ON SIP.ItemID = SI.ItemID
INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID
WHERE SIP.PropertyName = 'RamSize' AND PT.ParentPackageID = @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 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 ServiceItems AS SI ON SIP.ItemID = SI.ItemID
INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID
WHERE SIP.PropertyName = 'HddSize' AND PT.ParentPackageID = @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 SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP
INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID
INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID 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_CPU = "VPS_QUOTA_EXCEEDED_CPU";
public const string QUOTA_EXCEEDED_RAM = "VPS_QUOTA_EXCEEDED_RAM"; public const string QUOTA_EXCEEDED_RAM = "VPS_QUOTA_EXCEEDED_RAM";
public const string QUOTA_WRONG_RAM = "VPS_QUOTA_WRONG_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_EXCEEDED_HDD = "VPS_QUOTA_EXCEEDED_HDD";
public const string QUOTA_WRONG_HDD = "VPS_QUOTA_WRONG_HDD"; public const string QUOTA_WRONG_HDD = "VPS_QUOTA_WRONG_HDD";
public const string QUOTA_EXCEEDED_SNAPSHOTS = "VPS_QUOTA_EXCEEDED_SNAPSHOTS"; 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.Virtualization;
using WebsitePanel.Providers.ResultObjects; using WebsitePanel.Providers.ResultObjects;
/// <remarks/> /// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()]
@ -1105,65 +1104,6 @@ namespace WebsitePanel.EnterpriseServer {
string osTemplateFile, string osTemplateFile,
string password, string password,
string summaryLetterEmail, 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 cpuCores,
int ramMB, int ramMB,
int hddGB, int hddGB,
@ -1184,15 +1124,13 @@ namespace WebsitePanel.EnterpriseServer {
int privateAddressesNumber, int privateAddressesNumber,
bool randomPrivateAddresses, bool randomPrivateAddresses,
string[] privateAddresses, string[] privateAddresses,
System.AsyncCallback callback, VirtualMachine otherSettings) {
object asyncState) { object[] results = this.Invoke("CreateVirtualMachine", new object[] {
return this.BeginInvoke("CreateVirtualMachine", new object[] {
packageId, packageId,
hostname, hostname,
osTemplateFile, osTemplateFile,
password, password,
summaryLetterEmail, summaryLetterEmail,
generation,
cpuCores, cpuCores,
ramMB, ramMB,
hddGB, hddGB,
@ -1212,7 +1150,68 @@ namespace WebsitePanel.EnterpriseServer {
privateNetworkEnabled, privateNetworkEnabled,
privateAddressesNumber, privateAddressesNumber,
randomPrivateAddresses, 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/> /// <remarks/>
@ -1228,38 +1227,6 @@ namespace WebsitePanel.EnterpriseServer {
string osTemplateFile, string osTemplateFile,
string password, string password,
string summaryLetterEmail, 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 cpuCores,
int ramMB, int ramMB,
int hddGB, int hddGB,
@ -1280,6 +1247,38 @@ namespace WebsitePanel.EnterpriseServer {
int privateAddressesNumber, int privateAddressesNumber,
bool randomPrivateAddresses, bool randomPrivateAddresses,
string[] privateAddresses, 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) { object userState) {
if ((this.CreateVirtualMachineOperationCompleted == null)) { if ((this.CreateVirtualMachineOperationCompleted == null)) {
this.CreateVirtualMachineOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateVirtualMachineOperationCompleted); this.CreateVirtualMachineOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateVirtualMachineOperationCompleted);
@ -1290,7 +1289,6 @@ namespace WebsitePanel.EnterpriseServer {
osTemplateFile, osTemplateFile,
password, password,
summaryLetterEmail, summaryLetterEmail,
generation,
cpuCores, cpuCores,
ramMB, ramMB,
hddGB, hddGB,
@ -1310,7 +1308,8 @@ namespace WebsitePanel.EnterpriseServer {
privateNetworkEnabled, privateNetworkEnabled,
privateAddressesNumber, privateAddressesNumber,
randomPrivateAddresses, randomPrivateAddresses,
privateAddresses}, this.CreateVirtualMachineOperationCompleted, userState); privateAddresses,
otherSettings}, this.CreateVirtualMachineOperationCompleted, userState);
} }
private void OnCreateVirtualMachineOperationCompleted(object arg) { private void OnCreateVirtualMachineOperationCompleted(object arg) {
@ -1765,7 +1764,23 @@ namespace WebsitePanel.EnterpriseServer {
/// <remarks/> /// <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)] [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[] { object[] results = this.Invoke("UpdateVirtualMachineConfiguration", new object[] {
itemId, itemId,
cpuCores, cpuCores,
@ -1781,7 +1796,8 @@ namespace WebsitePanel.EnterpriseServer {
resetAllowed, resetAllowed,
reinstallAllowed, reinstallAllowed,
externalNetworkEnabled, externalNetworkEnabled,
privateNetworkEnabled}); privateNetworkEnabled,
otherSettings});
return ((ResultObject)(results[0])); return ((ResultObject)(results[0]));
} }
@ -1802,6 +1818,7 @@ namespace WebsitePanel.EnterpriseServer {
bool reinstallAllowed, bool reinstallAllowed,
bool externalNetworkEnabled, bool externalNetworkEnabled,
bool privateNetworkEnabled, bool privateNetworkEnabled,
VirtualMachine otherSettings,
System.AsyncCallback callback, System.AsyncCallback callback,
object asyncState) { object asyncState) {
return this.BeginInvoke("UpdateVirtualMachineConfiguration", new object[] { return this.BeginInvoke("UpdateVirtualMachineConfiguration", new object[] {
@ -1819,7 +1836,8 @@ namespace WebsitePanel.EnterpriseServer {
resetAllowed, resetAllowed,
reinstallAllowed, reinstallAllowed,
externalNetworkEnabled, externalNetworkEnabled,
privateNetworkEnabled}, callback, asyncState); privateNetworkEnabled,
otherSettings}, callback, asyncState);
} }
/// <remarks/> /// <remarks/>
@ -1828,11 +1846,6 @@ namespace WebsitePanel.EnterpriseServer {
return ((ResultObject)(results[0])); 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/> /// <remarks/>
public void UpdateVirtualMachineConfigurationAsync( public void UpdateVirtualMachineConfigurationAsync(
int itemId, int itemId,
@ -1850,6 +1863,28 @@ namespace WebsitePanel.EnterpriseServer {
bool reinstallAllowed, bool reinstallAllowed,
bool externalNetworkEnabled, bool externalNetworkEnabled,
bool privateNetworkEnabled, 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) { object userState) {
if ((this.UpdateVirtualMachineConfigurationOperationCompleted == null)) { if ((this.UpdateVirtualMachineConfigurationOperationCompleted == null)) {
this.UpdateVirtualMachineConfigurationOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateVirtualMachineConfigurationOperationCompleted); this.UpdateVirtualMachineConfigurationOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateVirtualMachineConfigurationOperationCompleted);
@ -1869,7 +1904,8 @@ namespace WebsitePanel.EnterpriseServer {
resetAllowed, resetAllowed,
reinstallAllowed, reinstallAllowed,
externalNetworkEnabled, externalNetworkEnabled,
privateNetworkEnabled}, this.UpdateVirtualMachineConfigurationOperationCompleted, userState); privateNetworkEnabled,
otherSettings}, this.UpdateVirtualMachineConfigurationOperationCompleted, userState);
} }
private void OnUpdateVirtualMachineConfigurationOperationCompleted(object arg) { private void OnUpdateVirtualMachineConfigurationOperationCompleted(object arg) {

View file

@ -98,6 +98,19 @@ namespace WebsitePanel.EnterpriseServer
svals[i] = ivals[i].ToString(); svals[i] = ivals[i].ToString();
s = String.Join(";", svals); 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 else
s = val.ToString(); 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) public static void CreateObjectFromHash(object obj, Hashtable propValues, bool persistentOnly)
{ {
Type type = obj.GetType(); Type type = obj.GetType();
@ -489,21 +537,7 @@ namespace WebsitePanel.EnterpriseServer
} }
else else
{ {
// create properties cache props = GetPropertiesForCache(type, persistentOnly);
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);
}
}
if (!propertiesCache.ContainsKey(type.Name)) if (!propertiesCache.ContainsKey(type.Name))
{ {
@ -518,38 +552,63 @@ namespace WebsitePanel.EnterpriseServer
// try to locate specified property // try to locate specified property
if (props[propName] != null) 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 // set property
// we support: // we support:
// String // String
// Int32 // Int32
// Boolean // Boolean
// Float // Float
PropertyInfo prop = (PropertyInfo)props[propName];
string val = propValues[propName].ToString();
if (prop.PropertyType == typeof(String)) if (prop.PropertyType == typeof(String))
prop.SetValue(obj, val, null); prop.SetValue(currentObj, val, null);
else if (prop.PropertyType == typeof(Int32)) else if (prop.PropertyType == typeof(Int32))
prop.SetValue(obj, Int32.Parse(val), null); prop.SetValue(currentObj, Int32.Parse(val), null);
else else
if (prop.PropertyType == typeof(long)) if (prop.PropertyType == typeof(long))
prop.SetValue(obj, long.Parse(val), null); prop.SetValue(currentObj, long.Parse(val), null);
else else
if (prop.PropertyType == typeof(Boolean)) 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)) 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) 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 else
if (prop.PropertyType == typeof(Guid)) if (prop.PropertyType == typeof(Guid))
prop.SetValue(obj, new Guid(val), null); prop.SetValue(currentObj, new Guid(val), null);
else else
if (prop.PropertyType == typeof(string[])) if (prop.PropertyType == typeof(string[]))
{ {
if (val == "") if (val == "")
prop.SetValue(obj, new string[0], null); prop.SetValue(currentObj, new string[0], null);
else else
prop.SetValue(obj, val.Split(';'), null); prop.SetValue(currentObj, val.Split(';'), null);
} }
else if (prop.PropertyType == typeof(int[])) else if (prop.PropertyType == typeof(int[]))
{ {
@ -562,7 +621,7 @@ namespace WebsitePanel.EnterpriseServer
if (val == "") if (val == "")
ivals = new int[0]; 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; return res;
} }
int generation = 1;
// CPU cores // CPU cores
int cpuCores = cntx.Quotas[Quotas.VPS2012_CPU_NUMBER].QuotaAllocatedValue; int cpuCores = cntx.Quotas[Quotas.VPS2012_CPU_NUMBER].QuotaAllocatedValue;
if (cpuCores == -1) // unlimited is not possible if (cpuCores == -1) // unlimited is not possible
@ -309,20 +307,20 @@ namespace WebsitePanel.EnterpriseServer
// create server and return result // create server and return result
return CreateVirtualMachine(packageId, hostname, osTemplate, password, summaryLetterEmail, return CreateVirtualMachine(packageId, hostname, osTemplate, password, summaryLetterEmail,
generation, cpuCores, ramMB, hddGB, snapshots, cpuCores, ramMB, hddGB, snapshots,
dvdInstalled, bootFromCD, numLock, dvdInstalled, bootFromCD, numLock,
startShutdownAllowed, pauseResumeAllowed, rebootAllowed, resetAllowed, reinstallAllowed, startShutdownAllowed, pauseResumeAllowed, rebootAllowed, resetAllowed, reinstallAllowed,
externalNetworkEnabled, externalAddressesNumber, randomExternalAddresses, externalAddresses, externalNetworkEnabled, externalAddressesNumber, randomExternalAddresses, externalAddresses,
privateNetworkEnabled, privateAddressesNumber, randomPrivateAddresses, privateAddresses); privateNetworkEnabled, privateAddressesNumber, randomPrivateAddresses, privateAddresses, new VirtualMachine());
} }
public static IntResult CreateVirtualMachine(int packageId, public static IntResult CreateVirtualMachine(int packageId,
string hostname, string osTemplateFile, string password, string summaryLetterEmail, 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 dvdInstalled, bool bootFromCD, bool numLock,
bool startShutdownAllowed, bool pauseResumeAllowed, bool rebootAllowed, bool resetAllowed, bool reinstallAllowed, bool startShutdownAllowed, bool pauseResumeAllowed, bool rebootAllowed, bool resetAllowed, bool reinstallAllowed,
bool externalNetworkEnabled, int externalAddressesNumber, bool randomExternalAddresses, int[] externalAddresses, 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 // result object
IntResult res = new IntResult(); IntResult res = new IntResult();
@ -368,10 +366,20 @@ namespace WebsitePanel.EnterpriseServer
List<string> quotaResults = new List<string>(); List<string> quotaResults = new List<string>();
PackageContext cntx = PackageController.GetPackageContext(packageId); 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); 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_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_HDD, hddGB, VirtualizationErrorCodes.QUOTA_EXCEEDED_HDD);
CheckNumericQuota(cntx, quotaResults, Quotas.VPS2012_SNAPSHOTS_NUMBER, snapshots, VirtualizationErrorCodes.QUOTA_EXCEEDED_SNAPSHOTS); 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.CurrentTaskId = Guid.NewGuid().ToString("N"); // generate creation task id
vm.ProvisioningStatus = VirtualMachineProvisioningStatus.InProgress; vm.ProvisioningStatus = VirtualMachineProvisioningStatus.InProgress;
vm.Generation = generation; vm.Generation = otherSettings.Generation;
vm.CpuCores = cpuCores; vm.CpuCores = cpuCores;
vm.RamSize = ramMB; vm.RamSize = ramMB;
vm.HddSize = hddGB; vm.HddSize = hddGB;
@ -472,6 +480,12 @@ namespace WebsitePanel.EnterpriseServer
vm.ResetAllowed = resetAllowed; vm.ResetAllowed = resetAllowed;
vm.ReinstallAllowed = reinstallAllowed; vm.ReinstallAllowed = reinstallAllowed;
// dynamic memory
if (otherSettings.DynamicMemory != null && otherSettings.DynamicMemory.Enabled)
vm.DynamicMemory = otherSettings.DynamicMemory;
else
vm.DynamicMemory = null;
// networking // networking
vm.ExternalNetworkEnabled = externalNetworkEnabled; vm.ExternalNetworkEnabled = externalNetworkEnabled;
vm.PrivateNetworkEnabled = privateNetworkEnabled; vm.PrivateNetworkEnabled = privateNetworkEnabled;
@ -1192,8 +1206,10 @@ namespace WebsitePanel.EnterpriseServer
item.Name = vm.Name; item.Name = vm.Name;
item.ProvisioningStatus = VirtualMachineProvisioningStatus.OK; item.ProvisioningStatus = VirtualMachineProvisioningStatus.OK;
item.Generation = vm.Generation;
item.CpuCores = vm.CpuCores; item.CpuCores = vm.CpuCores;
item.RamSize = vm.RamSize; item.RamSize = vm.RamSize;
item.DynamicMemory = vm.DynamicMemory;
item.HddSize = vm.HddSize; item.HddSize = vm.HddSize;
item.VirtualHardDrivePath = vm.VirtualHardDrivePath; item.VirtualHardDrivePath = vm.VirtualHardDrivePath;
item.RootFolderPath = Path.GetDirectoryName(vm.VirtualHardDrivePath); item.RootFolderPath = Path.GetDirectoryName(vm.VirtualHardDrivePath);
@ -1947,11 +1963,7 @@ namespace WebsitePanel.EnterpriseServer
#endregion #endregion
#region VPS Edit Configuration #region VPS Edit Configuration
public static ResultObject UpdateVirtualMachineConfiguration(int itemId, int cpuCores, int ramMB, int hddGB, int snapshots, 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)
bool dvdInstalled, bool bootFromCD, bool numLock,
bool startShutdownAllowed, bool pauseResumeAllowed, bool rebootAllowed, bool resetAllowed, bool reinstallAllowed,
bool externalNetworkEnabled,
bool privateNetworkEnabled)
{ {
ResultObject res = new ResultObject(); ResultObject res = new ResultObject();
@ -1978,8 +1990,22 @@ namespace WebsitePanel.EnterpriseServer
List<string> quotaResults = new List<string>(); List<string> quotaResults = new List<string>();
PackageContext cntx = PackageController.GetPackageContext(vm.PackageId); 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_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_HDD, vm.HddSize, hddGB, VirtualizationErrorCodes.QUOTA_EXCEEDED_HDD);
CheckNumericQuota(cntx, quotaResults, Quotas.VPS2012_SNAPSHOTS_NUMBER, snapshots, VirtualizationErrorCodes.QUOTA_EXCEEDED_SNAPSHOTS); CheckNumericQuota(cntx, quotaResults, Quotas.VPS2012_SNAPSHOTS_NUMBER, snapshots, VirtualizationErrorCodes.QUOTA_EXCEEDED_SNAPSHOTS);
@ -2058,7 +2084,7 @@ namespace WebsitePanel.EnterpriseServer
vm.RamSize = ramMB; vm.RamSize = ramMB;
vm.HddSize = hddGB; vm.HddSize = hddGB;
vm.SnapshotsNumber = snapshots; vm.SnapshotsNumber = snapshots;
vm.BootFromCD = bootFromCD; vm.BootFromCD = bootFromCD;
vm.NumLockEnabled = numLock; vm.NumLockEnabled = numLock;
vm.DvdDriveInstalled = dvdInstalled; vm.DvdDriveInstalled = dvdInstalled;
@ -2072,6 +2098,12 @@ namespace WebsitePanel.EnterpriseServer
vm.ExternalNetworkEnabled = externalNetworkEnabled; vm.ExternalNetworkEnabled = externalNetworkEnabled;
vm.PrivateNetworkEnabled = privateNetworkEnabled; vm.PrivateNetworkEnabled = privateNetworkEnabled;
// dynamic memory
if (otherSettings.DynamicMemory != null && otherSettings.DynamicMemory.Enabled)
vm.DynamicMemory = otherSettings.DynamicMemory;
else
vm.DynamicMemory = null;
// load service settings // load service settings
StringDictionary settings = ServerController.GetServiceSettings(vm.ServiceId); StringDictionary settings = ServerController.GetServiceSettings(vm.ServiceId);

View file

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

View file

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

View file

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

View file

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

View file

@ -4262,6 +4262,9 @@
<data name="VPS.VPS_QUOTA_WRONG_RAM" xml:space="preserve"> <data name="VPS.VPS_QUOTA_WRONG_RAM" xml:space="preserve">
<value>RAM size must be a positive number and greater than zero</value> <value>RAM size must be a positive number and greater than zero</value>
</data> </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"> <data name="VPS.VPS_QUOTA_WRONG_SNAPSHOTS" xml:space="preserve">
<value>Snapshots must be a positive number and greater than zero</value> <value>Snapshots must be a positive number and greater than zero</value>
</data> </data>

View file

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

View file

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

View file

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

View file

@ -338,12 +338,13 @@ namespace WebsitePanel.Portal.VPS2012
// create virtual machine // create virtual machine
IntResult res = ES.Services.VPS2012.CreateVirtualMachine(PanelSecurity.PackageId, IntResult res = ES.Services.VPS2012.CreateVirtualMachine(PanelSecurity.PackageId,
hostname, listOperatingSystems.SelectedValue, adminPassword, summaryEmail, 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()), Utils.ParseInt(txtHdd.Text.Trim()), Utils.ParseInt(txtSnapshots.Text.Trim()),
chkDvdInstalled.Checked, chkBootFromCd.Checked, chkNumLock.Checked, chkDvdInstalled.Checked, chkBootFromCd.Checked, chkNumLock.Checked,
chkStartShutdown.Checked, chkPauseResume.Checked, chkReboot.Checked, chkReset.Checked, chkReinstall.Checked, chkStartShutdown.Checked, chkPauseResume.Checked, chkReboot.Checked, chkReset.Checked, chkReinstall.Checked,
chkExternalNetworkEnabled.Checked, Utils.ParseInt(txtExternalAddressesNumber.Text.Trim()), radioExternalRandom.Checked, extIps.ToArray(), 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) if (res.IsSuccess)
{ {

View file

@ -381,6 +381,15 @@ namespace WebsitePanel.Portal.VPS2012 {
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.Localize locGB; 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> /// <summary>
/// secSnapshots control. /// secSnapshots control.
/// </summary> /// </summary>

View file

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

View file

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

View file

@ -246,6 +246,15 @@ namespace WebsitePanel.Portal.VPS2012 {
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.Panel ConfigurationPanel; 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> /// <summary>
/// locCPU control. /// locCPU control.
/// </summary> /// </summary>
@ -318,6 +327,15 @@ namespace WebsitePanel.Portal.VPS2012 {
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.Literal VhdPath; 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> /// <summary>
/// secBios control. /// secBios control.
/// </summary> /// </summary>

View file

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