@Override public boolean prepareMigration(final NicProfile nic, final Network network, final VirtualMachineProfile vm, final DeployDestination dest, final 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 boolean release(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { if (!canHandle(network, Service.Connectivity)) { return false; } if (nic.getBroadcastType() != Networks.BroadcastDomainType.Vswitch) { return false; } if (nic.getTrafficType() != Networks.TrafficType.Guest) { return false; } final HostVO host = _hostDao.findById(vm.getVirtualMachine().getHostId()); _ovsTunnelMgr.checkAndRemoveHostFromTunnelNetwork(network, host); return true; }
@Override public boolean prepare(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { 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(final NicProfile nic, final Network network, final VirtualMachineProfile vm, final ReservationContext src, final ReservationContext dst) { if (nic.getBroadcastType() != Networks.BroadcastDomainType.Pvlan) { return; } if (vm.getType() == VirtualMachine.Type.DomainRouter) { assert vm instanceof DomainRouterVO; final DomainRouterVO router = (DomainRouterVO) vm.getVirtualMachine(); final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId()); final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO); try { networkTopology.setupDhcpForPvlan(true, router, router.getHostId(), nic); } catch (final ResourceUnavailableException e) { s_logger.warn("Timed Out", e); } } else if (vm.getType() == VirtualMachine.Type.User) { assert vm instanceof UserVmVO; final UserVmVO userVm = (UserVmVO) vm.getVirtualMachine(); _userVmMgr.setupVmForPvlan(true, userVm.getHostId(), nic); } }
@Override public void commitMigration(final NicProfile nic, final Network network, final VirtualMachineProfile vm, final ReservationContext src, final ReservationContext dst) { if (nic.getBroadcastType() != Networks.BroadcastDomainType.Pvlan) { return; } if (vm.getType() == VirtualMachine.Type.DomainRouter) { assert vm instanceof DomainRouterVO; final DomainRouterVO router = (DomainRouterVO) vm.getVirtualMachine(); final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId()); final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO); try { networkTopology.setupDhcpForPvlan(true, router, router.getHostId(), nic); } catch (final ResourceUnavailableException e) { s_logger.warn("Timed Out", e); } } else if (vm.getType() == VirtualMachine.Type.User) { assert vm instanceof UserVmVO; final UserVmVO userVm = (UserVmVO) vm.getVirtualMachine(); _userVmMgr.setupVmForPvlan(true, userVm.getHostId(), nic); } }
@Override public boolean prepareMigration(final NicProfile nic, final Network network, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context) { if (nic.getBroadcastType() != Networks.BroadcastDomainType.Pvlan) { return true; } if (vm.getType() == VirtualMachine.Type.DomainRouter) { assert vm instanceof DomainRouterVO; final DomainRouterVO router = (DomainRouterVO) vm.getVirtualMachine(); final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId()); final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO); try { networkTopology.setupDhcpForPvlan(false, router, router.getHostId(), nic); } catch (final ResourceUnavailableException e) { s_logger.warn("Timed Out", e); } } else if (vm.getType() == VirtualMachine.Type.User) { assert vm instanceof UserVmVO; final UserVmVO userVm = (UserVmVO) vm.getVirtualMachine(); _userVmMgr.setupVmForPvlan(false, userVm.getHostId(), nic); } return true; }
NicTO to = new NicTO(); to.setDeviceId(profile.getDeviceId()); to.setBroadcastType(profile.getBroadcastType()); to.setType(profile.getTrafficType()); to.setIp(profile.getIPv4Address());