http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/vpc/VpcManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java index 04d0fea..2a07895 100644 --- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java +++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java @@ -48,6 +48,7 @@ import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationSe import org.apache.cloudstack.framework.config.ConfigDepot; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.managed.context.ManagedContextRunnable; +import org.apache.log4j.Logger; import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; @@ -144,6 +145,7 @@ import com.cloud.vm.dao.DomainRouterDao; @Local(value = {VpcManager.class, VpcService.class, VpcProvisioningService.class}) public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvisioningService, VpcService { + private static final Logger s_logger = Logger.getLogger(VpcManagerImpl.class); public static final String SERVICE = "service"; public static final String CAPABILITYTYPE = "capabilitytype"; @@ -250,7 +252,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis public void doInTransactionWithoutResult(final TransactionStatus status) { if (_vpcOffDao.findByUniqueName(VpcOffering.defaultVPCOfferingName) == null) { - logger.debug("Creating default VPC offering " + VpcOffering.defaultVPCOfferingName); + s_logger.debug("Creating default VPC offering " + VpcOffering.defaultVPCOfferingName); final Map<Service, Set<Provider>> svcProviderMap = new HashMap<Service, Set<Provider>>(); final Set<Provider> defaultProviders = new HashSet<Provider>(); @@ -271,7 +273,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis //configure default vpc offering with Netscaler as LB Provider if (_vpcOffDao.findByUniqueName(VpcOffering.defaultVPCNSOfferingName) == null) { - logger.debug("Creating default VPC offering with Netscaler as LB Provider" + VpcOffering.defaultVPCNSOfferingName); + s_logger.debug("Creating default VPC offering with Netscaler as LB Provider" + VpcOffering.defaultVPCNSOfferingName); final Map<Service, Set<Provider>> svcProviderMap = new HashMap<Service, Set<Provider>>(); final Set<Provider> defaultProviders = new HashSet<Provider>(); defaultProviders.add(Provider.VPCVirtualRouter); @@ -291,7 +293,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis } if (_vpcOffDao.findByUniqueName(VpcOffering.redundantVPCOfferingName) == null) { - logger.debug("Creating Redundant VPC offering " + VpcOffering.redundantVPCOfferingName); + s_logger.debug("Creating Redundant VPC offering " + VpcOffering.redundantVPCOfferingName); final Map<Service, Set<Provider>> svcProviderMap = new HashMap<Service, Set<Provider>>(); final Set<Provider> defaultProviders = new HashSet<Provider>(); @@ -381,7 +383,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis } if (service == Service.Connectivity) { - logger.debug("Applying Connectivity workaround, setting provider to NiciraNvp"); + s_logger.debug("Applying Connectivity workaround, setting provider to NiciraNvp"); svcProviderMap.put(service, sdnProviders); } else { svcProviderMap.put(service, defaultProviders); @@ -396,12 +398,12 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis } if (!sourceNatSvc) { - logger.debug("Automatically adding source nat service to the list of VPC services"); + s_logger.debug("Automatically adding source nat service to the list of VPC services"); svcProviderMap.put(Service.SourceNat, defaultProviders); } if (!firewallSvs) { - logger.debug("Automatically adding network ACL service to the list of VPC services"); + s_logger.debug("Automatically adding network ACL service to the list of VPC services"); svcProviderMap.put(Service.NetworkACL, defaultProviders); } @@ -462,7 +464,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis if (state != null) { offering.setState(state); } - logger.debug("Adding vpc offering " + offering); + s_logger.debug("Adding vpc offering " + offering); offering = _vpcOffDao.persist(offering); // populate services and providers if (svcProviderMap != null) { @@ -472,7 +474,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis for (final Network.Provider provider : providers) { final VpcOfferingServiceMapVO offService = new VpcOfferingServiceMapVO(offering.getId(), service, provider); _vpcOffSvcMapDao.persist(offService); - logger.trace("Added service for the vpc offering: " + offService + " with provider " + provider.getName()); + s_logger.trace("Added service for the vpc offering: " + offService + " with provider " + provider.getName()); } } else { throw new InvalidParameterValueException("Provider is missing for the VPC offering service " + service.getName()); @@ -752,7 +754,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis } if (_vpcOffDao.update(vpcOffId, offering)) { - logger.debug("Updated VPC offeirng id=" + vpcOffId); + s_logger.debug("Updated VPC offeirng id=" + vpcOffId); return _vpcOffDao.findById(vpcOffId); } else { return null; @@ -848,7 +850,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis final VpcVO persistedVpc = _vpcDao.persist(vpc, finalizeServicesAndProvidersForVpc(vpc.getZoneId(), vpc.getVpcOfferingId())); _resourceLimitMgr.incrementResourceCount(vpc.getAccountId(), ResourceType.vpc); - logger.debug("Created VPC " + persistedVpc); + s_logger.debug("Created VPC " + persistedVpc); return persistedVpc; } @@ -906,7 +908,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis @Override @DB public boolean destroyVpc(final Vpc vpc, final Account caller, final Long callerUserId) throws ConcurrentOperationException, ResourceUnavailableException { - logger.debug("Destroying vpc " + vpc); + s_logger.debug("Destroying vpc " + vpc); //don't allow to delete vpc if it's in use by existing non system networks (system networks are networks of a private gateway of the VPC, //and they will get removed as a part of VPC cleanup @@ -917,7 +919,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis //mark VPC as inactive if (vpc.getState() != Vpc.State.Inactive) { - logger.debug("Updating VPC " + vpc + " with state " + Vpc.State.Inactive + " as a part of vpc delete"); + s_logger.debug("Updating VPC " + vpc + " with state " + Vpc.State.Inactive + " as a part of vpc delete"); final VpcVO vpcVO = _vpcDao.findById(vpc.getId()); vpcVO.setState(Vpc.State.Inactive); @@ -934,22 +936,22 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis //shutdown VPC if (!shutdownVpc(vpc.getId())) { - logger.warn("Failed to shutdown vpc " + vpc + " as a part of vpc destroy process"); + s_logger.warn("Failed to shutdown vpc " + vpc + " as a part of vpc destroy process"); return false; } //cleanup vpc resources if (!cleanupVpcResources(vpc.getId(), caller, callerUserId)) { - logger.warn("Failed to cleanup resources for vpc " + vpc); + s_logger.warn("Failed to cleanup resources for vpc " + vpc); return false; } //update the instance with removed flag only when the cleanup is executed successfully if (_vpcDao.remove(vpc.getId())) { - logger.debug("Vpc " + vpc + " is destroyed succesfully"); + s_logger.debug("Vpc " + vpc + " is destroyed succesfully"); return true; } else { - logger.warn("Vpc " + vpc + " failed to destroy"); + s_logger.warn("Vpc " + vpc + " failed to destroy"); return false; } } @@ -987,7 +989,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis } if (_vpcDao.update(vpcId, vpc)) { - logger.debug("Updated VPC id=" + vpcId); + s_logger.debug("Updated VPC id=" + vpcId); return _vpcDao.findById(vpcId); } else { return null; @@ -1176,20 +1178,20 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis boolean result = true; try { if (!startVpc(vpc, dest, context)) { - logger.warn("Failed to start vpc " + vpc); + s_logger.warn("Failed to start vpc " + vpc); result = false; } } catch (final Exception ex) { - logger.warn("Failed to start vpc " + vpc + " due to ", ex); + s_logger.warn("Failed to start vpc " + vpc + " due to ", ex); result = false; } finally { //do cleanup if (!result && destroyOnFailure) { - logger.debug("Destroying vpc " + vpc + " that failed to start"); + s_logger.debug("Destroying vpc " + vpc + " that failed to start"); if (destroyVpc(vpc, caller, callerUser.getId())) { - logger.warn("Successfully destroyed vpc " + vpc + " that failed to start"); + s_logger.warn("Successfully destroyed vpc " + vpc + " that failed to start"); } else { - logger.warn("Failed to destroy vpc " + vpc + " that failed to start"); + s_logger.warn("Failed to destroy vpc " + vpc + " that failed to start"); } } } @@ -1204,9 +1206,9 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis for (final VpcProvider element : getVpcElements()) { if (providersToImplement.contains(element.getProvider())) { if (element.implementVpc(vpc, dest, context)) { - logger.debug("Vpc " + vpc + " has started succesfully"); + s_logger.debug("Vpc " + vpc + " has started succesfully"); } else { - logger.warn("Vpc " + vpc + " failed to start"); + s_logger.warn("Vpc " + vpc + " failed to start"); success = false; } } @@ -1229,7 +1231,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis _accountMgr.checkAccess(caller, null, false, vpc); //shutdown provider - logger.debug("Shutting down vpc " + vpc); + s_logger.debug("Shutting down vpc " + vpc); //TODO - shutdown all vpc resources here (ACLs, gateways, etc) boolean success = true; @@ -1238,9 +1240,9 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis for (final VpcProvider element : getVpcElements()) { if (providersToImplement.contains(element.getProvider())) { if (element.shutdownVpc(vpc, context)) { - logger.debug("Vpc " + vpc + " has been shutdown succesfully"); + s_logger.debug("Vpc " + vpc + " has been shutdown succesfully"); } else { - logger.warn("Vpc " + vpc + " failed to shutdown"); + s_logger.warn("Vpc " + vpc + " failed to shutdown"); success = false; } } @@ -1394,7 +1396,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis throw new InvalidParameterValueException("Invalid gateway specified. It should never be equal to the cidr subnet value"); } } finally { - logger.debug("Releasing lock for " + locked); + s_logger.debug("Releasing lock for " + locked); _vpcDao.releaseFromLockTable(locked.getId()); } } @@ -1423,18 +1425,18 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis } public boolean cleanupVpcResources(final long vpcId, final Account caller, final long callerUserId) throws ResourceUnavailableException, ConcurrentOperationException { - logger.debug("Cleaning up resources for vpc id=" + vpcId); + s_logger.debug("Cleaning up resources for vpc id=" + vpcId); boolean success = true; //1) Remove VPN connections and VPN gateway - logger.debug("Cleaning up existed site to site VPN connections"); + s_logger.debug("Cleaning up existed site to site VPN connections"); _s2sVpnMgr.cleanupVpnConnectionByVpc(vpcId); - logger.debug("Cleaning up existed site to site VPN gateways"); + s_logger.debug("Cleaning up existed site to site VPN gateways"); _s2sVpnMgr.cleanupVpnGatewayByVpc(vpcId); //2) release all ip addresses final List<IPAddressVO> ipsToRelease = _ipAddressDao.listByAssociatedVpc(vpcId, null); - logger.debug("Releasing ips for vpc id=" + vpcId + " as a part of vpc cleanup"); + s_logger.debug("Releasing ips for vpc id=" + vpcId + " as a part of vpc cleanup"); for (final IPAddressVO ipToRelease : ipsToRelease) { if (ipToRelease.isPortable()) { // portable IP address are associated with owner, until explicitly requested to be disassociated. @@ -1442,25 +1444,25 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis ipToRelease.setVpcId(null); ipToRelease.setAssociatedWithNetworkId(null); _ipAddressDao.update(ipToRelease.getId(), ipToRelease); - logger.debug("Portable IP address " + ipToRelease + " is no longer associated with any VPC"); + s_logger.debug("Portable IP address " + ipToRelease + " is no longer associated with any VPC"); } else { success = success && _ipAddrMgr.disassociatePublicIpAddress(ipToRelease.getId(), callerUserId, caller); if (!success) { - logger.warn("Failed to cleanup ip " + ipToRelease + " as a part of vpc id=" + vpcId + " cleanup"); + s_logger.warn("Failed to cleanup ip " + ipToRelease + " as a part of vpc id=" + vpcId + " cleanup"); } } } if (success) { - logger.debug("Released ip addresses for vpc id=" + vpcId + " as a part of cleanup vpc process"); + s_logger.debug("Released ip addresses for vpc id=" + vpcId + " as a part of cleanup vpc process"); } else { - logger.warn("Failed to release ip addresses for vpc id=" + vpcId + " as a part of cleanup vpc process"); + s_logger.warn("Failed to release ip addresses for vpc id=" + vpcId + " as a part of cleanup vpc process"); //although it failed, proceed to the next cleanup step as it doesn't depend on the public ip release } //3) Delete all static route rules if (!revokeStaticRoutesForVpc(vpcId, caller)) { - logger.warn("Failed to revoke static routes for vpc " + vpcId + " as a part of cleanup vpc process"); + s_logger.warn("Failed to revoke static routes for vpc " + vpcId + " as a part of cleanup vpc process"); return false; } @@ -1469,12 +1471,12 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis if (gateways != null) { for (final PrivateGateway gateway : gateways) { if (gateway != null) { - logger.debug("Deleting private gateway " + gateway + " as a part of vpc " + vpcId + " resources cleanup"); + s_logger.debug("Deleting private gateway " + gateway + " as a part of vpc " + vpcId + " resources cleanup"); if (!deleteVpcPrivateGateway(gateway.getId())) { success = false; - logger.debug("Failed to delete private gateway " + gateway + " as a part of vpc " + vpcId + " resources cleanup"); + s_logger.debug("Failed to delete private gateway " + gateway + " as a part of vpc " + vpcId + " resources cleanup"); } else { - logger.debug("Deleted private gateway " + gateway + " as a part of vpc " + vpcId + " resources cleanup"); + s_logger.debug("Deleted private gateway " + gateway + " as a part of vpc " + vpcId + " resources cleanup"); } } } @@ -1500,7 +1502,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis _accountMgr.checkAccess(caller, null, false, vpc); - logger.debug("Restarting VPC " + vpc); + s_logger.debug("Restarting VPC " + vpc); boolean restartRequired = false; try { @@ -1520,26 +1522,26 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis } if (forceCleanup) { - logger.debug("Shutting down VPC " + vpc + " as a part of VPC restart process"); + s_logger.debug("Shutting down VPC " + vpc + " as a part of VPC restart process"); if (!shutdownVpc(vpcId)) { - logger.warn("Failed to shutdown vpc as a part of VPC " + vpc + " restart process"); + s_logger.warn("Failed to shutdown vpc as a part of VPC " + vpc + " restart process"); restartRequired = true; return false; } } else { - logger.info("Will not shutdown vpc as a part of VPC " + vpc + " restart process."); + s_logger.info("Will not shutdown vpc as a part of VPC " + vpc + " restart process."); } - logger.debug("Starting VPC " + vpc + " as a part of VPC restart process"); + s_logger.debug("Starting VPC " + vpc + " as a part of VPC restart process"); if (!startVpc(vpcId, false)) { - logger.warn("Failed to start vpc as a part of VPC " + vpc + " restart process"); + s_logger.warn("Failed to start vpc as a part of VPC " + vpc + " restart process"); restartRequired = true; return false; } - logger.debug("VPC " + vpc + " was restarted successfully"); + s_logger.debug("VPC " + vpc + " was restarted successfully"); return true; } finally { - logger.debug("Updating VPC " + vpc + " with restartRequired=" + restartRequired); + s_logger.debug("Updating VPC " + vpc + " with restartRequired=" + restartRequired); final VpcVO vo = _vpcDao.findById(vpcId); vo.setRestartRequired(restartRequired); _vpcDao.update(vpc.getId(), vo); @@ -1615,7 +1617,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis @Override public VpcGatewayVO doInTransaction(final TransactionStatus status) throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException { - logger.debug("Creating Private gateway for VPC " + vpc); + s_logger.debug("Creating Private gateway for VPC " + vpc); //1) create private network unless it is existing and lswitch'd Network privateNtwk = null; if (BroadcastDomainType.getSchemeValue(BroadcastDomainType.fromString(broadcastUri)) == BroadcastDomainType.Lswitch) { @@ -1624,13 +1626,13 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis // if the dcid is different we get no network so next we try to create it } if (privateNtwk == null) { - logger.info("creating new network for vpc " + vpc + " using broadcast uri: " + broadcastUri); + s_logger.info("creating new network for vpc " + vpc + " using broadcast uri: " + broadcastUri); final String networkName = "vpc-" + vpc.getName() + "-privateNetwork"; privateNtwk = _ntwkSvc.createPrivateNetwork(networkName, networkName, physicalNetworkIdFinal, broadcastUri, ipAddress, null, gateway, netmask, gatewayOwnerId, vpcId, isSourceNat, networkOfferingId); } else { // create the nic/ip as createPrivateNetwork doesn''t do that work for us now - logger.info("found and using existing network for vpc " + vpc + ": " + broadcastUri); + s_logger.info("found and using existing network for vpc " + vpc + ": " + broadcastUri); final DataCenterVO dc = _dcDao.lockRow(physNetFinal.getDataCenterId(), true); //add entry to private_ip_address table @@ -1644,7 +1646,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis final Long nextMac = mac + 1; dc.setMacAddress(nextMac); - logger.info("creating private ip adress for vpc (" + ipAddress + ", " + privateNtwk.getId() + ", " + nextMac + ", " + vpcId + ", " + isSourceNat + ")"); + s_logger.info("creating private ip adress for vpc (" + ipAddress + ", " + privateNtwk.getId() + ", " + nextMac + ", " + vpcId + ", " + isSourceNat + ")"); privateIp = new PrivateIpVO(ipAddress, privateNtwk.getId(), nextMac, vpcId, isSourceNat); _privateIpDao.persist(privateIp); @@ -1682,7 +1684,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis vpc.getAccountId(), vpc.getDomainId(), isSourceNat, networkAclId); _vpcGatewayDao.persist(gatewayVO); - logger.debug("Created vpc gateway entry " + gatewayVO); + s_logger.debug("Created vpc gateway entry " + gatewayVO); return gatewayVO; } @@ -1716,28 +1718,28 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis } } if (success) { - logger.debug("Private gateway " + gateway + " was applied succesfully on the backend"); + s_logger.debug("Private gateway " + gateway + " was applied succesfully on the backend"); if (vo.getState() != VpcGateway.State.Ready) { vo.setState(VpcGateway.State.Ready); _vpcGatewayDao.update(vo.getId(), vo); - logger.debug("Marke gateway " + gateway + " with state " + VpcGateway.State.Ready); + s_logger.debug("Marke gateway " + gateway + " with state " + VpcGateway.State.Ready); } CallContext.current().setEventDetails("Private Gateway Id: " + gatewayId); return getVpcPrivateGateway(gatewayId); } else { - logger.warn("Private gateway " + gateway + " failed to apply on the backend"); + s_logger.warn("Private gateway " + gateway + " failed to apply on the backend"); return null; } } finally { //do cleanup if (!success) { if (destroyOnFailure) { - logger.debug("Destroying private gateway " + vo + " that failed to start"); + s_logger.debug("Destroying private gateway " + vo + " that failed to start"); // calling deleting from db because on createprivategateway fail, destroyPrivateGateway is already called if (deletePrivateGatewayFromTheDB(getVpcPrivateGateway(gatewayId))) { - logger.warn("Successfully destroyed vpc " + vo + " that failed to start"); + s_logger.warn("Successfully destroyed vpc " + vo + " that failed to start"); } else { - logger.warn("Failed to destroy vpc " + vo + " that failed to start"); + s_logger.warn("Failed to destroy vpc " + vo + " that failed to start"); } } } @@ -1767,7 +1769,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis gatewayVO.setState(VpcGateway.State.Deleting); _vpcGatewayDao.update(gatewayVO.getId(), gatewayVO); - logger.debug("Marked gateway " + gatewayVO + " with state " + VpcGateway.State.Deleting); + s_logger.debug("Marked gateway " + gatewayVO + " with state " + VpcGateway.State.Deleting); } }); @@ -1777,12 +1779,12 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis for (final VpcProvider provider : getVpcElements()) { if (providersToImplement.contains(provider.getProvider())) { if (provider.deletePrivateGateway(gateway)) { - logger.debug("Private gateway " + gateway + " was applied succesfully on the backend"); + s_logger.debug("Private gateway " + gateway + " was applied succesfully on the backend"); } else { - logger.warn("Private gateway " + gateway + " failed to apply on the backend"); + s_logger.warn("Private gateway " + gateway + " failed to apply on the backend"); gatewayVO.setState(VpcGateway.State.Ready); _vpcGatewayDao.update(gatewayVO.getId(), gatewayVO); - logger.debug("Marked gateway " + gatewayVO + " with state " + VpcGateway.State.Ready); + s_logger.debug("Marked gateway " + gatewayVO + " with state " + VpcGateway.State.Ready); return false; } @@ -1817,12 +1819,12 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis final Account owner = _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM); final ReservationContext context = new ReservationContextImpl(null, null, callerUser, owner); _ntwkMgr.destroyNetwork(networkId, context, false); - logger.debug("Deleted private network id=" + networkId); + s_logger.debug("Deleted private network id=" + networkId); } } catch (final InterruptedException e) { - logger.error("deletePrivateGatewayFromTheDB failed to delete network id " + networkId + "due to => ", e); + s_logger.error("deletePrivateGatewayFromTheDB failed to delete network id " + networkId + "due to => ", e); } catch (final ExecutionException e) { - logger.error("deletePrivateGatewayFromTheDB failed to delete network id " + networkId + "due to => ", e); + s_logger.error("deletePrivateGatewayFromTheDB failed to delete network id " + networkId + "due to => ", e); } return true; @@ -1916,19 +1918,19 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis staticRouteProfiles.add(new StaticRouteProfile(route, gateway)); } if (!applyStaticRoutes(staticRouteProfiles)) { - logger.warn("Routes are not completely applied"); + s_logger.warn("Routes are not completely applied"); return false; } else { if (updateRoutesInDB) { for (final StaticRoute route : routes) { if (route.getState() == StaticRoute.State.Revoke) { _staticRouteDao.remove(route.getId()); - logger.debug("Removed route " + route + " from the DB"); + s_logger.debug("Removed route " + route + " from the DB"); } else if (route.getState() == StaticRoute.State.Add) { final StaticRouteVO ruleVO = _staticRouteDao.findById(route.getId()); ruleVO.setState(StaticRoute.State.Active); _staticRouteDao.update(ruleVO.getId(), ruleVO); - logger.debug("Marked route " + route + " with state " + StaticRoute.State.Active); + s_logger.debug("Marked route " + route + " with state " + StaticRoute.State.Active); } } } @@ -1939,12 +1941,12 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis protected boolean applyStaticRoutes(final List<StaticRouteProfile> routes) throws ResourceUnavailableException { if (routes.isEmpty()) { - logger.debug("No static routes to apply"); + s_logger.debug("No static routes to apply"); return true; } final Vpc vpc = _vpcDao.findById(routes.get(0).getVpcId()); - logger.debug("Applying static routes for vpc " + vpc); + s_logger.debug("Applying static routes for vpc " + vpc); final String staticNatProvider = _vpcSrvcDao.getProviderForServiceInVpc(vpc.getId(), Service.StaticNat); for (final VpcProvider provider : getVpcElements()) { @@ -1953,9 +1955,9 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis } if (provider.applyStaticRoutes(vpc, routes)) { - logger.debug("Applied static routes for vpc " + vpc); + s_logger.debug("Applied static routes for vpc " + vpc); } else { - logger.warn("Failed to apply static routes for vpc " + vpc); + s_logger.warn("Failed to apply static routes for vpc " + vpc); return false; } } @@ -1984,7 +1986,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis protected boolean revokeStaticRoutesForVpc(final long vpcId, final Account caller) throws ResourceUnavailableException { //get all static routes for the vpc final List<StaticRouteVO> routes = _staticRouteDao.listByVpcId(vpcId); - logger.debug("Found " + routes.size() + " to revoke for the vpc " + vpcId); + s_logger.debug("Found " + routes.size() + " to revoke for the vpc " + vpcId); if (!routes.isEmpty()) { //mark all of them as revoke Transaction.execute(new TransactionCallbackNoReturn() { @@ -2047,7 +2049,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis @Override public StaticRouteVO doInTransaction(final TransactionStatus status) throws NetworkRuleConflictException { StaticRouteVO newRoute = new StaticRouteVO(gateway.getId(), cidr, vpc.getId(), vpc.getAccountId(), vpc.getDomainId()); - logger.debug("Adding static route " + newRoute); + s_logger.debug("Adding static route " + newRoute); newRoute = _staticRouteDao.persist(newRoute); detectRoutesConflict(newRoute); @@ -2168,20 +2170,20 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis } protected void markStaticRouteForRevoke(final StaticRouteVO route, final Account caller) { - logger.debug("Revoking static route " + route); + s_logger.debug("Revoking static route " + route); if (caller != null) { _accountMgr.checkAccess(caller, null, false, route); } if (route.getState() == StaticRoute.State.Staged) { - if (logger.isDebugEnabled()) { - logger.debug("Found a static route that is still in stage state so just removing it: " + route); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Found a static route that is still in stage state so just removing it: " + route); } _staticRouteDao.remove(route.getId()); } else if (route.getState() == StaticRoute.State.Add || route.getState() == StaticRoute.State.Active) { route.setState(StaticRoute.State.Revoke); _staticRouteDao.update(route.getId(), route); - logger.debug("Marked static route " + route + " with state " + StaticRoute.State.Revoke); + s_logger.debug("Marked static route " + route + " with state " + StaticRoute.State.Revoke); } } @@ -2191,12 +2193,12 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis try { final GlobalLock lock = GlobalLock.getInternLock("VpcCleanup"); if (lock == null) { - logger.debug("Couldn't get the global lock"); + s_logger.debug("Couldn't get the global lock"); return; } if (!lock.lock(30)) { - logger.debug("Couldn't lock the db"); + s_logger.debug("Couldn't lock the db"); return; } @@ -2204,19 +2206,19 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis // Cleanup inactive VPCs final List<VpcVO> inactiveVpcs = _vpcDao.listInactiveVpcs(); if (inactiveVpcs != null) { - logger.info("Found " + inactiveVpcs.size() + " removed VPCs to cleanup"); + s_logger.info("Found " + inactiveVpcs.size() + " removed VPCs to cleanup"); for (final VpcVO vpc : inactiveVpcs) { - logger.debug("Cleaning up " + vpc); + s_logger.debug("Cleaning up " + vpc); destroyVpc(vpc, _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM), User.UID_SYSTEM); } } } catch (final Exception e) { - logger.error("Exception ", e); + s_logger.error("Exception ", e); } finally { lock.unlock(); } } catch (final Exception e) { - logger.error("Exception ", e); + s_logger.error("Exception ", e); } } } @@ -2234,7 +2236,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis _accountMgr.checkAccess(caller, null, true, ipToAssoc); 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; } @@ -2251,7 +2253,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis isSourceNat = true; } - logger.debug("Associating ip " + ipToAssoc + " to vpc " + vpc); + s_logger.debug("Associating ip " + ipToAssoc + " to vpc " + vpc); final boolean isSourceNatFinal = isSourceNat; Transaction.execute(new TransactionCallbackNoReturn() { @@ -2269,7 +2271,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis } }); - logger.debug("Successfully assigned ip " + ipToAssoc + " to vpc " + vpc); + s_logger.debug("Successfully assigned ip " + ipToAssoc + " to vpc " + vpc); return _ipAddressDao.findById(ipId); } @@ -2285,7 +2287,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis return; } - logger.debug("Releasing VPC ip address " + ip + " from vpc network id=" + networkId); + s_logger.debug("Releasing VPC ip address " + ip + " from vpc network id=" + networkId); final long vpcId = ip.getVpcId(); boolean success = false; @@ -2299,11 +2301,11 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis if (success) { ip.setAssociatedWithNetworkId(null); _ipAddressDao.update(ipId, ip); - logger.debug("IP address " + ip + " is no longer associated with the network inside vpc id=" + vpcId); + s_logger.debug("IP address " + ip + " is no longer associated with the network inside vpc id=" + vpcId); } else { throw new CloudRuntimeException("Failed to apply ip associations for network id=" + networkId + " as a part of unassigning ip " + ipId + " from vpc"); } - logger.debug("Successfully released VPC ip address " + ip + " back to VPC pool "); + s_logger.debug("Successfully released VPC ip address " + ip + " back to VPC pool "); } @Override
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java index cdd0986..3c0188d 100644 --- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java +++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java @@ -25,6 +25,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.apache.cloudstack.acl.SecurityChecker.AccessType; import org.apache.cloudstack.api.command.user.vpn.ListRemoteAccessVpnsCmd; @@ -93,6 +94,7 @@ import com.cloud.utils.net.NetUtils; @Local(value = RemoteAccessVpnService.class) public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAccessVpnService, Configurable { + private final static Logger s_logger = Logger.getLogger(RemoteAccessVpnManagerImpl.class); static final ConfigKey<String> RemoteAccessVpnClientIpRange = new ConfigKey<String>("Network", String.class, RemoteAccessVpnClientIpRangeCK, "10.1.2.1-10.1.2.8", "The range of ips to be allocated to remote access vpn clients. The first ip in the range is used by the VPN server", false, ConfigKey.Scope.Account); @@ -258,7 +260,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc private void validateRemoteAccessVpnConfiguration() throws ConfigurationException { String ipRange = RemoteAccessVpnClientIpRange.value(); if (ipRange == null) { - logger.warn("Remote Access VPN global configuration missing client ip range -- ignoring"); + s_logger.warn("Remote Access VPN global configuration missing client ip range -- ignoring"); return; } Integer pskLength = _pskLength; @@ -284,7 +286,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc public boolean destroyRemoteAccessVpnForIp(long ipId, Account caller) throws ResourceUnavailableException { final RemoteAccessVpnVO vpn = _remoteAccessVpnDao.findByPublicIpAddress(ipId); if (vpn == null) { - logger.debug("there are no Remote access vpns for public ip address id=" + ipId); + s_logger.debug("there are no Remote access vpns for public ip address id=" + ipId); return true; } @@ -305,7 +307,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc }catch (ResourceUnavailableException ex) { vpn.setState(prevState); _remoteAccessVpnDao.update(vpn.getId(), vpn); - logger.debug("Failed to stop the vpn " + vpn.getId() + " , so reverted state to "+ + s_logger.debug("Failed to stop the vpn " + vpn.getId() + " , so reverted state to "+ RemoteAccessVpn.State.Running); success = false; } finally { @@ -330,12 +332,12 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc fwRules.add(_rulesDao.findByRelatedId(vpnFwRule.getId())); } - logger.debug("Marked " + fwRules.size() + " firewall rules as Revoked as a part of disable remote access vpn"); + s_logger.debug("Marked " + fwRules.size() + " firewall rules as Revoked as a part of disable remote access vpn"); } }); //now apply vpn rules on the backend - logger.debug("Reapplying firewall rules for ip id=" + ipId + " as a part of disable remote access vpn"); + s_logger.debug("Reapplying firewall rules for ip id=" + ipId + " as a part of disable remote access vpn"); success = _firewallMgr.applyIngressFirewallRules(ipId, caller); } @@ -357,14 +359,14 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc if (vpnFwRules != null) { for (FirewallRule vpnFwRule : vpnFwRules) { _rulesDao.remove(vpnFwRule.getId()); - logger.debug("Successfully removed firewall rule with ip id=" + vpnFwRule.getSourceIpAddressId() + " and port " + + s_logger.debug("Successfully removed firewall rule with ip id=" + vpnFwRule.getSourceIpAddressId() + " and port " + vpnFwRule.getSourcePortStart().intValue() + " as a part of vpn cleanup"); } } } }); } catch (Exception ex) { - logger.warn("Unable to release the three vpn ports from the firewall rules", ex); + s_logger.warn("Unable to release the three vpn ports from the firewall rules", ex); } } } @@ -506,7 +508,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc Account owner = _accountDao.findById(vpnOwnerId); _accountMgr.checkAccess(caller, null, true, owner); - logger.debug("Applying vpn users for " + owner); + s_logger.debug("Applying vpn users for " + owner); List<RemoteAccessVpnVO> vpns = _remoteAccessVpnDao.findByAccount(vpnOwnerId); List<VpnUserVO> users = _vpnUsersDao.listByAccount(vpnOwnerId); @@ -523,13 +525,13 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc boolean[] finals = new boolean[users.size()]; for (RemoteAccessVPNServiceProvider element : _vpnServiceProviders) { - logger.debug("Applying vpn access to " + element.getName()); + s_logger.debug("Applying vpn access to " + element.getName()); for (RemoteAccessVpnVO vpn : vpns) { try { String[] results = element.applyVpnUsers(vpn, users); if (results != null) { for (int i = 0; i < results.length; i++) { - logger.debug("VPN User " + users.get(i) + (results[i] == null ? " is set on " : (" couldn't be set due to " + results[i]) + " on ") + vpn); + s_logger.debug("VPN User " + users.get(i) + (results[i] == null ? " is set on " : (" couldn't be set due to " + results[i]) + " on ") + vpn); if (results[i] == null) { if (!finals[i]) { finals[i] = true; @@ -541,7 +543,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc } } } catch (Exception e) { - logger.warn("Unable to apply vpn users ", e); + s_logger.warn("Unable to apply vpn users ", e); success = false; for (int i = 0; i < finals.length; i++) { @@ -571,7 +573,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc } }); } - logger.warn("Failed to apply vpn for user " + user.getUsername() + ", accountId=" + user.getAccountId()); + s_logger.warn("Failed to apply vpn for user " + user.getUsername() + ", accountId=" + user.getAccountId()); } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java b/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java index f8d4fe7..bf4b8a3 100644 --- a/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java +++ b/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java @@ -24,6 +24,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import org.apache.cloudstack.api.command.user.vpn.CreateVpnConnectionCmd; @@ -82,6 +83,7 @@ import com.cloud.vm.DomainRouterVO; @Component @Local(value = {Site2SiteVpnManager.class, Site2SiteVpnService.class}) public class Site2SiteVpnManagerImpl extends ManagerBase implements Site2SiteVpnManager { + private static final Logger s_logger = Logger.getLogger(Site2SiteVpnManagerImpl.class); List<Site2SiteVpnServiceProvider> _s2sProviders; @Inject @@ -784,7 +786,7 @@ public class Site2SiteVpnManagerImpl extends ManagerBase implements Site2SiteVpn startVpnConnection(conn.getId()); } catch (ResourceUnavailableException e) { Site2SiteCustomerGatewayVO gw = _customerGatewayDao.findById(conn.getCustomerGatewayId()); - logger.warn("Site2SiteVpnManager: Fail to re-initiate VPN connection " + conn.getId() + " which connect to " + gw.getName()); + s_logger.warn("Site2SiteVpnManager: Fail to re-initiate VPN connection " + conn.getId() + " which connect to " + gw.getName()); } } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/projects/ProjectManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/projects/ProjectManagerImpl.java b/server/src/com/cloud/projects/ProjectManagerImpl.java index ff80fd3..510b55c 100644 --- a/server/src/com/cloud/projects/ProjectManagerImpl.java +++ b/server/src/com/cloud/projects/ProjectManagerImpl.java @@ -39,6 +39,7 @@ import javax.mail.URLName; import javax.mail.internet.InternetAddress; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.sun.mail.smtp.SMTPMessage; @@ -94,6 +95,7 @@ import com.cloud.utils.exception.CloudRuntimeException; @Component @Local(value = {ProjectService.class, ProjectManager.class}) public class ProjectManagerImpl extends ManagerBase implements ProjectManager { + public static final Logger s_logger = Logger.getLogger(ProjectManagerImpl.class); private EmailInvite _emailInvite; @Inject @@ -274,7 +276,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { boolean updateResult = Transaction.execute(new TransactionCallback<Boolean>() { @Override public Boolean doInTransaction(TransactionStatus status) { - logger.debug("Marking project id=" + project.getId() + " with state " + State.Disabled + " as a part of project delete..."); + s_logger.debug("Marking project id=" + project.getId() + " with state " + State.Disabled + " as a part of project delete..."); project.setState(State.Disabled); boolean updateResult = _projectDao.update(project.getId(), project); //owner can be already removed at this point, so adding the conditional check @@ -290,13 +292,13 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { if (updateResult) { //pass system caller when clenaup projects account if (!cleanupProject(project, _accountDao.findById(Account.ACCOUNT_ID_SYSTEM), User.UID_SYSTEM)) { - logger.warn("Failed to cleanup project's id=" + project.getId() + " resources, not removing the project yet"); + s_logger.warn("Failed to cleanup project's id=" + project.getId() + " resources, not removing the project yet"); return false; } else { return _projectDao.remove(project.getId()); } } else { - logger.warn("Failed to mark the project id=" + project.getId() + " with state " + State.Disabled); + s_logger.warn("Failed to mark the project id=" + project.getId() + " with state " + State.Disabled); return false; } } @@ -306,7 +308,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { boolean result = true; //Delete project's account AccountVO account = _accountDao.findById(project.getProjectAccountId()); - logger.debug("Deleting projects " + project + " internal account id=" + account.getId() + " as a part of project cleanup..."); + s_logger.debug("Deleting projects " + project + " internal account id=" + account.getId() + " as a part of project cleanup..."); result = result && _accountMgr.deleteAccount(account, callerUserId, caller); @@ -316,23 +318,23 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { @Override public Boolean doInTransaction(TransactionStatus status) { boolean result = true; - logger.debug("Unassigning all accounts from project " + project + " as a part of project cleanup..."); + s_logger.debug("Unassigning all accounts from project " + project + " as a part of project cleanup..."); List<? extends ProjectAccount> projectAccounts = _projectAccountDao.listByProjectId(project.getId()); for (ProjectAccount projectAccount : projectAccounts) { result = result && unassignAccountFromProject(projectAccount.getProjectId(), projectAccount.getAccountId()); } - logger.debug("Removing all invitations for the project " + project + " as a part of project cleanup..."); + s_logger.debug("Removing all invitations for the project " + project + " as a part of project cleanup..."); _projectInvitationDao.cleanupInvitations(project.getId()); return result; } }); if (result) { - logger.debug("Accounts are unassign successfully from project " + project + " as a part of project cleanup..."); + s_logger.debug("Accounts are unassign successfully from project " + project + " as a part of project cleanup..."); } } else { - logger.warn("Failed to cleanup project's internal account"); + s_logger.warn("Failed to cleanup project's internal account"); } return result; @@ -342,14 +344,14 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { public boolean unassignAccountFromProject(long projectId, long accountId) { ProjectAccountVO projectAccount = _projectAccountDao.findByProjectIdAccountId(projectId, accountId); if (projectAccount == null) { - logger.debug("Account id=" + accountId + " is not assigned to project id=" + projectId + " so no need to unassign"); + s_logger.debug("Account id=" + accountId + " is not assigned to project id=" + projectId + " so no need to unassign"); return true; } if (_projectAccountDao.remove(projectAccount.getId())) { return true; } else { - logger.warn("Failed to unassign account id=" + accountId + " from the project id=" + projectId); + s_logger.warn("Failed to unassign account id=" + accountId + " from the project id=" + projectId); return false; } } @@ -383,7 +385,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { //remove all invitations for account if (success) { - logger.debug("Removed account " + accountId + " from project " + projectId + " , cleaning up old invitations for account/project..."); + s_logger.debug("Removed account " + accountId + " from project " + projectId + " , cleaning up old invitations for account/project..."); ProjectInvitation invite = _projectInvitationDao.findByAccountIdProjectId(accountId, projectId); if (invite != null) { success = success && _projectInvitationDao.remove(invite.getId()); @@ -500,7 +502,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { _resourceLimitMgr.incrementResourceCount(futureOwnerAccount.getId(), ResourceType.project); } else { - logger.trace("Future owner " + newOwnerName + "is already the owner of the project id=" + projectId); + s_logger.trace("Future owner " + newOwnerName + "is already the owner of the project id=" + projectId); } } } @@ -553,7 +555,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { //Check if the account already added to the project ProjectAccount projectAccount = _projectAccountDao.findByProjectIdAccountId(projectId, account.getId()); if (projectAccount != null) { - logger.debug("Account " + accountName + " already added to the project id=" + projectId); + s_logger.debug("Account " + accountName + " already added to the project id=" + projectId); return true; } } @@ -567,7 +569,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { if (assignAccountToProject(project, account.getId(), ProjectAccount.Role.Regular) != null) { return true; } else { - logger.warn("Failed to add account " + accountName + " to project id=" + projectId); + s_logger.warn("Failed to add account " + accountName + " to project id=" + projectId); return false; } } @@ -578,7 +580,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { if (createAccountInvitation(project, account.getId()) != null) { return true; } else { - logger.warn("Failed to generate invitation for account " + account.getAccountName() + " to project id=" + project); + s_logger.warn("Failed to generate invitation for account " + account.getAccountName() + " to project id=" + project); return false; } } @@ -589,7 +591,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { if (generateTokenBasedInvitation(project, email, token) != null) { return true; } else { - logger.warn("Failed to generate invitation for email " + email + " to project id=" + project); + s_logger.warn("Failed to generate invitation for email " + email + " to project id=" + project); return false; } } @@ -682,9 +684,9 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { } //remove the expired/declined invitation if (accountId != null) { - logger.debug("Removing invitation in state " + invite.getState() + " for account id=" + accountId + " to project " + project); + s_logger.debug("Removing invitation in state " + invite.getState() + " for account id=" + accountId + " to project " + project); } else if (email != null) { - logger.debug("Removing invitation in state " + invite.getState() + " for email " + email + " to project " + project); + s_logger.debug("Removing invitation in state " + invite.getState() + " for email " + email + " to project " + project); } _projectInvitationDao.expunge(invite.getId()); @@ -706,7 +708,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { try { _emailInvite.sendInvite(token, email, project.getId()); } catch (Exception ex) { - logger.warn("Failed to send project id=" + project + " invitation to the email " + email + "; removing the invitation record from the db", ex); + s_logger.warn("Failed to send project id=" + project + " invitation to the email " + email + "; removing the invitation record from the db", ex); _projectInvitationDao.remove(projectInvitation.getId()); return null; } @@ -715,7 +717,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { } private boolean expireInvitation(ProjectInvitationVO invite) { - logger.debug("Expiring invitation id=" + invite.getId()); + s_logger.debug("Expiring invitation id=" + invite.getId()); invite.setState(ProjectInvitation.State.Expired); return _projectInvitationDao.update(invite.getId(), invite); } @@ -780,7 +782,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { ProjectInvitation.State newState = accept ? ProjectInvitation.State.Completed : ProjectInvitation.State.Declined; //update invitation - logger.debug("Marking invitation " + inviteFinal + " with state " + newState); + s_logger.debug("Marking invitation " + inviteFinal + " with state " + newState); inviteFinal.setState(newState); result = _projectInvitationDao.update(inviteFinal.getId(), inviteFinal); @@ -788,12 +790,12 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { //check if account already exists for the project (was added before invitation got accepted) ProjectAccount projectAccount = _projectAccountDao.findByProjectIdAccountId(projectId, accountIdFinal); if (projectAccount != null) { - logger.debug("Account " + accountNameFinal + " already added to the project id=" + projectId); + s_logger.debug("Account " + accountNameFinal + " already added to the project id=" + projectId); } else { assignAccountToProject(project, accountIdFinal, ProjectAccount.Role.Regular); } } else { - logger.warn("Failed to update project invitation " + inviteFinal + " with state " + newState); + s_logger.warn("Failed to update project invitation " + inviteFinal + " with state " + newState); } return result; @@ -834,7 +836,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { Project.State currentState = project.getState(); if (currentState == State.Active) { - logger.debug("The project id=" + projectId + " is already active, no need to activate it again"); + s_logger.debug("The project id=" + projectId + " is already active, no need to activate it again"); return project; } @@ -871,7 +873,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { _accountMgr.checkAccess(caller, AccessType.ModifyProject, true, _accountMgr.getAccount(project.getProjectAccountId())); if (suspendProject(project)) { - logger.debug("Successfully suspended project id=" + projectId); + s_logger.debug("Successfully suspended project id=" + projectId); return _projectDao.findById(projectId); } else { CloudRuntimeException ex = new CloudRuntimeException("Failed to suspend project with specified id"); @@ -883,14 +885,14 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { private boolean suspendProject(ProjectVO project) throws ConcurrentOperationException, ResourceUnavailableException { - logger.debug("Marking project " + project + " with state " + State.Suspended + " as a part of project suspend..."); + s_logger.debug("Marking project " + project + " with state " + State.Suspended + " as a part of project suspend..."); project.setState(State.Suspended); boolean updateResult = _projectDao.update(project.getId(), project); if (updateResult) { long projectAccountId = project.getProjectAccountId(); if (!_accountMgr.disableAccount(projectAccountId)) { - logger.warn("Failed to suspend all project's " + project + " resources; the resources will be suspended later by background thread"); + s_logger.warn("Failed to suspend all project's " + project + " resources; the resources will be suspended later by background thread"); } } else { throw new CloudRuntimeException("Failed to mark the project " + project + " with state " + State.Suspended); @@ -965,7 +967,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { try { address = new InternetAddress(email, email); } catch (Exception ex) { - logger.error("Exception creating address for: " + email, ex); + s_logger.error("Exception creating address for: " + email, ex); } } @@ -1013,10 +1015,10 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { _accountMgr.checkAccess(caller, AccessType.ModifyProject, true, _accountMgr.getAccount(project.getProjectAccountId())); if (_projectInvitationDao.remove(id)) { - logger.debug("Project Invitation id=" + id + " is removed"); + s_logger.debug("Project Invitation id=" + id + " is removed"); return true; } else { - logger.debug("Failed to remove project invitation id=" + id); + s_logger.debug("Failed to remove project invitation id=" + id); return false; } } @@ -1028,15 +1030,15 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { TimeZone.getDefault(); List<ProjectInvitationVO> invitationsToExpire = _projectInvitationDao.listInvitationsToExpire(_invitationTimeOut); if (!invitationsToExpire.isEmpty()) { - logger.debug("Found " + invitationsToExpire.size() + " projects to expire"); + s_logger.debug("Found " + invitationsToExpire.size() + " projects to expire"); for (ProjectInvitationVO invitationToExpire : invitationsToExpire) { invitationToExpire.setState(ProjectInvitation.State.Expired); _projectInvitationDao.update(invitationToExpire.getId(), invitationToExpire); - logger.trace("Expired project invitation id=" + invitationToExpire.getId()); + s_logger.trace("Expired project invitation id=" + invitationToExpire.getId()); } } } catch (Exception ex) { - logger.warn("Exception while running expired invitations cleanup", ex); + s_logger.warn("Exception while running expired invitations cleanup", ex); } } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/resource/DiscovererBase.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/resource/DiscovererBase.java b/server/src/com/cloud/resource/DiscovererBase.java index 0fdac13..ad32b9f 100644 --- a/server/src/com/cloud/resource/DiscovererBase.java +++ b/server/src/com/cloud/resource/DiscovererBase.java @@ -26,6 +26,7 @@ import com.cloud.network.NetworkModel; import com.cloud.utils.component.AdapterBase; import com.cloud.utils.net.UrlUtil; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.log4j.Logger; import javax.inject.Inject; import javax.naming.ConfigurationException; @@ -37,6 +38,7 @@ import java.util.Map; public abstract class DiscovererBase extends AdapterBase implements Discoverer { protected Map<String, String> _params; + private static final Logger s_logger = Logger.getLogger(DiscovererBase.class); @Inject protected ClusterDao _clusterDao; @Inject @@ -88,19 +90,19 @@ public abstract class DiscovererBase extends AdapterBase implements Discoverer { Constructor constructor = clazz.getConstructor(); resource = (ServerResource)constructor.newInstance(); } catch (ClassNotFoundException e) { - logger.warn("Unable to find class " + resourceName, e); + s_logger.warn("Unable to find class " + resourceName, e); } catch (InstantiationException e) { - logger.warn("Unablet to instantiate class " + resourceName, e); + s_logger.warn("Unablet to instantiate class " + resourceName, e); } catch (IllegalAccessException e) { - logger.warn("Illegal access " + resourceName, e); + s_logger.warn("Illegal access " + resourceName, e); } catch (SecurityException e) { - logger.warn("Security error on " + resourceName, e); + s_logger.warn("Security error on " + resourceName, e); } catch (NoSuchMethodException e) { - logger.warn("NoSuchMethodException error on " + resourceName, e); + s_logger.warn("NoSuchMethodException error on " + resourceName, e); } catch (IllegalArgumentException e) { - logger.warn("IllegalArgumentException error on " + resourceName, e); + s_logger.warn("IllegalArgumentException error on " + resourceName, e); } catch (InvocationTargetException e) { - logger.warn("InvocationTargetException error on " + resourceName, e); + s_logger.warn("InvocationTargetException error on " + resourceName, e); } return resource; @@ -155,11 +157,11 @@ public abstract class DiscovererBase extends AdapterBase implements Discoverer { try { resource.configure(host.getName(), params); } catch (ConfigurationException e) { - logger.warn("Unable to configure resource due to " + e.getMessage()); + s_logger.warn("Unable to configure resource due to " + e.getMessage()); return null; } if (!resource.start()) { - logger.warn("Unable to start the resource"); + s_logger.warn("Unable to start the resource"); return null; } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/resource/DummyHostDiscoverer.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/resource/DummyHostDiscoverer.java b/server/src/com/cloud/resource/DummyHostDiscoverer.java index ec026f2..4651498 100644 --- a/server/src/com/cloud/resource/DummyHostDiscoverer.java +++ b/server/src/com/cloud/resource/DummyHostDiscoverer.java @@ -25,6 +25,7 @@ import java.util.UUID; import javax.ejb.Local; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.host.HostVO; @@ -34,6 +35,7 @@ import com.cloud.utils.component.AdapterBase; @Component @Local(value = Discoverer.class) public class DummyHostDiscoverer extends AdapterBase implements Discoverer { + private static final Logger s_logger = Logger.getLogger(DummyHostDiscoverer.class); @Override public Map<ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url, String username, String password, List<String> hostTags) { @@ -60,7 +62,7 @@ public class DummyHostDiscoverer extends AdapterBase implements Discoverer { try { resource.configure("Dummy Host Server", params); } catch (ConfigurationException e) { - logger.warn("Unable to instantiate dummy host server resource"); + s_logger.warn("Unable to instantiate dummy host server resource"); } resource.start(); resources.put(resource, details);
