mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fixed VmSync issues in HyperV.
This commit is contained in:
parent
3c350ab0b8
commit
63b23bb341
@ -396,6 +396,20 @@ namespace HypervResource
|
||||
}
|
||||
}
|
||||
|
||||
public class VmState
|
||||
{
|
||||
[JsonProperty("state")]
|
||||
public String state;
|
||||
[JsonProperty("host")]
|
||||
String host;
|
||||
public VmState() { }
|
||||
public VmState(String vmState, String host)
|
||||
{
|
||||
this.state = vmState;
|
||||
this.host = host;
|
||||
}
|
||||
}
|
||||
|
||||
public struct StoragePoolInfo
|
||||
{
|
||||
[JsonProperty("uuid")]
|
||||
|
||||
@ -31,6 +31,7 @@ using System.Net.Http;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Principal;
|
||||
using System.Web.Http;
|
||||
using CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2;
|
||||
|
||||
namespace HypervResource
|
||||
{
|
||||
@ -1449,6 +1450,9 @@ namespace HypervResource
|
||||
logger.Debug(CloudStackTypes.StartupStorageCommand + " set available bytes to " + available);
|
||||
|
||||
string ipAddr = strtRouteCmd.privateIpAddress;
|
||||
var vmStates = wmiCallsV2.GetVmSync(config.PrivateIpAddress);
|
||||
strtRouteCmd.vms = Utils.CreateCloudStackMapObject(vmStates);
|
||||
|
||||
StoragePoolInfo pi = new StoragePoolInfo(
|
||||
poolGuid.ToString(),
|
||||
ipAddr,
|
||||
|
||||
@ -63,5 +63,6 @@ namespace HypervResource
|
||||
VirtualSystemSettingData GetVmSettings(ComputerSystem vm);
|
||||
void patchSystemVmIso(string vmName, string systemVmIso);
|
||||
void SetState(ComputerSystem vm, ushort requiredState);
|
||||
Dictionary<String, VmState> GetVmSync(String privateIpAddress);
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,6 +45,16 @@ namespace HypervResource
|
||||
return new JObject(objTypeValuePairing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// serialize dictonary to map json type
|
||||
/// </summary>
|
||||
/// <param name="objValue">Object's data, can be an anonymous object, e.g. </param>
|
||||
/// <returns></returns>
|
||||
public static JToken CreateCloudStackMapObject(object objValue)
|
||||
{
|
||||
JToken objContent = JToken.FromObject(objValue);
|
||||
return objContent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy file on network share to local volume.
|
||||
|
||||
@ -1549,6 +1549,19 @@ namespace HypervResource
|
||||
return null;
|
||||
}
|
||||
|
||||
public Dictionary<String, VmState> GetVmSync(String privateIpAddress)
|
||||
{
|
||||
List<String> vms = GetVmElementNames();
|
||||
Dictionary<String, VmState> vmSyncStates = new Dictionary<string, VmState>();
|
||||
String vmState;
|
||||
foreach (String vm in vms)
|
||||
{
|
||||
vmState = EnabledState.ToCloudStackState(GetComputerSystem(vm).EnabledState);
|
||||
vmSyncStates.Add(vm, new VmState(vmState, privateIpAddress));
|
||||
}
|
||||
return vmSyncStates;
|
||||
}
|
||||
|
||||
public List<string> GetVmElementNames()
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user