http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/resource/ResourceManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java index 125c3a2..b450e31 100644 --- a/server/src/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/com/cloud/resource/ResourceManagerImpl.java @@ -46,6 +46,7 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.utils.identity.ManagementServerNode; import org.apache.commons.lang.ObjectUtils; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.agent.AgentManager; @@ -173,6 +174,7 @@ import com.google.gson.Gson; @Component @Local({ResourceManager.class, ResourceService.class}) public class ResourceManagerImpl extends ManagerBase implements ResourceManager, ResourceService, Manager { + private static final Logger s_logger = Logger.getLogger(ResourceManagerImpl.class); Gson _gson; @@ -354,7 +356,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, } else { throw new CloudRuntimeException("Unknown resource event:" + event); } - logger.debug("Sent resource event " + eventName + " to listener " + l.getClass().getSimpleName()); + s_logger.debug("Sent resource event " + eventName + " to listener " + l.getClass().getSimpleName()); } } @@ -418,7 +420,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, final Hypervisor.HypervisorType hypervisorType = Hypervisor.HypervisorType.getType(cmd.getHypervisor()); if (hypervisorType == null) { - logger.error("Unable to resolve " + cmd.getHypervisor() + " to a valid supported hypervisor type"); + s_logger.error("Unable to resolve " + cmd.getHypervisor() + " to a valid supported hypervisor type"); throw new InvalidParameterValueException("Unable to resolve " + cmd.getHypervisor() + " to a supported "); } @@ -532,12 +534,12 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, } discoverer.postDiscovery(hosts, _nodeId); } - logger.info("External cluster has been successfully discovered by " + discoverer.getName()); + s_logger.info("External cluster has been successfully discovered by " + discoverer.getName()); success = true; return result; } - logger.warn("Unable to find the server resources at " + url); + s_logger.warn("Unable to find the server resources at " + url); throw new DiscoveryException("Unable to add the external cluster"); } finally { if (!success) { @@ -728,7 +730,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, } final List<HostVO> hosts = new ArrayList<HostVO>(); - logger.info("Trying to add a new host at " + url + " in data center " + dcId); + s_logger.info("Trying to add a new host at " + url + " in data center " + dcId); boolean isHypervisorTypeSupported = false; for (final Discoverer discoverer : _discoverers) { if (params != null) { @@ -747,7 +749,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, } catch (final DiscoveryException e) { throw e; } catch (final Exception e) { - logger.info("Exception in host discovery process with discoverer: " + discoverer.getName() + ", skip to another discoverer if there is any"); + s_logger.info("Exception in host discovery process with discoverer: " + discoverer.getName() + ", skip to another discoverer if there is any"); } processResourceEvent(ResourceListener.EVENT_DISCOVER_AFTER, resources); @@ -765,8 +767,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, for (final HostVO host : kvmHosts) { if (host.getGuid().equalsIgnoreCase(guid)) { if (hostTags != null) { - if (logger.isTraceEnabled()) { - logger.trace("Adding Host Tags for KVM host, tags: :" + hostTags); + if (s_logger.isTraceEnabled()) { + s_logger.trace("Adding Host Tags for KVM host, tags: :" + hostTags); } _hostTagsDao.persist(host.getId(), hostTags); } @@ -789,16 +791,16 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, discoverer.postDiscovery(hosts, _nodeId); } - logger.info("server resources successfully discovered by " + discoverer.getName()); + s_logger.info("server resources successfully discovered by " + discoverer.getName()); return hosts; } } if (!isHypervisorTypeSupported) { final String msg = "Do not support HypervisorType " + hypervisorType + " for " + url; - logger.warn(msg); + s_logger.warn(msg); throw new DiscoveryException(msg); } - logger.warn("Unable to find the server resources at " + url); + s_logger.warn("Unable to find the server resources at " + url); throw new DiscoveryException("Unable to add the host"); } @@ -877,7 +879,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, try { resourceStateTransitTo(host, ResourceState.Event.DeleteHost, _nodeId); } catch (final NoTransitionException e) { - logger.debug("Cannot transmit host " + host.getId() + " to Enabled state", e); + s_logger.debug("Cannot transmit host " + host.getId() + " to Enabled state", e); } // Delete the associated entries in host ref table @@ -902,7 +904,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, storagePool.setClusterId(null); _storagePoolDao.update(poolId, storagePool); _storagePoolDao.remove(poolId); - logger.debug("Local storage id=" + poolId + " is removed as a part of host removal id=" + hostId); + s_logger.debug("Local storage id=" + poolId + " is removed as a part of host removal id=" + hostId); } } @@ -946,8 +948,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, public void doInTransactionWithoutResult(final TransactionStatus status) { final ClusterVO cluster = _clusterDao.lockRow(cmd.getId(), true); if (cluster == null) { - if (logger.isDebugEnabled()) { - logger.debug("Cluster: " + cmd.getId() + " does not even exist. Delete call is ignored."); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Cluster: " + cmd.getId() + " does not even exist. Delete call is ignored."); } throw new CloudRuntimeException("Cluster: " + cmd.getId() + " does not exist"); } @@ -956,8 +958,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, final List<HostVO> hosts = listAllHostsInCluster(cmd.getId()); if (hosts.size() > 0) { - if (logger.isDebugEnabled()) { - logger.debug("Cluster: " + cmd.getId() + " still has hosts, can't remove"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Cluster: " + cmd.getId() + " still has hosts, can't remove"); } throw new CloudRuntimeException("Cluster: " + cmd.getId() + " cannot be removed. Cluster still has hosts"); } @@ -966,8 +968,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, // pools final List<StoragePoolVO> storagePools = _storagePoolDao.listPoolsByCluster(cmd.getId()); if (storagePools.size() > 0) { - if (logger.isDebugEnabled()) { - logger.debug("Cluster: " + cmd.getId() + " still has storage pools, can't remove"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Cluster: " + cmd.getId() + " still has storage pools, can't remove"); } throw new CloudRuntimeException("Cluster: " + cmd.getId() + " cannot be removed. Cluster still has storage pools"); } @@ -993,7 +995,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, } catch (final CloudRuntimeException e) { throw e; } catch (final Throwable t) { - logger.error("Unable to delete cluster: " + cmd.getId(), t); + s_logger.error("Unable to delete cluster: " + cmd.getId(), t); return false; } } @@ -1009,7 +1011,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, if (hypervisor != null && !hypervisor.isEmpty()) { final Hypervisor.HypervisorType hypervisorType = Hypervisor.HypervisorType.getType(hypervisor); if (hypervisorType == null) { - logger.error("Unable to resolve " + hypervisor + " to a valid supported hypervisor type"); + s_logger.error("Unable to resolve " + hypervisor + " to a valid supported hypervisor type"); throw new InvalidParameterValueException("Unable to resolve " + hypervisor + " to a supported type"); } else { cluster.setHypervisorType(hypervisor); @@ -1025,7 +1027,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, throw new InvalidParameterValueException("Unable to resolve " + clusterType + " to a supported type"); } if (newClusterType == null) { - logger.error("Unable to resolve " + clusterType + " to a valid supported cluster type"); + s_logger.error("Unable to resolve " + clusterType + " to a valid supported cluster type"); throw new InvalidParameterValueException("Unable to resolve " + clusterType + " to a supported type"); } else { cluster.setClusterType(newClusterType); @@ -1041,7 +1043,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, throw new InvalidParameterValueException("Unable to resolve Allocation State '" + allocationState + "' to a supported state"); } if (newAllocationState == null) { - logger.error("Unable to resolve " + allocationState + " to a valid supported allocation State"); + s_logger.error("Unable to resolve " + allocationState + " to a valid supported allocation State"); throw new InvalidParameterValueException("Unable to resolve " + allocationState + " to a supported state"); } else { cluster.setAllocationState(newAllocationState); @@ -1058,7 +1060,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, throw new InvalidParameterValueException("Unable to resolve Managed State '" + managedstate + "' to a supported state"); } if (newManagedState == null) { - logger.error("Unable to resolve Managed State '" + managedstate + "' to a supported state"); + s_logger.error("Unable to resolve Managed State '" + managedstate + "' to a supported state"); throw new InvalidParameterValueException("Unable to resolve Managed State '" + managedstate + "' to a supported state"); } else { doUpdate = true; @@ -1177,7 +1179,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, final HostVO host = _hostDao.findById(hostId); final MaintainAnswer answer = (MaintainAnswer)_agentMgr.easySend(hostId, new MaintainCommand()); if (answer == null || !answer.getResult()) { - logger.warn("Unable to send MaintainCommand to host: " + hostId); + s_logger.warn("Unable to send MaintainCommand to host: " + hostId); return false; } @@ -1185,7 +1187,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, resourceStateTransitTo(host, ResourceState.Event.AdminAskMaintenace, _nodeId); } catch (final NoTransitionException e) { final String err = "Cannot transmit resource state of host " + host.getId() + " to " + ResourceState.Maintenance; - logger.debug(err, e); + s_logger.debug(err, e); throw new CloudRuntimeException(err + e.getMessage()); } @@ -1234,7 +1236,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, final HostVO host = _hostDao.findById(hostId); if (host == null) { - logger.debug("Unable to find host " + hostId); + s_logger.debug("Unable to find host " + hostId); throw new InvalidParameterValueException("Unable to find host with ID: " + hostId + ". Please specify a valid host ID."); } @@ -1275,7 +1277,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, } } } catch (final NoTransitionException e) { - logger.debug("Cannot transmit host " + host.getId() + "to Maintenance state", e); + s_logger.debug("Cannot transmit host " + host.getId() + "to Maintenance state", e); } return hostInMaintenance; } @@ -1329,8 +1331,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, final List<String> hostTags = cmd.getHostTags(); if (hostTags != null) { - if (logger.isDebugEnabled()) { - logger.debug("Updating Host Tags to :" + hostTags); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Updating Host Tags to :" + hostTags); } _hostTagsDao.persist(hostId, hostTags); } @@ -1478,7 +1480,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, final ResourceStateAdapter adapter = item.getValue(); final String msg = "Dispatching resource state event " + event + " to " + item.getKey(); - logger.debug(msg); + s_logger.debug(msg); if (event == ResourceStateAdapter.Event.CREATE_HOST_VO_FOR_CONNECTED) { result = adapter.createHostVOForConnectedAgent((HostVO)args[0], (StartupCommand[])args[1]); @@ -1499,7 +1501,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, break; } } catch (final UnableDeleteHostException e) { - logger.debug("Adapter " + adapter.getName() + " says unable to delete host", e); + s_logger.debug("Adapter " + adapter.getName() + " says unable to delete host", e); result = new ResourceStateAdapter.DeleteHostAnswer(false, true); } } else { @@ -1525,7 +1527,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, final String cidrSubnet = NetUtils.getCidrSubNet(cidrAddress, cidrSize); final String serverSubnet = NetUtils.getSubNet(serverPrivateIP, serverPrivateNetmask); if (!cidrSubnet.equals(serverSubnet)) { - logger.warn("The private ip address of the server (" + serverPrivateIP + ") is not compatible with the CIDR of pod: " + pod.getName() + " and zone: " + + s_logger.warn("The private ip address of the server (" + serverPrivateIP + ") is not compatible with the CIDR of pod: " + pod.getName() + " and zone: " + dc.getName()); throw new IllegalArgumentException("The private ip address of the server (" + serverPrivateIP + ") is not compatible with the CIDR of pod: " + pod.getName() + " and zone: " + dc.getName()); @@ -1605,7 +1607,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, dcId = Long.parseLong(dataCenter); dc = _dcDao.findById(dcId); } catch (final NumberFormatException e) { - logger.debug("Cannot parse " + dataCenter + " into Long."); + s_logger.debug("Cannot parse " + dataCenter + " into Long."); } } if (dc == null) { @@ -1619,7 +1621,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, final long podId = Long.parseLong(pod); p = _podDao.findById(podId); } catch (final NumberFormatException e) { - logger.debug("Cannot parse " + pod + " into Long."); + s_logger.debug("Cannot parse " + pod + " into Long."); } } /* @@ -1706,12 +1708,12 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, /* Agent goes to Connecting status */ _agentMgr.agentStatusTransitTo(host, Status.Event.AgentConnected, _nodeId); } catch (final Exception e) { - logger.debug("Cannot transmit host " + host.getId() + " to Creating state", e); + s_logger.debug("Cannot transmit host " + host.getId() + " to Creating state", e); _agentMgr.agentStatusTransitTo(host, Status.Event.Error, _nodeId); try { resourceStateTransitTo(host, ResourceState.Event.Error, _nodeId); } catch (final NoTransitionException e1) { - logger.debug("Cannot transmit host " + host.getId() + "to Error state", e); + s_logger.debug("Cannot transmit host " + host.getId() + "to Error state", e); } } @@ -1764,7 +1766,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, try { cmds = resource.initialize(); if (cmds == null) { - logger.info("Unable to fully initialize the agent because no StartupCommands are returned"); + s_logger.info("Unable to fully initialize the agent because no StartupCommands are returned"); return null; } @@ -1777,7 +1779,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, } } - if (logger.isDebugEnabled()) { + if (s_logger.isDebugEnabled()) { new Request(-1l, -1l, cmds, true, false).logD("Startup request from directly connected host: ", true); } @@ -1788,7 +1790,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, host = findHostByGuid(firstCmd.getGuidWithoutResource()); } if (host != null && host.getRemoved() == null) { // host already added, no need to add again - logger.debug("Found the host " + host.getId() + " by guid: " + firstCmd.getGuid() + ", old host reconnected as new"); + s_logger.debug("Found the host " + host.getId() + " by guid: " + firstCmd.getGuid() + ", old host reconnected as new"); hostExists = true; // ensures that host status is left unchanged in case of adding same one again return null; } @@ -1801,7 +1803,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, host = _hostDao.findById(host.getId()); } } catch (final Exception e) { - logger.warn("Unable to connect due to ", e); + s_logger.warn("Unable to connect due to ", e); } finally { if (hostExists) { if (cmds != null) { @@ -1830,7 +1832,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, try { cmds = resource.initialize(); if (cmds == null) { - logger.info("Unable to fully initialize the agent because no StartupCommands are returned"); + s_logger.info("Unable to fully initialize the agent because no StartupCommands are returned"); return null; } @@ -1843,7 +1845,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, } } - if (logger.isDebugEnabled()) { + if (s_logger.isDebugEnabled()) { new Request(-1l, -1l, cmds, true, false).logD("Startup request from directly connected host: ", true); } @@ -1857,7 +1859,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, // added, no // need to add // again - logger.debug("Found the host " + host.getId() + " by guid: " + firstCmd.getGuid() + ", old host reconnected as new"); + s_logger.debug("Found the host " + host.getId() + " by guid: " + firstCmd.getGuid() + ", old host reconnected as new"); hostExists = true; // ensures that host status is left // unchanged in case of adding same one // again @@ -1901,7 +1903,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, } } } catch (final Exception e) { - logger.warn("Unable to connect due to ", e); + s_logger.warn("Unable to connect due to ", e); } finally { if (hostExists) { if (cmds != null) { @@ -1988,7 +1990,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, @Override public HostVO fillRoutingHostVO(final HostVO host, final StartupRoutingCommand ssCmd, final HypervisorType hyType, Map<String, String> details, final List<String> hostTags) { if (host.getPodId() == null) { - logger.error("Host " + ssCmd.getPrivateIpAddress() + " sent incorrect pod, pod id is null"); + s_logger.error("Host " + ssCmd.getPrivateIpAddress() + " sent incorrect pod, pod id is null"); throw new IllegalArgumentException("Host " + ssCmd.getPrivateIpAddress() + " sent incorrect pod, pod id is null"); } @@ -2029,8 +2031,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, throw new CloudRuntimeException("Non-Routing host gets in deleteRoutingHost, id is " + host.getId()); } - if (logger.isDebugEnabled()) { - logger.debug("Deleting Host: " + host.getId() + " Guid:" + host.getGuid()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Deleting Host: " + host.getId() + " Guid:" + host.getGuid()); } if (forceDestroyStorage) { @@ -2042,12 +2044,12 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, try { final StoragePool pool = _storageSvr.preparePrimaryStorageForMaintenance(storagePool.getId()); if (pool == null) { - logger.debug("Failed to set primary storage into maintenance mode"); + s_logger.debug("Failed to set primary storage into maintenance mode"); throw new UnableDeleteHostException("Failed to set primary storage into maintenance mode"); } } catch (final Exception e) { - logger.debug("Failed to set primary storage into maintenance mode, due to: " + e.toString()); + s_logger.debug("Failed to set primary storage into maintenance mode, due to: " + e.toString()); throw new UnableDeleteHostException("Failed to set primary storage into maintenance mode, due to: " + e.toString()); } } @@ -2058,7 +2060,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, _vmMgr.destroy(vm.getUuid()); } catch (final Exception e) { final String errorMsg = "There was an error Destory the vm: " + vm + " as a part of hostDelete id=" + host.getId(); - logger.debug(errorMsg, e); + s_logger.debug(errorMsg, e); throw new UnableDeleteHostException(errorMsg + "," + e.getMessage()); } } @@ -2072,16 +2074,16 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, // Restart HA enabled vms for (final VMInstanceVO vm : vms) { if (!vm.isHaEnabled() || vm.getState() == State.Stopping) { - logger.debug("Stopping vm: " + vm + " as a part of deleteHost id=" + host.getId()); + s_logger.debug("Stopping vm: " + vm + " as a part of deleteHost id=" + host.getId()); try { _vmMgr.advanceStop(vm.getUuid(), false); } catch (final Exception e) { final String errorMsg = "There was an error stopping the vm: " + vm + " as a part of hostDelete id=" + host.getId(); - logger.debug(errorMsg, e); + s_logger.debug(errorMsg, e); throw new UnableDeleteHostException(errorMsg + "," + e.getMessage()); } } else if (vm.isHaEnabled() && (vm.getState() == State.Running || vm.getState() == State.Starting)) { - logger.debug("Scheduling restart for vm: " + vm + " " + vm.getState() + " on the host id=" + host.getId()); + s_logger.debug("Scheduling restart for vm: " + vm + " " + vm.getState() + " on the host id=" + host.getId()); _haMgr.scheduleRestart(vm, false); } } @@ -2097,7 +2099,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, HostVO host; host = _hostDao.findById(hostId); if (host == null || host.getRemoved() != null) { - logger.warn("Unable to find host " + hostId); + s_logger.warn("Unable to find host " + hostId); return true; } @@ -2115,7 +2117,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, final List<VMInstanceVO> vms = _haMgr.findTakenMigrationWork(); for (final VMInstanceVO vm : vms) { if (vm != null && vm.getHostId() != null && vm.getHostId() == hostId) { - logger.info("Unable to cancel migration because the vm is being migrated: " + vm); + s_logger.info("Unable to cancel migration because the vm is being migrated: " + vm); return false; } } @@ -2129,7 +2131,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, final boolean sshToAgent = Boolean.parseBoolean(_configDao.getValue(Config.KvmSshToAgentEnabled.key())); if (!sshToAgent) { - logger.info("Configuration tells us not to SSH into Agents. Please restart the Agent (" + hostId + ") manually"); + s_logger.info("Configuration tells us not to SSH into Agents. Please restart the Agent (" + hostId + ") manually"); return true; } @@ -2137,12 +2139,12 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, final String password = host.getDetail("password"); final String username = host.getDetail("username"); if (password == null || username == null) { - logger.debug("Can't find password/username"); + s_logger.debug("Can't find password/username"); return false; } final com.trilead.ssh2.Connection connection = SSHCmdHelper.acquireAuthorizedConnection(host.getPrivateIpAddress(), 22, username, password); if (connection == null) { - logger.debug("Failed to connect to host: " + host.getPrivateIpAddress()); + s_logger.debug("Failed to connect to host: " + host.getPrivateIpAddress()); return false; } @@ -2155,7 +2157,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, return true; } catch (final NoTransitionException e) { - logger.debug("Cannot transmit host " + host.getId() + "to Enabled state", e); + s_logger.debug("Cannot transmit host " + host.getId() + "to Enabled state", e); return false; } } @@ -2195,7 +2197,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, private boolean doUmanageHost(final long hostId) { final HostVO host = _hostDao.findById(hostId); if (host == null) { - logger.debug("Cannot find host " + hostId + ", assuming it has been deleted, skip umanage"); + s_logger.debug("Cannot find host " + hostId + ", assuming it has been deleted, skip umanage"); return true; } @@ -2239,7 +2241,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, final UpdateHostPasswordCommand cmd = new UpdateHostPasswordCommand(username, password, hostIpAddress); final Answer answer = _agentMgr.easySend(hostId, cmd); - logger.info("Result returned from update host password ==> " + answer.getDetails()); + s_logger.info("Result returned from update host password ==> " + answer.getDetails()); return answer.getResult(); } @@ -2259,7 +2261,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, return result; } } catch (final AgentUnavailableException e) { - logger.error("Agent is not availbale!", e); + s_logger.error("Agent is not availbale!", e); } if (shouldUpdateHostPasswd) { @@ -2282,7 +2284,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, return result; } } catch (final AgentUnavailableException e) { - logger.error("Agent is not availbale!", e); + s_logger.error("Agent is not availbale!", e); } final boolean shouldUpdateHostPasswd = command.getUpdatePasswdOnHost(); @@ -2309,8 +2311,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, return null; } - if (logger.isDebugEnabled()) { - logger.debug("Propagating agent change request event:" + event.toString() + " to agent:" + agentId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Propagating agent change request event:" + event.toString() + " to agent:" + agentId); } final Command[] cmds = new Command[1]; cmds[0] = new PropagateResourceEventCommand(agentId, event); @@ -2322,8 +2324,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, final Answer[] answers = _gson.fromJson(AnsStr, Answer[].class); - if (logger.isDebugEnabled()) { - logger.debug("Result for agent change is " + answers[0].getResult()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Result for agent change is " + answers[0].getResult()); } return answers[0].getResult(); @@ -2333,15 +2335,15 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, public boolean maintenanceFailed(final long hostId) { final HostVO host = _hostDao.findById(hostId); if (host == null) { - if (logger.isDebugEnabled()) { - logger.debug("Cant not find host " + hostId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Cant not find host " + hostId); } return false; } else { try { return resourceStateTransitTo(host, ResourceState.Event.UnableToMigrate, _nodeId); } catch (final NoTransitionException e) { - logger.debug("No next resource state for host " + host.getId() + " while current state is " + host.getResourceState() + " with event " + + s_logger.debug("No next resource state for host " + host.getId() + " while current state is " + host.getResourceState() + " with event " + ResourceState.Event.UnableToMigrate, e); return false; } @@ -2488,7 +2490,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, if (answer == null || !answer.getResult()) { final String msg = "Unable to obtain host " + hostId + " statistics. "; - logger.warn(msg); + s_logger.warn(msg); return null; } else { @@ -2587,8 +2589,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, if(!listAvailableGPUDevice(hostId, groupName, vgpuType).isEmpty()) { return true; } else { - if (logger.isDebugEnabled()) { - logger.debug("Host ID: "+ hostId +" does not have GPU device available"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Host ID: "+ hostId +" does not have GPU device available"); } return false; } @@ -2618,7 +2620,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, } if (answer == null || !answer.getResult()) { final String msg = "Unable to obtain GPU stats for host " + host.getName(); - logger.warn(msg); + s_logger.warn(msg); return null; } else { // now construct the result object @@ -2642,8 +2644,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, final long id = reservationEntry.getId(); final PlannerHostReservationVO hostReservation = _plannerHostReserveDao.lockRow(id, true); if (hostReservation == null) { - if (logger.isDebugEnabled()) { - logger.debug("Host reservation for host: " + hostId + " does not even exist. Release reservartion call is ignored."); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Host reservation for host: " + hostId + " does not even exist. Release reservartion call is ignored."); } return false; } @@ -2652,8 +2654,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, return true; } - if (logger.isDebugEnabled()) { - logger.debug("Host reservation for host: " + hostId + " does not even exist. Release reservartion call is ignored."); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Host reservation for host: " + hostId + " does not even exist. Release reservartion call is ignored."); } return false; @@ -2662,7 +2664,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, } catch (final CloudRuntimeException e) { throw e; } catch (final Throwable t) { - logger.error("Unable to release host reservation for host: " + hostId, t); + s_logger.error("Unable to release host reservation for host: " + hostId, t); return false; } }
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java b/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java index 4a048a2..1651ad7 100644 --- a/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java +++ b/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java @@ -30,6 +30,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.acl.SecurityChecker.AccessType; @@ -109,6 +110,7 @@ import com.cloud.vm.dao.VMInstanceDao; @Component @Local(value = {ResourceLimitService.class}) public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLimitService { + public static final Logger s_logger = Logger.getLogger(ResourceLimitManagerImpl.class); @Inject private DomainDao _domainDao; @@ -247,7 +249,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim domainResourceLimitMap.put(Resource.ResourceType.primary_storage, Long.parseLong(_configDao.getValue(Config.DefaultMaxDomainPrimaryStorage.key()))); domainResourceLimitMap.put(Resource.ResourceType.secondary_storage, Long.parseLong(_configDao.getValue(Config.DefaultMaxDomainSecondaryStorage.key()))); } catch (NumberFormatException e) { - logger.error("NumberFormatException during configuration", e); + s_logger.error("NumberFormatException during configuration", e); throw new ConfigurationException("Configuration failed due to NumberFormatException, see log for the stacktrace"); } @@ -258,7 +260,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim public void incrementResourceCount(long accountId, ResourceType type, Long... delta) { // don't upgrade resource count for system account if (accountId == Account.ACCOUNT_ID_SYSTEM) { - logger.trace("Not incrementing resource count for system accounts, returning"); + s_logger.trace("Not incrementing resource count for system accounts, returning"); return; } @@ -274,7 +276,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim public void decrementResourceCount(long accountId, ResourceType type, Long... delta) { // don't upgrade resource count for system account if (accountId == Account.ACCOUNT_ID_SYSTEM) { - logger.trace("Not decrementing resource count for system accounts, returning"); + s_logger.trace("Not decrementing resource count for system accounts, returning"); return; } long numToDecrement = (delta.length == 0) ? 1 : delta[0].longValue(); @@ -448,7 +450,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim " has been exceeded."; } ResourceAllocationException e= new ResourceAllocationException(message, type);; - logger.error(message, e); + s_logger.error(message, e); throw e; } @@ -793,7 +795,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim for (ResourceCountVO rowToUpdate : rowsToUpdate) { if (!_resourceCountDao.updateById(rowToUpdate.getId(), increment, delta)) { - logger.trace("Unable to update resource count for the row " + rowToUpdate); + s_logger.trace("Unable to update resource count for the row " + rowToUpdate); result = false; } } @@ -802,7 +804,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim } }); } catch (Exception ex) { - logger.error("Failed to update resource count for account id=" + accountId); + s_logger.error("Failed to update resource count for account id=" + accountId); return false; } } @@ -848,7 +850,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim _resourceCountDao.setResourceCount(domainId, ResourceOwnerType.Domain, type, newCount); if (oldCount != newCount) { - logger.info("Discrepency in the resource count " + "(original count=" + oldCount + " correct count = " + newCount + ") for type " + type + + s_logger.info("Discrepency in the resource count " + "(original count=" + oldCount + " correct count = " + newCount + ") for type " + type + " for domain ID " + domainId + " is fixed during resource count recalculation."); } @@ -910,7 +912,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim // No need to log message for primary and secondary storage because both are recalculating the resource count which will not lead to any discrepancy. if (!Long.valueOf(oldCount).equals(newCount) && (type != Resource.ResourceType.primary_storage && type != Resource.ResourceType.secondary_storage)) { - logger.info("Discrepency in the resource count " + "(original count=" + oldCount + " correct count = " + newCount + ") for type " + type + + s_logger.info("Discrepency in the resource count " + "(original count=" + oldCount + " correct count = " + newCount + ") for type " + type + " for account ID " + accountId + " is fixed during resource count recalculation."); } @@ -1068,7 +1070,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim @Override protected void runInContext() { - logger.info("Running resource count check periodic task"); + s_logger.info("Running resource count check periodic task"); List<DomainVO> domains = _domainDao.findImmediateChildrenForParent(Domain.ROOT_DOMAIN); // recalculateDomainResourceCount will take care of re-calculation of resource counts for sub-domains http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/server/ConfigurationServerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index 6cf5516..5ff548c 100644 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -46,6 +46,7 @@ import javax.naming.ConfigurationException; import org.apache.commons.codec.binary.Base64; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; import org.apache.cloudstack.config.ApiServiceConfiguration; import org.apache.cloudstack.framework.config.ConfigDepot; @@ -120,6 +121,7 @@ import com.cloud.utils.nio.Link; import com.cloud.utils.script.Script; public class ConfigurationServerImpl extends ManagerBase implements ConfigurationServer { + public static final Logger s_logger = Logger.getLogger(ConfigurationServerImpl.class); @Inject private ConfigurationDao _configDao; @@ -180,7 +182,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio String init = _configDao.getValue("init"); if (init == null || init.equals("false")) { - logger.debug("ConfigurationServer is saving default values to the database."); + s_logger.debug("ConfigurationServer is saving default values to the database."); // Save default Configuration Table values List<String> categories = Config.getCategories(); @@ -210,19 +212,19 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio } _configDao.update(Config.UseSecondaryStorageVm.key(), Config.UseSecondaryStorageVm.getCategory(), "true"); - logger.debug("ConfigurationServer made secondary storage vm required."); + s_logger.debug("ConfigurationServer made secondary storage vm required."); _configDao.update(Config.SecStorageEncryptCopy.key(), Config.SecStorageEncryptCopy.getCategory(), "false"); - logger.debug("ConfigurationServer made secondary storage copy encrypt set to false."); + s_logger.debug("ConfigurationServer made secondary storage copy encrypt set to false."); _configDao.update("secstorage.secure.copy.cert", "realhostip"); - logger.debug("ConfigurationServer made secondary storage copy use realhostip."); + s_logger.debug("ConfigurationServer made secondary storage copy use realhostip."); _configDao.update("user.password.encoders.exclude", "MD5,LDAP,PLAINTEXT"); - logger.debug("Configuration server excluded insecure encoders"); + s_logger.debug("Configuration server excluded insecure encoders"); _configDao.update("user.authenticators.exclude", "PLAINTEXT"); - logger.debug("Configuration server excluded plaintext authenticator"); + s_logger.debug("Configuration server excluded plaintext authenticator"); // Save default service offerings createServiceOffering(User.UID_SYSTEM, "Small Instance", 1, 512, 500, "Small Instance", ProvisioningType.THIN, false, false, null); @@ -238,9 +240,9 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio String mountParent = getMountParent(); if (mountParent != null) { _configDao.update(Config.MountParent.key(), Config.MountParent.getCategory(), mountParent); - logger.debug("ConfigurationServer saved \"" + mountParent + "\" as mount.parent."); + s_logger.debug("ConfigurationServer saved \"" + mountParent + "\" as mount.parent."); } else { - logger.debug("ConfigurationServer could not detect mount.parent."); + s_logger.debug("ConfigurationServer could not detect mount.parent."); } String hostIpAdr = NetUtils.getDefaultHostIp(); @@ -256,7 +258,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio if (needUpdateHostIp) { _configDepot.createOrUpdateConfigObject(ApiServiceConfiguration.class.getSimpleName(), ApiServiceConfiguration.ManagementHostIPAdr, hostIpAdr); - logger.debug("ConfigurationServer saved \"" + hostIpAdr + "\" as host."); + s_logger.debug("ConfigurationServer saved \"" + hostIpAdr + "\" as host."); } } @@ -360,7 +362,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio } txn.commit(); } catch (Exception e) { - logger.warn("Unable to init template " + id + " datails: " + name, e); + s_logger.warn("Unable to init template " + id + " datails: " + name, e); throw new CloudRuntimeException("Unable to init template " + id + " datails: " + name); } } @@ -407,7 +409,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio } } } catch (Exception e) { - logger.debug("initiateXenServerPVDriverVersion failed due to " + e.toString()); + s_logger.debug("initiateXenServerPVDriverVersion failed due to " + e.toString()); // ignore } } @@ -453,7 +455,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio try(final FileInputStream finputstream = new FileInputStream(propsFile);) { props.load(finputstream); }catch (IOException e) { - logger.error("getEnvironmentProperty:Exception:" + e.getMessage()); + s_logger.error("getEnvironmentProperty:Exception:" + e.getMessage()); } return props.getProperty("mount.parent"); } @@ -475,7 +477,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql); stmt.executeUpdate(); } catch (SQLException ex) { - logger.debug("Looks like system account already exists"); + s_logger.debug("Looks like system account already exists"); } // insert system user insertSql = "INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id, firstname, lastname, created, user.default)" @@ -485,7 +487,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql); stmt.executeUpdate(); } catch (SQLException ex) { - logger.debug("Looks like system user already exists"); + s_logger.debug("Looks like system user already exists"); } // insert admin user, but leave the account disabled until we set a @@ -502,7 +504,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql); stmt.executeUpdate(); } catch (SQLException ex) { - logger.debug("Looks like admin account already exists"); + s_logger.debug("Looks like admin account already exists"); } // now insert the user @@ -513,7 +515,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql); stmt.executeUpdate(); } catch (SQLException ex) { - logger.debug("Looks like admin user already exists"); + s_logger.debug("Looks like admin user already exists"); } try { @@ -544,12 +546,12 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio stmt = txn.prepareAutoCloseStatement(insertSql); stmt.executeUpdate(); } catch (SQLException ex) { - logger.warn("Failed to create default security group for default admin account due to ", ex); + s_logger.warn("Failed to create default security group for default admin account due to ", ex); } } rs.close(); } catch (Exception ex) { - logger.warn("Failed to create default security group for default admin account due to ", ex); + s_logger.warn("Failed to create default security group for default admin account due to ", ex); } } }); @@ -591,7 +593,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio ou = group[i] + "." + ou; } } catch (UnknownHostException ex) { - logger.info("Fail to get user's domain name. Would use cloud.com. ", ex); + s_logger.info("Fail to get user's domain name. Would use cloud.com. ", ex); ou = "cloud.com"; } @@ -613,8 +615,8 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio } protected void updateSSLKeystore() { - if (logger.isInfoEnabled()) { - logger.info("Processing updateSSLKeyStore"); + if (s_logger.isInfoEnabled()) { + s_logger.info("Processing updateSSLKeyStore"); } String dbString = _configDao.getValue("ssl.keystore"); @@ -632,19 +634,19 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio boolean dbExisted = (dbString != null && !dbString.isEmpty()); - logger.info("SSL keystore located at " + keystorePath); + s_logger.info("SSL keystore located at " + keystorePath); try { if (!dbExisted && null != confFile) { if (!keystoreFile.exists()) { generateDefaultKeystore(keystorePath); - logger.info("Generated SSL keystore."); + s_logger.info("Generated SSL keystore."); } String base64Keystore = getBase64Keystore(keystorePath); ConfigurationVO configVO = new ConfigurationVO("Hidden", "DEFAULT", "management-server", "ssl.keystore", base64Keystore, "SSL Keystore for the management servers"); _configDao.persist(configVO); - logger.info("Stored SSL keystore to database."); + s_logger.info("Stored SSL keystore to database."); } else { // !keystoreFile.exists() and dbExisted // Export keystore to local file byte[] storeBytes = Base64.decodeBase64(dbString); @@ -668,10 +670,10 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio } catch (Exception e) { throw new IOException("Fail to create keystore file!", e); } - logger.info("Stored database keystore to local."); + s_logger.info("Stored database keystore to local."); } } catch (Exception ex) { - logger.warn("Would use fail-safe keystore to continue.", ex); + s_logger.warn("Would use fail-safe keystore to continue.", ex); } } @@ -696,9 +698,9 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio PreparedStatement stmt = txn.prepareAutoCloseStatement(wSql); stmt.setString(1, DBEncryptionUtil.encrypt(rpassword)); stmt.executeUpdate(); - logger.info("Updated systemvm password in database"); + s_logger.info("Updated systemvm password in database"); } catch (SQLException e) { - logger.error("Cannot retrieve systemvm password", e); + s_logger.error("Cannot retrieve systemvm password", e); } } @@ -712,7 +714,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio String username = System.getProperty("user.name"); Boolean devel = Boolean.valueOf(_configDao.getValue("developer")); if (!username.equalsIgnoreCase("cloud") && !devel) { - logger.warn("Systemvm keypairs could not be set. Management server should be run as cloud user, or in development mode."); + s_logger.warn("Systemvm keypairs could not be set. Management server should be run as cloud user, or in development mode."); return; } String already = _configDao.getValue("ssh.privatekey"); @@ -721,12 +723,12 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio throw new CloudRuntimeException("Cannot get home directory for account: " + username); } - if (logger.isInfoEnabled()) { - logger.info("Processing updateKeyPairs"); + if (s_logger.isInfoEnabled()) { + s_logger.info("Processing updateKeyPairs"); } if (homeDir != null && homeDir.startsWith("~")) { - logger.error("No home directory was detected for the user '" + username + "'. Please check the profile of this user."); + s_logger.error("No home directory was detected for the user '" + username + "'. Please check the profile of this user."); throw new CloudRuntimeException("No home directory was detected for the user '" + username + "'. Please check the profile of this user."); } @@ -742,8 +744,8 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio } if (already == null || already.isEmpty()) { - if (logger.isInfoEnabled()) { - logger.info("Systemvm keypairs not found in database. Need to store them in the database"); + if (s_logger.isInfoEnabled()) { + s_logger.info("Systemvm keypairs not found in database. Need to store them in the database"); } // FIXME: take a global database lock here for safety. boolean onWindows = isOnWindows(); @@ -755,9 +757,9 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio try (DataInputStream dis = new DataInputStream(new FileInputStream(privkeyfile))) { dis.readFully(arr1); } catch (EOFException e) { - logger.info("[ignored] eof reached"); + s_logger.info("[ignored] eof reached"); } catch (Exception e) { - logger.error("Cannot read the private key file", e); + s_logger.error("Cannot read the private key file", e); throw new CloudRuntimeException("Cannot read the private key file"); } String privateKey = new String(arr1).trim(); @@ -765,9 +767,9 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio try (DataInputStream dis = new DataInputStream(new FileInputStream(pubkeyfile))) { dis.readFully(arr2); } catch (EOFException e) { - logger.info("[ignored] eof reached"); + s_logger.info("[ignored] eof reached"); } catch (Exception e) { - logger.warn("Cannot read the public key file", e); + s_logger.warn("Cannot read the public key file", e); throw new CloudRuntimeException("Cannot read the public key file"); } String publicKey = new String(arr2).trim(); @@ -789,32 +791,32 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio try { PreparedStatement stmt1 = txn.prepareAutoCloseStatement(insertSql1); stmt1.executeUpdate(); - if (logger.isDebugEnabled()) { - logger.debug("Private key inserted into database"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Private key inserted into database"); } } catch (SQLException ex) { - logger.error("SQL of the private key failed", ex); + s_logger.error("SQL of the private key failed", ex); throw new CloudRuntimeException("SQL of the private key failed"); } try { PreparedStatement stmt2 = txn.prepareAutoCloseStatement(insertSql2); stmt2.executeUpdate(); - if (logger.isDebugEnabled()) { - logger.debug("Public key inserted into database"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Public key inserted into database"); } } catch (SQLException ex) { - logger.error("SQL of the public key failed", ex); + s_logger.error("SQL of the public key failed", ex); throw new CloudRuntimeException("SQL of the public key failed"); } } }); } else { - logger.info("Keypairs already in database, updating local copy"); + s_logger.info("Keypairs already in database, updating local copy"); updateKeyPairsOnDisk(homeDir); } - logger.info("Going to update systemvm iso with generated keypairs if needed"); + s_logger.info("Going to update systemvm iso with generated keypairs if needed"); try { injectSshKeysIntoSystemVmIsoPatch(pubkeyfile.getAbsolutePath(), privkeyfile.getAbsolutePath()); } catch (CloudRuntimeException e) { @@ -844,7 +846,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio try { keyfile.createNewFile(); } catch (IOException e) { - logger.warn("Failed to create file: " + e.toString()); + s_logger.warn("Failed to create file: " + e.toString()); throw new CloudRuntimeException("Failed to update keypairs on disk: cannot create key file " + keyPath); } } @@ -855,10 +857,10 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio kStream.write(key.getBytes()); } } catch (FileNotFoundException e) { - logger.warn("Failed to write key to " + keyfile.getAbsolutePath()); + s_logger.warn("Failed to write key to " + keyfile.getAbsolutePath()); throw new CloudRuntimeException("Failed to update keypairs on disk: cannot find key file " + keyPath); } catch (IOException e) { - logger.warn("Failed to write key to " + keyfile.getAbsolutePath()); + s_logger.warn("Failed to write key to " + keyfile.getAbsolutePath()); throw new CloudRuntimeException("Failed to update keypairs on disk: cannot write to key file " + keyPath); } } @@ -869,7 +871,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio File keyDir = new File(homeDir + "/.ssh"); Boolean devel = Boolean.valueOf(_configDao.getValue("developer")); if (!keyDir.isDirectory()) { - logger.warn("Failed to create " + homeDir + "/.ssh for storing the SSH keypars"); + s_logger.warn("Failed to create " + homeDir + "/.ssh for storing the SSH keypars"); keyDir.mkdir(); } String pubKey = _configDao.getValue("ssh.publickey"); @@ -886,7 +888,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio } protected void injectSshKeysIntoSystemVmIsoPatch(String publicKeyPath, String privKeyPath) { - logger.info("Trying to inject public and private keys into systemvm iso"); + s_logger.info("Trying to inject public and private keys into systemvm iso"); String injectScript = getInjectScript(); String scriptPath = Script.findScript("", injectScript); String systemVmIsoPath = Script.findScript("", "vms/systemvm.iso"); @@ -898,9 +900,9 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio } Script command = null; if(isOnWindows()) { - command = new Script("python", logger); + command = new Script("python", s_logger); } else { - command = new Script("/bin/bash", logger); + command = new Script("/bin/bash", s_logger); } if (isOnWindows()) { scriptPath = scriptPath.replaceAll("\\\\" ,"/" ); @@ -914,9 +916,9 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio command.add(systemVmIsoPath); final String result = command.execute(); - logger.info("Injected public and private keys into systemvm iso with result : " + result); + s_logger.info("Injected public and private keys into systemvm iso with result : " + result); if (result != null) { - logger.warn("Failed to inject generated public key into systemvm iso " + result); + s_logger.warn("Failed to inject generated public key into systemvm iso " + result); throw new CloudRuntimeException("Failed to inject generated public key into systemvm iso " + result); } } @@ -944,7 +946,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio if (already == null) { - logger.info("Need to store secondary storage vm copy password in the database"); + s_logger.info("Need to store secondary storage vm copy password in the database"); String password = PasswordGenerator.generateRandomPassword(12); final String insertSql1 = @@ -959,9 +961,9 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio try { PreparedStatement stmt1 = txn.prepareAutoCloseStatement(insertSql1); stmt1.executeUpdate(); - logger.debug("secondary storage vm copy password inserted into database"); + s_logger.debug("secondary storage vm copy password inserted into database"); } catch (SQLException ex) { - logger.warn("Failed to insert secondary storage vm copy password", ex); + s_logger.warn("Failed to insert secondary storage vm copy password", ex); } } }); @@ -972,7 +974,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio try { _configDao.update(Config.SSOKey.key(), Config.SSOKey.getCategory(), getPrivateKey()); } catch (NoSuchAlgorithmException ex) { - logger.error("error generating sso key", ex); + s_logger.error("error generating sso key", ex); } } @@ -985,14 +987,14 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio if(configInDB == null) { ConfigurationVO configVO = new ConfigurationVO(Config.SSVMPSK.getCategory(), "DEFAULT", Config.SSVMPSK.getComponent(), Config.SSVMPSK.key(), getPrivateKey(), Config.SSVMPSK.getDescription()); - logger.info("generating a new SSVM PSK. This goes to SSVM on Start"); + s_logger.info("generating a new SSVM PSK. This goes to SSVM on Start"); _configDao.persist(configVO); } else if (StringUtils.isEmpty(configInDB.getValue())) { - logger.info("updating the SSVM PSK with new value. This goes to SSVM on Start"); + s_logger.info("updating the SSVM PSK with new value. This goes to SSVM on Start"); _configDao.update(Config.SSVMPSK.key(), Config.SSVMPSK.getCategory(), getPrivateKey()); } } catch (NoSuchAlgorithmException ex) { - logger.error("error generating ssvm psk", ex); + s_logger.error("error generating ssvm psk", ex); } } @@ -1060,7 +1062,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio } }); } catch (Exception e) { - logger.error("Unable to create new pod due to " + e.getMessage(), e); + s_logger.error("Unable to create new pod due to " + e.getMessage(), e); throw new InternalErrorException("Failed to create new pod. Please contact Cloud Support."); } @@ -1169,7 +1171,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultSharedSGNetworkOffering.getId(), service, defaultSharedSGNetworkOfferingProviders.get(service)); _ntwkOfferingServiceMapDao.persist(offService); - logger.trace("Added service for the network offering: " + offService); + s_logger.trace("Added service for the network offering: " + offService); } // Offering #2 @@ -1184,7 +1186,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultSharedNetworkOffering.getId(), service, defaultSharedNetworkOfferingProviders.get(service)); _ntwkOfferingServiceMapDao.persist(offService); - logger.trace("Added service for the network offering: " + offService); + s_logger.trace("Added service for the network offering: " + offService); } // Offering #3 @@ -1201,7 +1203,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio new NetworkOfferingServiceMapVO(defaultIsolatedSourceNatEnabledNetworkOffering.getId(), service, defaultIsolatedSourceNatEnabledNetworkOfferingProviders.get(service)); _ntwkOfferingServiceMapDao.persist(offService); - logger.trace("Added service for the network offering: " + offService); + s_logger.trace("Added service for the network offering: " + offService); } // Offering #4 @@ -1216,7 +1218,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultIsolatedEnabledNetworkOffering.getId(), service, defaultIsolatedNetworkOfferingProviders.get(service)); _ntwkOfferingServiceMapDao.persist(offService); - logger.trace("Added service for the network offering: " + offService); + s_logger.trace("Added service for the network offering: " + offService); } // Offering #5 @@ -1232,7 +1234,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultNetscalerNetworkOffering.getId(), service, netscalerServiceProviders.get(service)); _ntwkOfferingServiceMapDao.persist(offService); - logger.trace("Added service for the network offering: " + offService); + s_logger.trace("Added service for the network offering: " + offService); } // Offering #6 @@ -1260,7 +1262,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultNetworkOfferingForVpcNetworks.getId(), entry.getKey(), entry.getValue()); _ntwkOfferingServiceMapDao.persist(offService); - logger.trace("Added service for the network offering: " + offService); + s_logger.trace("Added service for the network offering: " + offService); } // Offering #7 @@ -1287,7 +1289,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultNetworkOfferingForVpcNetworksNoLB.getId(), entry.getKey(), entry.getValue()); _ntwkOfferingServiceMapDao.persist(offService); - logger.trace("Added service for the network offering: " + offService); + s_logger.trace("Added service for the network offering: " + offService); } //offering #8 - network offering with internal lb service @@ -1311,7 +1313,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio for (Service service : internalLbOffProviders.keySet()) { NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(internalLbOff.getId(), service, internalLbOffProviders.get(service)); _ntwkOfferingServiceMapDao.persist(offService); - logger.trace("Added service for the network offering: " + offService); + s_logger.trace("Added service for the network offering: " + offService); } } }); @@ -1444,7 +1446,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio final int domainExpectedCount = domainSupportedResourceTypes.size(); if ((domainResourceCount.size() < domainExpectedCount * domains.size())) { - logger.debug("resource_count table has records missing for some domains...going to insert them"); + s_logger.debug("resource_count table has records missing for some domains...going to insert them"); for (final DomainVO domain : domains) { // Lock domain Transaction.execute(new TransactionCallbackNoReturn() { @@ -1461,7 +1463,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio for (ResourceType resourceType : domainSupportedResourceTypes) { if (!domainCountStr.contains(resourceType.toString())) { ResourceCountVO resourceCountVO = new ResourceCountVO(resourceType, 0, domain.getId(), ResourceOwnerType.Domain); - logger.debug("Inserting resource count of type " + resourceType + " for domain id=" + domain.getId()); + s_logger.debug("Inserting resource count of type " + resourceType + " for domain id=" + domain.getId()); _resourceCountDao.persist(resourceCountVO); } } @@ -1473,7 +1475,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio } if ((accountResourceCount.size() < accountExpectedCount * accounts.size())) { - logger.debug("resource_count table has records missing for some accounts...going to insert them"); + s_logger.debug("resource_count table has records missing for some accounts...going to insert them"); for (final AccountVO account : accounts) { // lock account Transaction.execute(new TransactionCallbackNoReturn() { @@ -1490,7 +1492,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio for (ResourceType resourceType : accountSupportedResourceTypes) { if (!accountCountStr.contains(resourceType.toString())) { ResourceCountVO resourceCountVO = new ResourceCountVO(resourceType, 0, account.getId(), ResourceOwnerType.Account); - logger.debug("Inserting resource count of type " + resourceType + " for account id=" + account.getId()); + s_logger.debug("Inserting resource count of type " + resourceType + " for account id=" + account.getId()); _resourceCountDao.persist(resourceCountVO); } }
