This commit is contained in:
me 2015-03-16 07:47:09 +04:00
commit ec898f2392
10 changed files with 272 additions and 269 deletions

View file

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WebsitePanel.Providers.Virtualization
{
public enum AutomaticStartAction
{
Undefined = 100,
Nothing = 0,
StartIfRunning = 1,
Start = 2,
}
}

View file

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WebsitePanel.Providers.Virtualization
{
public enum AutomaticStopAction
{
Undefined = 100,
TurnOff = 0,
Save = 1,
ShutDown = 2,
}
}

View file

@ -288,6 +288,8 @@
<Compile Include="Statistics\StatsServer.cs" /> <Compile Include="Statistics\StatsServer.cs" />
<Compile Include="Statistics\StatsSite.cs" /> <Compile Include="Statistics\StatsSite.cs" />
<Compile Include="Statistics\StatsUser.cs" /> <Compile Include="Statistics\StatsUser.cs" />
<Compile Include="Virtualization\AutomaticStopAction.cs" />
<Compile Include="Virtualization\AutomaticStartAction.cs" />
<Compile Include="Virtualization\BiosInfo.cs" /> <Compile Include="Virtualization\BiosInfo.cs" />
<Compile Include="Virtualization\ChangeJobStateReturnCode.cs" /> <Compile Include="Virtualization\ChangeJobStateReturnCode.cs" />
<Compile Include="Virtualization\ConcreteJob.cs"> <Compile Include="Virtualization\ConcreteJob.cs">

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WebsitePanel.Providers.Virtualization
{
public static class Constants
{
public const Int64 Size1G = 0x40000000;
public const Int64 Size1M = 0x100000;
}
}

View file

@ -87,7 +87,7 @@ namespace WebsitePanel.Providers.Virtualization
if (bootFromCD) if (bootFromCD)
cmd.Parameters.Add("FirstBootDevice", DvdDriveHelper.GetPS(powerShell, vm.Name)); cmd.Parameters.Add("FirstBootDevice", DvdDriveHelper.GetPS(powerShell, vm.Name));
else else
cmd.Parameters.Add("FirstBootDevice", VirtualMachineHelper.GetVirtualHardDisksPS(powerShell, vm.Name).FirstOrDefault()); cmd.Parameters.Add("FirstBootDevice", HardDriveHelper.GetPS(powerShell, vm.Name).FirstOrDefault());
powerShell.Execute(cmd, false); powerShell.Execute(cmd, false);
} }

View file

@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Text;
using System.Threading.Tasks;
namespace WebsitePanel.Providers.Virtualization
{
public static class HardDriveHelper
{
public static VirtualHardDiskInfo[] Get(PowerShellManager powerShell, string vmname)
{
List<VirtualHardDiskInfo> disks = new List<VirtualHardDiskInfo>();
Collection<PSObject> result = GetPS(powerShell, vmname);
if (result != null && result.Count > 0)
{
foreach (PSObject d in result)
{
VirtualHardDiskInfo disk = new VirtualHardDiskInfo();
disk.SupportPersistentReservations = Convert.ToBoolean(d.GetProperty("SupportPersistentReservations"));
disk.MaximumIOPS = Convert.ToUInt64(d.GetProperty("MaximumIOPS"));
disk.MinimumIOPS = Convert.ToUInt64(d.GetProperty("MinimumIOPS"));
disk.VHDControllerType = d.GetEnum<ControllerType>("ControllerType");
disk.ControllerNumber = Convert.ToInt32(d.GetProperty("ControllerNumber"));
disk.ControllerLocation = Convert.ToInt32(d.GetProperty("ControllerLocation"));
disk.Path = d.GetProperty("Path").ToString();
disk.Name = d.GetProperty("Name").ToString();
GetVirtualHardDiskDetail(powerShell, disk.Path, ref disk);
disks.Add(disk);
}
}
return disks.ToArray();
}
//public static VirtualHardDiskInfo GetByPath(PowerShellManager powerShell, string vhdPath)
//{
// VirtualHardDiskInfo info = null;
// var vmNames = new List<string>();
// Command cmd = new Command("Get-VM");
// Collection<PSObject> result = powerShell.Execute(cmd, false);
// if (result == null || result.Count == 0)
// return null;
// vmNames = result.Select(r => r.GetString("Name")).ToList();
// var drives = vmNames.SelectMany(n => Get(powerShell, n));
// return drives.FirstOrDefault(d=>d.Path == vhdPath);
//}
public static Collection<PSObject> GetPS(PowerShellManager powerShell, string vmname)
{
Command cmd = new Command("Get-VMHardDiskDrive");
cmd.Parameters.Add("VMName", vmname);
return powerShell.Execute(cmd, false);
}
public static void GetVirtualHardDiskDetail(PowerShellManager powerShell, string path, ref VirtualHardDiskInfo disk)
{
if (!string.IsNullOrEmpty(path))
{
Command cmd = new Command("Get-VHD");
cmd.Parameters.Add("Path", path);
Collection<PSObject> result = powerShell.Execute(cmd, false);
if (result != null && result.Count > 0)
{
disk.DiskFormat = result[0].GetEnum<VirtualHardDiskFormat>("VhdFormat");
disk.DiskType = result[0].GetEnum<VirtualHardDiskType>("VhdType");
disk.ParentPath = result[0].GetProperty<string>("ParentPath");
disk.MaxInternalSize = Convert.ToInt64(result[0].GetProperty("Size"));
disk.FileSize = Convert.ToInt64(result[0].GetProperty("FileSize"));
disk.Attached = disk.InUse = Convert.ToBoolean(result[0].GetProperty("Attached"));
}
}
}
}
}

View file

@ -12,16 +12,8 @@ namespace WebsitePanel.Providers.Virtualization
{ {
public static class VirtualMachineHelper public static class VirtualMachineHelper
{ {
#region Constants
private const Int64 Size1G = 0x40000000;
private const Int64 Size1M = 0x100000;
#endregion
public static OperationalStatus GetVMHeartBeatStatus(PowerShellManager powerShell, string name) public static OperationalStatus GetVMHeartBeatStatus(PowerShellManager powerShell, string name)
{ {
OperationalStatus status = OperationalStatus.None; OperationalStatus status = OperationalStatus.None;
Command cmd = new Command("Get-VMIntegrationService"); Command cmd = new Command("Get-VMIntegrationService");
@ -40,7 +32,6 @@ namespace WebsitePanel.Providers.Virtualization
return status; return status;
} }
public static int GetVMProcessors(PowerShellManager powerShell, string name) public static int GetVMProcessors(PowerShellManager powerShell, string name)
{ {
@ -71,73 +62,15 @@ namespace WebsitePanel.Providers.Virtualization
if (result != null && result.Count > 0) if (result != null && result.Count > 0)
{ {
info.DynamicMemoryEnabled = Convert.ToBoolean(result[0].GetProperty("DynamicMemoryEnabled")); info.DynamicMemoryEnabled = Convert.ToBoolean(result[0].GetProperty("DynamicMemoryEnabled"));
info.Startup = Convert.ToInt64(result[0].GetProperty("Startup")) / Size1M; info.Startup = Convert.ToInt64(result[0].GetProperty("Startup")) / Constants.Size1M;
info.Minimum = Convert.ToInt64(result[0].GetProperty("Minimum")) / Size1M; info.Minimum = Convert.ToInt64(result[0].GetProperty("Minimum")) / Constants.Size1M;
info.Maximum = Convert.ToInt64(result[0].GetProperty("Maximum")) / Size1M; info.Maximum = Convert.ToInt64(result[0].GetProperty("Maximum")) / Constants.Size1M;
info.Buffer = Convert.ToInt32(result[0].GetProperty("Buffer")); info.Buffer = Convert.ToInt32(result[0].GetProperty("Buffer"));
info.Priority = Convert.ToInt32(result[0].GetProperty("Priority")); info.Priority = Convert.ToInt32(result[0].GetProperty("Priority"));
} }
return info; return info;
} }
public static VirtualHardDiskInfo[] GetVirtualHardDisks(PowerShellManager powerShell, string name)
{
List<VirtualHardDiskInfo> disks = new List<VirtualHardDiskInfo>();
Collection<PSObject> result = GetVirtualHardDisksPS(powerShell, name);
if (result != null && result.Count > 0)
{
foreach (PSObject d in result)
{
VirtualHardDiskInfo disk = new VirtualHardDiskInfo();
disk.SupportPersistentReservations = Convert.ToBoolean(d.GetProperty("SupportPersistentReservations"));
disk.MaximumIOPS = Convert.ToUInt64(d.GetProperty("MaximumIOPS"));
disk.MinimumIOPS = Convert.ToUInt64(d.GetProperty("MinimumIOPS"));
disk.VHDControllerType = d.GetEnum<ControllerType>("ControllerType");
disk.ControllerNumber = Convert.ToInt32(d.GetProperty("ControllerNumber"));
disk.ControllerLocation = Convert.ToInt32(d.GetProperty("ControllerLocation"));
disk.Path = d.GetProperty("Path").ToString();
disk.Name = d.GetProperty("Name").ToString();
GetVirtualHardDiskDetail(powerShell, disk.Path, ref disk);
disks.Add(disk);
}
}
return disks.ToArray();
}
public static Collection<PSObject> GetVirtualHardDisksPS(PowerShellManager powerShell, string name)
{
Command cmd = new Command("Get-VMHardDiskDrive");
cmd.Parameters.Add("VMName", name);
return powerShell.Execute(cmd, false);
}
public static void GetVirtualHardDiskDetail(PowerShellManager powerShell, string path, ref VirtualHardDiskInfo disk)
{
if (!string.IsNullOrEmpty(path))
{
Command cmd = new Command("Get-VHD");
cmd.Parameters.Add("Path", path);
Collection<PSObject> result = powerShell.Execute(cmd, false);
if (result != null && result.Count > 0)
{
disk.DiskFormat = result[0].GetEnum<VirtualHardDiskFormat>("VhdFormat");
disk.DiskType = result[0].GetEnum<VirtualHardDiskType>("VhdType");
disk.ParentPath = result[0].GetProperty<string>("ParentPath");
disk.MaxInternalSize = Convert.ToInt64(result[0].GetProperty("Size")) / Size1G;
disk.FileSize = Convert.ToInt64(result[0].GetProperty("FileSize")) / Size1G;
disk.Attached = Convert.ToBoolean(result[0].GetProperty("Attached"));
}
}
}
public static void UpdateProcessors(PowerShellManager powerShell, VirtualMachine vm, int cpuCores, int cpuLimitSettings, int cpuReserveSettings, int cpuWeightSettings) public static void UpdateProcessors(PowerShellManager powerShell, VirtualMachine vm, int cpuCores, int cpuLimitSettings, int cpuReserveSettings, int cpuWeightSettings)
{ {
Command cmd = new Command("Set-VMProcessor"); Command cmd = new Command("Set-VMProcessor");
@ -150,12 +83,13 @@ namespace WebsitePanel.Providers.Virtualization
powerShell.Execute(cmd, false); powerShell.Execute(cmd, false);
} }
public static void UpdateMemory(PowerShellManager powerShell, VirtualMachine vm, long ramMB) public static void UpdateMemory(PowerShellManager powerShell, VirtualMachine vm, long ramMB)
{ {
Command cmd = new Command("Set-VMMemory"); Command cmd = new Command("Set-VMMemory");
cmd.Parameters.Add("VMName", vm.Name); cmd.Parameters.Add("VMName", vm.Name);
cmd.Parameters.Add("StartupBytes", ramMB * Size1M); cmd.Parameters.Add("StartupBytes", ramMB * Constants.Size1M);
powerShell.Execute(cmd, false); powerShell.Execute(cmd, false);
} }

View file

@ -198,12 +198,12 @@ namespace WebsitePanel.Providers.Virtualization
vm.DvdDriveInstalled = dvdInfo != null; vm.DvdDriveInstalled = dvdInfo != null;
// HDD // HDD
vm.Disks = VirtualMachineHelper.GetVirtualHardDisks(PowerShell, vm.Name); vm.Disks = HardDriveHelper.Get(PowerShell, vm.Name);
if (vm.Disks != null && vm.Disks.GetLength(0) > 0) if (vm.Disks != null && vm.Disks.GetLength(0) > 0)
{ {
vm.VirtualHardDrivePath = vm.Disks[0].Path; vm.VirtualHardDrivePath = vm.Disks[0].Path;
vm.HddSize = Convert.ToInt32(vm.Disks[0].FileSize); vm.HddSize = Convert.ToInt32(vm.Disks[0].FileSize / Size1G);
} }
// network adapters // network adapters
@ -327,104 +327,46 @@ namespace WebsitePanel.Providers.Virtualization
vm.OperatingSystemTemplatePath = FileUtils.EvaluateSystemVariables(vm.OperatingSystemTemplatePath); vm.OperatingSystemTemplatePath = FileUtils.EvaluateSystemVariables(vm.OperatingSystemTemplatePath);
vm.VirtualHardDrivePath = FileUtils.EvaluateSystemVariables(vm.VirtualHardDrivePath); vm.VirtualHardDrivePath = FileUtils.EvaluateSystemVariables(vm.VirtualHardDrivePath);
string vmID = null; try
// request management service
ManagementObject objVmsvc = GetVirtualSystemManagementService();
// display name
ManagementObject objGlobalSettings = wmi.GetWmiClass("msvm_VirtualSystemGlobalSettingData").CreateInstance();
objGlobalSettings["ElementName"] = vm.Name;
// VM folders
objGlobalSettings["ExternalDataRoot"] = vm.RootFolderPath;
objGlobalSettings["SnapshotDataRoot"] = vm.RootFolderPath;
wmi.Dump(objGlobalSettings);
// startup/shutdown actions
if (AutomaticStartActionSettings != 100)
{ {
objGlobalSettings["AutomaticStartupAction"] = AutomaticStartActionSettings; // Add new VM
objGlobalSettings["AutomaticStartupActionDelay"] = String.Format("000000000000{0:d2}.000000:000", AutomaticStartupDelaySettings); Command cmdNew = new Command("New-VM");
cmdNew.Parameters.Add("Name", vm.Name);
cmdNew.Parameters.Add("VHDPath", vm.VirtualHardDrivePath);
PowerShell.Execute(cmdNew, false);
// Set VM
Command cmdSet = new Command("Set-VM");
cmdSet.Parameters.Add("Name", vm.Name);
cmdSet.Parameters.Add("SmartPagingFilePath", vm.RootFolderPath);
cmdSet.Parameters.Add("SnapshotFileLocation", vm.RootFolderPath);
// startup/shutdown actions
var autoStartAction = (AutomaticStartAction) AutomaticStartActionSettings;
var autoStopAction = (AutomaticStopAction) AutomaticStartActionSettings;
if (autoStartAction != AutomaticStartAction.Undefined)
{
cmdSet.Parameters.Add("AutomaticStartAction", autoStartAction.ToString());
cmdSet.Parameters.Add("AutomaticStartDelay", AutomaticStartupDelaySettings);
}
if (autoStopAction != AutomaticStopAction.Undefined)
cmdSet.Parameters.Add("AutomaticStopAction", autoStopAction.ToString());
PowerShell.Execute(cmdSet, false);
// Get created machine Id
var createdMachine = GetVirtualMachines().FirstOrDefault(m => m.Name == vm.Name);
if (createdMachine == null)
throw new Exception("Can't find created machine");
vm.VirtualMachineId = createdMachine.VirtualMachineId;
// Update common settings
UpdateVirtualMachine(vm);
}
catch (Exception ex)
{
HostedSolutionLog.LogError("CreateVirtualMachine", ex);
throw;
} }
if (AutomaticStopActionSettings != 100)
objGlobalSettings["AutomaticShutdownAction"] = AutomaticStopActionSettings;
if (AutomaticRecoveryActionSettings != 100)
objGlobalSettings["AutomaticRecoveryAction"] = AutomaticRecoveryActionSettings;
// create machine
ManagementBaseObject inParams = objVmsvc.GetMethodParameters("DefineVirtualSystem");
inParams["SystemSettingData"] = objGlobalSettings.GetText(TextFormat.CimDtd20);
inParams["ResourceSettingData"] = new string[] { };
// invoke method
ManagementBaseObject outParams = objVmsvc.InvokeMethod("DefineVirtualSystem", inParams, null);
ManagementObject objVM = wmi.GetWmiObjectByPath((string)outParams["DefinedSystem"]);
// job
JobResult job = CreateJobResultFromWmiMethodResults(outParams); ;
// read VM id
vmID = (string)objVM["Name"];
// update general settings
//UpdateVirtualMachineGeneralSettings(vmID, objVM,
// vm.CpuCores,
// vm.RamSize,
// vm.BootFromCD,
// vm.NumLockEnabled);
// hard disks
// load IDE 0 controller
ManagementObject objIDE0 = wmi.GetWmiObject(
"Msvm_ResourceAllocationSettingData", "ResourceSubType = 'Microsoft Emulated IDE Controller'"
+ " and InstanceID Like 'Microsoft:{0}%' and Address = 0", vmID);
// load default hard disk drive
ManagementObject objDefaultHdd = wmi.GetWmiObject(
"Msvm_ResourceAllocationSettingData", "ResourceSubType = 'Microsoft Synthetic Disk Drive'"
+ " and InstanceID like '%Default'");
ManagementObject objHdd = (ManagementObject)objDefaultHdd.Clone();
objHdd["Parent"] = objIDE0.Path;
objHdd["Address"] = 0;
// add HDD to VM resources
ManagementObject objAddedHDD = AddVirtualMachineResources(objVM, objHdd);
// attach VHD
string fullVhdPath = vm.VirtualHardDrivePath;
ManagementObject objDefaultVHD = wmi.GetWmiObject(
"Msvm_ResourceAllocationSettingData", "ResourceSubType = 'Microsoft Virtual Hard Disk'"
+ " and InstanceID like '%Default'");
ManagementObject objVhd = (ManagementObject)objDefaultVHD.Clone();
objVhd["Parent"] = objAddedHDD.Path.Path;
objVhd["Connection"] = new string[] { fullVhdPath };
// add VHD to the system
AddVirtualMachineResources(objVM, objVhd);
// DVD drive
if (vm.DvdDriveInstalled)
{
AddVirtualMachineDvdDrive(vmID, objVM);
}
// add external adapter
if (vm.ExternalNetworkEnabled && !String.IsNullOrEmpty(vm.ExternalSwitchId))
AddNetworkAdapter(objVM, vm.ExternalSwitchId, vm.Name, vm.ExternalNicMacAddress, EXTERNAL_NETWORK_ADAPTER_NAME, vm.LegacyNetworkAdapter);
// add private adapter
if (vm.PrivateNetworkEnabled && !String.IsNullOrEmpty(vm.PrivateSwitchId))
AddNetworkAdapter(objVM, vm.PrivateSwitchId, vm.Name, vm.PrivateNicMacAddress, PRIVATE_NETWORK_ADAPTER_NAME, vm.LegacyNetworkAdapter);
// add management adapter
if (vm.ManagementNetworkEnabled && !String.IsNullOrEmpty(vm.ManagementSwitchId))
AddNetworkAdapter(objVM, vm.ManagementSwitchId, vm.Name, vm.ManagementNicMacAddress, MANAGEMENT_NETWORK_ADAPTER_NAME, vm.LegacyNetworkAdapter);
vm.VirtualMachineId = vmID;
return vm; return vm;
} }
@ -1483,33 +1425,17 @@ namespace WebsitePanel.Providers.Virtualization
#region Storage #region Storage
public VirtualHardDiskInfo GetVirtualHardDiskInfo(string vhdPath) public VirtualHardDiskInfo GetVirtualHardDiskInfo(string vhdPath)
{ {
ManagementObject objImgSvc = GetImageManagementService(); try
// get method params
ManagementBaseObject inParams = objImgSvc.GetMethodParameters("GetVirtualHardDiskInfo");
inParams["Path"] = FileUtils.EvaluateSystemVariables(vhdPath);
// execute method
ManagementBaseObject outParams = (ManagementBaseObject)objImgSvc.InvokeMethod("GetVirtualHardDiskInfo", inParams, null);
ReturnCode result = (ReturnCode)Convert.ToInt32(outParams["ReturnValue"]);
if (result == ReturnCode.OK)
{ {
// create XML VirtualHardDiskInfo hardDiskInfo = new VirtualHardDiskInfo();
string xml = (string)outParams["Info"]; HardDriveHelper.GetVirtualHardDiskDetail(PowerShell, vhdPath, ref hardDiskInfo);
XmlDocument doc = new XmlDocument(); return hardDiskInfo;
doc.LoadXml(xml); }
catch (Exception ex)
// read properties {
VirtualHardDiskInfo vhd = new VirtualHardDiskInfo(); HostedSolutionLog.LogError("GetVirtualHardDiskInfo", ex);
vhd.DiskType = (VirtualHardDiskType)Enum.Parse(typeof(VirtualHardDiskType), GetPropertyValue("Type", doc), true); throw;
vhd.FileSize = Int64.Parse(GetPropertyValue("FileSize", doc));
vhd.InSavedState = Boolean.Parse(GetPropertyValue("InSavedState", doc));
vhd.InUse = Boolean.Parse(GetPropertyValue("InUse", doc));
vhd.MaxInternalSize = Int64.Parse(GetPropertyValue("MaxInternalSize", doc));
vhd.ParentPath = GetPropertyValue("ParentPath", doc);
return vhd;
} }
return null;
} }
private string GetPropertyValue(string propertyName, XmlDocument doc) private string GetPropertyValue(string propertyName, XmlDocument doc)
@ -1741,9 +1667,6 @@ exit", Convert.ToInt32(objDisk["Index"])));
public JobResult ConvertVirtualHardDisk(string sourcePath, string destinationPath, VirtualHardDiskType diskType) public JobResult ConvertVirtualHardDisk(string sourcePath, string destinationPath, VirtualHardDiskType diskType)
{ {
sourcePath = FileUtils.EvaluateSystemVariables(sourcePath);
destinationPath = FileUtils.EvaluateSystemVariables(destinationPath);
// check source file // check source file
if (!FileExists(sourcePath)) if (!FileExists(sourcePath))
throw new Exception("Source VHD cannot be found: " + sourcePath); throw new Exception("Source VHD cannot be found: " + sourcePath);
@ -1752,17 +1675,26 @@ exit", Convert.ToInt32(objDisk["Index"])));
string destFolder = Path.GetDirectoryName(destinationPath); string destFolder = Path.GetDirectoryName(destinationPath);
if (!DirectoryExists(destFolder)) if (!DirectoryExists(destFolder))
CreateFolder(destFolder); CreateFolder(destFolder);
sourcePath = FileUtils.EvaluateSystemVariables(sourcePath);
destinationPath = FileUtils.EvaluateSystemVariables(destinationPath);
try
{
Command cmd = new Command("Convert-VHD");
ManagementObject objImgSvc = GetImageManagementService(); cmd.Parameters.Add("Path", sourcePath);
cmd.Parameters.Add("DestinationPath", destinationPath);
cmd.Parameters.Add("VHDType", diskType.ToString());
// get method params PowerShell.Execute(cmd, false);
ManagementBaseObject inParams = objImgSvc.GetMethodParameters("ConvertVirtualHardDisk"); return JobHelper.CreateSuccessResult(ReturnCode.JobStarted);
inParams["SourcePath"] = sourcePath; }
inParams["DestinationPath"] = destinationPath; catch (Exception ex)
inParams["Type"] = (UInt16)diskType; {
HostedSolutionLog.LogError("ConvertVirtualHardDisk", ex);
ManagementBaseObject outParams = (ManagementBaseObject)objImgSvc.InvokeMethod("ConvertVirtualHardDisk", inParams, null); throw;
return CreateJobResultFromWmiMethodResults(outParams); }
} }
public void DeleteRemoteFile(string path) public void DeleteRemoteFile(string path)

View file

@ -17,7 +17,7 @@
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>..\WebsitePanel.Server\bin\</OutputPath> <OutputPath>..\WebsitePanel.Server\bin\HyperV2012R2\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
@ -53,8 +53,10 @@
<Compile Include="..\VersionInfo.cs"> <Compile Include="..\VersionInfo.cs">
<Link>VersionInfo.cs</Link> <Link>VersionInfo.cs</Link>
</Compile> </Compile>
<Compile Include="Constants.cs" />
<Compile Include="Extensions\PSObjectExtension.cs" /> <Compile Include="Extensions\PSObjectExtension.cs" />
<Compile Include="Helpers\BiosHelper.cs" /> <Compile Include="Helpers\BiosHelper.cs" />
<Compile Include="Helpers\HardDriveHelper.cs" />
<Compile Include="Helpers\NetworkAdapterHelper.cs" /> <Compile Include="Helpers\NetworkAdapterHelper.cs" />
<Compile Include="Helpers\DvdDriveHelper.cs" /> <Compile Include="Helpers\DvdDriveHelper.cs" />
<Compile Include="Helpers\JobHelper.cs" /> <Compile Include="Helpers\JobHelper.cs" />

View file

@ -1,4 +1,4 @@
<?xml version="1.0"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<!-- Custom configuration sections --> <!-- Custom configuration sections -->
<configSections> <configSections>
@ -7,34 +7,34 @@
<section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings,Microsoft.Practices.EnterpriseLibrary.Caching"/> <section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings,Microsoft.Practices.EnterpriseLibrary.Caching"/>
</configSections> </configSections>
<appSettings> <appSettings>
<add key="WebsitePanel.HyperV.UseDiskPartClearReadOnlyFlag" value="false"/> <add key="WebsitePanel.HyperV.UseDiskPartClearReadOnlyFlag" value="false" />
<add key="WebsitePanel.Exchange.ClearQueryBaseDN" value="false"/> <add key="WebsitePanel.Exchange.ClearQueryBaseDN" value="false" />
<add key="WebsitePanel.Exchange.enableSP2abp" value="false"/> <add key="WebsitePanel.Exchange.enableSP2abp" value="false" />
<add key="SCVMMServerName" value=""/> <add key="SCVMMServerName" value="" />
<add key="SCVMMServerPort" value=""/> <add key="SCVMMServerPort" value="" />
</appSettings> </appSettings>
<system.diagnostics> <system.diagnostics>
<switches> <switches>
<add name="Log" value="2"/> <add name="Log" value="2" />
<!-- 0 - Off, 1 - Error, 2 - Warning, 3 - Info, 4 - Verbose --> <!-- 0 - Off, 1 - Error, 2 - Warning, 3 - Info, 4 - Verbose -->
</switches> </switches>
<trace autoflush="true"> <trace autoflush="true">
<listeners> <listeners>
<add name="DefaultListener" type="WebsitePanel.Server.Utils.EventLogTraceListener, WebsitePanel.Server.Utils" initializeData="WebsitePanel"/> <add name="DefaultListener" type="WebsitePanel.Server.Utils.EventLogTraceListener, WebsitePanel.Server.Utils" initializeData="WebsitePanel" />
<!-- Writes log to the file <!-- Writes log to the file
<add name="DefaultListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="WebsitePanel.Server.log" /> <add name="DefaultListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="WebsitePanel.Server.log" />
--> -->
<remove name="Default"/> <remove name="Default" />
</listeners> </listeners>
</trace> </trace>
</system.diagnostics> </system.diagnostics>
<!-- Caching Configuration --> <!-- Caching Configuration -->
<cachingConfiguration defaultCacheManager="Default Cache Manager"> <cachingConfiguration defaultCacheManager="Default Cache Manager">
<backingStores> <backingStores>
<add name="inMemory" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching"/> <add name="inMemory" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching" />
</backingStores> </backingStores>
<cacheManagers> <cacheManagers>
<add name="Default Cache Manager" expirationPollFrequencyInSeconds="43200" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="inMemory"/> <add name="Default Cache Manager" expirationPollFrequencyInSeconds="43200" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="inMemory" />
</cacheManagers> </cacheManagers>
</cachingConfiguration> </cachingConfiguration>
<!-- WebsitePanel Configuration --> <!-- WebsitePanel Configuration -->
@ -42,85 +42,85 @@
<!-- Security settings --> <!-- Security settings -->
<security> <security>
<!-- Perform security check --> <!-- Perform security check -->
<enabled value="true"/> <enabled value="true" />
<!-- Server password --> <!-- Server password -->
<password value="+uxnDOdf55yuH6iZYXgYAxsfIBw="/> <password value="+uxnDOdf55yuH6iZYXgYAxsfIBw=" />
</security> </security>
</websitepanel.server> </websitepanel.server>
<system.web> <system.web>
<!-- Disable any authentication --> <!-- Disable any authentication -->
<authentication mode="None"/> <authentication mode="None" />
<!-- Correct HTTP runtime settings --> <!-- Correct HTTP runtime settings -->
<httpRuntime executionTimeout="3600" maxRequestLength="16384"/> <httpRuntime executionTimeout="3600" maxRequestLength="16384" />
<!-- Set globalization settings --> <!-- Set globalization settings -->
<globalization culture="en-US" uiCulture="en" requestEncoding="UTF-8" responseEncoding="UTF-8" fileEncoding="UTF-8"/> <globalization culture="en-US" uiCulture="en" requestEncoding="UTF-8" responseEncoding="UTF-8" fileEncoding="UTF-8" />
<!-- Web Services settings --> <!-- Web Services settings -->
<webServices> <webServices>
<protocols> <protocols>
<remove name="HttpPost"/> <remove name="HttpPost" />
<remove name="HttpPostLocalhost"/> <remove name="HttpPostLocalhost" />
<remove name="HttpGet"/> <remove name="HttpGet" />
</protocols> </protocols>
<soapServerProtocolFactory type="Microsoft.Web.Services3.WseProtocolFactory, Microsoft.Web.Services3"/> <soapServerProtocolFactory type="Microsoft.Web.Services3.WseProtocolFactory, Microsoft.Web.Services3" />
</webServices> </webServices>
<compilation debug="true"> <compilation debug="true">
<assemblies> <assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies> </assemblies>
</compilation> </compilation>
<pages> <pages>
<controls> <controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</controls> </controls>
</pages> </pages>
<httpHandlers> <httpHandlers>
<remove verb="*" path="*.asmx"/> <remove verb="*" path="*.asmx" />
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpHandlers> </httpHandlers>
<httpModules> <httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpModules> </httpModules>
</system.web> </system.web>
<!-- WSE 3.0 settings --> <!-- WSE 3.0 settings -->
<microsoft.web.services3> <microsoft.web.services3>
<diagnostics> <diagnostics>
<trace enabled="false" input="InputTrace.webinfo" output="OutputTrace.webinfo"/> <trace enabled="false" input="InputTrace.webinfo" output="OutputTrace.webinfo" />
</diagnostics> </diagnostics>
<messaging> <messaging>
<maxMessageLength value="-1"/> <maxMessageLength value="-1" />
<mtom serverMode="optional" clientMode="On"/> <mtom serverMode="optional" clientMode="On" />
</messaging> </messaging>
<security> <security>
<securityTokenManager> <securityTokenManager>
<add type="WebsitePanel.Server.ServerUsernameTokenManager, WebsitePanel.Server" namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" localName="UsernameToken"/> <add type="WebsitePanel.Server.ServerUsernameTokenManager, WebsitePanel.Server" namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" localName="UsernameToken" />
</securityTokenManager> </securityTokenManager>
<timeToleranceInSeconds value="86400"/> <timeToleranceInSeconds value="86400" />
</security> </security>
<policy fileName="WsePolicyCache.Config"/> <policy fileName="WsePolicyCache.Config" />
</microsoft.web.services3> </microsoft.web.services3>
<system.serviceModel> <system.serviceModel>
<bindings> <bindings>
<wsHttpBinding> <wsHttpBinding>
<binding name="WSHttpBinding_IVirtualMachineManagementService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="10485760" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> <binding name="WSHttpBinding_IVirtualMachineManagementService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="10485760" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/> <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Message"> <security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/> <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default"/> <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
</security> </security>
</binding> </binding>
<binding name="WSHttpBinding_IMonitoringService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="10485760" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> <binding name="WSHttpBinding_IMonitoringService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="10485760" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/> <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Message"> <security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/> <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default"/> <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
</security> </security>
</binding> </binding>
</wsHttpBinding> </wsHttpBinding>
@ -129,40 +129,40 @@
<system.codedom> <system.codedom>
<compilers> <compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4"> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
<providerOption name="CompilerVersion" value="v3.5"/> <providerOption name="CompilerVersion" value="v3.5" />
<providerOption name="WarnAsError" value="false"/> <providerOption name="WarnAsError" value="false" />
</compiler> </compiler>
</compilers> </compilers>
</system.codedom> </system.codedom>
<system.webServer> <system.webServer>
<validation validateIntegratedModeConfiguration="false"/> <validation validateIntegratedModeConfiguration="false" />
<modules> <modules>
<remove name="ScriptModule"/> <remove name="ScriptModule" />
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</modules> </modules>
<handlers> <handlers>
<remove name="WebServiceHandlerFactory-Integrated"/> <remove name="WebServiceHandlerFactory-Integrated" />
<remove name="ScriptHandlerFactory"/> <remove name="ScriptHandlerFactory" />
<remove name="ScriptHandlerFactoryAppServices"/> <remove name="ScriptHandlerFactoryAppServices" />
<remove name="ScriptResource"/> <remove name="ScriptResource" />
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</handlers> </handlers>
</system.webServer> </system.webServer>
<runtime> <runtime>
<assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/> <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/> <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
</dependentAssembly> </dependentAssembly>
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/> <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/> <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
</dependentAssembly> </dependentAssembly>
</assemblyBinding> </assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin/Crm2011;bin/Crm2013;bin/Exchange2013;bin/Sharepoint2013;bin/Lync2013;bin/Lync2013HP;bin/Dns2012;bin/IceWarp;bin/IIs80"/> <probing privatePath="bin/Crm2011;bin/Crm2013;bin/Exchange2013;bin/Sharepoint2013;bin/Lync2013;bin/Lync2013HP;bin/Dns2012;bin/IceWarp;bin/IIs80;bin/HyperV2012R2" />
</assemblyBinding> </assemblyBinding>
</runtime> </runtime>
</configuration> </configuration>