CLOUDSTACK-6431: OVS migrating vm to a new host added to the cluster does not create gre tunnel port on the new host
ensure OveElement gets a chance to setup tunnel network on the host before VM is migrated. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5ba7f6c0 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5ba7f6c0 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5ba7f6c0 Branch: refs/heads/4.4 Commit: 5ba7f6c00628dc971a338e4b5ecab49ef1965b37 Parents: 61fc571 Author: Murali Reddy <muralimmre...@gmail.com> Authored: Fri Apr 25 17:18:24 2014 +0530 Committer: Daan Hoogland <d...@onecht.net> Committed: Fri Apr 25 22:13:03 2014 +0200 ---------------------------------------------------------------------- .../com/cloud/network/element/OvsElement.java | 39 +++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5ba7f6c0/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java index d767834..faf58fc 100644 --- a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java +++ b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java @@ -54,6 +54,7 @@ import com.cloud.network.PublicIpAddress; import com.cloud.network.dao.NetworkServiceMapDao; import com.cloud.network.lb.LoadBalancingRule; import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy; +import com.cloud.network.NetworkMigrationResponder; import com.cloud.network.ovs.OvsTunnelManager; import com.cloud.network.router.VirtualRouter.Role; import com.cloud.network.router.VpcVirtualNetworkApplianceManager; @@ -79,10 +80,10 @@ import com.cloud.vm.VirtualMachine; @Local(value = {NetworkElement.class, ConnectivityProvider.class, SourceNatServiceProvider.class, StaticNatServiceProvider.class, - PortForwardingServiceProvider.class, IpDeployer.class}) + PortForwardingServiceProvider.class, IpDeployer.class, NetworkMigrationResponder.class}) public class OvsElement extends AdapterBase implements NetworkElement, OvsElementService, ConnectivityProvider, ResourceStateAdapter, -PortForwardingServiceProvider, LoadBalancingServiceProvider, +PortForwardingServiceProvider, LoadBalancingServiceProvider, NetworkMigrationResponder, StaticNatServiceProvider, IpDeployer { @Inject OvsTunnelManager _ovsTunnelMgr; @@ -658,4 +659,38 @@ StaticNatServiceProvider, IpDeployer { } return true; } + + @Override + public boolean prepareMigration(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) { + if (!canHandle(network, Service.Connectivity)) { + return false; + } + + if (nic.getBroadcastType() != Networks.BroadcastDomainType.Vswitch) { + return false; + } + + if (nic.getTrafficType() != Networks.TrafficType.Guest) { + return false; + } + + if (vm.getType() != VirtualMachine.Type.User && vm.getType() != VirtualMachine.Type.DomainRouter) { + return false; + } + + // prepare the tunnel network on the host, in order for VM to get launched + _ovsTunnelMgr.checkAndPrepareHostForTunnelNetwork(network, dest.getHost()); + + return true; + } + + @Override + public void rollbackMigration(NicProfile nic, Network network, VirtualMachineProfile vm, ReservationContext src, ReservationContext dst) { + return; + } + + @Override + public void commitMigration(NicProfile nic, Network network, VirtualMachineProfile vm, ReservationContext src, ReservationContext dst) { + return; + } }