HyperV-R2 fixes

This commit is contained in:
Alexander Trofimov 2015-05-21 12:04:16 +03:00
parent bba637b689
commit 6320eee5d5
3 changed files with 21 additions and 11 deletions

View file

@ -91,7 +91,7 @@ namespace WebsitePanel.VmConfig
}
attempts++;
Log.WriteError(string.Format("Attempt #{0} to find network adapter failed!", attempts));
Log.WriteError(string.Format("Attempt #{0} to find network adapter (mac: {1}) failed!", attempts, macAddress));
// wait 1 min
System.Threading.Thread.Sleep(60000);
//repeat loop

View file

@ -6,7 +6,7 @@
<appSettings>
<!-- Start-up delay in milliseconds - time to wait before tasks execution -->
<add key="Service.StartupDelay" value="0"/>
<add key="Service.StartupDelay" value="20000"/>
<!-- Interval in milliseconds to poll registry keys. 1 - read registry only once -->
<add key="Service.RegistryPollInterval" value="30000"/>

View file

@ -228,21 +228,31 @@ namespace WebsitePanel.Providers.Virtualization
try
{
Command cmd = new Command("Get-VM");
HostedSolutionLog.LogInfo("Before Get-VM command");
Command cmd = new Command("Get-VM");
Collection<PSObject> result = PowerShell.Execute(cmd, true);
HostedSolutionLog.LogInfo("After Get-VM command");
foreach (PSObject current in result)
{
VirtualMachine vm = new VirtualMachine
{
VirtualMachineId = current.GetProperty("Id").ToString(),
Name = current.GetString("Name"),
State = current.GetEnum<VirtualMachineState>("State"),
Uptime = Convert.ToInt64(current.GetProperty<TimeSpan>("UpTime").TotalMilliseconds),
ReplicationState = current.GetEnum<ReplicationState>("ReplicationState")
};
HostedSolutionLog.LogInfo("- start VM -");
var vm = new VirtualMachine();
HostedSolutionLog.LogInfo("create");
vm.VirtualMachineId = current.GetProperty("Id").ToString();
HostedSolutionLog.LogInfo("VirtualMachineId {0}", vm.VirtualMachineId);
vm.Name = current.GetString("Name");
HostedSolutionLog.LogInfo("Name {0}", vm.Name);
vm.State = current.GetEnum<VirtualMachineState>("State");
HostedSolutionLog.LogInfo("State {0}", vm.State);
vm.Uptime = Convert.ToInt64(current.GetProperty<TimeSpan>("UpTime").TotalMilliseconds);
HostedSolutionLog.LogInfo("Uptime {0}", vm.Uptime);
vm.ReplicationState = current.GetEnum<ReplicationState>("ReplicationState");
HostedSolutionLog.LogInfo("ReplicationState {0}", vm.ReplicationState);
vmachines.Add(vm);
HostedSolutionLog.LogInfo("- end VM -");
}
HostedSolutionLog.LogInfo("Finish");
}
catch (Exception ex)
{