Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F3199173FB for ; Mon, 31 Aug 2015 06:01:22 +0000 (UTC) Received: (qmail 82722 invoked by uid 500); 31 Aug 2015 06:01:22 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 82605 invoked by uid 500); 31 Aug 2015 06:01:22 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 81633 invoked by uid 99); 31 Aug 2015 06:01:22 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 31 Aug 2015 06:01:22 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 29169DFDD7; Mon, 31 Aug 2015 06:01:22 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rajani@apache.org To: commits@cloudstack.apache.org Date: Mon, 31 Aug 2015 06:01:29 -0000 Message-Id: <40c7bef1291b4f4ea5eef04ca2b1fbe8@git.apache.org> In-Reply-To: <4b5d4aebe7884558918f0bca0a790f64@git.apache.org> References: <4b5d4aebe7884558918f0bca0a790f64@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [09/35] git commit: updated refs/heads/master to 8bc0294 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java index dfa9b7d..a13ff21 100644 --- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java @@ -27,6 +27,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.agent.api.Answer; @@ -95,6 +96,7 @@ import com.cloud.vm.dao.VMInstanceDao; @Component @Local(value = { VpcVirtualNetworkApplianceManager.class, VpcVirtualNetworkApplianceService.class }) public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplianceManagerImpl implements VpcVirtualNetworkApplianceManager { + private static final Logger s_logger = Logger.getLogger(VpcVirtualNetworkApplianceManagerImpl.class); @Inject private NetworkACLManager _networkACLMgr; @@ -125,7 +127,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian public boolean addVpcRouterToGuestNetwork(final VirtualRouter router, final Network network, final Map params) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { if (network.getTrafficType() != TrafficType.Guest) { - logger.warn("Network " + network + " is not of type " + TrafficType.Guest); + s_logger.warn("Network " + network + " is not of type " + TrafficType.Guest); return false; } @@ -141,7 +143,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian if (guestNic != null) { result = setupVpcGuestNetwork(network, router, true, guestNic); } else { - logger.warn("Failed to add router " + router + " to guest network " + network); + s_logger.warn("Failed to add router " + router + " to guest network " + network); result = false; } // 3) apply networking rules @@ -149,18 +151,18 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian sendNetworkRulesToRouter(router.getId(), network.getId()); } } catch (final Exception ex) { - logger.warn("Failed to add router " + router + " to network " + network + " due to ", ex); + s_logger.warn("Failed to add router " + router + " to network " + network + " due to ", ex); result = false; } finally { if (!result) { - logger.debug("Removing the router " + router + " from network " + network + " as a part of cleanup"); + s_logger.debug("Removing the router " + router + " from network " + network + " as a part of cleanup"); if (removeVpcRouterFromGuestNetwork(router, network)) { - logger.debug("Removed the router " + router + " from network " + network + " as a part of cleanup"); + s_logger.debug("Removed the router " + router + " from network " + network + " as a part of cleanup"); } else { - logger.warn("Failed to remove the router " + router + " from network " + network + " as a part of cleanup"); + s_logger.warn("Failed to remove the router " + router + " from network " + network + " as a part of cleanup"); } } else { - logger.debug("Succesfully added router " + router + " to guest network " + network); + s_logger.debug("Succesfully added router " + router + " to guest network " + network); } } @@ -171,7 +173,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian public boolean removeVpcRouterFromGuestNetwork(final VirtualRouter router, final Network network) throws ConcurrentOperationException, ResourceUnavailableException { if (network.getTrafficType() != TrafficType.Guest) { - logger.warn("Network " + network + " is not of type " + TrafficType.Guest); + s_logger.warn("Network " + network + " is not of type " + TrafficType.Guest); return false; } @@ -179,13 +181,13 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian try { // Check if router is a part of the Guest network if (!_networkModel.isVmPartOfNetwork(router.getId(), network.getId())) { - logger.debug("Router " + router + " is not a part of the Guest network " + network); + s_logger.debug("Router " + router + " is not a part of the Guest network " + network); return result; } result = setupVpcGuestNetwork(network, router, false, _networkModel.getNicProfile(router, network.getId(), null)); if (!result) { - logger.warn("Failed to destroy guest network config " + network + " on router " + router); + s_logger.warn("Failed to destroy guest network config " + network + " on router " + router); return false; } @@ -213,15 +215,15 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian final Answer setupAnswer = cmds.getAnswer("setupguestnetwork"); final String setup = add ? "set" : "destroy"; if (!(setupAnswer != null && setupAnswer.getResult())) { - logger.warn("Unable to " + setup + " guest network on router " + router); + s_logger.warn("Unable to " + setup + " guest network on router " + router); result = false; } return result; } else if (router.getState() == State.Stopped || router.getState() == State.Stopping) { - logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() + ", so not sending setup guest network command to the backend"); + s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() + ", so not sending setup guest network command to the backend"); return true; } else { - logger.warn("Unable to setup guest network on virtual router " + router + " is not in the right state " + router.getState()); + s_logger.warn("Unable to setup guest network on virtual router " + router + " is not in the right state " + router.getState()); throw new ResourceUnavailableException("Unable to setup guest network on the backend," + " virtual router " + router + " is not in the right state", DataCenter.class, router.getDataCenterId()); } @@ -247,7 +249,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian defaultDns1 = nic.getIPv4Dns1(); defaultDns2 = nic.getIPv4Dns2(); } - logger.debug("Removing nic " + nic + " of type " + nic.getTrafficType() + " from the nics passed on vm start. " + "The nic will be plugged later"); + s_logger.debug("Removing nic " + nic + " of type " + nic.getTrafficType() + " from the nics passed on vm start. " + "The nic will be plugged later"); it.remove(); } } @@ -280,7 +282,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian // 1) FORM SSH CHECK COMMAND final NicProfile controlNic = getControlNic(profile); if (controlNic == null) { - logger.error("Control network doesn't exist for the router " + domainRouterVO); + s_logger.error("Control network doesn't exist for the router " + domainRouterVO); return false; } @@ -378,7 +380,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian if (privateGwAclId != null) { // set network acl on private gateway final List networkACLs = _networkACLItemDao.listByACL(privateGwAclId); - logger.debug("Found " + networkACLs.size() + " network ACLs to apply as a part of VPC VR " + domainRouterVO + " start for private gateway ip = " + s_logger.debug("Found " + networkACLs.size() + " network ACLs to apply as a part of VPC VR " + domainRouterVO + " start for private gateway ip = " + ipVO.getIpAddress()); _commandSetupHelper.createNetworkACLsCommands(networkACLs, domainRouterVO, cmds, ipVO.getNetworkId(), true); @@ -386,7 +388,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian } } } catch (final Exception ex) { - logger.warn("Failed to add router " + domainRouterVO + " to network due to exception ", ex); + s_logger.warn("Failed to add router " + domainRouterVO + " to network due to exception ", ex); return false; } @@ -403,7 +405,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian staticRouteProfiles.add(new StaticRouteProfile(route, gateway)); } - logger.debug("Found " + staticRouteProfiles.size() + " static routes to apply as a part of vpc route " + domainRouterVO + " start"); + s_logger.debug("Found " + staticRouteProfiles.size() + " static routes to apply as a part of vpc route " + domainRouterVO + " start"); if (!staticRouteProfiles.isEmpty()) { _commandSetupHelper.createStaticRouteCommands(staticRouteProfiles, domainRouterVO, cmds); } @@ -462,7 +464,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.NetworkACL, Provider.VPCVirtualRouter)) { final List networkACLs = _networkACLMgr.listNetworkACLItems(guestNetworkId); if (networkACLs != null && !networkACLs.isEmpty()) { - logger.debug("Found " + networkACLs.size() + " network ACLs to apply as a part of VPC VR " + domainRouterVO + " start for guest network id=" + guestNetworkId); + s_logger.debug("Found " + networkACLs.size() + " network ACLs to apply as a part of VPC VR " + domainRouterVO + " start for guest network id=" + guestNetworkId); _commandSetupHelper.createNetworkACLsCommands(networkACLs, domainRouterVO, cmds, guestNetworkId, false); } } @@ -509,20 +511,20 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian try { if (_nwHelper.sendCommandsToRouter(router, cmds)) { - logger.debug("Successfully applied ip association for ip " + ip + " in vpc network " + network); + s_logger.debug("Successfully applied ip association for ip " + ip + " in vpc network " + network); return true; } else { - logger.warn("Failed to associate ip address " + ip + " in vpc network " + network); + s_logger.warn("Failed to associate ip address " + ip + " in vpc network " + network); return false; } } catch (final Exception ex) { - logger.warn("Failed to send " + (add ? "add " : "delete ") + " private network " + network + " commands to rotuer "); + s_logger.warn("Failed to send " + (add ? "add " : "delete ") + " private network " + network + " commands to rotuer "); return false; } } else if (router.getState() == State.Stopped || router.getState() == State.Stopping) { - logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() + ", so not sending setup private network command to the backend"); + s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() + ", so not sending setup private network command to the backend"); } else { - logger.warn("Unable to setup private gateway, virtual router " + router + " is not in the right state " + router.getState()); + s_logger.warn("Unable to setup private gateway, virtual router " + router + " is not in the right state " + router.getState()); throw new ResourceUnavailableException("Unable to setup Private gateway on the backend," + " virtual router " + router + " is not in the right state", DataCenter.class, router.getDataCenterId()); @@ -534,28 +536,28 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian public boolean destroyPrivateGateway(final PrivateGateway gateway, final VirtualRouter router) throws ConcurrentOperationException, ResourceUnavailableException { if (!_networkModel.isVmPartOfNetwork(router.getId(), gateway.getNetworkId())) { - logger.debug("Router doesn't have nic for gateway " + gateway + " so no need to removed it"); + s_logger.debug("Router doesn't have nic for gateway " + gateway + " so no need to removed it"); return true; } final Network privateNetwork = _networkModel.getNetwork(gateway.getNetworkId()); - logger.debug("Releasing private ip for gateway " + gateway + " from " + router); + s_logger.debug("Releasing private ip for gateway " + gateway + " from " + router); boolean result = setupVpcPrivateNetwork(router, false, _networkModel.getNicProfile(router, privateNetwork.getId(), null)); if (!result) { - logger.warn("Failed to release private ip for gateway " + gateway + " on router " + router); + s_logger.warn("Failed to release private ip for gateway " + gateway + " on router " + router); return false; } // revoke network acl on the private gateway. if (!_networkACLMgr.revokeACLItemsForPrivateGw(gateway)) { - logger.debug("Failed to delete network acl items on " + gateway + " from router " + router); + s_logger.debug("Failed to delete network acl items on " + gateway + " from router " + router); return false; } - logger.debug("Removing router " + router + " from private network " + privateNetwork + " as a part of delete private gateway"); + s_logger.debug("Removing router " + router + " from private network " + privateNetwork + " as a part of delete private gateway"); result = result && _itMgr.removeVmFromNetwork(router, privateNetwork, null); - logger.debug("Private gateawy " + gateway + " is removed from router " + router); + s_logger.debug("Private gateawy " + gateway + " is removed from router " + router); return result; } @@ -572,7 +574,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian final ArrayList publicIps = getPublicIpsToApply(domainRouterVO, provider, guestNetworkId, IpAddress.State.Releasing); if (publicIps != null && !publicIps.isEmpty()) { - logger.debug("Found " + publicIps.size() + " ip(s) to apply as a part of domR " + domainRouterVO + " start."); + s_logger.debug("Found " + publicIps.size() + " ip(s) to apply as a part of domR " + domainRouterVO + " start."); // Re-apply public ip addresses - should come before PF/LB/VPN _commandSetupHelper.createVpcAssociatePublicIPCommands(domainRouterVO, publicIps, cmds, vlanMacAddress); } @@ -582,7 +584,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian @Override public boolean startSite2SiteVpn(final Site2SiteVpnConnection conn, final VirtualRouter router) throws ResourceUnavailableException { if (router.getState() != State.Running) { - logger.warn("Unable to apply site-to-site VPN configuration, virtual router is not in the right state " + router.getState()); + s_logger.warn("Unable to apply site-to-site VPN configuration, virtual router is not in the right state " + router.getState()); throw new ResourceUnavailableException("Unable to apply site 2 site VPN configuration," + " virtual router is not in the right state", DataCenter.class, router.getDataCenterId()); } @@ -593,7 +595,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian @Override public boolean stopSite2SiteVpn(final Site2SiteVpnConnection conn, final VirtualRouter router) throws ResourceUnavailableException { if (router.getState() != State.Running) { - logger.warn("Unable to apply site-to-site VPN configuration, virtual router is not in the right state " + router.getState()); + s_logger.warn("Unable to apply site-to-site VPN configuration, virtual router is not in the right state " + router.getState()); throw new ResourceUnavailableException("Unable to apply site 2 site VPN configuration," + " virtual router is not in the right state", DataCenter.class, router.getDataCenterId()); } @@ -627,7 +629,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian final Nic nic = _nicDao.findByIp4AddressAndNetworkIdAndInstanceId(publicNtwkId, router.getId(), ip.getAddress().addr()); if (nic != null) { nicsToUnplug.put(ip.getVlanTag(), ip); - logger.debug("Need to unplug the nic for ip=" + ip + "; vlan=" + ip.getVlanTag() + " in public network id =" + publicNtwkId); + s_logger.debug("Need to unplug the nic for ip=" + ip + "; vlan=" + ip.getVlanTag() + " in public network id =" + publicNtwkId); } } } @@ -650,14 +652,14 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian if (nic == null && nicsToPlug.get(ip.getVlanTag()) == null) { nicsToPlug.put(ip.getVlanTag(), ip); - logger.debug("Need to plug the nic for ip=" + ip + "; vlan=" + ip.getVlanTag() + " in public network id =" + publicNtwkId); + s_logger.debug("Need to plug the nic for ip=" + ip + "; vlan=" + ip.getVlanTag() + " in public network id =" + publicNtwkId); } else { final PublicIpAddress nicToUnplug = nicsToUnplug.get(ip.getVlanTag()); if (nicToUnplug != null) { final NicVO nicVO = _nicDao.findByIp4AddressAndNetworkIdAndInstanceId(publicNtwkId, router.getId(), nicToUnplug.getAddress().addr()); nicVO.setIPv4Address(ip.getAddress().addr()); _nicDao.update(nicVO.getId(), nicVO); - logger.debug("Updated the nic " + nicVO + " with the new ip address " + ip.getAddress().addr()); + s_logger.debug("Updated the nic " + nicVO + " with the new ip address " + ip.getAddress().addr()); nicsToUnplug.remove(ip.getVlanTag()); } } @@ -688,7 +690,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian @Override public boolean startRemoteAccessVpn(final RemoteAccessVpn vpn, final VirtualRouter router) throws ResourceUnavailableException { if (router.getState() != State.Running) { - logger.warn("Unable to apply remote access VPN configuration, virtual router is not in the right state " + router.getState()); + s_logger.warn("Unable to apply remote access VPN configuration, virtual router is not in the right state " + router.getState()); throw new ResourceUnavailableException("Unable to apply remote access VPN configuration," + " virtual router is not in the right state", DataCenter.class, router.getDataCenterId()); } @@ -699,19 +701,19 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian try { _agentMgr.send(router.getHostId(), cmds); } catch (final OperationTimedoutException e) { - logger.debug("Failed to start remote access VPN: ", e); + s_logger.debug("Failed to start remote access VPN: ", e); throw new AgentUnavailableException("Unable to send commands to virtual router ", router.getHostId(), e); } Answer answer = cmds.getAnswer("users"); if (!answer.getResult()) { - logger.error("Unable to start vpn: unable add users to vpn in zone " + router.getDataCenterId() + " for account " + vpn.getAccountId() + " on domR: " + s_logger.error("Unable to start vpn: unable add users to vpn in zone " + router.getDataCenterId() + " for account " + vpn.getAccountId() + " on domR: " + router.getInstanceName() + " due to " + answer.getDetails()); throw new ResourceUnavailableException("Unable to start vpn: Unable to add users to vpn in zone " + router.getDataCenterId() + " for account " + vpn.getAccountId() + " on domR: " + router.getInstanceName() + " due to " + answer.getDetails(), DataCenter.class, router.getDataCenterId()); } answer = cmds.getAnswer("startVpn"); if (!answer.getResult()) { - logger.error("Unable to start vpn in zone " + router.getDataCenterId() + " for account " + vpn.getAccountId() + " on domR: " + router.getInstanceName() + " due to " + s_logger.error("Unable to start vpn in zone " + router.getDataCenterId() + " for account " + vpn.getAccountId() + " on domR: " + router.getInstanceName() + " due to " + answer.getDetails()); throw new ResourceUnavailableException("Unable to start vpn in zone " + router.getDataCenterId() + " for account " + vpn.getAccountId() + " on domR: " + router.getInstanceName() + " due to " + answer.getDetails(), DataCenter.class, router.getDataCenterId()); @@ -729,9 +731,9 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian _commandSetupHelper.createApplyVpnCommands(false, vpn, router, cmds); result = result && _nwHelper.sendCommandsToRouter(router, cmds); } else if (router.getState() == State.Stopped) { - logger.debug("Router " + router + " is in Stopped state, not sending deleteRemoteAccessVpn command to it"); + s_logger.debug("Router " + router + " is in Stopped state, not sending deleteRemoteAccessVpn command to it"); } else { - logger.warn("Failed to delete remote access VPN: domR " + router + " is not in right state " + router.getState()); + s_logger.warn("Failed to delete remote access VPN: domR " + router + " is not in right state " + router.getState()); throw new ResourceUnavailableException("Failed to delete remote access VPN: domR is not in right state " + router.getState(), DataCenter.class, router.getDataCenterId()); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/rules/RulesManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/rules/RulesManagerImpl.java b/server/src/com/cloud/network/rules/RulesManagerImpl.java index 38cd27c..3e2b15a 100644 --- a/server/src/com/cloud/network/rules/RulesManagerImpl.java +++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java @@ -28,6 +28,7 @@ import javax.inject.Inject; import org.apache.cloudstack.api.command.user.firewall.ListPortForwardingRulesCmd; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; +import org.apache.log4j.Logger; import com.cloud.configuration.ConfigurationManager; import com.cloud.domain.dao.DomainDao; @@ -98,6 +99,7 @@ import com.cloud.vm.dao.VMInstanceDao; @Local(value = {RulesManager.class, RulesService.class}) public class RulesManagerImpl extends ManagerBase implements RulesManager, RulesService { + private static final Logger s_logger = Logger.getLogger(RulesManagerImpl.class); @Inject IpAddressManager _ipAddrMgr; @@ -227,7 +229,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules if (assignToVpcNtwk) { _networkModel.checkIpForService(ipAddress, Service.PortForwarding, networkId); - logger.debug("The ip is not associated with the VPC network id=" + networkId + ", so assigning"); + s_logger.debug("The ip is not associated with the VPC network id=" + networkId + ", so assigning"); try { ipAddress = _ipAddrMgr.associateIPToGuestNetwork(ipAddrId, networkId, false); performedIpAssoc = true; @@ -497,15 +499,15 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules if (assignToVpcNtwk) { _networkModel.checkIpForService(ipAddress, Service.StaticNat, networkId); - logger.debug("The ip is not associated with the VPC network id=" + networkId + ", so assigning"); + s_logger.debug("The ip is not associated with the VPC network id=" + networkId + ", so assigning"); try { ipAddress = _ipAddrMgr.associateIPToGuestNetwork(ipId, networkId, false); } catch (Exception ex) { - logger.warn("Failed to associate ip id=" + ipId + " to VPC network id=" + networkId + " as " + "a part of enable static nat"); + s_logger.warn("Failed to associate ip id=" + ipId + " to VPC network id=" + networkId + " as " + "a part of enable static nat"); return false; } } else if (ipAddress.isPortable()) { - logger.info("Portable IP " + ipAddress.getUuid() + " is not associated with the network yet " + " so associate IP with the network " + + s_logger.info("Portable IP " + ipAddress.getUuid() + " is not associated with the network yet " + " so associate IP with the network " + networkId); try { // check if StaticNat service is enabled in the network @@ -519,7 +521,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules // associate portable IP with guest network ipAddress = _ipAddrMgr.associatePortableIPToGuestNetwork(ipId, networkId, false); } catch (Exception e) { - logger.warn("Failed to associate portable id=" + ipId + " to network id=" + networkId + " as " + "a part of enable static nat"); + s_logger.warn("Failed to associate portable id=" + ipId + " to network id=" + networkId + " as " + "a part of enable static nat"); return false; } } @@ -535,7 +537,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules _ipAddrMgr.transferPortableIP(ipId, ipAddress.getAssociatedWithNetworkId(), networkId); ipAddress = _ipAddressDao.findById(ipId); } catch (Exception e) { - logger.warn("Failed to associate portable id=" + ipId + " to network id=" + networkId + " as " + "a part of enable static nat"); + s_logger.warn("Failed to associate portable id=" + ipId + " to network id=" + networkId + " as " + "a part of enable static nat"); return false; } } else { @@ -594,19 +596,19 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules ipAddress.setVmIp(dstIp); if (_ipAddressDao.update(ipAddress.getId(), ipAddress)) { // enable static nat on the backend - logger.trace("Enabling static nat for ip address " + ipAddress + " and vm id=" + vmId + " on the backend"); + s_logger.trace("Enabling static nat for ip address " + ipAddress + " and vm id=" + vmId + " on the backend"); if (applyStaticNatForIp(ipId, false, caller, false)) { performedIpAssoc = false; // ignor unassignIPFromVpcNetwork in finally block return true; } else { - logger.warn("Failed to enable static nat rule for ip address " + ipId + " on the backend"); + s_logger.warn("Failed to enable static nat rule for ip address " + ipId + " on the backend"); ipAddress.setOneToOneNat(isOneToOneNat); ipAddress.setAssociatedWithVmId(associatedWithVmId); ipAddress.setVmIp(null); _ipAddressDao.update(ipAddress.getId(), ipAddress); } } else { - logger.warn("Failed to update ip address " + ipAddress + " in the DB as a part of enableStaticNat"); + s_logger.warn("Failed to update ip address " + ipAddress + " in the DB as a part of enableStaticNat"); } } finally { @@ -666,7 +668,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules oldIP.getUuid()); } // unassign old static nat rule - logger.debug("Disassociating static nat for ip " + oldIP); + s_logger.debug("Disassociating static nat for ip " + oldIP); if (!disableStaticNat(oldIP.getId(), caller, callerUserId, true)) { throw new CloudRuntimeException("Failed to disable old static nat rule for vm "+ vm.getInstanceName() + " with id "+vm.getUuid() +" and public ip " + oldIP); @@ -756,7 +758,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules Set ipsToReprogram = new HashSet(); if (rules == null || rules.isEmpty()) { - logger.debug("No port forwarding rules are found for vm id=" + vmId); + s_logger.debug("No port forwarding rules are found for vm id=" + vmId); return true; } @@ -768,9 +770,9 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules // apply rules for all ip addresses for (Long ipId : ipsToReprogram) { - logger.debug("Applying port forwarding rules for ip address id=" + ipId + " as a part of vm expunge"); + s_logger.debug("Applying port forwarding rules for ip address id=" + ipId + " as a part of vm expunge"); if (!applyPortForwardingRules(ipId, true, _accountMgr.getSystemAccount())) { - logger.warn("Failed to apply port forwarding rules for ip id=" + ipId); + s_logger.warn("Failed to apply port forwarding rules for ip id=" + ipId); success = false; } } @@ -864,7 +866,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules List rules = _portForwardingDao.listForApplication(ipId); if (rules.size() == 0) { - logger.debug("There are no port forwarding rules to apply for ip id=" + ipId); + s_logger.debug("There are no port forwarding rules to apply for ip id=" + ipId); return true; } @@ -877,7 +879,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules return false; } } catch (ResourceUnavailableException ex) { - logger.warn("Failed to apply port forwarding rules for ip due to ", ex); + s_logger.warn("Failed to apply port forwarding rules for ip due to ", ex); return false; } @@ -889,7 +891,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules List staticNatRules = new ArrayList(); if (rules.size() == 0) { - logger.debug("There are no static nat rules to apply for ip id=" + sourceIpId); + s_logger.debug("There are no static nat rules to apply for ip id=" + sourceIpId); return true; } @@ -906,7 +908,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules return false; } } catch (ResourceUnavailableException ex) { - logger.warn("Failed to apply static nat rules for ip due to ", ex); + s_logger.warn("Failed to apply static nat rules for ip due to ", ex); return false; } @@ -917,7 +919,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules public boolean applyPortForwardingRulesForNetwork(long networkId, boolean continueOnError, Account caller) { List rules = listByNetworkId(networkId); if (rules.size() == 0) { - logger.debug("There are no port forwarding rules to apply for network id=" + networkId); + s_logger.debug("There are no port forwarding rules to apply for network id=" + networkId); return true; } @@ -930,7 +932,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules return false; } } catch (ResourceUnavailableException ex) { - logger.warn("Failed to apply port forwarding rules for network due to ", ex); + s_logger.warn("Failed to apply port forwarding rules for network due to ", ex); return false; } @@ -943,7 +945,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules List staticNatRules = new ArrayList(); if (rules.size() == 0) { - logger.debug("There are no static nat rules to apply for network id=" + networkId); + s_logger.debug("There are no static nat rules to apply for network id=" + networkId); return true; } @@ -960,7 +962,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules return false; } } catch (ResourceUnavailableException ex) { - logger.warn("Failed to apply static nat rules for network due to ", ex); + s_logger.warn("Failed to apply static nat rules for network due to ", ex); return false; } @@ -971,7 +973,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules public boolean applyStaticNatsForNetwork(long networkId, boolean continueOnError, Account caller) { List ips = _ipAddressDao.listStaticNatPublicIps(networkId); if (ips.isEmpty()) { - logger.debug("There are no static nat to apply for network id=" + networkId); + s_logger.debug("There are no static nat to apply for network id=" + networkId); return true; } @@ -992,7 +994,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules return false; } } catch (ResourceUnavailableException ex) { - logger.warn("Failed to create static nat for network due to ", ex); + s_logger.warn("Failed to create static nat for network due to ", ex); return false; } @@ -1076,8 +1078,8 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules List rules = new ArrayList(); List pfRules = _portForwardingDao.listByIpAndNotRevoked(ipId); - if (logger.isDebugEnabled()) { - logger.debug("Releasing " + pfRules.size() + " port forwarding rules for ip id=" + ipId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Releasing " + pfRules.size() + " port forwarding rules for ip id=" + ipId); } for (PortForwardingRuleVO rule : pfRules) { @@ -1086,8 +1088,8 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules } List staticNatRules = _firewallDao.listByIpAndPurposeAndNotRevoked(ipId, Purpose.StaticNat); - if (logger.isDebugEnabled()) { - logger.debug("Releasing " + staticNatRules.size() + " static nat rules for ip id=" + ipId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Releasing " + staticNatRules.size() + " static nat rules for ip id=" + ipId); } for (FirewallRuleVO rule : staticNatRules) { @@ -1110,8 +1112,8 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules rules.addAll(_portForwardingDao.listByIpAndNotRevoked(ipId)); rules.addAll(_firewallDao.listByIpAndPurposeAndNotRevoked(ipId, Purpose.StaticNat)); - if (logger.isDebugEnabled() && success) { - logger.debug("Successfully released rules for ip id=" + ipId + " and # of rules now = " + rules.size()); + if (s_logger.isDebugEnabled() && success) { + s_logger.debug("Successfully released rules for ip id=" + ipId + " and # of rules now = " + rules.size()); } return (rules.size() == 0 && success); @@ -1122,13 +1124,13 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules List rules = new ArrayList(); List pfRules = _portForwardingDao.listByNetwork(networkId); - if (logger.isDebugEnabled()) { - logger.debug("Releasing " + pfRules.size() + " port forwarding rules for network id=" + networkId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Releasing " + pfRules.size() + " port forwarding rules for network id=" + networkId); } List staticNatRules = _firewallDao.listByNetworkAndPurpose(networkId, Purpose.StaticNat); - if (logger.isDebugEnabled()) { - logger.debug("Releasing " + staticNatRules.size() + " static nat rules for network id=" + networkId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Releasing " + staticNatRules.size() + " static nat rules for network id=" + networkId); } // Mark all pf rules (Active and non-Active) to be revoked, but don't revoke it yet - pass apply=false @@ -1152,8 +1154,8 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules rules.addAll(_portForwardingDao.listByNetworkAndNotRevoked(networkId)); rules.addAll(_firewallDao.listByNetworkAndPurposeAndNotRevoked(networkId, Purpose.StaticNat)); - if (logger.isDebugEnabled()) { - logger.debug("Successfully released rules for network id=" + networkId + " and # of rules now = " + rules.size()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Successfully released rules for network id=" + networkId + " and # of rules now = " + rules.size()); } return success && rules.size() == 0; @@ -1259,18 +1261,18 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules // Revoke all firewall rules for the ip try { - logger.debug("Revoking all " + Purpose.Firewall + "rules as a part of disabling static nat for public IP id=" + ipId); + s_logger.debug("Revoking all " + Purpose.Firewall + "rules as a part of disabling static nat for public IP id=" + ipId); if (!_firewallMgr.revokeFirewallRulesForIp(ipId, callerUserId, caller)) { - logger.warn("Unable to revoke all the firewall rules for ip id=" + ipId + " as a part of disable statis nat"); + s_logger.warn("Unable to revoke all the firewall rules for ip id=" + ipId + " as a part of disable statis nat"); 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; } if (!revokeAllPFAndStaticNatRulesForIp(ipId, callerUserId, caller)) { - logger.warn("Unable to revoke all static nat rules for ip " + ipAddress); + s_logger.warn("Unable to revoke all static nat rules for ip " + ipAddress); success = false; } @@ -1286,13 +1288,13 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules _vpcMgr.unassignIPFromVpcNetwork(ipAddress.getId(), networkId); if (isIpSystem && releaseIpIfElastic && !_ipAddrMgr.handleSystemIpRelease(ipAddress)) { - logger.warn("Failed to release system ip address " + ipAddress); + s_logger.warn("Failed to release system ip address " + ipAddress); success = false; } return true; } else { - logger.warn("Failed to disable one to one nat for the ip address id" + ipId); + s_logger.warn("Failed to disable one to one nat for the ip address id" + ipId); return false; } } @@ -1329,7 +1331,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules return false; } } catch (ResourceUnavailableException ex) { - logger.warn("Failed to create static nat rule due to ", ex); + s_logger.warn("Failed to create static nat rule due to ", ex); return false; } } @@ -1348,18 +1350,18 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules if (staticNats != null && !staticNats.isEmpty()) { if (forRevoke) { - logger.debug("Found " + staticNats.size() + " static nats to disable for network id " + networkId); + s_logger.debug("Found " + staticNats.size() + " static nats to disable for network id " + networkId); } try { if (!_ipAddrMgr.applyStaticNats(staticNats, continueOnError, forRevoke)) { return false; } } catch (ResourceUnavailableException ex) { - logger.warn("Failed to create static nat rule due to ", ex); + s_logger.warn("Failed to create static nat rule due to ", ex); return false; } } else { - logger.debug("Found 0 static nat rules to apply for network id " + networkId); + s_logger.debug("Found 0 static nat rules to apply for network id " + networkId); } return true; @@ -1368,7 +1370,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules protected List createStaticNatForIp(IpAddress sourceIp, Account caller, boolean forRevoke) { List staticNats = new ArrayList(); if (!sourceIp.isOneToOneNat()) { - logger.debug("Source ip id=" + sourceIp + " is not one to one nat"); + s_logger.debug("Source ip id=" + sourceIp + " is not one to one nat"); return staticNats; } @@ -1432,36 +1434,36 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules } // check if there is already static nat enabled if (_ipAddressDao.findByAssociatedVmId(vm.getId()) != null && !getNewIp) { - logger.debug("Vm " + vm + " already has ip associated with it in guest network " + guestNetwork); + s_logger.debug("Vm " + vm + " already has ip associated with it in guest network " + guestNetwork); continue; } - logger.debug("Allocating system ip and enabling static nat for it for the vm " + vm + " in guest network " + guestNetwork); + s_logger.debug("Allocating system ip and enabling static nat for it for the vm " + vm + " in guest network " + guestNetwork); IpAddress ip = _ipAddrMgr.assignSystemIp(guestNetwork.getId(), _accountMgr.getAccount(vm.getAccountId()), false, true); if (ip == null) { throw new CloudRuntimeException("Failed to allocate system ip for vm " + vm + " in guest network " + guestNetwork); } - logger.debug("Allocated system ip " + ip + ", now enabling static nat on it for vm " + vm); + s_logger.debug("Allocated system ip " + ip + ", now enabling static nat on it for vm " + vm); try { success = enableStaticNat(ip.getId(), vm.getId(), guestNetwork.getId(), isSystemVM, null); } catch (NetworkRuleConflictException ex) { - logger.warn("Failed to enable static nat as a part of enabling elasticIp and staticNat for vm " + vm + " in guest network " + guestNetwork + + s_logger.warn("Failed to enable static nat as a part of enabling elasticIp and staticNat for vm " + vm + " in guest network " + guestNetwork + " due to exception ", ex); success = false; } catch (ResourceUnavailableException ex) { - logger.warn("Failed to enable static nat as a part of enabling elasticIp and staticNat for vm " + vm + " in guest network " + guestNetwork + + s_logger.warn("Failed to enable static nat as a part of enabling elasticIp and staticNat for vm " + vm + " in guest network " + guestNetwork + " due to exception ", ex); success = false; } if (!success) { - logger.warn("Failed to enable static nat on system ip " + ip + " for the vm " + vm + ", releasing the ip..."); + s_logger.warn("Failed to enable static nat on system ip " + ip + " for the vm " + vm + ", releasing the ip..."); _ipAddrMgr.handleSystemIpRelease(ip); throw new CloudRuntimeException("Failed to enable static nat on system ip for the vm " + vm); } else { - logger.warn("Succesfully enabled static nat on system ip " + ip + " for the vm " + vm); + s_logger.warn("Succesfully enabled static nat on system ip " + ip + " for the vm " + vm); } } } @@ -1473,19 +1475,19 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules @Override public List listAssociatedRulesForGuestNic(Nic nic) { - logger.debug("Checking if PF/StaticNat/LoadBalancer rules are configured for nic " + nic.getId()); + s_logger.debug("Checking if PF/StaticNat/LoadBalancer rules are configured for nic " + nic.getId()); List result = new ArrayList(); // add PF rules result.addAll(_portForwardingDao.listByNetworkAndDestIpAddr(nic.getIPv4Address(), nic.getNetworkId())); if(result.size() > 0) { - logger.debug("Found " + result.size() + " portforwarding rule configured for the nic in the network " + nic.getNetworkId()); + s_logger.debug("Found " + result.size() + " portforwarding rule configured for the nic in the network " + nic.getNetworkId()); } // add static NAT rules List staticNatRules = _firewallDao.listStaticNatByVmId(nic.getInstanceId()); for (FirewallRuleVO rule : staticNatRules) { if (rule.getNetworkId() == nic.getNetworkId()) { result.add(rule); - logger.debug("Found rule " + rule.getId() + " " + rule.getPurpose() + " configured"); + s_logger.debug("Found rule " + rule.getId() + " " + rule.getPurpose() + " configured"); } } List staticNatIps = _ipAddressDao.listStaticNatPublicIps(nic.getNetworkId()); @@ -1498,7 +1500,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules new FirewallRuleVO(null, ip.getId(), 0, 65535, NetUtils.ALL_PROTO.toString(), nic.getNetworkId(), vm.getAccountId(), vm.getDomainId(), Purpose.StaticNat, null, null, null, null, null); result.add(staticNatRule); - logger.debug("Found rule " + staticNatRule.getId() + " " + staticNatRule.getPurpose() + " configured"); + s_logger.debug("Found rule " + staticNatRule.getId() + " " + staticNatRule.getPurpose() + " configured"); } } // add LB rules @@ -1507,7 +1509,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules FirewallRuleVO lbRule = _firewallDao.findById(lb.getLoadBalancerId()); if (lbRule.getNetworkId() == nic.getNetworkId()) { result.add(lbRule); - logger.debug("Found rule " + lbRule.getId() + " " + lbRule.getPurpose() + " configured"); + s_logger.debug("Found rule " + lbRule.getId() + " " + lbRule.getPurpose() + " configured"); } } return result; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/security/SecurityGroupManagerImpl2.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/security/SecurityGroupManagerImpl2.java b/server/src/com/cloud/network/security/SecurityGroupManagerImpl2.java index 434a8e4..47f6e77 100644 --- a/server/src/com/cloud/network/security/SecurityGroupManagerImpl2.java +++ b/server/src/com/cloud/network/security/SecurityGroupManagerImpl2.java @@ -77,7 +77,7 @@ public class SecurityGroupManagerImpl2 extends SecurityGroupManagerImpl { } }); } catch (final Throwable th) { - logger.error("SG Work: Caught this throwable, ", th); + s_logger.error("SG Work: Caught this throwable, ", th); } } } @@ -99,15 +99,15 @@ public class SecurityGroupManagerImpl2 extends SecurityGroupManagerImpl { return; } if (_schedulerDisabled) { - logger.debug("Security Group Mgr v2: scheduler disabled, doing nothing for " + affectedVms.size() + " vms"); + s_logger.debug("Security Group Mgr v2: scheduler disabled, doing nothing for " + affectedVms.size() + " vms"); return; } Set workItems = new TreeSet(); workItems.addAll(affectedVms); workItems.removeAll(_disabledVms); - if (logger.isDebugEnabled()) { - logger.debug("Security Group Mgr v2: scheduling ruleset updates for " + affectedVms.size() + " vms " + " (unique=" + workItems.size() + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Security Group Mgr v2: scheduling ruleset updates for " + affectedVms.size() + " vms " + " (unique=" + workItems.size() + "), current queue size=" + _workQueue.size()); } @@ -123,8 +123,8 @@ public class SecurityGroupManagerImpl2 extends SecurityGroupManagerImpl { int newJobs = _workQueue.submitWorkForVms(workItems); _mBean.logScheduledDetails(workItems); p.stop(); - if (logger.isDebugEnabled()) { - logger.debug("Security Group Mgr v2: done scheduling ruleset updates for " + workItems.size() + " vms: num new jobs=" + newJobs + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Security Group Mgr v2: done scheduling ruleset updates for " + workItems.size() + " vms: num new jobs=" + newJobs + " num rows insert or updated=" + updated + " time taken=" + p.getDurationInMillis()); } } @@ -139,31 +139,31 @@ public class SecurityGroupManagerImpl2 extends SecurityGroupManagerImpl { @Override public void work() { - logger.trace("Checking the work queue"); + s_logger.trace("Checking the work queue"); List workItems; try { workItems = _workQueue.getWork(1); for (SecurityGroupWork work : workItems) { - if (logger.isTraceEnabled()) { - logger.trace("Processing " + work.getInstanceId()); + if (s_logger.isTraceEnabled()) { + s_logger.trace("Processing " + work.getInstanceId()); } try { VmRulesetLogVO rulesetLog = _rulesetLogDao.findByVmId(work.getInstanceId()); if (rulesetLog == null) { - logger.warn("Could not find ruleset log for vm " + work.getInstanceId()); + s_logger.warn("Could not find ruleset log for vm " + work.getInstanceId()); continue; } work.setLogsequenceNumber(rulesetLog.getLogsequence()); sendRulesetUpdates(work); _mBean.logUpdateDetails(work.getInstanceId(), work.getLogsequenceNumber()); } catch (Exception e) { - logger.error("Problem during SG work " + work, e); + s_logger.error("Problem during SG work " + work, e); work.setStep(Step.Error); } } } catch (InterruptedException e1) { - logger.warn("SG work: caught InterruptException", e1); + s_logger.warn("SG work: caught InterruptException", e1); } } @@ -172,8 +172,8 @@ public class SecurityGroupManagerImpl2 extends SecurityGroupManagerImpl { UserVm vm = _userVMDao.findById(userVmId); if (vm != null && vm.getState() == State.Running) { - if (logger.isTraceEnabled()) { - logger.trace("SecurityGroupManager v2: found vm, " + userVmId + " state=" + vm.getState()); + if (s_logger.isTraceEnabled()) { + s_logger.trace("SecurityGroupManager v2: found vm, " + userVmId + " state=" + vm.getState()); } Map> ingressRules = generateRulesForVM(userVmId, SecurityRuleType.IngressRule); Map> egressRules = generateRulesForVM(userVmId, SecurityRuleType.EgressRule); @@ -193,28 +193,28 @@ public class SecurityGroupManagerImpl2 extends SecurityGroupManagerImpl { generateRulesetCmd(vm.getInstanceName(), vm.getPrivateIpAddress(), vm.getPrivateMacAddress(), vm.getId(), null, work.getLogsequenceNumber(), ingressRules, egressRules, nicSecIps); cmd.setMsId(_serverId); - if (logger.isDebugEnabled()) { - logger.debug("SecurityGroupManager v2: sending ruleset update for vm " + vm.getInstanceName() + ":ingress num rules=" + + if (s_logger.isDebugEnabled()) { + s_logger.debug("SecurityGroupManager v2: sending ruleset update for vm " + vm.getInstanceName() + ":ingress num rules=" + cmd.getIngressRuleSet().length + ":egress num rules=" + cmd.getEgressRuleSet().length + " num cidrs=" + cmd.getTotalNumCidrs() + " sig=" + cmd.getSignature()); } Commands cmds = new Commands(cmd); try { _agentMgr.send(agentId, cmds, _answerListener); - if (logger.isTraceEnabled()) { - logger.trace("SecurityGroupManager v2: sent ruleset updates for " + vm.getInstanceName() + " curr queue size=" + _workQueue.size()); + if (s_logger.isTraceEnabled()) { + s_logger.trace("SecurityGroupManager v2: sent ruleset updates for " + vm.getInstanceName() + " curr queue size=" + _workQueue.size()); } } catch (AgentUnavailableException e) { - logger.debug("Unable to send updates for vm: " + userVmId + "(agentid=" + agentId + ")"); + s_logger.debug("Unable to send updates for vm: " + userVmId + "(agentid=" + agentId + ")"); _workTracker.handleException(agentId); } } } else { - if (logger.isDebugEnabled()) { + if (s_logger.isDebugEnabled()) { if (vm != null) - logger.debug("No rules sent to vm " + vm + "state=" + vm.getState()); + s_logger.debug("No rules sent to vm " + vm + "state=" + vm.getState()); else - logger.debug("Could not find vm: No rules sent to vm " + userVmId); + s_logger.debug("Could not find vm: No rules sent to vm " + userVmId); } } } @@ -279,7 +279,7 @@ public class SecurityGroupManagerImpl2 extends SecurityGroupManagerImpl { try { JmxUtil.registerMBean("SecurityGroupManager", "SecurityGroupManagerImpl2", _mBean); } catch (Exception e) { - logger.error("Failed to register MBean", e); + s_logger.error("Failed to register MBean", e); } boolean result = super.configure(name, params); Map configs = _configDao.getConfiguration("Network", params); @@ -295,7 +295,7 @@ public class SecurityGroupManagerImpl2 extends SecurityGroupManagerImpl { } else { _disabledVms.remove(vmId); } - logger.warn("JMX operation: Scheduler state for vm " + vmId + ": new state disabled=" + disable); + s_logger.warn("JMX operation: Scheduler state for vm " + vmId + ": new state disabled=" + disable); } @@ -305,13 +305,13 @@ public class SecurityGroupManagerImpl2 extends SecurityGroupManagerImpl { } public void enableAllVmsForScheduler() { - logger.warn("Cleared list of disabled VMs (JMX operation?)"); + s_logger.warn("Cleared list of disabled VMs (JMX operation?)"); _disabledVms.clear(); } public void disableScheduler(boolean disable) { _schedulerDisabled = disable; - logger.warn("JMX operation: Scheduler state changed: new state disabled=" + disable); + s_logger.warn("JMX operation: Scheduler state changed: new state disabled=" + disable); } public boolean isSchedulerDisabled() { @@ -320,7 +320,7 @@ public class SecurityGroupManagerImpl2 extends SecurityGroupManagerImpl { public void clearWorkQueue() { _workQueue.clear(); - logger.warn("Cleared the work queue (possible JMX operation)"); + s_logger.warn("Cleared the work queue (possible JMX operation)"); } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java b/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java index d3db49a..de0465b 100644 --- a/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java +++ b/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java @@ -25,6 +25,7 @@ import javax.inject.Inject; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.framework.messagebus.MessageBus; import org.apache.cloudstack.framework.messagebus.PublishScope; +import org.apache.log4j.Logger; import com.cloud.configuration.ConfigurationManager; import com.cloud.event.ActionEvent; @@ -54,6 +55,7 @@ import com.cloud.utils.exception.CloudRuntimeException; @Local(value = {NetworkACLManager.class}) public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLManager { + private static final Logger s_logger = Logger.getLogger(NetworkACLManagerImpl.class); @Inject AccountManager _accountMgr; @@ -115,7 +117,7 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana if (!applyACLToPrivateGw(privateGateway)) { aclApplyStatus = false; - logger.debug("failed to apply network acl item on private gateway " + privateGateway.getId() + "acl id " + aclId); + s_logger.debug("failed to apply network acl item on private gateway " + privateGateway.getId() + "acl id " + aclId); break; } } @@ -167,7 +169,7 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana if (aclItems == null || aclItems.isEmpty()) { //Revoke ACL Items of the existing ACL if the new network acl is empty //Other wise existing rules will not be removed on the router elelment - logger.debug("New network ACL is empty. Revoke existing rules before applying ACL"); + s_logger.debug("New network ACL is empty. Revoke existing rules before applying ACL"); if (!revokeACLItemsForPrivateGw(gateway)) { throw new CloudRuntimeException("Failed to replace network ACL. Error while removing existing ACL " + "items for privatewa gateway: " + gateway.getId()); } @@ -200,7 +202,7 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana //Existing rules won't be removed otherwise List aclItems = _networkACLItemDao.listByACL(acl.getId()); if (aclItems == null || aclItems.isEmpty()) { - logger.debug("New network ACL is empty. Revoke existing rules before applying ACL"); + s_logger.debug("New network ACL is empty. Revoke existing rules before applying ACL"); if (!revokeACLItemsForNetwork(network.getId())) { throw new CloudRuntimeException("Failed to replace network ACL. Error while removing existing ACL items for network: " + network.getId()); } @@ -210,7 +212,7 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana network.setNetworkACLId(acl.getId()); //Update Network ACL if (_networkDao.update(network.getId(), network)) { - logger.debug("Updated network: " + network.getId() + " with Network ACL Id: " + acl.getId() + ", Applying ACL items"); + s_logger.debug("Updated network: " + network.getId() + " with Network ACL Id: " + acl.getId() + ", Applying ACL items"); //Apply ACL to network Boolean result = applyACLToNetwork(network.getId()); if (result) { @@ -290,8 +292,8 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana @DB private void revokeRule(NetworkACLItemVO rule) { if (rule.getState() == State.Staged) { - if (logger.isDebugEnabled()) { - logger.debug("Found a rule that is still in stage state so just removing it: " + rule); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Found a rule that is still in stage state so just removing it: " + rule); } _networkACLItemDao.remove(rule.getId()); } else if (rule.getState() == State.Add || rule.getState() == State.Active) { @@ -308,12 +310,12 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana } List aclItems = _networkACLItemDao.listByACL(network.getNetworkACLId()); if (aclItems.isEmpty()) { - logger.debug("Found no network ACL Items for network id=" + networkId); + s_logger.debug("Found no network ACL Items for network id=" + networkId); return true; } - if (logger.isDebugEnabled()) { - logger.debug("Releasing " + aclItems.size() + " Network ACL Items for network id=" + networkId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Releasing " + aclItems.size() + " Network ACL Items for network id=" + networkId); } for (NetworkACLItemVO aclItem : aclItems) { @@ -325,8 +327,8 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana boolean success = applyACLItemsToNetwork(network.getId(), aclItems); - if (logger.isDebugEnabled() && success) { - logger.debug("Successfully released Network ACLs for network id=" + networkId + " and # of rules now = " + aclItems.size()); + if (s_logger.isDebugEnabled() && success) { + s_logger.debug("Successfully released Network ACLs for network id=" + networkId + " and # of rules now = " + aclItems.size()); } return success; @@ -337,12 +339,12 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana List aclItems = _networkACLItemDao.listByACL(gateway.getNetworkACLId()); if (aclItems.isEmpty()) { - logger.debug("Found no network ACL Items for private gateway id=" + gateway.getId()); + s_logger.debug("Found no network ACL Items for private gateway id=" + gateway.getId()); return true; } - if (logger.isDebugEnabled()) { - logger.debug("Releasing " + aclItems.size() + " Network ACL Items for private gateway id=" + gateway.getId()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Releasing " + aclItems.size() + " Network ACL Items for private gateway id=" + gateway.getId()); } for (NetworkACLItemVO aclItem : aclItems) { @@ -354,8 +356,8 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana boolean success = applyACLToPrivateGw(gateway, aclItems); - if (logger.isDebugEnabled() && success) { - logger.debug("Successfully released Network ACLs for private gateway id=" + gateway.getId() + " and # of rules now = " + aclItems.size()); + if (s_logger.isDebugEnabled() && success) { + s_logger.debug("Successfully released Network ACLs for private gateway id=" + gateway.getId() + " and # of rules now = " + aclItems.size()); } return success; @@ -396,7 +398,7 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana return provider.applyACLItemsToPrivateGw(gateway, rules); } } catch(Exception ex) { - logger.debug("Failed to apply acl to private gateway " + gateway); + s_logger.debug("Failed to apply acl to private gateway " + gateway); } return false; } @@ -486,7 +488,7 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana continue; } foundProvider = true; - logger.debug("Applying NetworkACL for network: " + network.getId() + " with Network ACL service provider"); + s_logger.debug("Applying NetworkACL for network: " + network.getId() + " with Network ACL service provider"); handled = element.applyNetworkACLs(network, rules); if (handled) { // publish message on message bus, so that network elements implementing distributed routing @@ -496,7 +498,7 @@ public class NetworkACLManagerImpl extends ManagerBase implements NetworkACLMana } } if (!foundProvider) { - logger.debug("Unable to find NetworkACL service provider for network: " + network.getId()); + s_logger.debug("Unable to find NetworkACL service provider for network: " + network.getId()); } return handled; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java b/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java index b146595..9f61f08 100644 --- a/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java +++ b/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java @@ -24,6 +24,7 @@ import javax.ejb.Local; import javax.inject.Inject; import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import org.apache.cloudstack.api.ApiErrorCode; @@ -66,6 +67,7 @@ import com.cloud.utils.net.NetUtils; @Component @Local(value = {NetworkACLService.class}) public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLService { + private static final Logger s_logger = Logger.getLogger(NetworkACLServiceImpl.class); @Inject AccountManager _accountMgr; @@ -322,7 +324,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ if (aclId == null) { //Network is not associated with any ACL. Create a new ACL and add aclItem in it for backward compatibility - logger.debug("Network " + network.getId() + " is not associated with any ACL. Creating an ACL before adding acl item"); + s_logger.debug("Network " + network.getId() + " is not associated with any ACL. Creating an ACL before adding acl item"); //verify that ACLProvider is supported by network offering if (!_networkModel.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Network.Service.NetworkACL)) { @@ -341,14 +343,14 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ if (acl == null) { throw new CloudRuntimeException("Error while create ACL before adding ACL Item for network " + network.getId()); } - logger.debug("Created ACL: " + aclName + " for network " + network.getId()); + s_logger.debug("Created ACL: " + aclName + " for network " + network.getId()); aclId = acl.getId(); //Apply acl to network try { if (!_networkAclMgr.replaceNetworkACL(acl, (NetworkVO)network)) { throw new CloudRuntimeException("Unable to apply auto created ACL to network " + network.getId()); } - logger.debug("Created ACL is applied to network " + network.getId()); + s_logger.debug("Created ACL is applied to network " + network.getId()); } catch (ResourceUnavailableException e) { throw new CloudRuntimeException("Unable to apply auto created ACL to network " + network.getId(), e); }