Fixed VmSync issues in HyperV.

This commit is contained in:
Rajesh Battala 2013-11-08 13:11:32 +05:30
parent 3c350ab0b8
commit 63b23bb341
5 changed files with 42 additions and 0 deletions

View File

@ -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 public struct StoragePoolInfo
{ {
[JsonProperty("uuid")] [JsonProperty("uuid")]

View File

@ -31,6 +31,7 @@ using System.Net.Http;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Security.Principal; using System.Security.Principal;
using System.Web.Http; using System.Web.Http;
using CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2;
namespace HypervResource namespace HypervResource
{ {
@ -1449,6 +1450,9 @@ namespace HypervResource
logger.Debug(CloudStackTypes.StartupStorageCommand + " set available bytes to " + available); logger.Debug(CloudStackTypes.StartupStorageCommand + " set available bytes to " + available);
string ipAddr = strtRouteCmd.privateIpAddress; string ipAddr = strtRouteCmd.privateIpAddress;
var vmStates = wmiCallsV2.GetVmSync(config.PrivateIpAddress);
strtRouteCmd.vms = Utils.CreateCloudStackMapObject(vmStates);
StoragePoolInfo pi = new StoragePoolInfo( StoragePoolInfo pi = new StoragePoolInfo(
poolGuid.ToString(), poolGuid.ToString(),
ipAddr, ipAddr,

View File

@ -63,5 +63,6 @@ namespace HypervResource
VirtualSystemSettingData GetVmSettings(ComputerSystem vm); VirtualSystemSettingData GetVmSettings(ComputerSystem vm);
void patchSystemVmIso(string vmName, string systemVmIso); void patchSystemVmIso(string vmName, string systemVmIso);
void SetState(ComputerSystem vm, ushort requiredState); void SetState(ComputerSystem vm, ushort requiredState);
Dictionary<String, VmState> GetVmSync(String privateIpAddress);
} }
} }

View File

@ -45,6 +45,16 @@ namespace HypervResource
return new JObject(objTypeValuePairing); 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> /// <summary>
/// Copy file on network share to local volume. /// Copy file on network share to local volume.

View File

@ -1549,6 +1549,19 @@ namespace HypervResource
return null; 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() public List<string> GetVmElementNames()
{ {
List<string> result = new List<string>(); List<string> result = new List<string>();