public void setProperties(ModelController controller, VMInstanceVO instance, NicVO nic) throws IOException { _vmName = instance.getInstanceName(); _deviceId = nic.getDeviceId(); Network network = controller.getNetworkDao().findById(nic.getNetworkId()); switch (nic.getState()) { case Allocated: case Reserved: _nicActive = true; break; default: _nicActive = false; break; } switch (network.getState()) { case Implemented: case Setup: _netActive = true; break; default: _netActive = false; break; } assert _vnModel != null; _networkId = _vnModel.getUuid(); }
if (userNic.getVmType() == VirtualMachine.Type.DomainRouter || userNic.getState() != Nic.State.Reserved) { iterator.remove(); continue;
/** * reassigns the nics to the new network from the src network. * @param srcNetworkId * @param dstNetworkId */ private void assignUserNicsToNewNetwork(long srcNetworkId, long dstNetworkId) { List<NicVO> nics = _nicDao.listByNetworkId(srcNetworkId); for (NicVO nic : nics) { if (nic.getVmType() == VirtualMachine.Type.User) { nic.setNetworkId(dstNetworkId); _nicDao.persist(nic); //update the number of active nics in both networks after migration. if (nic.getState() == Nic.State.Reserved) { _networksDao.changeActiveNicsBy(srcNetworkId, -1); _networksDao.changeActiveNicsBy(dstNetworkId, 1); } } } List<? extends IPAddressVO> publicIps = _ipAddressDao.listByAssociatedNetwork(srcNetworkId, null); for (IPAddressVO ipAddress : publicIps) { ipAddress.setAssociatedWithNetworkId(dstNetworkId); _ipAddressDao.persist(ipAddress); } }
protected void removeNic(final VirtualMachineProfile vm, final NicVO nic) { if (nic.getReservationStrategy() == Nic.ReservationStrategy.Start && nic.getState() != Nic.State.Allocated) {
if(nicVO.getState() == Nic.State.Reserved) { configureExtraDhcpOptions(network, nicVO.getId());
if (originalNic.getState() == Nic.State.Reserved) { final VirtualMachine vm = vmProfile.getVirtualMachine(); final Host host = _hostDao.findById(vm.getHostId());
long nicIp = NetUtils.ip2Long(nic.getIPv4Address()); if ((nicIp < startIp || nicIp > endIp) && nic.getState() != Nic.State.Deallocating) { throw new InvalidParameterValueException("Active IPs like " + nic.getIPv4Address() + " exist outside the Guest VM CIDR. Cannot apply reservation ");
final Nic.State originalState = nic.getState(); final NetworkVO network = _networksDao.findById(nic.getNetworkId());
NonReleasedSearch.and("instance", NonReleasedSearch.entity().getInstanceId(), Op.EQ); NonReleasedSearch.and("network", NonReleasedSearch.entity().getNetworkId(), Op.EQ); NonReleasedSearch.and("state", NonReleasedSearch.entity().getState(), Op.NOTIN); NonReleasedSearch.done();