http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/user/DomainManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/user/DomainManagerImpl.java b/server/src/com/cloud/user/DomainManagerImpl.java index 91271a3..fbbe0c2 100644 --- a/server/src/com/cloud/user/DomainManagerImpl.java +++ b/server/src/com/cloud/user/DomainManagerImpl.java @@ -24,6 +24,7 @@ import java.util.UUID; import javax.ejb.Local; import javax.inject.Inject; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import org.apache.cloudstack.api.command.admin.domain.ListDomainChildrenCmd; @@ -77,6 +78,7 @@ import com.cloud.vm.ReservationContextImpl; @Component @Local(value = {DomainManager.class, DomainService.class}) public class DomainManagerImpl extends ManagerBase implements DomainManager, DomainService { + public static final Logger s_logger = Logger.getLogger(DomainManagerImpl.class); @Inject private DomainDao _domainDao; @@ -254,7 +256,7 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom @Override public boolean deleteDomain(DomainVO domain, Boolean cleanup) { // mark domain as inactive - logger.debug("Marking domain id=" + domain.getId() + " as " + Domain.State.Inactive + " before actually deleting it"); + s_logger.debug("Marking domain id=" + domain.getId() + " as " + Domain.State.Inactive + " before actually deleting it"); domain.setState(Domain.State.Inactive); _domainDao.update(domain.getId(), domain); boolean rollBackState = false; @@ -277,7 +279,7 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom List<AccountVO> accountsForCleanup = _accountDao.findCleanupsForRemovedAccounts(domain.getId()); List<DedicatedResourceVO> dedicatedResources = _dedicatedDao.listByDomainId(domain.getId()); if (dedicatedResources != null && !dedicatedResources.isEmpty()) { - logger.error("There are dedicated resources for the domain " + domain.getId()); + s_logger.error("There are dedicated resources for the domain " + domain.getId()); hasDedicatedResources = true; } if (accountsForCleanup.isEmpty() && networkIds.isEmpty() && !hasDedicatedResources) { @@ -310,7 +312,7 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom CallContext.current().putContextParameter(Domain.class, domain.getUuid()); return true; } catch (Exception ex) { - logger.error("Exception deleting domain with id " + domain.getId(), ex); + s_logger.error("Exception deleting domain with id " + domain.getId(), ex); if (ex instanceof CloudRuntimeException) throw (CloudRuntimeException)ex; else @@ -318,7 +320,7 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom } finally { //when success is false if (rollBackState) { - logger.debug("Changing domain id=" + domain.getId() + " state back to " + Domain.State.Active + + s_logger.debug("Changing domain id=" + domain.getId() + " state back to " + Domain.State.Active + " because it can't be removed due to resources referencing to it"); domain.setState(Domain.State.Active); _domainDao.update(domain.getId(), domain); @@ -340,7 +342,7 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom } private boolean cleanupDomain(Long domainId, Long ownerId) throws ConcurrentOperationException, ResourceUnavailableException { - logger.debug("Cleaning up domain id=" + domainId); + s_logger.debug("Cleaning up domain id=" + domainId); boolean success = true; { DomainVO domainHandle = _domainDao.findById(domainId); @@ -365,7 +367,7 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom for (DomainVO domain : domains) { success = (success && cleanupDomain(domain.getId(), domain.getAccountId())); if (!success) { - logger.warn("Failed to cleanup domain id=" + domain.getId()); + s_logger.warn("Failed to cleanup domain id=" + domain.getId()); } } } @@ -376,18 +378,18 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom List<AccountVO> accounts = _accountDao.search(sc, null); for (AccountVO account : accounts) { if (account.getType() != Account.ACCOUNT_TYPE_PROJECT) { - logger.debug("Deleting account " + account + " as a part of domain id=" + domainId + " cleanup"); + s_logger.debug("Deleting account " + account + " as a part of domain id=" + domainId + " cleanup"); boolean deleteAccount = _accountMgr.deleteAccount(account, CallContext.current().getCallingUserId(), CallContext.current().getCallingAccount()); if (!deleteAccount) { - logger.warn("Failed to cleanup account id=" + account.getId() + " as a part of domain cleanup"); + s_logger.warn("Failed to cleanup account id=" + account.getId() + " as a part of domain cleanup"); } success = (success && deleteAccount); } else { ProjectVO project = _projectDao.findByProjectAccountId(account.getId()); - logger.debug("Deleting project " + project + " as a part of domain id=" + domainId + " cleanup"); + s_logger.debug("Deleting project " + project + " as a part of domain id=" + domainId + " cleanup"); boolean deleteProject = _projectMgr.deleteProject(CallContext.current().getCallingAccount(), CallContext.current().getCallingUserId(), project); if (!deleteProject) { - logger.warn("Failed to cleanup project " + project + " as a part of domain cleanup"); + s_logger.warn("Failed to cleanup project " + project + " as a part of domain cleanup"); } success = (success && deleteProject); } @@ -395,23 +397,23 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom //delete the domain shared networks boolean networksDeleted = true; - logger.debug("Deleting networks for domain id=" + domainId); + s_logger.debug("Deleting networks for domain id=" + domainId); List<Long> networkIds = _networkDomainDao.listNetworkIdsByDomain(domainId); CallContext ctx = CallContext.current(); ReservationContext context = new ReservationContextImpl(null, null, _accountMgr.getActiveUser(ctx.getCallingUserId()), ctx.getCallingAccount()); for (Long networkId : networkIds) { - logger.debug("Deleting network id=" + networkId + " as a part of domain id=" + domainId + " cleanup"); + s_logger.debug("Deleting network id=" + networkId + " as a part of domain id=" + domainId + " cleanup"); if (!_networkMgr.destroyNetwork(networkId, context, false)) { - logger.warn("Unable to destroy network id=" + networkId + " as a part of domain id=" + domainId + " cleanup."); + s_logger.warn("Unable to destroy network id=" + networkId + " as a part of domain id=" + domainId + " cleanup."); networksDeleted = false; } else { - logger.debug("Network " + networkId + " successfully deleted as a part of domain id=" + domainId + " cleanup."); + s_logger.debug("Network " + networkId + " successfully deleted as a part of domain id=" + domainId + " cleanup."); } } //don't proceed if networks failed to cleanup. The cleanup will be performed for inactive domain once again if (!networksDeleted) { - logger.debug("Failed to delete the shared networks as a part of domain id=" + domainId + " clenaup"); + s_logger.debug("Failed to delete the shared networks as a part of domain id=" + domainId + " clenaup"); return false; } @@ -422,10 +424,10 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom //release dedication if any, before deleting the domain List<DedicatedResourceVO> dedicatedResources = _dedicatedDao.listByDomainId(domainId); if (dedicatedResources != null && !dedicatedResources.isEmpty()) { - logger.debug("Releasing dedicated resources for domain" + domainId); + s_logger.debug("Releasing dedicated resources for domain" + domainId); for (DedicatedResourceVO dr : dedicatedResources) { if (!_dedicatedDao.remove(dr.getId())) { - logger.warn("Fail to release dedicated resources for domain " + domainId); + s_logger.warn("Fail to release dedicated resources for domain " + domainId); return false; } } @@ -437,7 +439,7 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom _resourceCountDao.removeEntriesByOwner(domainId, ResourceOwnerType.Domain); _resourceLimitDao.removeEntriesByOwner(domainId, ResourceOwnerType.Domain); } else { - logger.debug("Can't delete the domain yet because it has " + accountsForCleanup.size() + "accounts that need a cleanup"); + s_logger.debug("Can't delete the domain yet because it has " + accountsForCleanup.size() + "accounts that need a cleanup"); return false; }
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/vm/UserVmManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 1433050..b23f984 100644 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -89,6 +89,7 @@ import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO; import org.apache.commons.codec.binary.Base64; +import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; import com.cloud.agent.api.Answer; @@ -285,6 +286,7 @@ import com.cloud.vm.snapshot.dao.VMSnapshotDao; @Local(value = {UserVmManager.class, UserVmService.class}) public class UserVmManagerImpl extends ManagerBase implements UserVmManager, VirtualMachineGuru, UserVmService, Configurable { + private static final Logger s_logger = Logger.getLogger(UserVmManagerImpl.class); private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 3; // 3 @@ -607,7 +609,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir boolean decrementCount = true; try { - logger.debug("Trying for vm "+ vmId +" nic Id "+nicId +" ip retrieval ..."); + s_logger.debug("Trying for vm "+ vmId +" nic Id "+nicId +" ip retrieval ..."); Answer answer = _agentMgr.send(hostId, cmd); NicVO nic = _nicDao.findById(nicId); if (answer.getResult()) { @@ -618,7 +620,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (nic != null) { nic.setIPv4Address(vmIp); _nicDao.update(nicId, nic); - logger.debug("Vm "+ vmId +" IP "+vmIp +" got retrieved successfully"); + s_logger.debug("Vm "+ vmId +" IP "+vmIp +" got retrieved successfully"); vmIdCountMap.remove(nicId); decrementCount = false; ActionEventUtils.onActionEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, @@ -634,18 +636,18 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir _nicDao.update(nicId, nic); } if (answer.getDetails() != null) { - logger.debug("Failed to get vm ip for Vm "+ vmId + answer.getDetails()); + s_logger.debug("Failed to get vm ip for Vm "+ vmId + answer.getDetails()); } } } catch (OperationTimedoutException e) { - logger.warn("Timed Out", e); + s_logger.warn("Timed Out", e); } catch (AgentUnavailableException e) { - logger.warn("Agent Unavailable ", e); + s_logger.warn("Agent Unavailable ", e); } finally { if (decrementCount) { VmAndCountDetails vmAndCount = vmIdCountMap.get(nicId); vmAndCount.decrementCount(); - logger.debug("Ip is not retrieved for VM " + vmId +" nic "+nicId + " ... decremented count to "+vmAndCount.getRetrievalCount()); + s_logger.debug("Ip is not retrieved for VM " + vmId +" nic "+nicId + " ... decremented count to "+vmAndCount.getRetrievalCount()); vmIdCountMap.put(nicId, vmAndCount); } } @@ -676,7 +678,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } if (userVm.getState() == State.Error || userVm.getState() == State.Expunging) { - logger.error("vm is not in the right state: " + vmId); + s_logger.error("vm is not in the right state: " + vmId); throw new InvalidParameterValueException("Vm with id " + vmId + " is not in the right state"); } @@ -709,7 +711,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (template.getEnablePassword()) { Nic defaultNic = _networkModel.getDefaultNic(vmId); if (defaultNic == null) { - logger.error("Unable to reset password for vm " + vmInstance + " as the instance doesn't have default nic"); + s_logger.error("Unable to reset password for vm " + vmInstance + " as the instance doesn't have default nic"); return false; } @@ -729,25 +731,25 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir // Need to reboot the virtual machine so that the password gets // redownloaded from the DomR, and reset on the VM if (!result) { - logger.debug("Failed to reset password for the virutal machine; no need to reboot the vm"); + s_logger.debug("Failed to reset password for the virutal machine; no need to reboot the vm"); return false; } else { if (vmInstance.getState() == State.Stopped) { - logger.debug("Vm " + vmInstance + " is stopped, not rebooting it as a part of password reset"); + s_logger.debug("Vm " + vmInstance + " is stopped, not rebooting it as a part of password reset"); return true; } if (rebootVirtualMachine(userId, vmId) == null) { - logger.warn("Failed to reboot the vm " + vmInstance); + s_logger.warn("Failed to reboot the vm " + vmInstance); return false; } else { - logger.debug("Vm " + vmInstance + " is rebooted successfully as a part of password reset"); + s_logger.debug("Vm " + vmInstance + " is rebooted successfully as a part of password reset"); return true; } } } else { - if (logger.isDebugEnabled()) { - logger.debug("Reset password called for a vm that is not using a password enabled template"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Reset password called for a vm that is not using a password enabled template"); } return false; } @@ -772,11 +774,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir // Do parameters input validation if (userVm.getState() == State.Error || userVm.getState() == State.Expunging) { - logger.error("vm is not in the right state: " + vmId); + s_logger.error("vm is not in the right state: " + vmId); throw new InvalidParameterValueException("Vm with specified id is not in the right state"); } if (userVm.getState() != State.Stopped) { - logger.error("vm is not in the right state: " + vmId); + s_logger.error("vm is not in the right state: " + vmId); throw new InvalidParameterValueException("Vm " + userVm + " should be stopped to do SSH Key reset"); } @@ -816,7 +818,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir VMTemplateVO template = _templateDao.findByIdIncludingRemoved(vmInstance.getTemplateId()); Nic defaultNic = _networkModel.getDefaultNic(vmId); if (defaultNic == null) { - logger.error("Unable to reset SSH Key for vm " + vmInstance + " as the instance doesn't have default nic"); + s_logger.error("Unable to reset SSH Key for vm " + vmInstance + " as the instance doesn't have default nic"); return false; } @@ -838,18 +840,18 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir // Need to reboot the virtual machine so that the password gets redownloaded from the DomR, and reset on the VM if (!result) { - logger.debug("Failed to reset SSH Key for the virutal machine; no need to reboot the vm"); + s_logger.debug("Failed to reset SSH Key for the virutal machine; no need to reboot the vm"); return false; } else { if (vmInstance.getState() == State.Stopped) { - logger.debug("Vm " + vmInstance + " is stopped, not rebooting it as a part of SSH Key reset"); + s_logger.debug("Vm " + vmInstance + " is stopped, not rebooting it as a part of SSH Key reset"); return true; } if (rebootVirtualMachine(userId, vmId) == null) { - logger.warn("Failed to reboot the vm " + vmInstance); + s_logger.warn("Failed to reboot the vm " + vmInstance); return false; } else { - logger.debug("Vm " + vmInstance + " is rebooted successfully as a part of SSH Key reset"); + s_logger.debug("Vm " + vmInstance + " is rebooted successfully as a part of SSH Key reset"); return true; } } @@ -858,13 +860,13 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir @Override public boolean stopVirtualMachine(long userId, long vmId) { boolean status = false; - if (logger.isDebugEnabled()) { - logger.debug("Stopping vm=" + vmId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Stopping vm=" + vmId); } UserVmVO vm = _vmDao.findById(vmId); if (vm == null || vm.getRemoved() != null) { - if (logger.isDebugEnabled()) { - logger.debug("VM is either removed or deleted."); + if (s_logger.isDebugEnabled()) { + s_logger.debug("VM is either removed or deleted."); } return true; } @@ -874,7 +876,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid()); status = vmEntity.stop(Long.toString(userId)); } catch (ResourceUnavailableException e) { - logger.debug("Unable to stop due to ", e); + s_logger.debug("Unable to stop due to ", e); status = false; } catch (CloudException e) { throw new CloudRuntimeException("Unable to contact the agent to stop the virtual machine " + vm, e); @@ -886,7 +888,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir UserVmVO vm = _vmDao.findById(vmId); if (vm == null || vm.getState() == State.Destroyed || vm.getState() == State.Expunging || vm.getRemoved() != null) { - logger.warn("Vm id=" + vmId + " doesn't exist"); + s_logger.warn("Vm id=" + vmId + " doesn't exist"); return null; } @@ -907,7 +909,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir //Safe to start the stopped router serially, this is consistent with the way how multiple networks are added to vm during deploy //and routers are started serially ,may revisit to make this process parallel for(DomainRouterVO routerToStart : routers) { - logger.warn("Trying to start router " + routerToStart.getInstanceName() + " as part of vm: " + vm.getInstanceName() + " reboot"); + s_logger.warn("Trying to start router " + routerToStart.getInstanceName() + " as part of vm: " + vm.getInstanceName() + " reboot"); _virtualNetAppliance.startRouter(routerToStart.getId(),true); } } @@ -916,12 +918,12 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } catch (Exception ex){ throw new CloudRuntimeException("Router start failed due to" + ex); }finally { - logger.info("Rebooting vm " + vm.getInstanceName()); + s_logger.info("Rebooting vm " + vm.getInstanceName()); _itMgr.reboot(vm.getUuid(), null); } return _vmDao.findById(vmId); } else { - logger.error("Vm id=" + vmId + " is not in Running state, failed to reboot"); + s_logger.error("Vm id=" + vmId + " is not in Running state, failed to reboot"); return null; } } @@ -1211,7 +1213,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir throw new CloudRuntimeException("Unable to add NIC to " + vmInstance); } CallContext.current().putContextParameter(Nic.class.getName(), guestNic.getUuid()); - logger.debug("Successful addition of " + network + " from " + vmInstance); + s_logger.debug("Successful addition of " + network + " from " + vmInstance); return _vmDao.findById(vmInstance.getId()); } @@ -1283,7 +1285,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir throw new CloudRuntimeException("Unable to remove " + network + " from " + vmInstance); } - logger.debug("Successful removal of " + network + " from " + vmInstance); + s_logger.debug("Successful removal of " + network + " from " + vmInstance); return _vmDao.findById(vmInstance.getId()); } @@ -1348,7 +1350,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } if (existing == null) { - logger.warn("Failed to update default nic, no nic profile found for existing default network"); + s_logger.warn("Failed to update default nic, no nic profile found for existing default network"); throw new CloudRuntimeException("Failed to find a nic profile for the existing default network. This is bad and probably means some sort of configuration corruption"); } @@ -1390,7 +1392,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } throw new CloudRuntimeException("Failed to change default nic to " + nic + " and now we have no default"); } else if (newdefault.getId() == nic.getNetworkId()) { - logger.debug("successfully set default network to " + network + " for " + vmInstance); + s_logger.debug("successfully set default network to " + network + " for " + vmInstance); String nicIdString = Long.toString(nic.getId()); long newNetworkOfferingId = network.getNetworkOfferingId(); UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NETWORK_OFFERING_REMOVE, vmInstance.getAccountId(), vmInstance.getDataCenterId(), vmInstance.getId(), @@ -1451,13 +1453,13 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir Answer answer = _agentMgr.easySend(hostId, new GetVmDiskStatsCommand(vmNames, _hostDao.findById(hostId).getGuid(), hostName)); if (answer == null || !answer.getResult()) { - logger.warn("Unable to obtain VM disk statistics."); + s_logger.warn("Unable to obtain VM disk statistics."); return null; } else { HashMap<String, List<VmDiskStatsEntry>> vmDiskStatsByName = ((GetVmDiskStatsAnswer)answer).getVmDiskStatsMap(); if (vmDiskStatsByName == null) { - logger.warn("Unable to obtain VM disk statistics."); + s_logger.warn("Unable to obtain VM disk statistics."); return null; } @@ -1499,7 +1501,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir Account caller = CallContext.current().getCallingAccount(); VMInstanceVO vmInstance = _vmInstanceDao.findById(vmId); if (vmInstance.getHypervisorType() != HypervisorType.XenServer && vmInstance.getHypervisorType() != HypervisorType.VMware) { - logger.info("Scaling the VM dynamically is not supported for VMs running on Hypervisor "+vmInstance.getHypervisorType()); + s_logger.info("Scaling the VM dynamically is not supported for VMs running on Hypervisor "+vmInstance.getHypervisorType()); throw new InvalidParameterValueException("Scaling the VM dynamically is not supported for VMs running on Hypervisor "+vmInstance.getHypervisorType()); } @@ -1605,13 +1607,13 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } return success; } catch (InsufficientCapacityException e) { - logger.warn("Received exception while scaling ", e); + s_logger.warn("Received exception while scaling ", e); } catch (ResourceUnavailableException e) { - logger.warn("Received exception while scaling ", e); + s_logger.warn("Received exception while scaling ", e); } catch (ConcurrentOperationException e) { - logger.warn("Received exception while scaling ", e); + s_logger.warn("Received exception while scaling ", e); } catch (Exception e) { - logger.warn("Received exception while scaling ", e); + s_logger.warn("Received exception while scaling ", e); } finally { if (!success) { _itMgr.upgradeVmDb(vmId, currentServiceOffering.getId()); // rollback @@ -1679,13 +1681,13 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir Answer answer = _agentMgr.easySend(hostId, new GetVmStatsCommand(vmNames, _hostDao.findById(hostId).getGuid(), hostName)); if (answer == null || !answer.getResult()) { - logger.warn("Unable to obtain VM statistics."); + s_logger.warn("Unable to obtain VM statistics."); return null; } else { HashMap<String, VmStatsEntry> vmStatsByName = ((GetVmStatsAnswer)answer).getVmStatsMap(); if (vmStatsByName == null) { - logger.warn("Unable to obtain VM statistics."); + s_logger.warn("Unable to obtain VM statistics."); return null; } @@ -1718,21 +1720,21 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } if (vm.getRemoved() != null) { - if (logger.isDebugEnabled()) { - logger.debug("Unable to find vm or vm is removed: " + vmId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Unable to find vm or vm is removed: " + vmId); } throw new InvalidParameterValueException("Unable to find vm by id " + vmId); } if (vm.getState() != State.Destroyed) { - if (logger.isDebugEnabled()) { - logger.debug("vm is not in the right state: " + vmId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("vm is not in the right state: " + vmId); } throw new InvalidParameterValueException("Vm with id " + vmId + " is not in the right state"); } - if (logger.isDebugEnabled()) { - logger.debug("Recovering vm " + vmId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Recovering vm " + vmId); } Transaction.execute(new TransactionCallbackWithExceptionNoReturn<ResourceAllocationException>() { @@ -1757,7 +1759,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir try { if (!_itMgr.stateTransitTo(vm, VirtualMachine.Event.RecoveryRequested, null)) { - logger.debug("Unable to recover the vm because it is not in the correct state: " + vmId); + s_logger.debug("Unable to recover the vm because it is not in the correct state: " + vmId); throw new InvalidParameterValueException("Unable to recover the vm because it is not in the correct state: " + vmId); } } catch (NoTransitionException e) { @@ -1838,7 +1840,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir _scaleRetry = NumbersUtil.parseInt(configs.get(Config.ScaleRetry.key()), 2); - logger.info("User VM Manager is configured."); + s_logger.info("User VM Manager is configured."); return true; } @@ -1915,11 +1917,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (vm.getRemoved() == null) { // Cleanup vm resources - all the PF/LB/StaticNat rules // associated with vm - logger.debug("Starting cleaning up vm " + vm + " resources..."); + s_logger.debug("Starting cleaning up vm " + vm + " resources..."); if (cleanupVmResources(vm.getId())) { - logger.debug("Successfully cleaned up vm " + vm + " resources as a part of expunge process"); + s_logger.debug("Successfully cleaned up vm " + vm + " resources as a part of expunge process"); } else { - logger.warn("Failed to cleanup resources as a part of vm " + vm + " expunge"); + s_logger.warn("Failed to cleanup resources as a part of vm " + vm + " expunge"); return false; } @@ -1929,13 +1931,13 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir return true; } catch (ResourceUnavailableException e) { - logger.warn("Unable to expunge " + vm, e); + s_logger.warn("Unable to expunge " + vm, e); return false; } catch (OperationTimedoutException e) { - logger.warn("Operation time out on expunging " + vm, e); + s_logger.warn("Operation time out on expunging " + vm, e); return false; } catch (ConcurrentOperationException e) { - logger.warn("Concurrent operations on expunging " + vm, e); + s_logger.warn("Concurrent operations on expunging " + vm, e); return false; } finally { _vmDao.releaseFromLockTable(vm.getId()); @@ -1952,26 +1954,26 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir // cleanup firewall rules if (_firewallMgr.revokeFirewallRulesForVm(vmId)) { - logger.debug("Firewall rules are removed successfully as a part of vm id=" + vmId + " expunge"); + s_logger.debug("Firewall rules are removed successfully as a part of vm id=" + vmId + " expunge"); } else { success = false; - logger.warn("Fail to remove firewall rules as a part of vm id=" + vmId + " expunge"); + s_logger.warn("Fail to remove firewall rules as a part of vm id=" + vmId + " expunge"); } // cleanup port forwarding rules if (_rulesMgr.revokePortForwardingRulesForVm(vmId)) { - logger.debug("Port forwarding rules are removed successfully as a part of vm id=" + vmId + " expunge"); + s_logger.debug("Port forwarding rules are removed successfully as a part of vm id=" + vmId + " expunge"); } else { success = false; - logger.warn("Fail to remove port forwarding rules as a part of vm id=" + vmId + " expunge"); + s_logger.warn("Fail to remove port forwarding rules as a part of vm id=" + vmId + " expunge"); } // cleanup load balancer rules if (_lbMgr.removeVmFromLoadBalancers(vmId)) { - logger.debug("Removed vm id=" + vmId + " from all load balancers as a part of expunge process"); + s_logger.debug("Removed vm id=" + vmId + " from all load balancers as a part of expunge process"); } else { success = false; - logger.warn("Fail to remove vm id=" + vmId + " from load balancers as a part of expunge process"); + s_logger.warn("Fail to remove vm id=" + vmId + " from load balancers as a part of expunge process"); } // If vm is assigned to static nat, disable static nat for the ip @@ -1981,14 +1983,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir for (IPAddressVO ip : ips) { try { if (_rulesMgr.disableStaticNat(ip.getId(), _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM), User.UID_SYSTEM, true)) { - logger.debug("Disabled 1-1 nat for ip address " + ip + " as a part of vm id=" + vmId + " expunge"); + s_logger.debug("Disabled 1-1 nat for ip address " + ip + " as a part of vm id=" + vmId + " expunge"); } else { - logger.warn("Failed to disable static nat for ip address " + ip + " as a part of vm id=" + vmId + " expunge"); + s_logger.warn("Failed to disable static nat for ip address " + ip + " as a part of vm id=" + vmId + " expunge"); success = false; } } catch (ResourceUnavailableException e) { success = false; - logger.warn("Failed to disable static nat for ip address " + ip + " as a part of vm id=" + vmId + " expunge because resource is unavailable", e); + s_logger.warn("Failed to disable static nat for ip address " + ip + " as a part of vm id=" + vmId + " expunge because resource is unavailable", e); } } @@ -2009,11 +2011,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (vm != null) { if (vm.getState().equals(State.Stopped)) { - logger.debug("Destroying vm " + vm + " as it failed to create on Host with Id:" + hostId); + s_logger.debug("Destroying vm " + vm + " as it failed to create on Host with Id:" + hostId); try { _itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationFailedToError, null); } catch (NoTransitionException e1) { - logger.warn(e1.getMessage()); + s_logger.warn(e1.getMessage()); } // destroy associated volumes for vm in error state // get all volumes in non destroyed state @@ -2058,7 +2060,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (vmIdAndCount.getRetrievalCount() <= 0) { vmIdCountMap.remove(nicId); - logger.debug("Vm " + vmId +" nic "+nicId + " count is zero .. removing vm nic from map "); + s_logger.debug("Vm " + vmId +" nic "+nicId + " count is zero .. removing vm nic from map "); ActionEventUtils.onActionEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, Domain.ROOT_DOMAIN, EventTypes.EVENT_NETWORK_EXTERNAL_DHCP_VM_IPFETCH, @@ -2082,7 +2084,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } } catch (Exception e) { - logger.error("Caught the Exception in VmIpFetchTask", e); + s_logger.error("Caught the Exception in VmIpFetchTask", e); } finally { scanLock.unlock(); } @@ -2106,22 +2108,22 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (scanLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION)) { try { List<UserVmVO> vms = _vmDao.findDestroyedVms(new Date(System.currentTimeMillis() - ((long)_expungeDelay << 10))); - if (logger.isInfoEnabled()) { + if (s_logger.isInfoEnabled()) { if (vms.size() == 0) { - logger.trace("Found " + vms.size() + " vms to expunge."); + s_logger.trace("Found " + vms.size() + " vms to expunge."); } else { - logger.info("Found " + vms.size() + " vms to expunge."); + s_logger.info("Found " + vms.size() + " vms to expunge."); } } for (UserVmVO vm : vms) { try { expungeVm(vm.getId()); } catch (Exception e) { - logger.warn("Unable to expunge " + vm, e); + s_logger.warn("Unable to expunge " + vm, e); } } } catch (Exception e) { - logger.error("Caught the following Exception", e); + s_logger.error("Caught the following Exception", e); } finally { scanLock.unlock(); } @@ -2261,7 +2263,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } if (vm.getState() == State.Error || vm.getState() == State.Expunging) { - logger.error("vm is not in the right state: " + id); + s_logger.error("vm is not in the right state: " + id); throw new InvalidParameterValueException("Vm with id " + id + " is not in the right state"); } @@ -2314,7 +2316,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir checkNameForRFCCompliance(hostName); if (vm.getHostName().equalsIgnoreCase(hostName)) { - logger.debug("Vm " + vm + " is already set with the hostName specified: " + hostName); + s_logger.debug("Vm " + vm + " is already set with the hostName specified: " + hostName); hostName = null; } @@ -2332,7 +2334,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (updateUserdata) { boolean result = updateUserDataInternal(_vmDao.findById(id)); if (result) { - logger.debug("User data successfully updated for vm id=" + id); + s_logger.debug("User data successfully updated for vm id=" + id); } else { throw new CloudRuntimeException("Failed to reset userdata for the virtual machine "); } @@ -2346,7 +2348,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir List<? extends Nic> nics = _nicDao.listByVmId(vm.getId()); if (nics == null || nics.isEmpty()) { - logger.error("unable to find any nics for vm " + vm.getUuid()); + s_logger.error("unable to find any nics for vm " + vm.getUuid()); return false; } @@ -2363,7 +2365,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } boolean result = element.saveUserData(network, nicProfile, vmProfile); if (!result) { - logger.error("Failed to update userdata for vm " + vm + " and nic " + nic); + s_logger.error("Failed to update userdata for vm " + vm + " and nic " + nic); } } @@ -2460,7 +2462,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir // not // created. if (account == null) { - logger.warn("Failed to acquire lock on account"); + s_logger.warn("Failed to acquire lock on account"); return null; } InstanceGroupVO group = _vmGroupDao.findByAccountAndName(accountId, groupName); @@ -2523,7 +2525,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (group != null) { UserVm userVm = _vmDao.acquireInLockTable(userVmId); if (userVm == null) { - logger.warn("Failed to acquire lock on user vm id=" + userVmId); + s_logger.warn("Failed to acquire lock on user vm id=" + userVmId); } try { final InstanceGroupVO groupFinal = group; @@ -2534,7 +2536,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir // it. InstanceGroupVO ngrpLock = _vmGroupDao.lockRow(groupFinal.getId(), false); if (ngrpLock == null) { - logger.warn("Failed to acquire lock on vm group id=" + groupFinal.getId() + " name=" + groupFinal.getName()); + s_logger.warn("Failed to acquire lock on vm group id=" + groupFinal.getId() + " name=" + groupFinal.getName()); throw new CloudRuntimeException("Failed to acquire lock on vm group id=" + groupFinal.getId() + " name=" + groupFinal.getName()); } @@ -2578,7 +2580,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir return null; } } catch (Exception e) { - logger.warn("Error trying to get group for a vm: ", e); + s_logger.warn("Error trying to get group for a vm: ", e); return null; } } @@ -2593,7 +2595,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir _groupVMMapDao.expunge(sc); } } catch (Exception e) { - logger.warn("Error trying to remove vm from group: ", e); + s_logger.warn("Error trying to remove vm from group: ", e); } } @@ -2651,8 +2653,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir securityGroupIdList.add(defaultGroup.getId()); } else { // create default security group for the account - if (logger.isDebugEnabled()) { - logger.debug("Couldn't find default security group for the account " + owner + " so creating a new one"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Couldn't find default security group for the account " + owner + " so creating a new one"); } defaultGroup = _securityGroupMgr.createSecurityGroup(SecurityGroupManager.DEFAULT_GROUP_NAME, SecurityGroupManager.DEFAULT_GROUP_DESCRIPTION, owner.getDomainId(), owner.getId(), owner.getAccountName()); @@ -2762,8 +2764,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir securityGroupIdList.add(defaultGroup.getId()); } else { // create default security group for the account - if (logger.isDebugEnabled()) { - logger.debug("Couldn't find default security group for the account " + owner + " so creating a new one"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Couldn't find default security group for the account " + owner + " so creating a new one"); } defaultGroup = _securityGroupMgr.createSecurityGroup(SecurityGroupManager.DEFAULT_GROUP_NAME, SecurityGroupManager.DEFAULT_GROUP_DESCRIPTION, owner.getDomainId(), owner.getId(), owner.getAccountName()); @@ -2826,7 +2828,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir throw new InvalidParameterValueException("Unable to find physical network with id: " + physicalNetworkId + " and tag: " + requiredOfferings.get(0).getTags()); } - logger.debug("Creating network for account " + owner + " from the network offering id=" + requiredOfferings.get(0).getId() + " as a part of deployVM process"); + s_logger.debug("Creating network for account " + owner + " from the network offering id=" + requiredOfferings.get(0).getId() + " as a part of deployVM process"); Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null, null, null, owner, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, null, null, true, null); if (newNetwork != null) { @@ -3080,7 +3082,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir Long physicalNetworkId = _networkModel.findPhysicalNetworkId(zone.getId(), ntwkOffering.getTags(), ntwkOffering.getTrafficType()); if (physicalNetworkId == null) { - logger.warn("Network id " + network.getId() + " could not be streched to the zone " + zone.getId() + s_logger.warn("Network id " + network.getId() + " could not be streched to the zone " + zone.getId() + " as valid phyical network could not be found"); throw new InvalidParameterValueException("Network in which is VM getting deployed could not be" + " streched to the zone."); @@ -3088,7 +3090,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir String provider = _ntwkSrvcDao.getProviderForServiceInNetwork(network.getId(), Service.Connectivity); if (!_networkModel.isProviderEnabledInPhysicalNetwork(physicalNetworkId, provider)) { - logger.warn("Network id " + network.getId() + " could not be streched to the zone " +zone.getId() + s_logger.warn("Network id " + network.getId() + " could not be streched to the zone " +zone.getId() + " as Connectivity service provider is not enabled in the zone " + zone.getId()); throw new InvalidParameterValueException("Network in which is VM getting deployed could not be" + " streched to the zone."); @@ -3329,10 +3331,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir throw new InvalidParameterValueException("unsupported: rootdisksize override is smaller than template size " + templateVO.getSize() + "B (" + templateVOSizeGB + "GB)"); } else { - logger.debug("rootdisksize of " + (rootDiskSize << 30) + " was larger than template size of " + templateVO.getSize()); + s_logger.debug("rootdisksize of " + (rootDiskSize << 30) + " was larger than template size of " + templateVO.getSize()); } - logger.debug("found root disk size of " + rootDiskSize); + s_logger.debug("found root disk size of " + rootDiskSize); customParameters.remove("rootdisksize"); } @@ -3366,7 +3368,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir vm.setDetail("smc.present", "TRUE"); vm.setDetail(VmDetailConstants.ROOK_DISK_CONTROLLER, "scsi"); vm.setDetail("firmware", "efi"); - logger.info("guestOS is OSX : overwrite root disk controller to scsi, use smc and efi"); + s_logger.info("guestOS is OSX : overwrite root disk controller to scsi, use smc and efi"); } } @@ -3376,7 +3378,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } _vmDao.saveDetails(vm); - logger.debug("Allocating in the DB for vm"); + s_logger.debug("Allocating in the DB for vm"); DataCenterDeployment plan = new DataCenterDeployment(zone.getId()); List<String> computeTags = new ArrayList<String>(); @@ -3394,8 +3396,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir offering.getCpu(), offering.getSpeed(), offering.getRamSize(), diskSize, computeTags, rootDiskTags, networkNicMap, plan, rootDiskSize); } - if (logger.isDebugEnabled()) { - logger.debug("Successfully allocated DB entry for " + vm); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Successfully allocated DB entry for " + vm); } CallContext.current().setEventDetails("Vm Id: " + vm.getId()); @@ -3555,10 +3557,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir try { answer = _agentMgr.send(hostId, cmd); } catch (OperationTimedoutException e) { - logger.warn("Timed Out", e); + s_logger.warn("Timed Out", e); return false; } catch (AgentUnavailableException e) { - logger.warn("Agent Unavailable ", e); + s_logger.warn("Agent Unavailable ", e); return false; } @@ -3606,8 +3608,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir Answer[] answersToCmds = cmds.getAnswers(); if (answersToCmds == null) { - if (logger.isDebugEnabled()) { - logger.debug("Returning from finalizeStart() since there are no answers to read"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Returning from finalizeStart() since there are no answers to read"); } return true; } @@ -3669,7 +3671,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir userVm.setPrivateIpAddress(guestNic.getIPv4Address()); _vmDao.update(userVm.getId(), userVm); - logger.info("Detected that ip changed in the answer, updated nic in the db with new ip " + returnedIp); + s_logger.info("Detected that ip changed in the answer, updated nic in the db with new ip " + returnedIp); } } @@ -3677,7 +3679,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir try { _rulesMgr.getSystemIpAndEnableStaticNatForVm(profile.getVirtualMachine(), false); } catch (Exception ex) { - logger.warn("Failed to get system ip and enable static nat for the vm " + profile.getVirtualMachine() + " due to exception ", ex); + s_logger.warn("Failed to get system ip and enable static nat for the vm " + profile.getVirtualMachine() + " due to exception ", ex); return false; } @@ -3736,7 +3738,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir assert (offering.getAssociatePublicIP() == true) : "User VM should not have system owned public IP associated with it when offering configured not to associate public IP."; _rulesMgr.disableStaticNat(ip.getId(), ctx.getCallingAccount(), ctx.getCallingUserId(), true); } catch (Exception ex) { - logger.warn("Failed to disable static nat and release system ip " + ip + " as a part of vm " + profile.getVirtualMachine() + " stop due to exception ", ex); + s_logger.warn("Failed to disable static nat and release system ip " + ip + " as a part of vm " + profile.getVirtualMachine() + " stop due to exception ", ex); } } @@ -3798,8 +3800,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (_securityGroupMgr.isVmSecurityGroupEnabled(vmId) && _securityGroupMgr.getSecurityGroupsForVm(vmId).isEmpty() && !_securityGroupMgr.isVmMappedToDefaultSecurityGroup(vmId) && _networkModel.canAddDefaultSecurityGroup()) { // if vm is not mapped to security group, create a mapping - if (logger.isDebugEnabled()) { - logger.debug("Vm " + vm + " is security group enabled, but not mapped to default security group; creating the mapping automatically"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Vm " + vm + " is security group enabled, but not mapped to default security group; creating the mapping automatically"); } SecurityGroup defaultSecurityGroup = _securityGroupMgr.getDefaultSecurityGroup(vm.getAccountId()); @@ -3812,7 +3814,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir DataCenterDeployment plan = null; if (destinationHost != null) { - logger.debug("Destination Host to deploy the VM is specified, specifying a deployment plan to deploy the VM"); + s_logger.debug("Destination Host to deploy the VM is specified, specifying a deployment plan to deploy the VM"); plan = new DataCenterDeployment(vm.getDataCenterId(), destinationHost.getPodId(), destinationHost.getClusterId(), destinationHost.getId(), null, null); } @@ -3894,7 +3896,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } if (vm.getState() == State.Destroyed || vm.getState() == State.Expunging) { - logger.trace("Vm id=" + vmId + " is already destroyed"); + s_logger.trace("Vm id=" + vmId + " is already destroyed"); return vm; } @@ -3941,7 +3943,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir // support KVM only util 2013.06.25 if (!userVm.getHypervisorType().equals(HypervisorType.KVM)) return; - logger.debug("Collect vm disk statistics from host before stopping Vm"); + s_logger.debug("Collect vm disk statistics from host before stopping Vm"); long hostId = userVm.getHostId(); List<String> vmNames = new ArrayList<String>(); vmNames.add(userVm.getInstanceName()); @@ -3951,12 +3953,12 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir try { diskStatsAnswer = (GetVmDiskStatsAnswer)_agentMgr.easySend(hostId, new GetVmDiskStatsCommand(vmNames, host.getGuid(), host.getName())); } catch (Exception e) { - logger.warn("Error while collecting disk stats for vm: " + userVm.getInstanceName() + " from host: " + host.getName(), e); + s_logger.warn("Error while collecting disk stats for vm: " + userVm.getInstanceName() + " from host: " + host.getName(), e); return; } if (diskStatsAnswer != null) { if (!diskStatsAnswer.getResult()) { - logger.warn("Error while collecting disk stats vm: " + userVm.getInstanceName() + " from host: " + host.getName() + "; details: " + diskStatsAnswer.getDetails()); + s_logger.warn("Error while collecting disk stats vm: " + userVm.getInstanceName() + " from host: " + host.getName() + "; details: " + diskStatsAnswer.getDetails()); return; } try { @@ -3982,12 +3984,12 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir VmDiskStatisticsVO vmDiskStat_lock = _vmDiskStatsDao.lock(userVm.getAccountId(), userVm.getDataCenterId(), userVm.getId(), volume.getId()); if ((vmDiskStat.getIORead() == 0) && (vmDiskStat.getIOWrite() == 0) && (vmDiskStat.getBytesRead() == 0) && (vmDiskStat.getBytesWrite() == 0)) { - logger.debug("Read/Write of IO and Bytes are both 0. Not updating vm_disk_statistics"); + s_logger.debug("Read/Write of IO and Bytes are both 0. Not updating vm_disk_statistics"); continue; } if (vmDiskStat_lock == null) { - logger.warn("unable to find vm disk stats from host for account: " + userVm.getAccountId() + " with vmId: " + userVm.getId() + " and volumeId:" + s_logger.warn("unable to find vm disk stats from host for account: " + userVm.getAccountId() + " with vmId: " + userVm.getId() + " and volumeId:" + volume.getId()); continue; } @@ -3997,39 +3999,39 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir .getCurrentIOWrite()) || (previousVmDiskStats.getCurrentBytesRead() != vmDiskStat_lock.getCurrentBytesRead()) || (previousVmDiskStats .getCurrentBytesWrite() != vmDiskStat_lock.getCurrentBytesWrite())))) { - logger.debug("vm disk stats changed from the time GetVmDiskStatsCommand was sent. " + "Ignoring current answer. Host: " + host.getName() + s_logger.debug("vm disk stats changed from the time GetVmDiskStatsCommand was sent. " + "Ignoring current answer. Host: " + host.getName() + " . VM: " + vmDiskStat.getVmName() + " IO Read: " + vmDiskStat.getIORead() + " IO Write: " + vmDiskStat.getIOWrite() + " Bytes Read: " + vmDiskStat.getBytesRead() + " Bytes Write: " + vmDiskStat.getBytesWrite()); continue; } if (vmDiskStat_lock.getCurrentIORead() > vmDiskStat.getIORead()) { - if (logger.isDebugEnabled()) { - logger.debug("Read # of IO that's less than the last one. " + "Assuming something went wrong and persisting it. Host: " + host.getName() + if (s_logger.isDebugEnabled()) { + s_logger.debug("Read # of IO that's less than the last one. " + "Assuming something went wrong and persisting it. Host: " + host.getName() + " . VM: " + vmDiskStat.getVmName() + " Reported: " + vmDiskStat.getIORead() + " Stored: " + vmDiskStat_lock.getCurrentIORead()); } vmDiskStat_lock.setNetIORead(vmDiskStat_lock.getNetIORead() + vmDiskStat_lock.getCurrentIORead()); } vmDiskStat_lock.setCurrentIORead(vmDiskStat.getIORead()); if (vmDiskStat_lock.getCurrentIOWrite() > vmDiskStat.getIOWrite()) { - if (logger.isDebugEnabled()) { - logger.debug("Write # of IO that's less than the last one. " + "Assuming something went wrong and persisting it. Host: " + host.getName() + if (s_logger.isDebugEnabled()) { + s_logger.debug("Write # of IO that's less than the last one. " + "Assuming something went wrong and persisting it. Host: " + host.getName() + " . VM: " + vmDiskStat.getVmName() + " Reported: " + vmDiskStat.getIOWrite() + " Stored: " + vmDiskStat_lock.getCurrentIOWrite()); } vmDiskStat_lock.setNetIOWrite(vmDiskStat_lock.getNetIOWrite() + vmDiskStat_lock.getCurrentIOWrite()); } vmDiskStat_lock.setCurrentIOWrite(vmDiskStat.getIOWrite()); if (vmDiskStat_lock.getCurrentBytesRead() > vmDiskStat.getBytesRead()) { - if (logger.isDebugEnabled()) { - logger.debug("Read # of Bytes that's less than the last one. " + "Assuming something went wrong and persisting it. Host: " + host.getName() + if (s_logger.isDebugEnabled()) { + s_logger.debug("Read # of Bytes that's less than the last one. " + "Assuming something went wrong and persisting it. Host: " + host.getName() + " . VM: " + vmDiskStat.getVmName() + " Reported: " + vmDiskStat.getBytesRead() + " Stored: " + vmDiskStat_lock.getCurrentBytesRead()); } vmDiskStat_lock.setNetBytesRead(vmDiskStat_lock.getNetBytesRead() + vmDiskStat_lock.getCurrentBytesRead()); } vmDiskStat_lock.setCurrentBytesRead(vmDiskStat.getBytesRead()); if (vmDiskStat_lock.getCurrentBytesWrite() > vmDiskStat.getBytesWrite()) { - if (logger.isDebugEnabled()) { - logger.debug("Write # of Bytes that's less than the last one. " + "Assuming something went wrong and persisting it. Host: " + host.getName() + if (s_logger.isDebugEnabled()) { + s_logger.debug("Write # of Bytes that's less than the last one. " + "Assuming something went wrong and persisting it. Host: " + host.getName() + " . VM: " + vmDiskStat.getVmName() + " Reported: " + vmDiskStat.getBytesWrite() + " Stored: " + vmDiskStat_lock.getCurrentBytesWrite()); } @@ -4050,7 +4052,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } }); } catch (Exception e) { - logger.warn("Unable to update vm disk statistics for vm: " + userVm.getId() + " from host: " + hostId, e); + s_logger.warn("Unable to update vm disk statistics for vm: " + userVm.getId() + " from host: " + hostId, e); } } } @@ -4070,7 +4072,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } if (vm.getRemoved() != null) { - logger.trace("Vm id=" + vmId + " is already expunged"); + s_logger.trace("Vm id=" + vmId + " is already expunged"); return vm; } @@ -4127,8 +4129,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir // access check - only root admin can migrate VM Account caller = CallContext.current().getCallingAccount(); if (!_accountMgr.isRootAdmin(caller.getId())) { - if (logger.isDebugEnabled()) { - logger.debug("Caller is not a root admin, permission denied to migrate the VM"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Caller is not a root admin, permission denied to migrate the VM"); } throw new PermissionDeniedException("No permission to migrate VM, Only Root Admin can migrate a VM!"); } @@ -4197,8 +4199,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir // access check - only root admin can migrate VM Account caller = CallContext.current().getCallingAccount(); if (!_accountMgr.isRootAdmin(caller.getId())) { - if (logger.isDebugEnabled()) { - logger.debug("Caller is not a root admin, permission denied to migrate the VM"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Caller is not a root admin, permission denied to migrate the VM"); } throw new PermissionDeniedException("No permission to migrate VM, Only Root Admin can migrate a VM!"); } @@ -4209,8 +4211,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } // business logic if (vm.getState() != State.Running) { - if (logger.isDebugEnabled()) { - logger.debug("VM is not Running, unable to migrate the vm " + vm); + if (s_logger.isDebugEnabled()) { + s_logger.debug("VM is not Running, unable to migrate the vm " + vm); } InvalidParameterValueException ex = new InvalidParameterValueException("VM is not Running, unable to migrate the vm with specified id"); ex.addProxyObject(vm.getUuid(), "vmId"); @@ -4225,8 +4227,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir && !vm.getHypervisorType().equals(HypervisorType.Ovm) && !vm.getHypervisorType().equals(HypervisorType.Hyperv) && !vm.getHypervisorType().equals(HypervisorType.LXC) && !vm.getHypervisorType().equals(HypervisorType.Simulator) && !vm.getHypervisorType().equals(HypervisorType.Ovm3)) { - if (logger.isDebugEnabled()) { - logger.debug(vm + " is not XenServer/VMware/KVM/Ovm/Hyperv, cannot migrate this VM."); + if (s_logger.isDebugEnabled()) { + s_logger.debug(vm + " is not XenServer/VMware/KVM/Ovm/Hyperv, cannot migrate this VM."); } throw new InvalidParameterValueException("Unsupported Hypervisor Type for VM migration, we support XenServer/VMware/KVM/Ovm/Hyperv/Ovm3 only"); } @@ -4236,8 +4238,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } if (isVMUsingLocalStorage(vm)) { - if (logger.isDebugEnabled()) { - logger.debug(vm + " is using Local Storage, cannot migrate this VM."); + if (s_logger.isDebugEnabled()) { + s_logger.debug(vm + " is using Local Storage, cannot migrate this VM."); } throw new InvalidParameterValueException("Unsupported operation, VM uses Local storage, cannot migrate"); } @@ -4276,8 +4278,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir // check max guest vm limit for the destinationHost HostVO destinationHostVO = _hostDao.findById(destinationHost.getId()); if (_capacityMgr.checkIfHostReachMaxGuestLimit(destinationHostVO)) { - if (logger.isDebugEnabled()) { - logger.debug("Host name: " + destinationHost.getName() + ", hostId: " + destinationHost.getId() + if (s_logger.isDebugEnabled()) { + s_logger.debug("Host name: " + destinationHost.getName() + ", hostId: " + destinationHost.getId() + " already has max Running VMs(count includes system VMs), cannot migrate to this host"); } throw new VirtualMachineMigrationException("Destination host, hostId: " + destinationHost.getId() @@ -4353,14 +4355,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir //raise an alert String msg = "VM is being migrated from a explicitly dedicated host " + srcHost.getName() + " to non-dedicated host " + destHost.getName(); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg); - logger.warn(msg); + s_logger.warn(msg); } //if srcHost is non dedicated but destination Host is explicitly dedicated if (!srcExplDedicated && destExplDedicated) { //raise an alert String msg = "VM is being migrated from a non dedicated host " + srcHost.getName() + " to a explicitly dedicated host " + destHost.getName(); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg); - logger.warn(msg); + s_logger.warn(msg); } //if hosts are dedicated to different account/domains, raise an alert @@ -4369,13 +4371,13 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir String msg = "VM is being migrated from host " + srcHost.getName() + " explicitly dedicated to account " + accountOfDedicatedHost(srcHost) + " to host " + destHost.getName() + " explicitly dedicated to account " + accountOfDedicatedHost(destHost); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg); - logger.warn(msg); + s_logger.warn(msg); } if (!((domainOfDedicatedHost(srcHost) == null) || (domainOfDedicatedHost(srcHost).equals(domainOfDedicatedHost(destHost))))) { String msg = "VM is being migrated from host " + srcHost.getName() + " explicitly dedicated to domain " + domainOfDedicatedHost(srcHost) + " to host " + destHost.getName() + " explicitly dedicated to domain " + domainOfDedicatedHost(destHost); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg); - logger.warn(msg); + s_logger.warn(msg); } } @@ -4413,7 +4415,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } } _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg); - logger.warn(msg); + s_logger.warn(msg); } else { //VM is not deployed using implicit planner, check if it migrated between dedicated hosts @@ -4436,12 +4438,12 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir msg = "VM is being migrated from implicitly dedicated host " + srcHost.getName() + " to shared host " + destHost.getName(); } _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg); - logger.warn(msg); + s_logger.warn(msg); } else { if (destImplDedicated) { msg = "VM is being migrated from shared host " + srcHost.getName() + " to implicitly dedicated host " + destHost.getName(); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg); - logger.warn(msg); + s_logger.warn(msg); } } } @@ -4481,11 +4483,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir return false; for (VMInstanceVO vm : allVmsOnHost) { if (!isImplicitPlannerUsedByOffering(vm.getServiceOfferingId()) || vm.getAccountId() != accountId) { - logger.info("Host " + vm.getHostId() + " found to be running a vm created by a planner other" + " than implicit, or running vms of other account"); + s_logger.info("Host " + vm.getHostId() + " found to be running a vm created by a planner other" + " than implicit, or running vms of other account"); createdByImplicitStrict = false; break; } else if (isServiceOfferingUsingPlannerInPreferredMode(vm.getServiceOfferingId()) || vm.getAccountId() != accountId) { - logger.info("Host " + vm.getHostId() + " found to be running a vm created by an implicit planner" + " in preferred mode, or running vms of other account"); + s_logger.info("Host " + vm.getHostId() + " found to be running a vm created by an implicit planner" + " in preferred mode, or running vms of other account"); createdByImplicitStrict = false; break; } @@ -4497,7 +4499,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir boolean implicitPlannerUsed = false; ServiceOfferingVO offering = _serviceOfferingDao.findByIdIncludingRemoved(offeringId); if (offering == null) { - logger.error("Couldn't retrieve the offering by the given id : " + offeringId); + s_logger.error("Couldn't retrieve the offering by the given id : " + offeringId); } else { String plannerName = offering.getDeploymentPlanner(); if (plannerName != null) { @@ -4517,8 +4519,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir // Access check - only root administrator can migrate VM. Account caller = CallContext.current().getCallingAccount(); if (!_accountMgr.isRootAdmin(caller.getId())) { - if (logger.isDebugEnabled()) { - logger.debug("Caller is not a root admin, permission denied to migrate the VM"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Caller is not a root admin, permission denied to migrate the VM"); } throw new PermissionDeniedException("No permission to migrate VM, Only Root Admin can migrate a VM!"); } @@ -4529,8 +4531,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } if (vm.getState() != State.Running) { - if (logger.isDebugEnabled()) { - logger.debug("VM is not Running, unable to migrate the vm " + vm); + if (s_logger.isDebugEnabled()) { + s_logger.debug("VM is not Running, unable to migrate the vm " + vm); } CloudRuntimeException ex = new CloudRuntimeException("VM is not Running, unable to migrate the vm with" + " specified id"); ex.addProxyObject(vm.getUuid(), "vmId"); @@ -4656,8 +4658,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir throw new InvalidParameterValueException("There is no vm by that id " + cmd.getVmId()); } else if (vm.getState() == State.Running) { // VV 3: check if vm is // running - if (logger.isDebugEnabled()) { - logger.debug("VM is Running, unable to move the vm " + vm); + if (s_logger.isDebugEnabled()) { + s_logger.debug("VM is Running, unable to move the vm " + vm); } InvalidParameterValueException ex = new InvalidParameterValueException("VM is Running, unable to move the vm with specified vmId"); ex.addProxyObject(vm.getUuid(), "vmId"); @@ -4844,8 +4846,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } else { // create default security group for the account - if (logger.isDebugEnabled()) { - logger.debug("Couldn't find default security group for the account " + newAccount + " so creating a new one"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Couldn't find default security group for the account " + newAccount + " so creating a new one"); } defaultGroup = _securityGroupMgr.createSecurityGroup(SecurityGroupManager.DEFAULT_GROUP_NAME, SecurityGroupManager.DEFAULT_GROUP_DESCRIPTION, newAccount.getDomainId(), newAccount.getId(), newAccount.getAccountName()); @@ -4864,7 +4866,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir _securityGroupMgr.addInstanceToGroups(vm.getId(), securityGroupIdList); - logger.debug("AssignVM: Basic zone, adding security groups no " + securityGroupIdList.size() + " to " + vm.getInstanceName()); + s_logger.debug("AssignVM: Basic zone, adding security groups no " + securityGroupIdList.size() + " to " + vm.getInstanceName()); } else { if (zone.isSecurityGroupEnabled()) { throw new InvalidParameterValueException("Not yet implemented for SecurityGroupEnabled advanced networks."); @@ -4918,7 +4920,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir throw new InvalidParameterValueException("Unable to find physical network with id: " + physicalNetworkId + " and tag: " + requiredOfferings.get(0).getTags()); } - logger.debug("Creating network for account " + newAccount + " from the network offering id=" + requiredOfferings.get(0).getId() + s_logger.debug("Creating network for account " + newAccount + " from the network offering id=" + requiredOfferings.get(0).getId() + " as a part of deployVM process"); Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), newAccount.getAccountName() + "-network", newAccount.getAccountName() + "-network", null, null, null, null, newAccount, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, @@ -4927,17 +4929,17 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (requiredOfferings.get(0).getIsPersistent()) { DeployDestination dest = new DeployDestination(zone, null, null, null); UserVO callerUser = _userDao.findById(CallContext.current().getCallingUserId()); - Journal journal = new Journal.LogJournal("Implementing " + newNetwork, logger); + Journal journal = new Journal.LogJournal("Implementing " + newNetwork, s_logger); ReservationContext context = new ReservationContextImpl(UUID.randomUUID().toString(), journal, callerUser, caller); - logger.debug("Implementing the network for account" + newNetwork + " as a part of" + " network provision for persistent networks"); + s_logger.debug("Implementing the network for account" + newNetwork + " as a part of" + " network provision for persistent networks"); try { Pair<? extends NetworkGuru, ? extends Network> implementedNetwork = _networkMgr.implementNetwork(newNetwork.getId(), dest, context); if (implementedNetwork == null || implementedNetwork.first() == null) { - logger.warn("Failed to implement the network " + newNetwork); + s_logger.warn("Failed to implement the network " + newNetwork); } newNetwork = implementedNetwork.second(); } catch (Exception ex) { - logger.warn("Failed to implement network " + newNetwork + " elements and" + s_logger.warn("Failed to implement network " + newNetwork + " elements and" + " resources as a part of network provision for persistent network due to ", ex); CloudRuntimeException e = new CloudRuntimeException("Failed to implement network" + " (with specified id) elements and resources as a part of network provision"); @@ -4973,10 +4975,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir VirtualMachine vmi = _itMgr.findById(vm.getId()); VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmi); _networkMgr.allocate(vmProfile, networks); - logger.debug("AssignVM: Advance virtual, adding networks no " + networks.size() + " to " + vm.getInstanceName()); + s_logger.debug("AssignVM: Advance virtual, adding networks no " + networks.size() + " to " + vm.getInstanceName()); } // END IF NON SEC GRP ENABLED } // END IF ADVANCED - logger.info("AssignVM: vm " + vm.getInstanceName() + " now belongs to account " + cmd.getAccountName()); + s_logger.info("AssignVM: vm " + vm.getInstanceName() + " now belongs to account " + cmd.getAccountName()); return vm; } @@ -5087,7 +5089,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir try { _itMgr.stop(vm.getUuid()); } catch (ResourceUnavailableException e) { - logger.debug("Stop vm " + vm.getUuid() + " failed", e); + s_logger.debug("Stop vm " + vm.getUuid() + " failed", e); CloudRuntimeException ex = new CloudRuntimeException("Stop vm failed for specified vmId"); ex.addProxyObject(vm.getUuid(), "vmId"); throw ex; @@ -5132,12 +5134,12 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (vm.getHypervisorType() == HypervisorType.VMware) { VolumeInfo volumeInStorage = volFactory.getVolume(root.getId()); if (volumeInStorage != null) { - logger.info("Expunging volume " + root.getId() + " from primary data store"); + s_logger.info("Expunging volume " + root.getId() + " from primary data store"); AsyncCallFuture<VolumeApiResult> future = _volService.expungeVolumeAsync(volFactory.getVolume(root.getId())); try { future.get(); } catch (Exception e) { - logger.debug("Failed to expunge volume:" + root.getId(), e); + s_logger.debug("Failed to expunge volume:" + root.getId(), e); } } } @@ -5182,7 +5184,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } } } catch (Exception e) { - logger.debug("Unable to start VM " + vm.getUuid(), e); + s_logger.debug("Unable to start VM " + vm.getUuid(), e); CloudRuntimeException ex = new CloudRuntimeException("Unable to start VM with specified id" + e.getMessage()); ex.addProxyObject(vm.getUuid(), "vmId"); throw ex; @@ -5190,7 +5192,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } } - logger.debug("Restore VM " + vmId + " done successfully"); + s_logger.debug("Restore VM " + vmId + " done successfully"); return vm; } @@ -5258,7 +5260,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (!cmds.isSuccessful()) { for (Answer answer : cmds.getAnswers()) { if (!answer.getResult()) { - logger.warn("Failed to reset vm due to: " + answer.getDetails()); + s_logger.warn("Failed to reset vm due to: " + answer.getDetails()); throw new CloudRuntimeException("Unable to reset " + vm + " due to " + answer.getDetails()); } @@ -5283,7 +5285,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir String sshPublicKey = vm.getDetail("SSH.PublicKey"); if (sshPublicKey != null && !sshPublicKey.equals("") && password != null && !password.equals("saved_password")) { if (!sshPublicKey.startsWith("ssh-rsa")) { - logger.warn("Only RSA public keys can be used to encrypt a vm password."); + s_logger.warn("Only RSA public keys can be used to encrypt a vm password."); return; } String encryptedPasswd = RSAHelper.encryptWithSSHPublicKey(sshPublicKey, password);
