From 88681f444ed5f5de3910d58cc3590491c0bc9e52 Mon Sep 17 00:00:00 2001 From: Alexander Trofimov Date: Tue, 7 Apr 2015 21:49:03 +0300 Subject: [PATCH] wsp-10327 Add Dynamic Memory to VPS - Enterprise Part. --- WebsitePanel/Database/update_db.sql | 17 +- .../VirtualizationErrorCodes.cs | 1 + .../VirtualizationServerProxy2012.cs | 252 ++++++++++-------- .../Common/ObjectUtils.cs | 113 ++++++-- .../VirtualizationServerController2012.cs | 62 +++-- .../esVirtualizationServer2012.asmx.cs | 14 +- .../Common/PersistentAttribute.cs | 2 +- .../Virtualization/DynamicMemory.cs | 6 + .../Helpers/MemoryHelper.cs | 4 +- .../WebsitePanel_SharedResources.ascx.resx | 3 + .../DynamicMemoryControl.ascx.resx | 6 +- .../UserControls/DynamicMemoryControl.ascx.cs | 2 +- .../WebsitePanel/VPS2012/VdcCreateServer.ascx | 2 +- .../VPS2012/VdcCreateServer.ascx.cs | 5 +- .../VPS2012/VdcCreateServer.ascx.designer.cs | 9 + .../WebsitePanel/VPS2012/VdcImportServer.ascx | 15 +- .../VPS2012/VdcImportServer.ascx.cs | 5 +- .../VPS2012/VdcImportServer.ascx.designer.cs | 18 ++ .../VpsDetailsEditConfiguration.ascx.cs | 6 +- 19 files changed, 364 insertions(+), 178 deletions(-) diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index 972a6006..cdeae8e4 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -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 diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Virtualization/VirtualizationErrorCodes.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Virtualization/VirtualizationErrorCodes.cs index e97a8914..6ccd5695 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Virtualization/VirtualizationErrorCodes.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Virtualization/VirtualizationErrorCodes.cs @@ -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"; diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/VirtualizationServerProxy2012.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/VirtualizationServerProxy2012.cs index 45cfcd16..0798c760 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/VirtualizationServerProxy2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/VirtualizationServerProxy2012.cs @@ -23,7 +23,6 @@ namespace WebsitePanel.EnterpriseServer { using WebsitePanel.Providers.Virtualization; using WebsitePanel.Providers.ResultObjects; - /// [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])); - } - - /// - 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])); + } + + /// + 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); } /// @@ -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); - } - - /// - 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); + } + + /// + 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 { /// [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); } /// @@ -1828,11 +1846,6 @@ namespace WebsitePanel.EnterpriseServer { return ((ResultObject)(results[0])); } - /// - 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); - } - /// 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); + } + + /// + 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) { diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Common/ObjectUtils.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Common/ObjectUtils.cs index 67b8a138..b8e28155 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Common/ObjectUtils.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Common/ObjectUtils.cs @@ -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); } } } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Virtualization2012/VirtualizationServerController2012.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Virtualization2012/VirtualizationServerController2012.cs index 40a599ab..8f4402e7 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Virtualization2012/VirtualizationServerController2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Virtualization2012/VirtualizationServerController2012.cs @@ -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 quotaResults = new List(); 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 quotaResults = new List(); 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); @@ -2058,7 +2084,7 @@ namespace WebsitePanel.EnterpriseServer vm.RamSize = ramMB; vm.HddSize = hddGB; vm.SnapshotsNumber = snapshots; - + vm.BootFromCD = bootFromCD; vm.NumLockEnabled = numLock; vm.DvdDriveInstalled = dvdInstalled; @@ -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); diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esVirtualizationServer2012.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esVirtualizationServer2012.asmx.cs index bd486169..79bfecbf 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esVirtualizationServer2012.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esVirtualizationServer2012.asmx.cs @@ -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 diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Common/PersistentAttribute.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Common/PersistentAttribute.cs index 1f3b7108..232b90bd 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Common/PersistentAttribute.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Common/PersistentAttribute.cs @@ -30,7 +30,7 @@ using System; namespace WebsitePanel.Providers { - [AttributeUsage(AttributeTargets.Property)] + [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class)] public class PersistentAttribute : Attribute { public PersistentAttribute() diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/DynamicMemory.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/DynamicMemory.cs index 91b91a08..64b23a64 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/DynamicMemory.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/DynamicMemory.cs @@ -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 } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Virtualization.HyperV-2012R2/Helpers/MemoryHelper.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Virtualization.HyperV-2012R2/Helpers/MemoryHelper.cs index e999b0c4..035da473 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Virtualization.HyperV-2012R2/Helpers/MemoryHelper.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Virtualization.HyperV-2012R2/Helpers/MemoryHelper.cs @@ -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; diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx index 56ba857f..046c66ef 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx @@ -4262,6 +4262,9 @@ RAM size must be a positive number and greater than zero + + RAM size must be between the minimum and maximum of the dynamic memory + Snapshots must be a positive number and greater than zero diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/UserControls/App_LocalResources/DynamicMemoryControl.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/UserControls/App_LocalResources/DynamicMemoryControl.ascx.resx index 2e9c22f9..8ddc22e8 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/UserControls/App_LocalResources/DynamicMemoryControl.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/UserControls/App_LocalResources/DynamicMemoryControl.ascx.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Minimum RAM: + Minimum RAM, Mb: Minimum memory must be a whole number @@ -145,10 +145,10 @@ Enter the buffer - Buffer (%): + Buffer, %: - Maximum RAM: + Maximum RAM, Mb: Weight (Priority): diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/UserControls/DynamicMemoryControl.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/UserControls/DynamicMemoryControl.ascx.cs index e2344882..1ee4fc95 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/UserControls/DynamicMemoryControl.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/UserControls/DynamicMemoryControl.ascx.cs @@ -82,7 +82,7 @@ namespace WebsitePanel.Portal.VPS2012.UserControls if (string.IsNullOrEmpty(text)) return 0; - return Int32.Parse(txtMinimum.Text); + return Int32.Parse(text); } } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcCreateServer.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcCreateServer.ascx index 9719b3a9..058854d5 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcCreateServer.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcCreateServer.ascx @@ -193,7 +193,7 @@ - + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcCreateServer.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcCreateServer.ascx.cs index 0427461b..ad7cdbb3 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcCreateServer.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcCreateServer.ascx.cs @@ -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) { diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcCreateServer.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcCreateServer.ascx.designer.cs index e7a1f597..4baed83d 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcCreateServer.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcCreateServer.ascx.designer.cs @@ -381,6 +381,15 @@ namespace WebsitePanel.Portal.VPS2012 { /// protected global::System.Web.UI.WebControls.Localize locGB; + /// + /// DynamicMemorySetting control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.VPS2012.UserControls.DynamicMemoryControl DynamicMemorySetting; + /// /// secSnapshots control. /// diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcImportServer.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcImportServer.ascx index c9e4f6e5..65b9f276 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcImportServer.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcImportServer.ascx @@ -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" %> @@ -114,11 +116,12 @@ + - - @@ -126,7 +129,7 @@ - @@ -134,7 +137,7 @@ - @@ -142,13 +145,15 @@ -
+ +
+
+
+
+ + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcImportServer.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcImportServer.ascx.cs index 11a4c795..a9a41098 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcImportServer.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcImportServer.ascx.cs @@ -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; diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcImportServer.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcImportServer.ascx.designer.cs index 6b29702f..eb489aea 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcImportServer.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VdcImportServer.ascx.designer.cs @@ -246,6 +246,15 @@ namespace WebsitePanel.Portal.VPS2012 { ///
protected global::System.Web.UI.WebControls.Panel ConfigurationPanel; + /// + /// GenerationSetting control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.VPS2012.UserControls.Generation GenerationSetting; + /// /// locCPU control. /// @@ -318,6 +327,15 @@ namespace WebsitePanel.Portal.VPS2012 { ///
protected global::System.Web.UI.WebControls.Literal VhdPath; + /// + /// DynamicMemorySetting control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.VPS2012.UserControls.DynamicMemoryControl DynamicMemorySetting; + /// /// secBios control. /// diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VpsDetailsEditConfiguration.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VpsDetailsEditConfiguration.ascx.cs index 34530902..21ccc0c6 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VpsDetailsEditConfiguration.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS2012/VpsDetailsEditConfiguration.ascx.cs @@ -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) {