@Override public Nic getDefaultNic(long vmId) { List<NicVO> nics = _nicDao.listByVmId(vmId); Nic defaultNic = null; if (nics != null) { for (Nic nic : nics) { if (nic.isDefaultNic()) { defaultNic = nic; break; } } } else { s_logger.debug("Unable to find default network for the vm; vm doesn't have any nics"); return null; } if (defaultNic == null) { s_logger.debug("Unable to find default network for the vm; vm doesn't have default nic"); } return defaultNic; }
private boolean getDefaultHasDns(Map<Long, Boolean> cache, Nic nic) { Long networkId = nic.isDefaultNic() ? Long.valueOf(nic.getNetworkId()) : getDefaultNetwork(nic.getInstanceId()); Boolean hasDns = cache.computeIfAbsent(networkId, k -> networkHasDns(_networkDao.findById(networkId))); return hasDns; }
if (nic.isDefaultNic() && vm.getType() == VirtualMachine.Type.User) { s_logger.warn("Failed to remove nic from " + vm + " in " + network + ", nic is default."); throw new CloudRuntimeException("Failed to remove nic from " + vm + " in " + network + ", nic is default.");
if (result) { s_logger.debug("Nic is unplugged successfully for vm " + vm + " in network " + network); 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());
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; } }
response.setIsDefault(result.isDefaultNic()); if (result.getSecondaryIp()) { List<NicSecondaryIpVO> secondaryIps = ApiDBUtils.findNicSecondaryIps(result.getId());
if (vm.getType() == Type.User) { final Nic nic = _nicDao.findByNtwkIdAndInstanceId(networkId, vmId); if (nic != null && nic.isDefaultNic()) { return _configMgr.getServiceOfferingNetworkRate(vm.getServiceOfferingId(), network.getDataCenterId());