@DB @Override public void removeDhcpServiceInSubnet(final Nic nic) { final Network network = _networksDao.findById(nic.getNetworkId()); final DhcpServiceProvider dhcpServiceProvider = getDhcpServiceProvider(network); try { final NicIpAliasVO ipAlias = _nicIpAliasDao.findByGatewayAndNetworkIdAndState(nic.getIPv4Gateway(), network.getId(), NicIpAlias.State.active); if (ipAlias != null) { ipAlias.setState(NicIpAlias.State.revoked); Transaction.execute(new TransactionCallbackNoReturn() { @Override public void doInTransactionWithoutResult(final TransactionStatus status) { _nicIpAliasDao.update(ipAlias.getId(), ipAlias); final IPAddressVO aliasIpaddressVo = _publicIpAddressDao.findByIpAndSourceNetworkId(ipAlias.getNetworkId(), ipAlias.getIp4Address()); _publicIpAddressDao.unassignIpAddress(aliasIpaddressVo.getId()); } }); if (!dhcpServiceProvider.removeDhcpSupportForSubnet(network)) { s_logger.warn("Failed to remove the ip alias on the router, marking it as removed in db and freed the allocated ip " + ipAlias.getIp4Address()); } } } catch (final ResourceUnavailableException e) { //failed to remove the dhcpconfig on the router. s_logger.info("Unable to delete the ip alias due to unable to contact the virtualrouter."); } }
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.setGateway(result.getIPv4Gateway());