merge commit
This commit is contained in:
commit
d2790fad11
213 changed files with 32903 additions and 1796 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3456,6 +3456,21 @@ namespace WebsitePanel.EnterpriseServer
|
|||
new SqlParameter("@Recursive", recursive));
|
||||
return reader;
|
||||
}
|
||||
public static IDataReader GetVirtualMachinesPaged2012(int actorId, int packageId, string filterColumn, string filterValue,
|
||||
string sortColumn, int startRow, int maximumRows, bool recursive)
|
||||
{
|
||||
IDataReader reader = SqlHelper.ExecuteReader(ConnectionString, CommandType.StoredProcedure,
|
||||
"GetVirtualMachinesPaged2012",
|
||||
new SqlParameter("@ActorID", actorId),
|
||||
new SqlParameter("@PackageID", packageId),
|
||||
new SqlParameter("@FilterColumn", VerifyColumnName(filterColumn)),
|
||||
new SqlParameter("@FilterValue", VerifyColumnValue(filterValue)),
|
||||
new SqlParameter("@SortColumn", VerifyColumnName(sortColumn)),
|
||||
new SqlParameter("@StartRow", startRow),
|
||||
new SqlParameter("@MaximumRows", maximumRows),
|
||||
new SqlParameter("@Recursive", recursive));
|
||||
return reader;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static IDataReader GetVirtualMachinesForPCPaged(int actorId, int packageId, string filterColumn, string filterValue,
|
||||
|
|
|
@ -488,6 +488,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.MySql5, domain, "");
|
||||
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.Statistics, domain, "");
|
||||
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPS, domain, "");
|
||||
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPS2012, domain, "");
|
||||
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPSForPC, domain, "");
|
||||
}
|
||||
}
|
||||
|
@ -711,6 +712,11 @@ namespace WebsitePanel.EnterpriseServer
|
|||
if (Utils.ParseBool(vpsSettings["AutoAssignExternalIP"], true))
|
||||
ServerController.AllocateMaximumPackageIPAddresses(packageId, ResourceGroups.VPS, IPAddressPool.VpsExternalNetwork);
|
||||
|
||||
// allocate "VPS" IP addresses
|
||||
int vps2012ServiceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.VPS2012);
|
||||
StringDictionary vps2012Settings = ServerController.GetServiceSettings(vps2012ServiceId);
|
||||
if (Utils.ParseBool(vps2012Settings["AutoAssignExternalIP"], true))
|
||||
ServerController.AllocateMaximumPackageIPAddresses(packageId, ResourceGroups.VPS2012, IPAddressPool.VpsExternalNetwork);
|
||||
|
||||
// allocate "VPSForPC" IP addresses
|
||||
int vpsfcpServiceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.VPSForPC);
|
||||
|
@ -1681,6 +1687,18 @@ namespace WebsitePanel.EnterpriseServer
|
|||
}
|
||||
}
|
||||
|
||||
// VPS2012
|
||||
else if (String.Compare(PackageSettings.VIRTUAL_PRIVATE_SERVERS_2012, settingsName, true) == 0)
|
||||
{
|
||||
// load Exchange service settings
|
||||
int vpsServiceId = GetPackageServiceId(packageId, ResourceGroups.VPS2012);
|
||||
if (vpsServiceId > 0)
|
||||
{
|
||||
StringDictionary vpsSettings = ServerController.GetServiceSettings(vpsServiceId);
|
||||
settings["HostnamePattern"] = vpsSettings["HostnamePattern"];
|
||||
}
|
||||
}
|
||||
|
||||
//vpforCP
|
||||
else if (String.Compare(PackageSettings.VIRTUAL_PRIVATE_SERVERS_FOR_PRIVATE_CLOUD, settingsName, true) == 0)
|
||||
{
|
||||
|
|
|
@ -1481,6 +1481,10 @@ namespace WebsitePanel.EnterpriseServer
|
|||
{
|
||||
return Quotas.VPS_EXTERNAL_IP_ADDRESSES_NUMBER;
|
||||
}
|
||||
else if (String.Compare(groupName, ResourceGroups.VPS2012, true) == 0)
|
||||
{
|
||||
return Quotas.VPS2012_EXTERNAL_IP_ADDRESSES_NUMBER;
|
||||
}
|
||||
else if (String.Compare(groupName, ResourceGroups.VPSForPC, true) == 0)
|
||||
{
|
||||
return Quotas.VPSForPC_EXTERNAL_IP_ADDRESSES_NUMBER;
|
||||
|
@ -1840,6 +1844,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.MySql5, domain, "");
|
||||
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.Statistics, domain, "");
|
||||
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPS, domain, "");
|
||||
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPS2012, domain, "");
|
||||
ServerController.AddServiceDNSRecords(packageId, ResourceGroups.VPSForPC, domain, "");
|
||||
}
|
||||
|
||||
|
@ -2403,6 +2408,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
ServerController.AddServiceDNSRecords(domain.PackageId, ResourceGroups.MySql5, domain, "");
|
||||
ServerController.AddServiceDNSRecords(domain.PackageId, ResourceGroups.Statistics, domain, "");
|
||||
ServerController.AddServiceDNSRecords(domain.PackageId, ResourceGroups.VPS, domain, "");
|
||||
ServerController.AddServiceDNSRecords(domain.PackageId, ResourceGroups.VPS2012, domain, "");
|
||||
ServerController.AddServiceDNSRecords(domain.PackageId, ResourceGroups.VPSForPC, domain, "");
|
||||
ServerController.AddServiceDNSRecords(domain.PackageId, ResourceGroups.Dns, domain, "");
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
// Copyright (c) 2015, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// - Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
//
|
||||
// - Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// - Neither the name of the Outercurve Foundation nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Threading;
|
||||
|
||||
using WebsitePanel.Providers.Virtualization;
|
||||
|
||||
namespace WebsitePanel.EnterpriseServer
|
||||
{
|
||||
public class CreateServerAsyncWorker2012
|
||||
{
|
||||
#region Properties
|
||||
public int ThreadUserId { get; set; }
|
||||
public string TaskId { get; set; }
|
||||
|
||||
public VirtualMachine Item { get; set; }
|
||||
public LibraryItem OsTemplate { get; set; }
|
||||
|
||||
public int ExternalAddressesNumber { get; set; }
|
||||
public bool RandomExternalAddresses { get; set; }
|
||||
public int[] ExternalAddresses { get; set; }
|
||||
|
||||
public int PrivateAddressesNumber { get; set; }
|
||||
public bool RandomPrivateAddresses { get; set; }
|
||||
public string[] PrivateAddresses { get; set; }
|
||||
|
||||
public string SummaryLetterEmail { get; set; }
|
||||
#endregion
|
||||
|
||||
public CreateServerAsyncWorker2012()
|
||||
{
|
||||
ThreadUserId = -1; // admin
|
||||
}
|
||||
|
||||
#region Create
|
||||
public void CreateAsync()
|
||||
{
|
||||
// start asynchronously
|
||||
Thread t = new Thread(new ThreadStart(Create));
|
||||
t.Start();
|
||||
}
|
||||
|
||||
private void Create()
|
||||
{
|
||||
// impersonate thread
|
||||
if (ThreadUserId != -1)
|
||||
SecurityContext.SetThreadPrincipal(ThreadUserId);
|
||||
|
||||
// perform backup
|
||||
VirtualizationServerController2012.CreateVirtualMachineInternal(TaskId, Item, OsTemplate,
|
||||
ExternalAddressesNumber, RandomExternalAddresses, ExternalAddresses,
|
||||
PrivateAddressesNumber, RandomPrivateAddresses, PrivateAddresses,
|
||||
SummaryLetterEmail);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -174,6 +174,8 @@
|
|||
<Compile Include="Tasks\TaskManager.cs" />
|
||||
<Compile Include="Users\UserAsyncWorker.cs" />
|
||||
<Compile Include="Users\UserController.cs" />
|
||||
<Compile Include="Virtualization2012\CreateServerAsyncWorker2012.cs" />
|
||||
<Compile Include="Virtualization2012\VirtualizationServerController2012.cs" />
|
||||
<Compile Include="VirtualizationForPrivateCloud\CreateAsyncVMfromVM.cs" />
|
||||
<Compile Include="VirtualizationForPrivateCloud\CreateServerAsyncWorkerForPrivateCloud.cs" />
|
||||
<Compile Include="VirtualizationForPrivateCloud\VirtualizationServerControllerForPrivateCloud.cs" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue