mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 07:19:18 +01:00
CA-238901: PVS proxy not setup for imported VM
For ElyOrGreater hosts, we try move the existing VIFs to the desired networks. We will only destroy and create new ones for older hosts or when a corresponding VIF cannot be found in the network mapping. Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
parent
a59e4f4ad3
commit
74885674c3
@ -33,6 +33,7 @@ using System;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using XenAdmin.Core;
|
using XenAdmin.Core;
|
||||||
@ -166,11 +167,14 @@ namespace XenAdmin.Actions
|
|||||||
{
|
{
|
||||||
Description = isTemplate ? Messages.IMPORT_TEMPLATE_UPDATING_NETWORKS : Messages.IMPORTVM_UPDATING_NETWORKS;
|
Description = isTemplate ? Messages.IMPORT_TEMPLATE_UPDATING_NETWORKS : Messages.IMPORTVM_UPDATING_NETWORKS;
|
||||||
|
|
||||||
// We need to destroy all vifs and recreate them.
|
// For ElyOrGreater hosts, we can move the VIFs to another network,
|
||||||
|
// but for older hosts we need to destroy all vifs and recreate them
|
||||||
|
|
||||||
List<XenRef<VIF>> vifs = VM.get_VIFs(Session, vmRef);
|
List<XenRef<VIF>> vifs = VM.get_VIFs(Session, vmRef);
|
||||||
List<XenAPI.Network> networks = new List<XenAPI.Network>();
|
List<XenAPI.Network> networks = new List<XenAPI.Network>();
|
||||||
|
|
||||||
|
bool canMoveVifs = Helpers.ElyOrGreater(Connection);
|
||||||
|
|
||||||
foreach (XenRef<VIF> vif in vifs)
|
foreach (XenRef<VIF> vif in vifs)
|
||||||
{
|
{
|
||||||
// Save the network as we may have to delete it later
|
// Save the network as we may have to delete it later
|
||||||
@ -178,9 +182,27 @@ namespace XenAdmin.Actions
|
|||||||
if (network != null)
|
if (network != null)
|
||||||
networks.Add(network);
|
networks.Add(network);
|
||||||
|
|
||||||
|
if (canMoveVifs)
|
||||||
|
{
|
||||||
|
var vifObj = Connection.Resolve(vif);
|
||||||
|
if (vifObj == null)
|
||||||
|
continue;
|
||||||
|
// try to find a matching VIF in the m_proxyVIFs list, based on the device field
|
||||||
|
var matchingProxyVif = m_proxyVIFs.FirstOrDefault(proxyVIF => proxyVIF.device == vifObj.device);
|
||||||
|
if (matchingProxyVif != null)
|
||||||
|
{
|
||||||
|
// move the VIF to the desired network
|
||||||
|
VIF.move(Session, vif, matchingProxyVif.network);
|
||||||
|
// remove matchingProxyVif from the list, so we don't create the VIF again later
|
||||||
|
m_proxyVIFs.Remove(matchingProxyVif);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// destroy the VIF, if we haven't managed to move it
|
||||||
VIF.destroy(Session, vif);
|
VIF.destroy(Session, vif);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// recreate VIFs if needed (m_proxyVIFs can be empty, if we moved all the VIFs in the previous step)
|
||||||
foreach (Proxy_VIF proxyVIF in m_proxyVIFs)
|
foreach (Proxy_VIF proxyVIF in m_proxyVIFs)
|
||||||
{
|
{
|
||||||
VIF vif = new VIF(proxyVIF) {VM = new XenRef<VM>(vmRef)};
|
VIF vif = new VIF(proxyVIF) {VM = new XenRef<VM>(vmRef)};
|
||||||
|
Loading…
Reference in New Issue
Block a user