From e7a7beac5b43478b2b8ce49b83ffec0efe8343ee Mon Sep 17 00:00:00 2001 From: anthony Date: Wed, 3 Nov 2010 19:21:34 -0700 Subject: [PATCH] merge from 2.1.x 80a32ad031eea2765ae727897bb865c0d0e9cdc8 not create bond any more --- .../xen/resource/CitrixResourceBase.java | 50 +++++++++++++++---- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 2eb4221eb44..64a88d0232e 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -2073,6 +2073,10 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR vmtmpltvdi = cloudVDIcopy(tmpltvdi, poolsr); snapshotvdi = vmtmpltvdi.snapshot(conn, new HashMap()); vmtmpltvdi.destroy(conn); + try { + poolsr.scan(conn); + } catch (Exception e) { + } snapshotvdi.setNameLabel(conn, "Template " + cmd.getName()); // vmtmpltvdi.setNameDescription(conn, cmd.getDescription()); uuid = snapshotvdi.getUuid(conn); @@ -3420,7 +3424,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR return true; } - protected Nic getLocalNetwork(Connection conn, String name) throws XmlRpcException, XenAPIException { + protected Nic getManageMentNetwork(Connection conn, String name) throws XmlRpcException, XenAPIException { if( name == null) { return null; } @@ -3433,7 +3437,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR if (s_logger.isDebugEnabled()) { s_logger.debug("Found a network called " + name + " on host=" + _host.ip + "; Network=" + nr.uuid + "; pif=" + pr.uuid); } - if (pr.bondMasterOf != null && pr.bondMasterOf.size() > 0) { + if (!pr.management && pr.bondMasterOf != null && pr.bondMasterOf.size() > 0) { if (pr.bondMasterOf.size() > 1) { String msg = new StringBuilder("Unsupported configuration. Network " + name + " has more than one bond. Network=").append(nr.uuid) .append("; pif=").append(pr.uuid).toString(); @@ -3464,6 +3468,27 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR return null; } + + + protected Nic getLocalNetwork(Connection conn, String name) throws XmlRpcException, XenAPIException { + Set networks = Network.getByNameLabel(conn, name); + for (Network network : networks) { + Network.Record nr = network.getRecord(conn); + for (PIF pif : nr.PIFs) { + PIF.Record pr = pif.getRecord(conn); + if (_host.uuid.equals(pr.host.getUuid(conn))) { + if (s_logger.isDebugEnabled()) { + s_logger.debug("Found a network called " + name + " on host=" + _host.ip + "; Network=" + + nr.uuid + "; pif=" + pr.uuid); + } + return new Nic(network, nr, pif, pr); + } + } + } + + return null; + } + protected VIF getCorrectVif(VM router, String vlanId) { try { @@ -3912,11 +3937,6 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR throw new CloudRuntimeException("can not find systemvmiso"); } - String name = "cloud-private"; - if (_privateNetworkName != null) { - name = _privateNetworkName; - } - _localGateway = callHostPlugin("vmops", "getgateway", "mgmtIP", myself.getAddress(conn)); if (_localGateway == null || _localGateway.isEmpty()) { s_logger.warn("can not get gateway for host :" + _host.uuid); @@ -3924,8 +3944,17 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR } _canBridgeFirewall = can_bridge_firewall(); + + + Nic privateNic = null; + privateNic = getManageMentNetwork(conn, "cloud-private"); + if (privateNic == null) { + privateNic = getManageMentNetwork(conn, _privateNetworkName); + } else { + _privateNetworkName = "cloud-private"; + } + String name = _privateNetworkName; - Nic privateNic = getLocalNetwork(conn, name); if (privateNic == null) { s_logger.debug("Unable to find any private network. Trying to determine that by route for host " + _host.ip); name = callHostPlugin("vmops", "getnetwork", "mgmtIP", myself.getAddress(conn)); @@ -3934,13 +3963,12 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR return false; } _privateNetworkName = name; - privateNic = getLocalNetwork(conn, name); + privateNic = getManageMentNetwork(conn, name); if (privateNic == null) { s_logger.warn("Unable to get private network " + name); return false; } - } else { - _privateNetworkName = name; + name = privateNic.nr.nameLabel; } _host.privatePif = privateNic.pr.uuid;