diff --git a/src/TopoMojo.Abstractions/Models/VmTemplate.cs b/src/TopoMojo.Abstractions/Models/VmTemplate.cs index 6ec9504..1493a74 100644 --- a/src/TopoMojo.Abstractions/Models/VmTemplate.cs +++ b/src/TopoMojo.Abstractions/Models/VmTemplate.cs @@ -32,6 +32,7 @@ public class VmNet { public int Id { get; set; } public string Net { get; set; } + public string Key { get; set; } public string Type { get; set; } public string Mac { get; set; } public string Ip { get; set; } diff --git a/src/TopoMojo.vSphere/DistributedNetworkManager.cs b/src/TopoMojo.vSphere/DistributedNetworkManager.cs index 86d828f..acb76a3 100644 --- a/src/TopoMojo.vSphere/DistributedNetworkManager.cs +++ b/src/TopoMojo.vSphere/DistributedNetworkManager.cs @@ -91,7 +91,7 @@ public override async Task GetVmNetworks(ManagedObjectReference mor result.Add(new VmNetwork { - NetworkMOR = back.port.portgroupKey, + NetworkMOR = $"DistributedVirtualPortgroup|{back.port.portgroupKey}", VmName = vmName }); } @@ -169,7 +169,7 @@ public override void UpdateEthernetCardBacking(VirtualEthernetCard card, string port = new DistributedVirtualSwitchPortConnection { switchUuid = _client.DvsUuid, - portgroupKey = netMorName + portgroupKey = netMorName.AsReference().Value } }; } diff --git a/src/TopoMojo.vSphere/HypervisorService.cs b/src/TopoMojo.vSphere/HypervisorService.cs index c3ee1f5..bbc60c6 100644 --- a/src/TopoMojo.vSphere/HypervisorService.cs +++ b/src/TopoMojo.vSphere/HypervisorService.cs @@ -132,7 +132,8 @@ public async Task Load(string id) Vm vm = _vmCache.Values.Where(o=>o.Id == id || o.Name == id).FirstOrDefault(); - CheckProgress(vm); + if (vm != null) + CheckProgress(vm); return vm; } diff --git a/src/TopoMojo.vSphere/NetworkManager.cs b/src/TopoMojo.vSphere/NetworkManager.cs index 796802e..d0ffddd 100644 --- a/src/TopoMojo.vSphere/NetworkManager.cs +++ b/src/TopoMojo.vSphere/NetworkManager.cs @@ -117,7 +117,7 @@ public async Task Provision(VmTemplate template) _pgAllocation[eth.Net].Counter += 1; } - eth.Net = _pgAllocation[eth.Net].Key; + eth.Key = _pgAllocation[eth.Net].Key; } } } diff --git a/src/TopoMojo.vSphere/VimTransform.cs b/src/TopoMojo.vSphere/VimTransform.cs index 010b19b..df94404 100755 --- a/src/TopoMojo.vSphere/VimTransform.cs +++ b/src/TopoMojo.vSphere/VimTransform.cs @@ -129,8 +129,8 @@ private static VirtualDeviceConfigSpec GetEthernetAdapter(ref int key, VmNet nic if (nic.Net.StartsWith("nsx.")) { eth.backing = new VirtualEthernetCardOpaqueNetworkBackingInfo { - opaqueNetworkId = nic.Net.Tag(), - opaqueNetworkType = nic.Net.Untagged() + opaqueNetworkId = nic.Key.Tag(), + opaqueNetworkType = nic.Key.Untagged() }; } else if (dvsuuid.HasValue()) @@ -139,13 +139,13 @@ private static VirtualDeviceConfigSpec GetEthernetAdapter(ref int key, VmNet nic port = new DistributedVirtualSwitchPortConnection { switchUuid = dvsuuid, - portgroupKey = nic.Net + portgroupKey = nic.Key.AsReference().Value } }; } else { - eth.backing = new VirtualEthernetCardNetworkBackingInfo { deviceName = nic.Net }; + eth.backing = new VirtualEthernetCardNetworkBackingInfo { deviceName = nic.Key }; } devicespec = new VirtualDeviceConfigSpec();