http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/IpAddressManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/IpAddressManagerImpl.java b/server/src/com/cloud/network/IpAddressManagerImpl.java index 5113b7f..28df971 100644 --- a/server/src/com/cloud/network/IpAddressManagerImpl.java +++ b/server/src/com/cloud/network/IpAddressManagerImpl.java @@ -40,6 +40,7 @@ import org.apache.cloudstack.region.PortableIp; import org.apache.cloudstack.region.PortableIpDao; import org.apache.cloudstack.region.PortableIpVO; import org.apache.cloudstack.region.Region; +import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; import com.cloud.alert.AlertManager; @@ -167,6 +168,7 @@ import com.cloud.vm.dao.UserVmDao; import com.cloud.vm.dao.VMInstanceDao; public class IpAddressManagerImpl extends ManagerBase implements IpAddressManager, Configurable { + private static final Logger s_logger = Logger.getLogger(IpAddressManagerImpl.class); @Inject NetworkOrchestrationService _networkMgr = null; @@ -397,7 +399,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage Network.State.getStateMachine().registerListener(new NetworkStateListener(_usageEventDao, _networksDao, _configDao)); - logger.info("Network Manager is configured."); + s_logger.info("Network Manager is configured."); return true; } @@ -449,14 +451,14 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage if (postApplyRules) { if (revokeCount != null && revokeCount.longValue() == totalCount.longValue()) { - logger.trace("All rules are in Revoke state, have to dis-assiciate IP from the backend"); + s_logger.trace("All rules are in Revoke state, have to dis-assiciate IP from the backend"); return true; } } else { if (activeCount != null && activeCount > 0) { continue; } else if (addCount != null && addCount.longValue() == totalCount.longValue()) { - logger.trace("All rules are in Add state, have to assiciate IP with the backend"); + s_logger.trace("All rules are in Add state, have to assiciate IP with the backend"); return true; } else { continue; @@ -473,7 +475,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage public boolean applyRules(List<? extends FirewallRule> rules, FirewallRule.Purpose purpose, NetworkRuleApplier applier, boolean continueOnError) throws ResourceUnavailableException { if (rules == null || rules.size() == 0) { - logger.debug("There are no rules to forward to the network elements"); + s_logger.debug("There are no rules to forward to the network elements"); return true; } @@ -504,7 +506,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage if (!continueOnError) { throw e; } - logger.warn("Problems with applying " + purpose + " rules but pushing on", e); + s_logger.warn("Problems with applying " + purpose + " rules but pushing on", e); success = false; } @@ -522,31 +524,31 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage // Revoke all firewall rules for the ip try { - logger.debug("Revoking all " + Purpose.Firewall + "rules as a part of public IP id=" + ipId + " release..."); + s_logger.debug("Revoking all " + Purpose.Firewall + "rules as a part of public IP id=" + ipId + " release..."); if (!_firewallMgr.revokeFirewallRulesForIp(ipId, userId, caller)) { - logger.warn("Unable to revoke all the firewall rules for ip id=" + ipId + " as a part of ip release"); + s_logger.warn("Unable to revoke all the firewall rules for ip id=" + ipId + " as a part of ip release"); success = false; } } catch (ResourceUnavailableException e) { - logger.warn("Unable to revoke all firewall rules for ip id=" + ipId + " as a part of ip release", e); + s_logger.warn("Unable to revoke all firewall rules for ip id=" + ipId + " as a part of ip release", e); success = false; } // Revoke all PF/Static nat rules for the ip try { - logger.debug("Revoking all " + Purpose.PortForwarding + "/" + Purpose.StaticNat + " rules as a part of public IP id=" + ipId + " release..."); + s_logger.debug("Revoking all " + Purpose.PortForwarding + "/" + Purpose.StaticNat + " rules as a part of public IP id=" + ipId + " release..."); if (!_rulesMgr.revokeAllPFAndStaticNatRulesForIp(ipId, userId, caller)) { - logger.warn("Unable to revoke all the port forwarding rules for ip id=" + ipId + " as a part of ip release"); + s_logger.warn("Unable to revoke all the port forwarding rules for ip id=" + ipId + " as a part of ip release"); success = false; } } catch (ResourceUnavailableException e) { - logger.warn("Unable to revoke all the port forwarding rules for ip id=" + ipId + " as a part of ip release", e); + s_logger.warn("Unable to revoke all the port forwarding rules for ip id=" + ipId + " as a part of ip release", e); success = false; } - logger.debug("Revoking all " + Purpose.LoadBalancing + " rules as a part of public IP id=" + ipId + " release..."); + s_logger.debug("Revoking all " + Purpose.LoadBalancing + " rules as a part of public IP id=" + ipId + " release..."); if (!_lbMgr.removeAllLoadBalanacersForIp(ipId, caller, userId)) { - logger.warn("Unable to revoke all the load balancer rules for ip id=" + ipId + " as a part of ip release"); + s_logger.warn("Unable to revoke all the load balancer rules for ip id=" + ipId + " as a part of ip release"); success = false; } @@ -554,11 +556,11 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage // conditions // only when ip address failed to be cleaned up as a part of account destroy and was marked as Releasing, this part of // the code would be triggered - logger.debug("Cleaning up remote access vpns as a part of public IP id=" + ipId + " release..."); + s_logger.debug("Cleaning up remote access vpns as a part of public IP id=" + ipId + " release..."); try { _vpnMgr.destroyRemoteAccessVpnForIp(ipId, caller); } catch (ResourceUnavailableException e) { - logger.warn("Unable to destroy remote access vpn for ip id=" + ipId + " as a part of ip release", e); + s_logger.warn("Unable to destroy remote access vpn for ip id=" + ipId + " as a part of ip release", e); success = false; } @@ -573,7 +575,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage // Cleanup all ip address resources - PF/LB/Static nat rules if (!cleanupIpResources(addrId, userId, caller)) { success = false; - logger.warn("Failed to release resources for ip address id=" + addrId); + s_logger.warn("Failed to release resources for ip address id=" + addrId); } IPAddressVO ip = markIpAsUnavailable(addrId); @@ -581,15 +583,15 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage return true; } - if (logger.isDebugEnabled()) { - logger.debug("Releasing ip id=" + addrId + "; sourceNat = " + ip.isSourceNat()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Releasing ip id=" + addrId + "; sourceNat = " + ip.isSourceNat()); } if (ip.getAssociatedWithNetworkId() != null) { Network network = _networksDao.findById(ip.getAssociatedWithNetworkId()); try { if (!applyIpAssociations(network, true)) { - logger.warn("Unable to apply ip address associations for " + network); + s_logger.warn("Unable to apply ip address associations for " + network); success = false; } } catch (ResourceUnavailableException e) { @@ -605,7 +607,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage if (ip.isPortable()) { releasePortableIpAddress(addrId); } - logger.debug("Released a public ip id=" + addrId); + s_logger.debug("Released a public ip id=" + addrId); } return success; @@ -701,7 +703,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage ex.addProxyObject(ApiDBUtils.findPodById(podId).getUuid()); throw ex; } - logger.warn(errorMessage.toString()); + s_logger.warn(errorMessage.toString()); InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException("Insufficient address capacity", DataCenter.class, dcId); ex.addProxyObject(ApiDBUtils.findZoneById(dcId).getUuid()); throw ex; @@ -746,7 +748,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage ex.addProxyObject(ApiDBUtils.findPodById(podId).getUuid()); throw ex; } - logger.warn(errorMessage.toString()); + s_logger.warn(errorMessage.toString()); InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException("Insufficient address capacity", DataCenter.class, dcId); ex.addProxyObject(ApiDBUtils.findZoneById(dcId).getUuid()); throw ex; @@ -759,7 +761,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage try { _resourceLimitMgr.checkResourceLimit(owner, ResourceType.public_ip); } catch (ResourceAllocationException ex) { - logger.warn("Failed to allocate resource of type " + ex.getResourceType() + " for account " + owner); + s_logger.warn("Failed to allocate resource of type " + ex.getResourceType() + " for account " + owner); throw new AccountLimitException("Maximum number of public IP addresses for account: " + owner.getAccountName() + " has been exceeded."); } } @@ -877,8 +879,8 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage ConcurrentOperationException ex = new ConcurrentOperationException("Unable to lock account"); throw ex; } - if (logger.isDebugEnabled()) { - logger.debug("lock account " + ownerId + " is acquired"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("lock account " + ownerId + " is acquired"); } boolean displayIp = true; if (guestNtwkId != null) { @@ -902,14 +904,14 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage return ip; } finally { if (owner != null) { - if (logger.isDebugEnabled()) { - logger.debug("Releasing lock account " + ownerId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Releasing lock account " + ownerId); } _accountDao.releaseFromLockTable(ownerId); } if (ip == null) { - logger.error("Unable to get source nat ip address for account " + ownerId); + s_logger.error("Unable to get source nat ip address for account " + ownerId); } } } @@ -932,7 +934,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage _ipAddressDao.unassignIpAddress(addr.getId()); } else { success = false; - logger.warn("Failed to release resources for ip address id=" + addr.getId()); + s_logger.warn("Failed to release resources for ip address id=" + addr.getId()); } } } @@ -979,7 +981,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage if (!continueOnError) { throw e; } else { - logger.debug("Resource is not available: " + provider.getName(), e); + s_logger.debug("Resource is not available: " + provider.getName(), e); } } } @@ -1007,17 +1009,17 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage Account accountToLock = null; try { - if (logger.isDebugEnabled()) { - logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId()); } accountToLock = _accountDao.acquireInLockTable(ipOwner.getId()); if (accountToLock == null) { - logger.warn("Unable to lock account: " + ipOwner.getId()); + s_logger.warn("Unable to lock account: " + ipOwner.getId()); throw new ConcurrentOperationException("Unable to acquire account lock"); } - if (logger.isDebugEnabled()) { - logger.debug("Associate IP address lock acquired"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Associate IP address lock acquired"); } ip = Transaction.execute(new TransactionCallbackWithException<PublicIp, InsufficientAddressCapacityException>() { @@ -1034,7 +1036,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage CallContext.current().setEventDetails("Ip Id: " + ip.getId()); Ip ipAddress = ip.getAddress(); - logger.debug("Got " + ipAddress + " to assign for account " + ipOwner.getId() + " in zone " + zone.getId()); + s_logger.debug("Got " + ipAddress + " to assign for account " + ipOwner.getId() + " in zone " + zone.getId()); return ip; } @@ -1042,11 +1044,11 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage } finally { if (accountToLock != null) { - if (logger.isDebugEnabled()) { - logger.debug("Releasing lock account " + ipOwner); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Releasing lock account " + ipOwner); } _accountDao.releaseFromLockTable(ipOwner.getId()); - logger.debug("Associate IP address lock released"); + s_logger.debug("Associate IP address lock released"); } } return ip; @@ -1175,12 +1177,12 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage } owner = _accountMgr.getAccount(ipToAssoc.getAllocatedToAccountId()); } else { - logger.debug("Unable to find ip address by id: " + ipId); + s_logger.debug("Unable to find ip address by id: " + ipId); return null; } if (ipToAssoc.getAssociatedWithNetworkId() != null) { - logger.debug("IP " + ipToAssoc + " is already assocaited with network id" + networkId); + s_logger.debug("IP " + ipToAssoc + " is already assocaited with network id" + networkId); return ipToAssoc; } @@ -1188,7 +1190,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage if (network != null) { _accountMgr.checkAccess(owner, AccessType.UseEntry, false, network); } else { - logger.debug("Unable to find ip address by id: " + ipId); + s_logger.debug("Unable to find ip address by id: " + ipId); return null; } @@ -1235,7 +1237,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage } } - logger.debug("Associating ip " + ipToAssoc + " to network " + network); + s_logger.debug("Associating ip " + ipToAssoc + " to network " + network); IPAddressVO ip = _ipAddressDao.findById(ipId); //update ip address with networkId @@ -1247,16 +1249,16 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage try { success = applyIpAssociations(network, false); if (success) { - logger.debug("Successfully associated ip address " + ip.getAddress().addr() + " to network " + network); + s_logger.debug("Successfully associated ip address " + ip.getAddress().addr() + " to network " + network); } else { - logger.warn("Failed to associate ip address " + ip.getAddress().addr() + " to network " + network); + s_logger.warn("Failed to associate ip address " + ip.getAddress().addr() + " to network " + network); } return ip; } finally { if (!success && releaseOnFailure) { if (ip != null) { try { - logger.warn("Failed to associate ip address, so releasing ip from the database " + ip); + s_logger.warn("Failed to associate ip address, so releasing ip from the database " + ip); _ipAddressDao.markAsUnavailable(ip.getId()); if (!applyIpAssociations(network, true)) { // if fail to apply ip assciations again, unassign ip address without updating resource @@ -1264,7 +1266,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage _ipAddressDao.unassignIpAddress(ip.getId()); } } catch (Exception e) { - logger.warn("Unable to disassociate ip address for recovery", e); + s_logger.warn("Unable to disassociate ip address for recovery", e); } } } @@ -1326,7 +1328,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage } owner = _accountMgr.getAccount(ipToAssoc.getAllocatedToAccountId()); } else { - logger.debug("Unable to find ip address by id: " + ipId); + s_logger.debug("Unable to find ip address by id: " + ipId); return null; } @@ -1361,9 +1363,9 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage try { boolean success = applyIpAssociations(network, false); if (success) { - logger.debug("Successfully associated ip address " + ip.getAddress().addr() + " to network " + network); + s_logger.debug("Successfully associated ip address " + ip.getAddress().addr() + " to network " + network); } else { - logger.warn("Failed to associate ip address " + ip.getAddress().addr() + " to network " + network); + s_logger.warn("Failed to associate ip address " + ip.getAddress().addr() + " to network " + network); } return ip; } finally { @@ -1524,12 +1526,12 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage + requiredOfferings.get(0).getTags()); } - logger.debug("Creating network for account " + owner + " from the network offering id=" + requiredOfferings.get(0).getId() + s_logger.debug("Creating network for account " + owner + " from the network offering id=" + requiredOfferings.get(0).getId() + " as a part of createVlanIpRange process"); guestNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null, null, null, owner, null, physicalNetwork, zoneId, ACLType.Account, null, null, null, null, true, null); if (guestNetwork == null) { - logger.warn("Failed to create default Virtual network for the account " + accountId + "in zone " + zoneId); + s_logger.warn("Failed to create default Virtual network for the account " + accountId + "in zone " + zoneId); throw new CloudRuntimeException("Failed to create a Guest Isolated Networks with SourceNAT " + "service enabled as a part of createVlanIpRange, for the account " + accountId + "in zone " + zoneId); } @@ -1586,19 +1588,19 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage DeployDestination dest = new DeployDestination(zone, null, null, null); Account callerAccount = CallContext.current().getCallingAccount(); UserVO callerUser = _userDao.findById(CallContext.current().getCallingUserId()); - Journal journal = new Journal.LogJournal("Implementing " + guestNetwork, logger); + Journal journal = new Journal.LogJournal("Implementing " + guestNetwork, s_logger); ReservationContext context = new ReservationContextImpl(UUID.randomUUID().toString(), journal, callerUser, callerAccount); - logger.debug("Implementing network " + guestNetwork + " as a part of network provision for persistent network"); + s_logger.debug("Implementing network " + guestNetwork + " as a part of network provision for persistent network"); try { Pair<? extends NetworkGuru, ? extends Network> implementedNetwork = _networkMgr.implementNetwork(guestNetwork.getId(), dest, context); if (implementedNetwork == null || implementedNetwork.first() == null) { - logger.warn("Failed to implement the network " + guestNetwork); + s_logger.warn("Failed to implement the network " + guestNetwork); } if (implementedNetwork != null) { guestNetwork = implementedNetwork.second(); } } catch (Exception ex) { - logger.warn("Failed to implement network " + guestNetwork + " elements and resources as a part of" + " network provision due to ", ex); + s_logger.warn("Failed to implement network " + guestNetwork + " elements and resources as a part of" + " network provision due to ", ex); CloudRuntimeException e = new CloudRuntimeException("Failed to implement network (with specified id)" + " elements and resources as a part of network provision for persistent network"); e.addProxyObject(guestNetwork.getUuid(), "networkId"); @@ -1614,7 +1616,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage final IPAddressVO ip = _ipAddressDao.findById(addrId); if (ip.getAllocatedToAccountId() == null && ip.getAllocatedTime() == null) { - logger.trace("Ip address id=" + addrId + " is already released"); + s_logger.trace("Ip address id=" + addrId + " is already released"); return ip; } @@ -1655,14 +1657,14 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage @DB public String acquireGuestIpAddress(Network network, String requestedIp) { if (requestedIp != null && requestedIp.equals(network.getGateway())) { - logger.warn("Requested ip address " + requestedIp + " is used as a gateway address in network " + network); + s_logger.warn("Requested ip address " + requestedIp + " is used as a gateway address in network " + network); return null; } Set<Long> availableIps = _networkModel.getAvailableIps(network, requestedIp); if (availableIps == null || availableIps.isEmpty()) { - logger.debug("There are no free ips in the network " + network); + s_logger.debug("There are no free ips in the network " + network); return null; } @@ -1673,10 +1675,10 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage String[] cidr = network.getCidr().split("/"); boolean isSameCidr = NetUtils.sameSubnetCIDR(requestedIp, NetUtils.long2Ip(array[0]), Integer.parseInt(cidr[1])); if (!isSameCidr) { - logger.warn("Requested ip address " + requestedIp + " doesn't belong to the network " + network + " cidr"); + s_logger.warn("Requested ip address " + requestedIp + " doesn't belong to the network " + network + " cidr"); return null; } else if (NetUtils.IsIpEqualToNetworkOrBroadCastIp(requestedIp, cidr[0], Integer.parseInt(cidr[1]))) { - logger.warn("Requested ip address " + requestedIp + " is equal to the to the network/broadcast ip of the network" + network); + s_logger.warn("Requested ip address " + requestedIp + " is equal to the to the network/broadcast ip of the network" + network); return null; } return requestedIp; @@ -1694,7 +1696,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage @Override public boolean applyStaticNats(List<? extends StaticNat> staticNats, boolean continueOnError, boolean forRevoke) throws ResourceUnavailableException { if (staticNats == null || staticNats.size() == 0) { - logger.debug("There are no static nat rules for the network elements"); + s_logger.debug("There are no static nat rules for the network elements"); return true; } @@ -1703,7 +1705,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage // Check if the StaticNat service is supported if (!_networkModel.areServicesSupportedInNetwork(network.getId(), Service.StaticNat)) { - logger.debug("StaticNat service is not supported in specified network id"); + s_logger.debug("StaticNat service is not supported in specified network id"); return true; } @@ -1731,7 +1733,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage if (!continueOnError) { throw e; } - logger.warn("Problems with " + element.getName() + " but pushing on", e); + s_logger.warn("Problems with " + element.getName() + " but pushing on", e); success = false; } @@ -1792,7 +1794,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage if ((off.getElasticLb() && forElasticLb) || (off.getElasticIp() && forElasticIp)) { try { - logger.debug("Allocating system IP address for load balancer rule..."); + s_logger.debug("Allocating system IP address for load balancer rule..."); // allocate ip ip = allocateIP(owner, true, guestNetwork.getDataCenterId()); // apply ip associations @@ -1822,10 +1824,10 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage if (ip.getSystem()) { CallContext ctx = CallContext.current(); if (!disassociatePublicIpAddress(ip.getId(), ctx.getCallingUserId(), ctx.getCallingAccount())) { - logger.warn("Unable to release system ip address id=" + ip.getId()); + s_logger.warn("Unable to release system ip address id=" + ip.getId()); success = false; } else { - logger.warn("Successfully released system ip address id=" + ip.getId()); + s_logger.warn("Successfully released system ip address id=" + ip.getId()); } } } @@ -1853,7 +1855,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage if (placeholderNic != null) { IPAddressVO userIp = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(), placeholderNic.getIPv4Address()); ip = PublicIp.createFromAddrAndVlan(userIp, _vlanDao.findById(userIp.getVlanId())); - logger.debug("Nic got an ip address " + placeholderNic.getIPv4Address() + " stored in placeholder nic for the network " + network); + s_logger.debug("Nic got an ip address " + placeholderNic.getIPv4Address() + " stored in placeholder nic for the network " + network); } } @@ -1926,7 +1928,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage //Get ip address from the placeholder and don't allocate a new one if (requestedIpv4 != null && vm.getType() == VirtualMachine.Type.DomainRouter) { - logger.debug("There won't be nic assignment for VR id " + vm.getId() +" in this network " + network); + s_logger.debug("There won't be nic assignment for VR id " + vm.getId() +" in this network " + network); } @@ -1993,7 +1995,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage public String allocatePublicIpForGuestNic(Network network, Long podId, Account owner, String requestedIp) throws InsufficientAddressCapacityException { PublicIp ip = assignPublicIpAddress(network.getDataCenterId(), podId, owner, VlanType.DirectAttached, network.getId(), requestedIp, false); if (ip == null) { - logger.debug("There is no free public ip address"); + s_logger.debug("There is no free public ip address"); return null; } Ip ipAddr = ip.getAddress();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/Ipv6AddressManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/Ipv6AddressManagerImpl.java b/server/src/com/cloud/network/Ipv6AddressManagerImpl.java index 0655da7..d8a9d68 100644 --- a/server/src/com/cloud/network/Ipv6AddressManagerImpl.java +++ b/server/src/com/cloud/network/Ipv6AddressManagerImpl.java @@ -24,6 +24,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; @@ -45,6 +46,7 @@ import com.cloud.utils.net.NetUtils; @Local(value = {Ipv6AddressManager.class}) public class Ipv6AddressManagerImpl extends ManagerBase implements Ipv6AddressManager { + public static final Logger s_logger = Logger.getLogger(Ipv6AddressManagerImpl.class.getName()); String _name = null; int _ipv6RetryMax = 0; @@ -78,7 +80,7 @@ public class Ipv6AddressManagerImpl extends ManagerBase implements Ipv6AddressMa } List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(networkId); if (vlans == null) { - logger.debug("Cannot find related vlan attached to network " + networkId); + s_logger.debug("Cannot find related vlan attached to network " + networkId); return null; } String ip = null; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/NetworkModelImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/NetworkModelImpl.java b/server/src/com/cloud/network/NetworkModelImpl.java index 39c7f0c..154e666 100644 --- a/server/src/com/cloud/network/NetworkModelImpl.java +++ b/server/src/com/cloud/network/NetworkModelImpl.java @@ -38,6 +38,7 @@ import org.apache.cloudstack.acl.ControlledEntity.ACLType; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDao; import org.apache.commons.codec.binary.Base64; +import org.apache.log4j.Logger; import com.cloud.api.ApiDBUtils; import com.cloud.configuration.Config; @@ -126,6 +127,7 @@ import com.cloud.vm.dao.VMInstanceDao; @Local(value = {NetworkModel.class}) public class NetworkModelImpl extends ManagerBase implements NetworkModel { + static final Logger s_logger = Logger.getLogger(NetworkModelImpl.class); @Inject EntityManager _entityMgr; @Inject @@ -337,7 +339,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { // no active rules/revoked rules are associated with this public IP, so remove the // association with the provider if (ip.isSourceNat()) { - logger.debug("Not releasing ip " + ip.getAddress().addr() + " as it is in use for SourceNat"); + s_logger.debug("Not releasing ip " + ip.getAddress().addr() + " as it is in use for SourceNat"); } else { ip.setState(State.Releasing); } @@ -592,7 +594,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { } } else { if (network.getCidr() == null) { - logger.debug("Network - " + network.getId() + " has NULL CIDR."); + s_logger.debug("Network - " + network.getId() + " has NULL CIDR."); return false; } hasFreeIps = (getAvailableIps(network, null)).size() > 0; @@ -764,7 +766,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { } } if (ret_network == null) { - logger.debug("Can not find network with security group enabled with free IPs"); + s_logger.debug("Can not find network with security group enabled with free IPs"); } return ret_network; } @@ -777,7 +779,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { } if (networks.size() > 1) { - logger.debug("There are multiple network with security group enabled? select one of them..."); + s_logger.debug("There are multiple network with security group enabled? select one of them..."); } return networks.get(0); } @@ -871,12 +873,12 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { } } } else { - logger.debug("Unable to find default network for the vm; vm doesn't have any nics"); + s_logger.debug("Unable to find default network for the vm; vm doesn't have any nics"); return null; } if (defaultNic == null) { - logger.debug("Unable to find default network for the vm; vm doesn't have default nic"); + s_logger.debug("Unable to find default network for the vm; vm doesn't have default nic"); } return defaultNic; @@ -888,7 +890,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { String userDataProvider = _ntwkSrvcDao.getProviderForServiceInNetwork(network.getId(), Service.UserData); if (userDataProvider == null) { - logger.debug("Network " + network + " doesn't support service " + Service.UserData.getName()); + s_logger.debug("Network " + network + " doesn't support service " + Service.UserData.getName()); return null; } @@ -930,7 +932,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { List<NetworkVO> virtualNetworks = _networksDao.listByZoneAndGuestType(accountId, dataCenterId, Network.GuestType.Isolated, false); if (virtualNetworks.isEmpty()) { - logger.trace("Unable to find default Virtual network account id=" + accountId); + s_logger.trace("Unable to find default Virtual network account id=" + accountId); return null; } @@ -941,7 +943,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { if (networkElementNic != null) { return networkElementNic.getIPv4Address(); } else { - logger.warn("Unable to set find network element for the network id=" + virtualNetwork.getId()); + s_logger.warn("Unable to set find network element for the network id=" + virtualNetwork.getId()); return null; } } @@ -1148,7 +1150,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { Long pNtwkId = null; for (PhysicalNetwork pNtwk : pNtwks) { if (pNtwk.getTags().contains(tag)) { - logger.debug("Found physical network id=" + pNtwk.getId() + " based on requested tags " + tag); + s_logger.debug("Found physical network id=" + pNtwk.getId() + " based on requested tags " + tag); pNtwkId = pNtwk.getId(); break; } @@ -1185,7 +1187,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { @Override public boolean isSecurityGroupSupportedInNetwork(Network network) { if (network.getTrafficType() != TrafficType.Guest) { - logger.trace("Security group can be enabled for Guest networks only; and network " + network + " has a diff traffic type"); + s_logger.trace("Security group can be enabled for Guest networks only; and network " + network + " has a diff traffic type"); return false; } @@ -1253,8 +1255,8 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { return label; } } catch (Exception ex) { - if (logger.isDebugEnabled()) { - logger.debug("Failed to retrive the default label for management traffic:" + "zone: " + zoneId + " hypervisor: " + hypervisorType + " due to:" + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Failed to retrive the default label for management traffic:" + "zone: " + zoneId + " hypervisor: " + hypervisorType + " due to:" + ex.getMessage()); } } @@ -1288,8 +1290,8 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { return label; } } catch (Exception ex) { - if (logger.isDebugEnabled()) { - logger.debug("Failed to retrive the default label for storage traffic:" + "zone: " + zoneId + " hypervisor: " + hypervisorType + " due to:" + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Failed to retrive the default label for storage traffic:" + "zone: " + zoneId + " hypervisor: " + hypervisorType + " due to:" + ex.getMessage()); } } @@ -1326,7 +1328,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { public boolean isProviderEnabledInPhysicalNetwork(long physicalNetowrkId, String providerName) { PhysicalNetworkServiceProviderVO ntwkSvcProvider = _pNSPDao.findByServiceProvider(physicalNetowrkId, providerName); if (ntwkSvcProvider == null) { - logger.warn("Unable to find provider " + providerName + " in physical network id=" + physicalNetowrkId); + s_logger.warn("Unable to find provider " + providerName + " in physical network id=" + physicalNetowrkId); return false; } return isProviderEnabled(ntwkSvcProvider); @@ -1368,7 +1370,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { if (physicalNetworkId == null) { assert (false) : "Can't get the physical network"; - logger.warn("Can't get the physical network"); + s_logger.warn("Can't get the physical network"); return null; } @@ -1655,8 +1657,8 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { return label; } } catch (Exception ex) { - if (logger.isDebugEnabled()) { - logger.debug("Failed to retrieve the default label for public traffic." + "zone: " + dcId + " hypervisor: " + hypervisorType + " due to: " + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Failed to retrieve the default label for public traffic." + "zone: " + dcId + " hypervisor: " + hypervisorType + " due to: " + ex.getMessage()); } } @@ -1690,8 +1692,8 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { return label; } } catch (Exception ex) { - if (logger.isDebugEnabled()) { - logger.debug("Failed to retrive the default label for management traffic:" + "zone: " + dcId + " hypervisor: " + hypervisorType + " due to:" + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Failed to retrive the default label for management traffic:" + "zone: " + dcId + " hypervisor: " + hypervisorType + " due to:" + ex.getMessage()); } } @@ -1764,13 +1766,13 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { Long networkDomainId = null; Network network = getNetwork(networkId); if (network.getGuestType() != Network.GuestType.Shared) { - logger.trace("Network id=" + networkId + " is not shared"); + s_logger.trace("Network id=" + networkId + " is not shared"); return false; } NetworkDomainVO networkDomainMap = _networkDomainDao.getDomainNetworkMapByNetworkId(networkId); if (networkDomainMap == null) { - logger.trace("Network id=" + networkId + " is shared, but not domain specific"); + s_logger.trace("Network id=" + networkId + " is shared, but not domain specific"); return true; } else { networkDomainId = networkDomainMap.getDomainId(); @@ -1799,7 +1801,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { for (String ip : ips) { if (requestedIp != null && requestedIp.equals(ip)) { - logger.warn("Requested ip address " + requestedIp + " is already in use in network" + network); + s_logger.warn("Requested ip address " + requestedIp + " is already in use in network" + network); return null; } @@ -1857,14 +1859,14 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { boolean isServiceEnabledInNetwork(long physicalNetworkId, long networkId, Service service) { // check if the service is supported in the network if (!areServicesSupportedInNetwork(networkId, service)) { - logger.debug("Service " + service.getName() + " is not supported in the network id=" + networkId); + s_logger.debug("Service " + service.getName() + " is not supported in the network id=" + networkId); return false; } // get provider for the service and check if all of them are supported String provider = _ntwkSrvcDao.getProviderForServiceInNetwork(networkId, service); if (!isProviderEnabledInPhysicalNetwork(physicalNetworkId, provider)) { - logger.debug("Provider " + provider + " is not enabled in physical network id=" + physicalNetworkId); + s_logger.debug("Provider " + provider + " is not enabled in physical network id=" + physicalNetworkId); return false; } @@ -1888,7 +1890,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { } if (networkList.size() > 1) { - logger.info("More than one physical networks exist in zone id=" + zoneId + " with traffic type=" + trafficType + ". "); + s_logger.info("More than one physical networks exist in zone id=" + zoneId + " with traffic type=" + trafficType + ". "); } return networkList.get(0); @@ -2035,7 +2037,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { networkSearch.and("traffictype", networkSearch.entity().getTrafficType(), Op.EQ); NicForTrafficTypeSearch.done(); - logger.info("Network Model is configured."); + s_logger.info("Network Model is configured."); return true; } @@ -2049,11 +2051,11 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { Provider implementedProvider = element.getProvider(); if (implementedProvider != null) { if (s_providerToNetworkElementMap.containsKey(implementedProvider.getName())) { - logger.error("Cannot start NetworkModel: Provider <-> NetworkElement must be a one-to-one map, " + "multiple NetworkElements found for Provider: " + + s_logger.error("Cannot start NetworkModel: Provider <-> NetworkElement must be a one-to-one map, " + "multiple NetworkElements found for Provider: " + implementedProvider.getName()); continue; } - logger.info("Add provider <-> element map entry. " + implementedProvider.getName() + "-" + element.getName() + "-" + element.getClass().getSimpleName()); + s_logger.info("Add provider <-> element map entry. " + implementedProvider.getName() + "-" + element.getName() + "-" + element.getClass().getSimpleName()); s_providerToNetworkElementMap.put(implementedProvider.getName(), element.getName()); } if (capabilities != null && implementedProvider != null) { @@ -2069,7 +2071,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { } } } - logger.info("Started Network Model"); + s_logger.info("Started Network Model"); return true; } @@ -2263,7 +2265,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { //if the network has vms in Starting state (nics for those might not be allocated yet as Starting state also used when vm is being Created) //don't GC if (_nicDao.countNicsForStartingVms(networkId) > 0) { - logger.debug("Network id=" + networkId + " is not ready for GC as it has vms that are Starting at the moment"); + s_logger.debug("Network id=" + networkId + " is not ready for GC as it has vms that are Starting at the moment"); return false; } @@ -2316,7 +2318,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel { try { md5 = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { - logger.error("Unexpected exception " + e.getMessage(), e); + s_logger.error("Unexpected exception " + e.getMessage(), e); throw new CloudRuntimeException("Unable to get MD5 MessageDigest", e); } md5.reset(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/NetworkServiceImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java index d5ee63f..abee178 100644 --- a/server/src/com/cloud/network/NetworkServiceImpl.java +++ b/server/src/com/cloud/network/NetworkServiceImpl.java @@ -57,6 +57,7 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.framework.messagebus.MessageBus; import org.apache.cloudstack.framework.messagebus.PublishScope; import org.apache.cloudstack.network.element.InternalLoadBalancerElementService; +import org.apache.log4j.Logger; import com.cloud.api.ApiDBUtils; import com.cloud.configuration.Config; @@ -198,6 +199,7 @@ import com.cloud.vm.dao.VMInstanceDao; */ @Local(value = {NetworkService.class}) public class NetworkServiceImpl extends ManagerBase implements NetworkService { + private static final Logger s_logger = Logger.getLogger(NetworkServiceImpl.class); private static final long MIN_VLAN_ID = 0L; private static final long MAX_VLAN_ID = 4095L; // 2^12 - 1 @@ -552,8 +554,8 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { if (zone.getNetworkType() == NetworkType.Advanced) { if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) { _accountMgr.checkAccess(caller, AccessType.UseEntry, false, network); - if (logger.isDebugEnabled()) { - logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId()); } return _ipAddrMgr.allocateIp(ipOwner, false, caller, callerUserId, zone, displayIp); } else { @@ -595,8 +597,8 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { if (zone.getNetworkType() == NetworkType.Advanced) { if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) { _accountMgr.checkAccess(caller, AccessType.UseEntry, false, network); - if (logger.isDebugEnabled()) { - logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId()); } return _ipAddrMgr.allocatePortableIp(ipOwner, caller, zoneId, networkId, null); } else { @@ -638,7 +640,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { _allowSubdomainNetworkAccess = Boolean.valueOf(_configs.get(Config.SubDomainNetworkAccess.key())); - logger.info("Network Service is configured."); + s_logger.info("Network Service is configured."); return true; } @@ -664,7 +666,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { if (isZoneSgEnabled) { success = _securityGroupService.securityGroupRulesForVmSecIp(secIp.getNicId(), secIp.getIp4Address(), true); - logger.info("Associated ip address to NIC : " + secIp.getIp4Address()); + s_logger.info("Associated ip address to NIC : " + secIp.getIp4Address()); } else { success = true; } @@ -706,12 +708,12 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { int maxAllowedIpsPerNic = NumbersUtil.parseInt(_configDao.getValue(Config.MaxNumberOfSecondaryIPsPerNIC.key()), 10); Long nicWiseIpCount = _nicSecondaryIpDao.countByNicId(nicId); if(nicWiseIpCount.intValue() >= maxAllowedIpsPerNic) { - logger.error("Maximum Number of Ips \"vm.network.nic.max.secondary.ipaddresses = \"" + maxAllowedIpsPerNic + " per Nic has been crossed for the nic " + nicId + "."); + s_logger.error("Maximum Number of Ips \"vm.network.nic.max.secondary.ipaddresses = \"" + maxAllowedIpsPerNic + " per Nic has been crossed for the nic " + nicId + "."); throw new InsufficientAddressCapacityException("Maximum Number of Ips per Nic has been crossed.", Nic.class, nicId); } - logger.debug("Calling the ip allocation ..."); + s_logger.debug("Calling the ip allocation ..."); String ipaddr = null; //Isolated network can exist in Basic zone only, so no need to verify the zone type if (network.getGuestType() == Network.GuestType.Isolated) { @@ -739,11 +741,11 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { throw new InvalidParameterValueException("Allocating ip to guest nic " + nicId + " failed"); } } catch (InsufficientAddressCapacityException e) { - logger.error("Allocating ip to guest nic " + nicId + " failed"); + s_logger.error("Allocating ip to guest nic " + nicId + " failed"); return null; } } else { - logger.error("AddIpToVMNic is not supported in this network..."); + s_logger.error("AddIpToVMNic is not supported in this network..."); return null; } @@ -757,11 +759,11 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { if (!nicSecondaryIpSet) { nicVO.setSecondaryIp(true); // commit when previously set ?? - logger.debug("Setting nics table ..."); + s_logger.debug("Setting nics table ..."); _nicDao.update(nicId, nicVO); } - logger.debug("Setting nic_secondary_ip table ..."); + s_logger.debug("Setting nic_secondary_ip table ..."); Long vmId = nicVO.getInstanceId(); NicSecondaryIpVO secondaryIpVO = new NicSecondaryIpVO(nicId, addrFinal, vmId, ipOwner.getId(), ipOwner.getDomainId(), networkId); _nicSecondaryIpDao.persist(secondaryIpVO); @@ -806,7 +808,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(network.getNetworkOfferingId()); Long nicId = secIpVO.getNicId(); - logger.debug("ip id = " + ipAddressId + " nic id = " + nicId); + s_logger.debug("ip id = " + ipAddressId + " nic id = " + nicId); //check is this the last secondary ip for NIC List<NicSecondaryIpVO> ipList = _nicSecondaryIpDao.listByNicId(nicId); boolean lastIp = false; @@ -820,7 +822,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { throw new InvalidParameterValueException("Invalid zone Id is given"); } - logger.debug("Calling secondary ip " + secIpVO.getIp4Address() + " release "); + s_logger.debug("Calling secondary ip " + secIpVO.getIp4Address() + " release "); if (dc.getNetworkType() == NetworkType.Advanced && network.getGuestType() == Network.GuestType.Isolated) { //check PF or static NAT is configured on this ip address String secondaryIp = secIpVO.getIp4Address(); @@ -829,7 +831,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { if (fwRulesList.size() != 0) { for (FirewallRuleVO rule : fwRulesList) { if (_portForwardingDao.findByIdAndIp(rule.getId(), secondaryIp) != null) { - logger.debug("VM nic IP " + secondaryIp + " is associated with the port forwarding rule"); + s_logger.debug("VM nic IP " + secondaryIp + " is associated with the port forwarding rule"); throw new InvalidParameterValueException("Can't remove the secondary ip " + secondaryIp + " is associate with the port forwarding rule"); } } @@ -837,12 +839,12 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { //check if the secondary ip associated with any static nat rule IPAddressVO publicIpVO = _ipAddressDao.findByVmIp(secondaryIp); if (publicIpVO != null) { - logger.debug("VM nic IP " + secondaryIp + " is associated with the static NAT rule public IP address id " + publicIpVO.getId()); + s_logger.debug("VM nic IP " + secondaryIp + " is associated with the static NAT rule public IP address id " + publicIpVO.getId()); throw new InvalidParameterValueException("Can' remove the ip " + secondaryIp + "is associate with static NAT rule public IP address id " + publicIpVO.getId()); } if (_lbService.isLbRuleMappedToVmGuestIp(secondaryIp)) { - logger.debug("VM nic IP " + secondaryIp + " is mapped to load balancing rule"); + s_logger.debug("VM nic IP " + secondaryIp + " is mapped to load balancing rule"); throw new InvalidParameterValueException("Can't remove the secondary ip " + secondaryIp + " is mapped to load balancing rule"); } @@ -874,11 +876,11 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { public void doInTransactionWithoutResult(TransactionStatus status) { if (lastIp) { nic.setSecondaryIp(false); - logger.debug("Setting nics secondary ip to false ..."); + s_logger.debug("Setting nics secondary ip to false ..."); _nicDao.update(nicId, nic); } - logger.debug("Revoving nic secondary ip entry ..."); + s_logger.debug("Revoving nic secondary ip entry ..."); _nicSecondaryIpDao.remove(ipVO.getId()); } }); @@ -912,7 +914,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { } if (ipVO.getAllocatedTime() == null) { - logger.debug("Ip Address id= " + ipAddressId + " is not allocated, so do nothing."); + s_logger.debug("Ip Address id= " + ipAddressId + " is not allocated, so do nothing."); return true; } @@ -951,7 +953,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { } } } else { - logger.warn("Failed to release public ip address id=" + ipAddressId); + s_logger.warn("Failed to release public ip address id=" + ipAddressId); } return success; } @@ -1171,7 +1173,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { ipv4 = true; } } catch (UnknownHostException e) { - logger.error("Unable to convert gateway IP to a InetAddress", e); + s_logger.error("Unable to convert gateway IP to a InetAddress", e); throw new InvalidParameterValueException("Gateway parameter is invalid"); } } @@ -1305,21 +1307,21 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { if (ntwkOff.getIsPersistent()) { try { if (network.getState() == Network.State.Setup) { - logger.debug("Network id=" + network.getId() + " is already provisioned"); + s_logger.debug("Network id=" + network.getId() + " is already provisioned"); return network; } DeployDestination dest = new DeployDestination(zone, null, null, null); UserVO callerUser = _userDao.findById(CallContext.current().getCallingUserId()); - Journal journal = new Journal.LogJournal("Implementing " + network, logger); + Journal journal = new Journal.LogJournal("Implementing " + network, s_logger); ReservationContext context = new ReservationContextImpl(UUID.randomUUID().toString(), journal, callerUser, caller); - logger.debug("Implementing network " + network + " as a part of network provision for persistent network"); + s_logger.debug("Implementing network " + network + " as a part of network provision for persistent network"); Pair<? extends NetworkGuru, ? extends Network> implementedNetwork = _networkMgr.implementNetwork(network.getId(), dest, context); if (implementedNetwork == null || implementedNetwork.first() == null) { - logger.warn("Failed to provision the network " + network); + s_logger.warn("Failed to provision the network " + network); } network = implementedNetwork.second(); } catch (ResourceUnavailableException ex) { - logger.warn("Failed to implement persistent guest network " + network + "due to ", ex); + s_logger.warn("Failed to implement persistent guest network " + network + "due to ", ex); CloudRuntimeException e = new CloudRuntimeException("Failed to implement persistent guest network"); e.addProxyObject(network.getUuid(), "networkId"); throw e; @@ -1889,9 +1891,9 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { boolean success = _networkMgr.restartNetwork(networkId, callerAccount, callerUser, cleanup); if (success) { - logger.debug("Network id=" + networkId + " is restarted successfully."); + s_logger.debug("Network id=" + networkId + " is restarted successfully."); } else { - logger.warn("Network id=" + networkId + " failed to restart."); + s_logger.warn("Network id=" + networkId + " failed to restart."); } return success; @@ -2176,11 +2178,11 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { List<NicVO> nicsPresent = _nicDao.listByNetworkId(networkId); String cidrIpRange[] = NetUtils.getIpRangeFromCidr(guestVmCidrPair[0], size); - logger.info("The start IP of the specified guest vm cidr is: " + cidrIpRange[0] + " and end IP is: " + cidrIpRange[1]); + s_logger.info("The start IP of the specified guest vm cidr is: " + cidrIpRange[0] + " and end IP is: " + cidrIpRange[1]); long startIp = NetUtils.ip2Long(cidrIpRange[0]); long endIp = NetUtils.ip2Long(cidrIpRange[1]); long range = endIp - startIp + 1; - logger.info("The specified guest vm cidr has " + range + " IPs"); + s_logger.info("The specified guest vm cidr has " + range + " IPs"); for (NicVO nic : nicsPresent) { long nicIp = NetUtils.ip2Long(nic.getIPv4Address()); @@ -2216,14 +2218,14 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { // Condition for IP Reservation reset : guestVmCidr and network CIDR are same if (network.getNetworkCidr().equals(guestVmCidr)) { - logger.warn("Guest VM CIDR and Network CIDR both are same, reservation will reset."); + s_logger.warn("Guest VM CIDR and Network CIDR both are same, reservation will reset."); network.setNetworkCidr(null); } // Finally update "cidr" with the guestVmCidr // which becomes the effective address space for CloudStack guest VMs network.setCidr(guestVmCidr); _networksDao.update(networkId, network); - logger.info("IP Reservation has been applied. The new CIDR for Guests Vms is " + guestVmCidr); + s_logger.info("IP Reservation has been applied. The new CIDR for Guests Vms is " + guestVmCidr); } ReservationContext context = new ReservationContextImpl(null, null, callerUser, callerAccount); @@ -2233,21 +2235,21 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { if (restartNetwork) { if (validStateToShutdown) { if (!changeCidr) { - logger.debug("Shutting down elements and resources for network id=" + networkId + " as a part of network update"); + s_logger.debug("Shutting down elements and resources for network id=" + networkId + " as a part of network update"); if (!_networkMgr.shutdownNetworkElementsAndResources(context, true, network)) { - logger.warn("Failed to shutdown the network elements and resources as a part of network restart: " + network); + s_logger.warn("Failed to shutdown the network elements and resources as a part of network restart: " + network); CloudRuntimeException ex = new CloudRuntimeException("Failed to shutdown the network elements and resources as a part of update to network of specified id"); ex.addProxyObject(network.getUuid(), "networkId"); throw ex; } } else { // We need to shutdown the network, since we want to re-implement the network. - logger.debug("Shutting down network id=" + networkId + " as a part of network update"); + s_logger.debug("Shutting down network id=" + networkId + " as a part of network update"); //check if network has reservation if (NetUtils.isNetworkAWithinNetworkB(network.getCidr(), network.getNetworkCidr())) { - logger.warn("Existing IP reservation will become ineffective for the network with id = " + networkId + s_logger.warn("Existing IP reservation will become ineffective for the network with id = " + networkId + " You need to reapply reservation after network reimplementation."); //set cidr to the newtork cidr network.setCidr(network.getNetworkCidr()); @@ -2256,7 +2258,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { } if (!_networkMgr.shutdownNetwork(network.getId(), context, true)) { - logger.warn("Failed to shutdown the network as a part of update to network with specified id"); + s_logger.warn("Failed to shutdown the network as a part of update to network with specified id"); CloudRuntimeException ex = new CloudRuntimeException("Failed to shutdown the network as a part of update of specified network id"); ex.addProxyObject(network.getUuid(), "networkId"); throw ex; @@ -2296,7 +2298,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { long vmId = nic.getInstanceId(); VMInstanceVO vm = _vmDao.findById(vmId); if (vm == null) { - logger.error("Vm for nic " + nic.getId() + " not found with Vm Id:" + vmId); + s_logger.error("Vm for nic " + nic.getId() + " not found with Vm Id:" + vmId); continue; } long isDefault = (nic.isDefaultNic()) ? 1 : 0; @@ -2321,7 +2323,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { if (restartNetwork) { if (network.getState() != Network.State.Allocated) { DeployDestination dest = new DeployDestination(_dcDao.findById(network.getDataCenterId()), null, null, null); - logger.debug("Implementing the network " + network + " elements and resources as a part of network update"); + s_logger.debug("Implementing the network " + network + " elements and resources as a part of network update"); try { if (!changeCidr) { _networkMgr.implementNetworkElementsAndResources(dest, context, network, _networkOfferingDao.findById(network.getNetworkOfferingId())); @@ -2329,7 +2331,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { _networkMgr.implementNetwork(network.getId(), dest, context); } } catch (Exception ex) { - logger.warn("Failed to implement network " + network + " elements and resources as a part of network update due to ", ex); + s_logger.warn("Failed to implement network " + network + " elements and resources as a part of network update due to ", ex); CloudRuntimeException e = new CloudRuntimeException("Failed to implement network (with specified id) elements and resources as a part of network update"); e.addProxyObject(network.getUuid(), "networkId"); throw e; @@ -2345,7 +2347,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { DeployDestination dest = new DeployDestination(_dcDao.findById(network.getDataCenterId()), null, null, null); _networkMgr.implementNetwork(network.getId(), dest, context); } catch (Exception ex) { - logger.warn("Failed to implement network " + network + " elements and resources as a part o" + "f network update due to ", ex); + s_logger.warn("Failed to implement network " + network + " elements and resources as a part o" + "f network update due to ", ex); CloudRuntimeException e = new CloudRuntimeException("Failed to implement network (with specified" + " id) elements and resources as a part of network update"); e.addProxyObject(network.getUuid(), "networkId"); throw e; @@ -2363,7 +2365,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { for (String ip : ips) { if (requestedIp != null && requestedIp.equals(ip)) { - logger.warn("Requested ip address " + requestedIp + " is already in use in network" + network); + s_logger.warn("Requested ip address " + requestedIp + " is already in use in network" + network); return null; } @@ -2389,44 +2391,44 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { // security group service should be the same if (areServicesSupportedByNetworkOffering(oldNetworkOfferingId, Service.SecurityGroup) != areServicesSupportedByNetworkOffering(newNetworkOfferingId, Service.SecurityGroup)) { - logger.debug("Offerings " + newNetworkOfferingId + " and " + oldNetworkOfferingId + " have different securityGroupProperty, can't upgrade"); + s_logger.debug("Offerings " + newNetworkOfferingId + " and " + oldNetworkOfferingId + " have different securityGroupProperty, can't upgrade"); return false; } // Type of the network should be the same if (oldNetworkOffering.getGuestType() != newNetworkOffering.getGuestType()) { - logger.debug("Network offerings " + newNetworkOfferingId + " and " + oldNetworkOfferingId + " are of different types, can't upgrade"); + s_logger.debug("Network offerings " + newNetworkOfferingId + " and " + oldNetworkOfferingId + " are of different types, can't upgrade"); return false; } // tags should be the same if (newNetworkOffering.getTags() != null) { if (oldNetworkOffering.getTags() == null) { - logger.debug("New network offering id=" + newNetworkOfferingId + " has tags and old network offering id=" + oldNetworkOfferingId + " doesn't, can't upgrade"); + s_logger.debug("New network offering id=" + newNetworkOfferingId + " has tags and old network offering id=" + oldNetworkOfferingId + " doesn't, can't upgrade"); return false; } if (!StringUtils.areTagsEqual(oldNetworkOffering.getTags(), newNetworkOffering.getTags())) { - logger.debug("Network offerings " + newNetworkOffering.getUuid() + " and " + oldNetworkOffering.getUuid() + " have different tags, can't upgrade"); + s_logger.debug("Network offerings " + newNetworkOffering.getUuid() + " and " + oldNetworkOffering.getUuid() + " have different tags, can't upgrade"); return false; } } // Traffic types should be the same if (oldNetworkOffering.getTrafficType() != newNetworkOffering.getTrafficType()) { - logger.debug("Network offerings " + newNetworkOfferingId + " and " + oldNetworkOfferingId + " have different traffic types, can't upgrade"); + s_logger.debug("Network offerings " + newNetworkOfferingId + " and " + oldNetworkOfferingId + " have different traffic types, can't upgrade"); return false; } // specify vlan should be the same if (oldNetworkOffering.getSpecifyVlan() != newNetworkOffering.getSpecifyVlan()) { - logger.debug("Network offerings " + newNetworkOfferingId + " and " + oldNetworkOfferingId + " have different values for specifyVlan, can't upgrade"); + s_logger.debug("Network offerings " + newNetworkOfferingId + " and " + oldNetworkOfferingId + " have different values for specifyVlan, can't upgrade"); return false; } // specify ipRanges should be the same if (oldNetworkOffering.getSpecifyIpRanges() != newNetworkOffering.getSpecifyIpRanges()) { - logger.debug("Network offerings " + newNetworkOfferingId + " and " + oldNetworkOfferingId + " have different values for specifyIpRangess, can't upgrade"); + s_logger.debug("Network offerings " + newNetworkOfferingId + " and " + oldNetworkOfferingId + " have different values for specifyIpRangess, can't upgrade"); return false; } @@ -2564,7 +2566,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { } }); } catch (Exception ex) { - logger.warn("Exception: ", ex); + s_logger.warn("Exception: ", ex); throw new CloudRuntimeException("Fail to create a physical network"); } } @@ -2701,13 +2703,13 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { @Override public void doInTransactionWithoutResult(TransactionStatus status) { if (addVnetsFinal != null) { - logger.debug("Adding vnet range " + addVnetsFinal.toString() + " for the physicalNetwork id= " + network.getId() + " and zone id=" + s_logger.debug("Adding vnet range " + addVnetsFinal.toString() + " for the physicalNetwork id= " + network.getId() + " and zone id=" + network.getDataCenterId() + " as a part of updatePhysicalNetwork call"); //add vnet takes a list of strings to be added. each string is a vnet. _dcDao.addVnet(network.getDataCenterId(), network.getId(), addVnetsFinal); } if (removeVnetsFinal != null) { - logger.debug("removing vnet range " + removeVnetsFinal.toString() + " for the physicalNetwork id= " + network.getId() + " and zone id=" + s_logger.debug("removing vnet range " + removeVnetsFinal.toString() + " for the physicalNetwork id= " + network.getId() + " and zone id=" + network.getDataCenterId() + " as a part of updatePhysicalNetwork call"); //deleteVnets takes a list of strings to be removed. each string is a vnet. _datacneterVnet.deleteVnets(TransactionLegacy.currentTxn(), network.getDataCenterId(), network.getId(), removeVnetsFinal); @@ -2734,7 +2736,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { // for GRE phynets allow up to 32bits // TODO: Not happy about this test. // What about guru-like objects for physical networs? - logger.debug("ISOLATION METHODS:" + network.getIsolationMethods()); + s_logger.debug("ISOLATION METHODS:" + network.getIsolationMethods()); // Java does not have unsigned types... if (network.getIsolationMethods().contains("GRE")) { minVnet = MIN_GRE_KEY; @@ -2745,12 +2747,12 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { // fail if zone already contains VNI, need to be unique per zone. // since adding a range adds each VNI to the database, need only check min/max for (String vnet : VnetRange) { - logger.debug("Looking to see if VNI " + vnet + " already exists on another network in zone " + network.getDataCenterId()); + s_logger.debug("Looking to see if VNI " + vnet + " already exists on another network in zone " + network.getDataCenterId()); List<DataCenterVnetVO> vnis = _datacneterVnet.findVnet(network.getDataCenterId(), vnet); if (vnis != null && !vnis.isEmpty()) { for (DataCenterVnetVO vni : vnis) { if (vni.getPhysicalNetworkId() != network.getId()) { - logger.debug("VNI " + vnet + " already exists on another network in zone, please specify a unique range"); + s_logger.debug("VNI " + vnet + " already exists on another network in zone, please specify a unique range"); throw new InvalidParameterValueException("VNI " + vnet + " already exists on another network in zone, please specify a unique range"); } } @@ -2774,7 +2776,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { StartVnet = Integer.parseInt(VnetRange[0]); EndVnet = Integer.parseInt(VnetRange[1]); } catch (NumberFormatException e) { - logger.warn("Unable to parse vnet range:", e); + s_logger.warn("Unable to parse vnet range:", e); throw new InvalidParameterValueException("Please provide valid vnet range. The vnet range should be a coma seperated list example 2001-2012,3000-3005." + rangeMessage); } @@ -2912,10 +2914,10 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { try { deleteNetworkServiceProvider(provider.getId()); } catch (ResourceUnavailableException e) { - logger.warn("Unable to complete destroy of the physical network provider: " + provider.getProviderName() + ", id: " + provider.getId(), e); + s_logger.warn("Unable to complete destroy of the physical network provider: " + provider.getProviderName() + ", id: " + provider.getId(), e); return false; } catch (ConcurrentOperationException e) { - logger.warn("Unable to complete destroy of the physical network provider: " + provider.getProviderName() + ", id: " + provider.getId(), e); + s_logger.warn("Unable to complete destroy of the physical network provider: " + provider.getProviderName() + ", id: " + provider.getId(), e); return false; } } @@ -3053,7 +3055,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { startVlan = Integer.parseInt(vlanRange[0]); endVlan = Integer.parseInt(vlanRange[1]); } catch (NumberFormatException e) { - logger.warn("Unable to parse guest vlan range:", e); + s_logger.warn("Unable to parse guest vlan range:", e); throw new InvalidParameterValueException("Please provide valid guest vlan range"); } @@ -3167,7 +3169,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { tokens.add(startVlan); tokens.add(endVlan); } catch (NumberFormatException e) { - logger.warn("Unable to parse guest vlan range:", e); + s_logger.warn("Unable to parse guest vlan range:", e); throw new InvalidParameterValueException("Please provide valid guest vlan range"); } return tokens; @@ -3381,7 +3383,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { return nsp; } catch (Exception ex) { - logger.warn("Exception: ", ex); + s_logger.warn("Exception: ", ex); throw new CloudRuntimeException("Fail to add a provider to physical network"); } @@ -3437,8 +3439,8 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { boolean update = false; if (state != null) { - if (logger.isDebugEnabled()) { - logger.debug("trying to update the state of the service provider id=" + id + " on physical network: " + provider.getPhysicalNetworkId() + " to state: " + if (s_logger.isDebugEnabled()) { + s_logger.debug("trying to update the state of the service provider id=" + id + " on physical network: " + provider.getPhysicalNetworkId() + " to state: " + stateStr); } switch (state) { @@ -3506,8 +3508,8 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { Account callerAccount = _accountMgr.getActiveAccountById(callerUser.getAccountId()); // shutdown the provider instances ReservationContext context = new ReservationContextImpl(null, null, callerUser, callerAccount); - if (logger.isDebugEnabled()) { - logger.debug("Shutting down the service provider id=" + id + " on physical network: " + provider.getPhysicalNetworkId()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Shutting down the service provider id=" + id + " on physical network: " + provider.getPhysicalNetworkId()); } NetworkElement element = _networkModel.getElementImplementingProvider(provider.getProviderName()); if (element == null) { @@ -3564,7 +3566,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { Long pNtwkId = null; for (PhysicalNetwork pNtwk : pNtwks) { if (pNtwk.getTags().contains(tag)) { - logger.debug("Found physical network id=" + pNtwk.getId() + " based on requested tags " + tag); + s_logger.debug("Found physical network id=" + pNtwk.getId() + " based on requested tags " + tag); pNtwkId = pNtwk.getId(); break; } @@ -3646,7 +3648,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { // find row in networks table that is defined as 'Public', created when zone was deployed NetworkVO publicNetwork = _networksDao.listByZoneAndTrafficType(network.getDataCenterId(),TrafficType.Public).get(0); if (publicNetwork != null) { - logger.debug("setting public network " + publicNetwork + " to broadcast type vxlan"); + s_logger.debug("setting public network " + publicNetwork + " to broadcast type vxlan"); publicNetwork.setBroadcastDomainType(BroadcastDomainType.Vxlan); _networksDao.persist(publicNetwork); } @@ -3655,7 +3657,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { return pNetworktrafficType; } catch (Exception ex) { - logger.warn("Exception: ", ex); + s_logger.warn("Exception: ", ex); throw new CloudRuntimeException("Fail to add a traffic type to physical network"); } @@ -3809,7 +3811,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { } OvsProviderVO element = _ovsProviderDao.findByNspId(nsp.getId()); if (element != null) { - logger.debug("There is already a Ovs element with service provider id " + nsp.getId()); + s_logger.debug("There is already a Ovs element with service provider id " + nsp.getId()); return nsp; } element = new OvsProviderVO(nsp.getId()); @@ -4011,12 +4013,12 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { privateNetwork = _networkMgr.createGuestNetwork(ntwkOffFinal.getId(), networkName, displayText, gateway, cidr, uriString, null, owner, null, pNtwk, pNtwk.getDataCenterId(), ACLType.Account, null, vpcId, null, null, true, null); if (privateNetwork != null) { - logger.debug("Successfully created guest network " + privateNetwork); + s_logger.debug("Successfully created guest network " + privateNetwork); } else { throw new CloudRuntimeException("Creating guest network failed"); } } else { - logger.debug("Private network already exists: " + privateNetwork); + s_logger.debug("Private network already exists: " + privateNetwork); //Do not allow multiple private gateways with same Vlan within a VPC if (vpcId != null && vpcId.equals(privateNetwork.getVpcId())) { throw new InvalidParameterValueException("Private network for the vlan: " + uriString + " and cidr " + cidr + " already exists " + "for Vpc " + vpcId @@ -4038,7 +4040,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { _dcDao.update(dc.getId(), dc); } - logger.debug("Private network " + privateNetwork + " is created"); + s_logger.debug("Private network " + privateNetwork + " is created"); return privateNetwork; }
