private void updateExtraDhcpOptionsForExistingVm(Network network, Nic nic) { _networkOrchestrationService.configureExtraDhcpOptions(network, nic.getId()); }
@Override @DB public void releaseNic(final VirtualMachineProfile vmProfile, final Nic nic) throws ConcurrentOperationException, ResourceUnavailableException { releaseNic(vmProfile, nic.getId()); }
@Override public void removeNic(final VirtualMachineProfile vm, final Nic nic) { removeNic(vm, _nicDao.findById(nic.getId())); }
@Override public void doInTransactionWithoutResult(TransactionStatus status) { for (Nic nic : nics) { if (nic.getIPv4Address() != null) { s_logger.debug("Releasing ip " + nic.getIPv4Address() + " of placeholder nic " + nic); IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIPv4Address()); if (ip != null) { _ipAddrMgr.markIpAsUnavailable(ip.getId()); _ipAddressDao.unassignIpAddress(ip.getId()); s_logger.debug("Removing placeholder nic " + nic); _nicDao.remove(nic.getId()); } } } } });
@Override public List<FirewallRuleVO> listAssociatedRulesForGuestNic(Nic nic) { s_logger.debug("Checking if PF/StaticNat/LoadBalancer rules are configured for nic " + nic.getId()); List<FirewallRuleVO> result = new ArrayList<FirewallRuleVO>();
continue; if(_nicSecondaryIpDao.findByIp4AddressAndNicId(ip,nicInSameNetwork.getId()) == null) { throw new InvalidParameterValueException("VM ip "+ ip + " specified does not belong to " + "nic in network " + nicInSameNetwork.getNetworkId());
final Nic lock = _nicsDao.acquireInLockTable(nic.getId()); if (lock == null) { if (_nicsDao.findById(nic.getId()) == null) { if (s_logger.isDebugEnabled()) { s_logger.debug("Not need to remove the vm " + vm + " from network " + network + " as the vm doesn't have nic in this network"); throw new ConcurrentOperationException("Unable to lock nic " + nic.getId()); s_logger.debug("Lock is acquired for nic id " + lock.getId() + " as a part of remove vm " + vm + " from network " + network); } finally { if (lock != null) { _nicsDao.releaseFromLockTable(lock.getId()); if (s_logger.isDebugEnabled()) { s_logger.debug("Lock is released for nic id " + lock.getId() + " as a part of remove vm " + vm + " from network " + network);
protected boolean applyUserData(HypervisorType hyperVisorType, UserVm vm, Nic nic) throws ResourceUnavailableException, InsufficientCapacityException { Network network = _networkDao.findById(nic.getNetworkId()); NicProfile nicProfile = new NicProfile(nic, network, null, null, null, _networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag( hyperVisorType, network)); VirtualMachineProfile vmProfile = new VirtualMachineProfileImpl(vm); if (_networkModel.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Service.UserData)) { UserDataServiceProvider element = _networkModel.getUserDataUpdateProvider(network); if (element == null) { throw new CloudRuntimeException("Can't find network element for " + Service.UserData.getName() + " provider needed for UserData update"); } boolean result = element.saveUserData(network, nicProfile, vmProfile); if (!result) { s_logger.error("Failed to update userdata for vm " + vm + " and nic " + nic); } else { return true; } } else { s_logger.debug("Not applying userdata for nic id=" + nic.getId() + " in vm id=" + vmProfile.getId() + " because it is not supported in network id=" + network.getId()); } return false; }
final long isDefault = nic.isDefaultNic() ? 1 : 0; UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NETWORK_OFFERING_REMOVE, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), Long.toString(nic.getId()), network.getNetworkOfferingId(), null, isDefault, VirtualMachine.class.getName(), vm.getUuid(), vm.isDisplay()); } else { s_logger.warn("Failed to unplug nic for the vm " + vm + " from network " + network); _nicsDao.expunge(nic.getId()); return true;
public Outcome<VirtualMachine> removeNicFromVmThroughJobQueue( final VirtualMachine vm, final Nic nic) { final CallContext context = CallContext.current(); final User user = context.getCallingUser(); final Account account = context.getCallingAccount(); final List<VmWorkJobVO> pendingWorkJobs = _workJobDao.listPendingWorkJobs( VirtualMachine.Type.Instance, vm.getId(), VmWorkRemoveNicFromVm.class.getName()); VmWorkJobVO workJob = null; if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { assert pendingWorkJobs.size() == 1; workJob = pendingWorkJobs.get(0); } else { workJob = new VmWorkJobVO(context.getContextId()); workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); workJob.setCmd(VmWorkRemoveNicFromVm.class.getName()); workJob.setAccountId(account.getId()); workJob.setUserId(user.getId()); workJob.setVmType(VirtualMachine.Type.Instance); workJob.setVmInstanceId(vm.getId()); workJob.setRelated(AsyncJobExecutionContext.getOriginJobId()); // save work context info (there are some duplications) final VmWorkRemoveNicFromVm workInfo = new VmWorkRemoveNicFromVm(user.getId(), account.getId(), vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, nic.getId()); workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); } AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(workJob.getId()); return new VmJobVirtualMachineOutcome(workJob, vm.getId()); }
.findFirst() .get() .getUuid(), nic.getId(), extraDhcpOptionsMap);
_nicDao.remove(selfipNic.getId());
NicSecondaryIp secondaryIp = _nicSecondaryDao.findByIp4AddressAndNicId(vmGuestIp.toString(), guestNic.getId()); if (secondaryIp == null) { throw new InvalidParameterValueException("IP Address is not in the VM nic's network ");
VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, result.getInstanceId()); UserVmJoinVO userVm = _entityMgr.findById(UserVmJoinVO.class, result.getInstanceId()); List<NicExtraDhcpOptionVO> nicExtraDhcpOptionVOs = _nicExtraDhcpOptionDao.listByNicId(result.getId()); List<NicSecondaryIpVO> secondaryIps = ApiDBUtils.findNicSecondaryIps(result.getId()); if (secondaryIps != null) { List<NicSecondaryIpResponse> ipList = new ArrayList<NicSecondaryIpResponse>();
boolean secondaryIpSet = _networkMgr.isSecondaryIpSetForNic(guestNic.getId()); if (!secondaryIpSet) { throw new InvalidParameterValueException("VM ip " + vmGuestIp + " address not belongs to the vm"); nicSecIp = _nicSecondaryDao.findByIp4AddressAndNicId(vmGuestIp, guestNic.getId()); if (nicSecIp == null) { throw new InvalidParameterValueException("VM ip " + vmGuestIp + " address not belongs to the vm");
public NicProfile(Nic nic, Network network, URI broadcastUri, URI isolationUri, Integer networkRate, boolean isSecurityGroupEnabled, String name) { id = nic.getId(); networkId = network.getId(); mode = network.getMode(); broadcastType = network.getBroadcastDomainType(); trafficType = network.getTrafficType(); format = nic.getAddressFormat(); iPv4Address = nic.getIPv4Address(); iPv4Netmask = nic.getIPv4Netmask(); iPv4Gateway = nic.getIPv4Gateway(); iPv6Address = nic.getIPv6Address(); iPv6Gateway = nic.getIPv6Gateway(); iPv6Cidr = nic.getIPv6Cidr(); macAddress = nic.getMacAddress(); reservationId = nic.getReservationId(); strategy = nic.getReservationStrategy(); deviceId = nic.getDeviceId(); defaultNic = nic.isDefaultNic(); this.broadcastUri = broadcastUri; this.isolationUri = isolationUri; this.isSecurityGroupEnabled = isSecurityGroupEnabled; vmId = nic.getInstanceId(); this.name = name; uuid = nic.getUuid(); if (networkRate != null) { this.networkRate = networkRate; } }
String oldNicIdString = Long.toString(_networkModel.getDefaultNic(vmId).getId()); long oldNetworkOfferingId = -1L;
NicSecondaryIp secondaryIp = _nicSecondaryDao.findByIp4AddressAndNicId(vmIp.toString(), guestNic.getId()); if (secondaryIp == null) { throw new InvalidParameterValueException("IP Address is not in the VM nic's network ");