From d077b127aaa04653c9f6332237b60f370615e564 Mon Sep 17 00:00:00 2001 From: alena Date: Mon, 13 Dec 2010 14:40:27 -0800 Subject: [PATCH] bug 7498: fixed search by keyword in listUserVm/listSystemVms/listRouters commands status 7498: resolved fixed --- api/src/com/cloud/vm/VirtualMachine.java | 2 +- .../src/com/cloud/agent/api/StartCommand.java | 2 +- .../agent/api/StartConsoleProxyCommand.java | 2 +- .../cloud/agent/api/StartRouterCommand.java | 2 +- .../agent/api/StartSecStorageVmCommand.java | 2 +- core/src/com/cloud/vm/VMInstanceVO.java | 10 +- .../src/com/cloud/api/ApiResponseHelper.java | 16 +- .../executor/ConsoleProxyExecutorHelper.java | 2 +- .../async/executor/DeployVMExecutor.java | 4 +- .../async/executor/DestroyVMExecutor.java | 8 +- .../async/executor/RebootVMExecutor.java | 10 +- .../async/executor/RouterExecutorHelper.java | 2 +- .../cloud/async/executor/StopVMExecutor.java | 10 +- .../async/executor/SystemVmCmdExecutor.java | 2 +- .../async/executor/VMExecutorHelper.java | 4 +- .../executor/VolumeOperationExecutor.java | 2 +- .../AgentBasedConsoleProxyManager.java | 2 +- .../consoleproxy/ConsoleProxyManagerImpl.java | 68 +++---- .../cloud/ha/HighAvailabilityManagerImpl.java | 44 ++--- server/src/com/cloud/ha/InvestigatorImpl.java | 4 +- .../migration/Db20to21MigrationUtil.java | 14 +- .../router/DomainRouterManagerImpl.java | 90 ++++----- .../cloud/server/ManagementServerImpl.java | 15 +- .../cloud/servlet/ConsoleProxyServlet.java | 2 +- .../com/cloud/storage/StorageManagerImpl.java | 2 +- .../SecondaryStorageManagerImpl.java | 70 +++---- .../storage/snapshot/SnapshotManagerImpl.java | 2 +- .../com/cloud/user/AccountManagerImpl.java | 2 +- .../src/com/cloud/vm/UserVmManagerImpl.java | 186 +++++++++--------- .../cloud/vm/VirtualMachineManagerImpl.java | 2 +- .../cloud/vm/VirtualMachineProfileImpl.java | 2 +- .../src/com/cloud/vm/dao/UserVmDaoImpl.java | 2 +- .../com/cloud/vm/dao/VMInstanceDaoImpl.java | 2 +- 33 files changed, 292 insertions(+), 297 deletions(-) diff --git a/api/src/com/cloud/vm/VirtualMachine.java b/api/src/com/cloud/vm/VirtualMachine.java index 538a6fb5db5..d410340d408 100755 --- a/api/src/com/cloud/vm/VirtualMachine.java +++ b/api/src/com/cloud/vm/VirtualMachine.java @@ -61,7 +61,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity { /** * @return the name of the virtual machine. */ - public String getHostName(); + public String getName(); /** * @return the ip address of the virtual machine. diff --git a/core/src/com/cloud/agent/api/StartCommand.java b/core/src/com/cloud/agent/api/StartCommand.java index ac99dfd88cf..7960d1ec571 100755 --- a/core/src/com/cloud/agent/api/StartCommand.java +++ b/core/src/com/cloud/agent/api/StartCommand.java @@ -67,7 +67,7 @@ public class StartCommand extends AbstractStartCommand { this.guestNetworkId = guestNetworkId; guestMacAddress = vm.getGuestMacAddress(); vncPassword = vm.getVncPassword(); - hostName = vm.getHostName(); + hostName = vm.getName(); networkRateMbps = networkRate; networkRateMulticastMbps = multicastRate; if (bits == 32) { diff --git a/core/src/com/cloud/agent/api/StartConsoleProxyCommand.java b/core/src/com/cloud/agent/api/StartConsoleProxyCommand.java index 2eb470fb570..93db6751518 100644 --- a/core/src/com/cloud/agent/api/StartConsoleProxyCommand.java +++ b/core/src/com/cloud/agent/api/StartConsoleProxyCommand.java @@ -107,7 +107,7 @@ public class StartConsoleProxyCommand extends AbstractStartCommand { String basic = " eth0ip=" + proxy.getGuestIpAddress() + " eth0mask=" + proxy.getGuestNetmask() + " eth1ip=" + eth1Ip + " eth1mask=" + eth1NetMask + " eth2ip=" + eth2Ip + " eth2mask=" + eth2NetMask + " gateway=" + gateWay - + " dns1=" + proxy.getDns1() + " type=consoleproxy"+ " name=" + proxy.getHostName() + " template=domP"; + + " dns1=" + proxy.getDns1() + " type=consoleproxy"+ " name=" + proxy.getName() + " template=domP"; if (proxy.getDns2() != null) { basic = basic + " dns2=" + proxy.getDns2(); } diff --git a/core/src/com/cloud/agent/api/StartRouterCommand.java b/core/src/com/cloud/agent/api/StartRouterCommand.java index fea4dbd85ac..9ffa97fe570 100755 --- a/core/src/com/cloud/agent/api/StartRouterCommand.java +++ b/core/src/com/cloud/agent/api/StartRouterCommand.java @@ -78,7 +78,7 @@ public class StartRouterCommand extends AbstractStartCommand { String eth2Ip = router.getPublicIpAddress()==null?"0.0.0.0":router.getPublicIpAddress(); String basic = " eth0ip=" + router.getGuestIpAddress() + " eth0mask=" + router.getGuestNetmask() + " eth1ip=" + router.getPrivateIpAddress() + " eth1mask=" + router.getPrivateNetmask() + " gateway=" + router.getGateway() - + " dns1=" + router.getDns1() + " name=" + router.getHostName() + " mgmtcidr=" + mgmt_host; + + " dns1=" + router.getDns1() + " name=" + router.getName() + " mgmtcidr=" + mgmt_host; if (!router.getPublicMacAddress().equalsIgnoreCase("FE:FF:FF:FF:FF:FF")) { basic = basic + " eth2ip=" + eth2Ip + " eth2mask=" + router.getPublicNetmask(); } diff --git a/core/src/com/cloud/agent/api/StartSecStorageVmCommand.java b/core/src/com/cloud/agent/api/StartSecStorageVmCommand.java index 089281add4a..1268c9b4dfc 100644 --- a/core/src/com/cloud/agent/api/StartSecStorageVmCommand.java +++ b/core/src/com/cloud/agent/api/StartSecStorageVmCommand.java @@ -98,7 +98,7 @@ public class StartSecStorageVmCommand extends AbstractStartCommand { String basic = " eth0ip=" + secStorageVm.getGuestIpAddress() + " eth0mask=" + secStorageVm.getGuestNetmask() + " eth1ip=" + eth1Ip + " eth1mask=" + eth1NetMask + " eth2ip=" + eth2Ip + " eth2mask=" + eth2NetMask + " gateway=" + gateWay - + " dns1=" + secStorageVm.getDns1() + " type=secstorage" + " name=" + secStorageVm.getHostName() + " template=domP"; + + " dns1=" + secStorageVm.getDns1() + " type=secstorage" + " name=" + secStorageVm.getName() + " template=domP"; if (secStorageVm.getDns2() != null) { basic = basic + " dns2=" + secStorageVm.getDns2(); } diff --git a/core/src/com/cloud/vm/VMInstanceVO.java b/core/src/com/cloud/vm/VMInstanceVO.java index a610ff3076e..1ac64b2803d 100644 --- a/core/src/com/cloud/vm/VMInstanceVO.java +++ b/core/src/com/cloud/vm/VMInstanceVO.java @@ -51,7 +51,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject -1) this.templateId = vmTemplateId; else @@ -267,8 +267,8 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject vols = _storageMgr.prepare(proxy, routingHost); if (vols == null || vols.size() == 0) { - String msg = "Unable to prepare storage for " + proxy.getHostName() + " in pod " + pod.getId(); + String msg = "Unable to prepare storage for " + proxy.getName() + " in pod " + pod.getId(); s_logger.debug(msg); throw new CloudRuntimeException(msg); } @@ -703,7 +703,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx GuestOSVO guestOS = _guestOSDao.findById(proxy.getGuestOSId()); if (guestOS == null) { String msg = "Could not find guest OS description for OSId " - + proxy.getGuestOSId() + " for vm: " + proxy.getHostName(); + + proxy.getGuestOSId() + " for vm: " + proxy.getName(); s_logger.debug(msg); throw new CloudRuntimeException(msg); } else { @@ -714,10 +714,10 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx // carry the console proxy port info over so that we don't // need to configure agent on this StartConsoleProxyCommand cmdStart = new StartConsoleProxyCommand(_networkRate, _multicastRate, - _proxyCmdPort, proxy, proxy.getHostName(), "", vols, Integer.toString(_consoleProxyPort), + _proxyCmdPort, proxy, proxy.getName(), "", vols, Integer.toString(_consoleProxyPort), Integer.toString(_consoleProxyUrlPort), _mgmt_host, _mgmt_port, _sslEnabled, guestOSDescription); if (s_logger.isDebugEnabled()) { - s_logger.debug("Sending start command for console proxy " + proxy.getHostName() + " to " + routingHost.getName()); + s_logger.debug("Sending start command for console proxy " + proxy.getName() + " to " + routingHost.getName()); } try { answer = _agentMgr.send(routingHost.getId(), cmdStart); @@ -725,12 +725,12 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx s_logger.debug("StartConsoleProxy Answer: " + (answer != null ? answer : "null")); if (s_logger.isDebugEnabled()) { - s_logger.debug("Received answer on starting console proxy " + proxy.getHostName() + " on " + routingHost.getName()); + s_logger.debug("Received answer on starting console proxy " + proxy.getName() + " on " + routingHost.getName()); } if (answer != null && answer.getResult()) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Console proxy " + proxy.getHostName() + " started on " + routingHost.getName()); + s_logger.debug("Console proxy " + proxy.getName() + " started on " + routingHost.getName()); } if (answer instanceof StartConsoleProxyAnswer) { @@ -749,7 +749,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx event.setType(EventTypes.EVENT_PROXY_START); event.setLevel(EventVO.LEVEL_INFO); event.setStartId(startEventId); - event.setDescription("Console proxy started - " + proxy.getHostName()); + event.setDescription("Console proxy started - " + proxy.getName()); _eventDao.persist(event); break; } @@ -757,13 +757,13 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx + answer.getDetails()); } catch (OperationTimedoutException e) { if (e.isActive()) { - s_logger.debug("Unable to start vm " + proxy.getHostName() + s_logger.debug("Unable to start vm " + proxy.getName() + " due to operation timed out and it is active so scheduling a restart."); _haMgr.scheduleRestart(proxy, true); return null; } } catch (AgentUnavailableException e) { - s_logger.debug("Agent " + routingHost.toString() + " was unavailable to start VM " + proxy.getHostName()); + s_logger.debug("Agent " + routingHost.toString() + " was unavailable to start VM " + proxy.getName()); } avoid.add(routingHost); @@ -789,7 +789,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx event.setType(EventTypes.EVENT_PROXY_START); event.setLevel(EventVO.LEVEL_ERROR); event.setStartId(startEventId); - event.setDescription("Starting console proxy failed due to unable to find a host - " + proxy.getHostName()); + event.setDescription("Starting console proxy failed due to unable to find a host - " + proxy.getName()); _eventDao.persist(event); throw new ExecutionException("Couldn't find a routingHost to run console proxy"); } @@ -877,7 +877,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx if (s_logger.isTraceEnabled()) { s_logger.trace("Running proxy pool size : " + runningList.size()); for (ConsoleProxyVO proxy : runningList) { - s_logger.trace("Running proxy instance : " + proxy.getHostName()); + s_logger.trace("Running proxy instance : " + proxy.getName()); } } @@ -1078,7 +1078,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx event.setAccountId(Account.ACCOUNT_ID_SYSTEM); event.setType(EventTypes.EVENT_PROXY_CREATE); event.setLevel(EventVO.LEVEL_INFO); - event.setDescription("New console proxy created - " + proxy.getHostName()); + event.setDescription("New console proxy created - " + proxy.getName()); _eventDao.persist(event); txn.commit(); @@ -1532,7 +1532,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx } } else { if (s_logger.isInfoEnabled()) { - s_logger.info("Unable to acquire synchronization lock to start console proxy : " + readyProxy.getHostName()); + s_logger.info("Unable to acquire synchronization lock to start console proxy : " + readyProxy.getName()); } } } finally { @@ -1753,7 +1753,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx } } else { if (s_logger.isInfoEnabled()) { - s_logger.info("Console proxy " + proxy.getHostName() + " is started"); + s_logger.info("Console proxy " + proxy.getName() + " is started"); } } } @@ -1952,7 +1952,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx return stop(proxy, startEventId); } catch (AgentUnavailableException e) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Stopping console proxy " + proxy.getHostName() + " failed : exception " + e.toString()); + s_logger.debug("Stopping console proxy " + proxy.getName() + " failed : exception " + e.toString()); } return false; } @@ -1987,7 +1987,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx if (answer != null) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully reboot console proxy " + proxy.getHostName()); + s_logger.debug("Successfully reboot console proxy " + proxy.getName()); } SubscriptionMgr.getInstance() @@ -2003,12 +2003,12 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx event.setType(EventTypes.EVENT_PROXY_REBOOT); event.setLevel(EventVO.LEVEL_INFO); event.setStartId(startEventId); - event.setDescription("Console proxy rebooted - " + proxy.getHostName()); + event.setDescription("Console proxy rebooted - " + proxy.getName()); _eventDao.persist(event); return true; } else { if (s_logger.isDebugEnabled()) { - s_logger.debug("failed to reboot console proxy : " + proxy.getHostName()); + s_logger.debug("failed to reboot console proxy : " + proxy.getName()); } final EventVO event = new EventVO(); @@ -2017,7 +2017,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx event.setType(EventTypes.EVENT_PROXY_REBOOT); event.setLevel(EventVO.LEVEL_ERROR); event.setStartId(startEventId); - event.setDescription("Rebooting console proxy failed - " + proxy.getHostName()); + event.setDescription("Rebooting console proxy failed - " + proxy.getName()); _eventDao.persist(event); return false; } @@ -2092,7 +2092,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx event.setType(EventTypes.EVENT_PROXY_DESTROY); event.setLevel(EventVO.LEVEL_INFO); event.setStartId(startEventId); - event.setDescription("Console proxy destroyed - " + vm.getHostName()); + event.setDescription("Console proxy destroyed - " + vm.getName()); _eventDao.persist(event); txn.commit(); @@ -2101,7 +2101,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx txn.rollback(); return false; } finally { - s_logger.debug("console proxy vm is destroyed : " + vm.getHostName()); + s_logger.debug("console proxy vm is destroyed : " + vm.getName()); } } } @@ -2126,7 +2126,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx event.setAccountId(Account.ACCOUNT_ID_SYSTEM); event.setType(EventTypes.EVENT_PROXY_DESTROY); event.setLevel(EventVO.LEVEL_INFO); - event.setDescription("Console proxy destroyed - " + proxy.getHostName()); + event.setDescription("Console proxy destroyed - " + proxy.getName()); _eventDao.persist(event); } @@ -2174,7 +2174,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx event.setType(EventTypes.EVENT_PROXY_STOP); event.setLevel(EventVO.LEVEL_ERROR); event.setStartId(startEventId); - event.setDescription("Stopping console proxy failed due to negative answer from agent - " + proxy.getHostName()); + event.setDescription("Stopping console proxy failed due to negative answer from agent - " + proxy.getName()); _eventDao.persist(event); return false; } @@ -2192,7 +2192,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx event.setType(EventTypes.EVENT_PROXY_STOP); event.setLevel(EventVO.LEVEL_INFO); event.setStartId(startEventId); - event.setDescription("Console proxy stopped - " + proxy.getHostName()); + event.setDescription("Console proxy stopped - " + proxy.getName()); _eventDao.persist(event); return true; } catch (OperationTimedoutException e) { @@ -2202,7 +2202,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx event.setType(EventTypes.EVENT_PROXY_STOP); event.setLevel(EventVO.LEVEL_ERROR); event.setStartId(startEventId); - event.setDescription("Stopping console proxy failed due to operation time out - " + proxy.getHostName()); + event.setDescription("Stopping console proxy failed due to operation time out - " + proxy.getName()); _eventDao.persist(event); throw new AgentUnavailableException(proxy.getHostId()); } @@ -2279,7 +2279,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx storageIps[1] = vols.get(1).getHostIp(); } - PrepareForMigrationCommand cmd = new PrepareForMigrationCommand(proxy.getHostName(), null, storageIps, vols, mirroredVols); + PrepareForMigrationCommand cmd = new PrepareForMigrationCommand(proxy.getName(), null, storageIps, vols, mirroredVols); HostVO routingHost = null; HashSet avoid = new HashSet(); @@ -2299,8 +2299,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx } if (!_storageMgr.share(proxy, vols, routingHost, false)) { - s_logger.warn("Can not share " + proxy.getHostName()); - throw new StorageUnavailableException("Can not share " + proxy.getHostName(), vol.getPoolId()); + s_logger.warn("Can not share " + proxy.getName()); + throw new StorageUnavailableException("Can not share " + proxy.getName(), vol.getPoolId()); } Answer answer = _agentMgr.easySend(routingHost.getId(), cmd); @@ -2499,7 +2499,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx buf.append(" template=domP type=consoleproxy"); buf.append(" host=").append(_mgmt_host); buf.append(" port=").append(_mgmt_port); - buf.append(" name=").append(profile.getVirtualMachine().getHostName()); + buf.append(" name=").append(profile.getVirtualMachine().getName()); if (_sslEnabled) { buf.append(" premium=true"); } @@ -2618,7 +2618,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx ConsoleProxyVO consoleProxy = _consoleProxyDao.findById(proxyVmId); //find corresponding host if(consoleProxy!=null){ - HostVO consoleProxyHost = _hostDao.findConsoleProxyHost(consoleProxy.getHostName(), Type.ConsoleProxy); + HostVO consoleProxyHost = _hostDao.findConsoleProxyHost(consoleProxy.getName(), Type.ConsoleProxy); //now send a command to console proxy host UpdateCertificateCommand certCmd = new UpdateCertificateCommand(certStr, true); try { diff --git a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java index 245bffcc561..0fe4676dbc0 100644 --- a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java +++ b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java @@ -199,12 +199,12 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager { // collect list of vm names for the alert email VMInstanceVO vm = vms.get(0); if (vm.isHaEnabled()) { - sb.append(" " + vm.getHostName()); + sb.append(" " + vm.getName()); } for (int i = 1; i < vms.size(); i++) { vm = vms.get(i); if (vm.isHaEnabled()) { - sb.append(" " + vm.getHostName()); + sb.append(" " + vm.getName()); } } } @@ -217,7 +217,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager { for (final VMInstanceVO vm : vms) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Notifying HA Mgr of to investigate vm " + vm.getId() + "-" + vm.getHostName()); + s_logger.debug("Notifying HA Mgr of to investigate vm " + vm.getId() + "-" + vm.getName()); } scheduleRestart(vm, true); } @@ -284,8 +284,8 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager { if (!(_forceHA || vm.isHaEnabled())) { _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "VM (name: " - + vm.getHostName() + ", id: " + vm.getId() + ") stopped unexpectedly on host " - + vm.getHostId(), "Virtual Machine " + vm.getHostName() + " (id: " + + vm.getName() + ", id: " + vm.getId() + ") stopped unexpectedly on host " + + vm.getHostId(), "Virtual Machine " + vm.getName() + " (id: " + vm.getId() + ") running on host [" + vm.getHostId() + "] stopped unexpectedly."); @@ -371,12 +371,12 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager { investigator = en.nextElement(); alive = investigator.isVmAlive(vm, host); if (alive != null) { - s_logger.debug(investigator.getName() + " found VM " + vm.getHostName() + "to be alive? " + alive); + s_logger.debug(investigator.getName() + " found VM " + vm.getName() + "to be alive? " + alive); break; } } if (alive != null && alive) { - s_logger.debug("VM " + vm.getHostName() + " is found to be alive by " + investigator.getName()); + s_logger.debug("VM " + vm.getName() + " is found to be alive by " + investigator.getName()); if (host.getStatus() == Status.Up) { compareState(vm, new AgentVmInfo(vm.getInstanceName(), mgr, State.Running), false); return null; @@ -402,7 +402,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager { if (alive== null && !fenced) { s_logger.debug("We were unable to fence off the VM " + vm.toString()); - _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc, "Insufficient capacity to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc); + _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getName() + " which was running on host " + hostDesc, "Insufficient capacity to restart VM, name: " + vm.getName() + ", id: " + vmId + " which was running on host " + hostDesc); return (System.currentTimeMillis() >> 10) + _restartRetryInterval; } @@ -414,8 +414,8 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager { // send an alert for VMs that stop unexpectedly _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), - "VM (name: " + vm.getHostName() + ", id: " + vmId + ") stopped unexpectedly on host " - + hostDesc, "Virtual Machine " + vm.getHostName() + " (id: " + "VM (name: " + vm.getName() + ", id: " + vmId + ") stopped unexpectedly on host " + + hostDesc, "Virtual Machine " + vm.getName() + " (id: " + vm.getId() + ") running on host [" + hostDesc + "] stopped unexpectedly."); vm = mgr.get(vm.getId()); @@ -455,19 +455,19 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager { return (System.currentTimeMillis() >> 10) + _restartRetryInterval; } catch (final InsufficientCapacityException e) { s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage()); - _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc, "Insufficient capacity to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc); + _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getName() + " which was running on host " + hostDesc, "Insufficient capacity to restart VM, name: " + vm.getName() + ", id: " + vmId + " which was running on host " + hostDesc); return null; } catch (final StorageUnavailableException e) { s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage()); - _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc, "The Storage is unavailable for trying to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc); + _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getName() + " which was running on host " + hostDesc, "The Storage is unavailable for trying to restart VM, name: " + vm.getName() + ", id: " + vmId + " which was running on host " + hostDesc); return null; } catch (ConcurrentOperationException e) { s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage()); - _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc, "The Storage is unavailable for trying to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc); + _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getName() + " which was running on host " + hostDesc, "The Storage is unavailable for trying to restart VM, name: " + vm.getName() + ", id: " + vmId + " which was running on host " + hostDesc); return null; } catch (ExecutionException e) { s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage()); - _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc, "The Storage is unavailable for trying to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc); + _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to restart " + vm.getName() + " which was running on host " + hostDesc, "The Storage is unavailable for trying to restart VM, name: " + vm.getName() + ", id: " + vmId + " which was running on host " + hostDesc); return null; } } @@ -483,7 +483,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager { State agentState = info.state; final String agentName = info.name; final State serverState = vm.getState(); - final String serverName = vm.getHostName(); + final String serverName = vm.getName(); Command command = null; @@ -507,7 +507,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager { HostVO hostVO = _hostDao.findById(vm.getHostId()); String hostDesc = "name: " + hostVO.getName() + " (id:" + hostVO.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName(); - _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "VM (name: " + vm.getHostName() + ", id: " + vm.getId() + ") stopped on host " + hostDesc + " due to storage failure", "Virtual Machine " + vm.getHostName() + " (id: " + vm.getId() + ") running on host [" + vm.getHostId() + "] stopped due to storage failure."); + _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "VM (name: " + vm.getName() + ", id: " + vm.getId() + ") stopped on host " + hostDesc + " due to storage failure", "Virtual Machine " + vm.getName() + " (id: " + vm.getId() + ") running on host [" + vm.getHostId() + "] stopped due to storage failure."); } if (serverState == State.Migrating) { @@ -545,10 +545,10 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager { info.mgr.completeStopCommand(vm); command = info.mgr.cleanup(vm, agentName); } else { - s_logger.debug("Ignoring VM in stopping mode: " + vm.getHostName()); + s_logger.debug("Ignoring VM in stopping mode: " + vm.getName()); } } else if (serverState == State.Starting) { - s_logger.debug("Ignoring VM in starting mode: " + vm.getHostName()); + s_logger.debug("Ignoring VM in starting mode: " + vm.getName()); } else { s_logger.debug("Sending cleanup to a stopped vm: " + agentName); _itMgr.stateTransitTo(vm, VirtualMachine.Event.AgentReportStopped, null); @@ -721,14 +721,14 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager { if (s_logger.isDebugEnabled()) { s_logger.debug("Unable to find a host for migrating vm " + vmId); } - _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to migrate vm " + vm.getHostName() + " from host " + fromHostName + " in zone " + dcVO.getName() + " and pod " + podVO.getName(), "Unable to find a suitable host"); + _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to migrate vm " + vm.getName() + " from host " + fromHostName + " in zone " + dcVO.getName() + " and pod " + podVO.getName(), "Unable to find a suitable host"); } } catch(final InsufficientCapacityException e) { s_logger.warn("Unable to mgirate due to insufficient capacity " + vm.toString()); - _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to migrate vm " + vm.getHostName() + " from host " + fromHostName + " in zone " + dcVO.getName() + " and pod " + podVO.getName(), "Insufficient capacity"); + _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to migrate vm " + vm.getName() + " from host " + fromHostName + " in zone " + dcVO.getName() + " and pod " + podVO.getName(), "Insufficient capacity"); } catch(final StorageUnavailableException e) { s_logger.warn("Storage is unavailable: " + vm.toString()); - _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to migrate vm " + vm.getHostName() + " from host " + fromHostName + " in zone " + dcVO.getName() + " and pod " + podVO.getName(), "Storage is gone."); + _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodId(), "Unable to migrate vm " + vm.getName() + " from host " + fromHostName + " in zone " + dcVO.getName() + " and pod " + podVO.getName(), "Storage is gone."); } if (toHost == null) { @@ -775,7 +775,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager { DataCenterVO dcVO = _dcDao.findById(vm.getDataCenterId()); HostPodVO podVO = _podDao.findById(vm.getPodId()); - _alertMgr.sendAlert(alertType, fromHost.getDataCenterId(), fromHost.getPodId(), "Unable to migrate vm " + vm.getHostName() + " from host " + fromHost.getName() + " in zone " + dcVO.getName() + " and pod " + podVO.getName(), "Migrate Command failed. Please check logs."); + _alertMgr.sendAlert(alertType, fromHost.getDataCenterId(), fromHost.getPodId(), "Unable to migrate vm " + vm.getName() + " from host " + fromHost.getName() + " in zone " + dcVO.getName() + " and pod " + podVO.getName(), "Migrate Command failed. Please check logs."); _itMgr.stateTransitTo(vm, Event.MigrationFailedOnSource, toHost.getId()); _agentMgr.maintenanceFailed(vm.getHostId()); diff --git a/server/src/com/cloud/ha/InvestigatorImpl.java b/server/src/com/cloud/ha/InvestigatorImpl.java index 0b88ee02b27..3d1e49c6237 100644 --- a/server/src/com/cloud/ha/InvestigatorImpl.java +++ b/server/src/com/cloud/ha/InvestigatorImpl.java @@ -197,7 +197,7 @@ public class InvestigatorImpl implements Investigator { Answer pingTestAnswer = _agentMgr.send(otherHost.getId(), new PingTestCommand(routerPrivateIp, privateIp), 30 * 1000); if (pingTestAnswer.getResult()) { if (s_logger.isDebugEnabled()) { - s_logger.debug("user vm " + vm.getHostName() + " has been successfully pinged, returning that it is alive"); + s_logger.debug("user vm " + vm.getName() + " has been successfully pinged, returning that it is alive"); } return Boolean.TRUE; } @@ -214,7 +214,7 @@ public class InvestigatorImpl implements Investigator { } } if (s_logger.isDebugEnabled()) { - s_logger.debug("user vm " + vm.getHostName() + " could not be pinged, returning that it is unknown"); + s_logger.debug("user vm " + vm.getName() + " could not be pinged, returning that it is unknown"); } return null; diff --git a/server/src/com/cloud/migration/Db20to21MigrationUtil.java b/server/src/com/cloud/migration/Db20to21MigrationUtil.java index 6168fe6f6c6..fdf5da9d126 100644 --- a/server/src/com/cloud/migration/Db20to21MigrationUtil.java +++ b/server/src/com/cloud/migration/Db20to21MigrationUtil.java @@ -564,7 +564,7 @@ public class Db20to21MigrationUtil { proxy.setGuestMacAddress(guestMacAddress); if(proxy.getState() == State.Running || proxy.getState() == State.Starting) { - System.out.println("System VM " + proxy.getHostName() + " is in active state, mark it to Stopping state for migration"); + System.out.println("System VM " + proxy.getName() + " is in active state, mark it to Stopping state for migration"); proxy.setState(State.Stopping); } @@ -572,7 +572,7 @@ public class Db20to21MigrationUtil { proxy.setGuestIpAddress(guestIpAddress); proxy.setGuestNetmask("255.255.0.0"); - System.out.println("Assign link loal address to proxy " + proxy.getHostName() + ", link local address: " + guestIpAddress); + System.out.println("Assign link loal address to proxy " + proxy.getName() + ", link local address: " + guestIpAddress); _consoleProxyDao.update(proxy.getId(), proxy); } @@ -591,7 +591,7 @@ public class Db20to21MigrationUtil { secStorageVm.setGuestMacAddress(guestMacAddress); if(secStorageVm.getState() == State.Running || secStorageVm.getState() == State.Starting) { - System.out.println("System VM " + secStorageVm.getHostName() + " is in active state, mark it to Stopping state for migration"); + System.out.println("System VM " + secStorageVm.getName() + " is in active state, mark it to Stopping state for migration"); secStorageVm.setState(State.Stopping); } @@ -599,7 +599,7 @@ public class Db20to21MigrationUtil { secStorageVm.setGuestIpAddress(guestIpAddress); secStorageVm.setGuestNetmask("255.255.0.0"); - System.out.println("Assign link loal address to secondary storage VM " + secStorageVm.getHostName() + ", link local address: " + guestIpAddress); + System.out.println("Assign link loal address to secondary storage VM " + secStorageVm.getName() + ", link local address: " + guestIpAddress); _secStorageVmDao.update(secStorageVm.getId(), secStorageVm); } @@ -616,7 +616,7 @@ public class Db20to21MigrationUtil { if(router.getState() == State.Running || router.getState() == State.Starting) { router.setState(State.Stopping); - System.out.println("System VM " + router.getHostName() + " is in active state, mark it to Stopping state for migration"); + System.out.println("System VM " + router.getName() + " is in active state, mark it to Stopping state for migration"); _routerDao.update(router.getId(), router); } } @@ -680,11 +680,11 @@ public class Db20to21MigrationUtil { deviceId = 1; // reset for each VM iteration for(VolumeVO vol : volumes) { if(vol.getVolumeType() == VolumeType.ROOT) { - System.out.println("Setting root volume device id to zero, vol: " + vol.getName() + ", instance: " + vm.getHostName()); + System.out.println("Setting root volume device id to zero, vol: " + vol.getName() + ", instance: " + vm.getName()); vol.setDeviceId(0L); } else if(vol.getVolumeType() == VolumeType.DATADISK) { - System.out.println("Setting data volume device id, vol: " + vol.getName() + ", instance: " + vm.getHostName() + ", device id: " + deviceId); + System.out.println("Setting data volume device id, vol: " + vol.getName() + ", instance: " + vm.getName() + ", device id: " + deviceId); vol.setDeviceId(deviceId); diff --git a/server/src/com/cloud/network/router/DomainRouterManagerImpl.java b/server/src/com/cloud/network/router/DomainRouterManagerImpl.java index 27608fb6b79..db46b55f33a 100644 --- a/server/src/com/cloud/network/router/DomainRouterManagerImpl.java +++ b/server/src/com/cloud/network/router/DomainRouterManagerImpl.java @@ -388,16 +388,16 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute event.setType(EventTypes.EVENT_ROUTER_CREATE); if (vols == null) { - event.setDescription("failed to create DHCP Server : " + router.getHostName()); + event.setDescription("failed to create DHCP Server : " + router.getName()); event.setLevel(EventVO.LEVEL_ERROR); _eventDao.persist(event); throw new ExecutionException("Unable to create DHCP Server"); } _itMgr.stateTransitTo(router, VirtualMachine.Event.OperationSucceeded, null); - s_logger.info("DHCP server created: id=" + router.getId() + "; name=" + router.getHostName() + "; vlan=" + guestVlan.getVlanId() + "; pod=" + pod.getName()); + s_logger.info("DHCP server created: id=" + router.getId() + "; name=" + router.getName() + "; vlan=" + guestVlan.getVlanId() + "; pod=" + pod.getName()); - event.setDescription("successfully created DHCP Server : " + router.getHostName() + " with ip : " + router.getGuestIpAddress()); + event.setDescription("successfully created DHCP Server : " + router.getName() + " with ip : " + router.getGuestIpAddress()); _eventDao.persist(event); return router; @@ -565,14 +565,14 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute } _itMgr.stateTransitTo(router, VirtualMachine.Event.OperationSucceeded, null); - s_logger.debug("Router created: id=" + router.getId() + "; name=" + router.getHostName()); + s_logger.debug("Router created: id=" + router.getId() + "; name=" + router.getName()); event = new EventVO(); event.setUserId(1L); // system user performed the action event.setAccountId(accountId); event.setType(EventTypes.EVENT_ROUTER_CREATE); event.setStartId(startEventId); - event.setDescription("successfully created Domain Router : " + router.getHostName() + " with ip : " + publicIpAddress); + event.setDescription("successfully created Domain Router : " + router.getName() + " with ip : " + publicIpAddress); _eventDao.persist(event); success = true; return router; @@ -628,7 +628,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute event.setType(EventTypes.EVENT_ROUTER_DESTROY); event.setState(Event.State.Started); event.setParameters("id=" + routerId); - event.setDescription("Starting to destroy router : " + router.getHostName()); + event.setDescription("Starting to destroy router : " + router.getName()); event = _eventDao.persist(event); try { @@ -673,7 +673,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute completedEvent.setType(EventTypes.EVENT_ROUTER_DESTROY); completedEvent.setStartId(event.getId()); completedEvent.setParameters("id=" + routerId); - completedEvent.setDescription("successfully destroyed router : " + router.getHostName()); + completedEvent.setDescription("successfully destroyed router : " + router.getName()); _eventDao.persist(completedEvent); return true; @@ -748,7 +748,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute final DomainRouterVO router = _routerDao.findById(routerId); final String routerPrivateIpAddress = router.getPrivateIpAddress(); - final String vmName = router.getHostName(); + final String vmName = router.getName(); final String encodedPassword = rot13(password); final SavePasswordCommand cmdSavePassword = new SavePasswordCommand(encodedPassword, vmIpAddress, routerPrivateIpAddress, vmName); @@ -891,9 +891,9 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute } if (vnet != null) { - s_logger.debug("Router: " + router.getHostName() + " discovered vnet: " + vnet + " from existing VMs."); + s_logger.debug("Router: " + router.getName() + " discovered vnet: " + vnet + " from existing VMs."); } else { - s_logger.debug("Router: " + router.getHostName() + " was unable to discover vnet from existing VMs. Acquiring new vnet."); + s_logger.debug("Router: " + router.getName() + " was unable to discover vnet from existing VMs. Acquiring new vnet."); } String routerMacAddress = null; @@ -919,10 +919,10 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute } if (vnet == null) { - s_logger.error("Unable to get another vnet while starting router " + router.getHostName()); + s_logger.error("Unable to get another vnet while starting router " + router.getName()); return null; } else { - s_logger.debug("Router: " + router.getHostName() + " is using vnet: " + vnet); + s_logger.debug("Router: " + router.getName() + " is using vnet: " + vnet); } Answer answer = null; @@ -961,7 +961,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute /*Ram size can be changed by upgradeRouterCmd*/ router.setRamSize(offering.getRamSize()); - final String name = VirtualMachineName.attachVnet(router.getHostName(), vnet); + final String name = VirtualMachineName.attachVnet(router.getName(), vnet); router.setInstanceName(name); long accountId = router.getAccountId(); // Use account level network domain if available @@ -998,7 +998,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute GuestOSVO guestOS = _guestOSDao.findById(router.getGuestOSId()); if (guestOS == null) { String msg = "Could not find guest OS description for OSId " - + router.getGuestOSId() + " for vm: " + router.getHostName(); + + router.getGuestOSId() + " for vm: " + router.getName(); s_logger.debug(msg); throw new CloudRuntimeException(msg); } else { @@ -1020,13 +1020,13 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute } if (resendRouterState(router)) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Router " + router.getHostName() + " started on " + routingHost.getName()); + s_logger.debug("Router " + router.getName() + " started on " + routingHost.getName()); } started = true; break; } else { if (s_logger.isDebugEnabled()) { - s_logger.debug("Router " + router.getHostName() + " started on " + routingHost.getName() + " but failed to program rules"); + s_logger.debug("Router " + router.getName() + " started on " + routingHost.getName() + " but failed to program rules"); } sendStopCommand(router); } @@ -1034,12 +1034,12 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute s_logger.debug("Unable to start " + router.toString() + " on host " + routingHost.toString() + " due to " + answer.getDetails()); } catch (OperationTimedoutException e) { if (e.isActive()) { - s_logger.debug("Unable to start vm " + router.getHostName() + " due to operation timed out and it is active so scheduling a restart."); + s_logger.debug("Unable to start vm " + router.getName() + " due to operation timed out and it is active so scheduling a restart."); _haMgr.scheduleRestart(router, true); return null; } } catch (AgentUnavailableException e) { - s_logger.debug("Agent " + routingHost.toString() + " was unavailable to start VM " + router.getHostName()); + s_logger.debug("Agent " + routingHost.toString() + " was unavailable to start VM " + router.getName()); } avoid.add(routingHost); @@ -1064,7 +1064,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute s_logger.debug("Router " + router.toString() + " is now started on " + routingHost.toString()); } - event.setDescription("successfully started Domain Router: " + router.getHostName()); + event.setDescription("successfully started Domain Router: " + router.getName()); _eventDao.persist(event); return _routerDao.findById(routerId); @@ -1181,10 +1181,10 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute final List vms = _vmDao.listBy(router.getId(), State.Creating, State.Starting, State.Running, State.Stopping, State.Stopped, State.Migrating); Commands cmds = new Commands(OnError.Continue); for (UserVmVO vm: vms) { - if (vm.getGuestIpAddress() == null || vm.getGuestMacAddress() == null || vm.getHostName() == null) { + if (vm.getGuestIpAddress() == null || vm.getGuestMacAddress() == null || vm.getName() == null) { continue; } - DhcpEntryCommand decmd = new DhcpEntryCommand(vm.getGuestMacAddress(), vm.getGuestIpAddress(), router.getPrivateIpAddress(), vm.getHostName()); + DhcpEntryCommand decmd = new DhcpEntryCommand(vm.getGuestMacAddress(), vm.getGuestIpAddress(), router.getPrivateIpAddress(), vm.getName()); cmds.addCommand(decmd); } if (cmds.size() > 0) { @@ -1424,11 +1424,11 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute if (answer != null && resendRouterState(router)) { processStopOrRebootAnswer(router, answer); - event.setDescription("successfully rebooted Domain Router : " + router.getHostName()); + event.setDescription("successfully rebooted Domain Router : " + router.getName()); _eventDao.persist(event); return true; } else { - event.setDescription("failed to reboot Domain Router : " + router.getHostName()); + event.setDescription("failed to reboot Domain Router : " + router.getName()); event.setLevel(EventVO.LEVEL_ERROR); _eventDao.persist(event); return false; @@ -1729,7 +1729,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute answer = _agentMgr.send(hostId, stop); if (!answer.getResult()) { s_logger.error("Unable to stop router"); - event.setDescription("failed to stop Domain Router : " + router.getHostName()); + event.setDescription("failed to stop Domain Router : " + router.getName()); event.setLevel(EventVO.LEVEL_ERROR); _eventDao.persist(event); } else { @@ -1743,7 +1743,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute } if (!stopped) { - event.setDescription("failed to stop Domain Router : " + router.getHostName()); + event.setDescription("failed to stop Domain Router : " + router.getName()); event.setLevel(EventVO.LEVEL_ERROR); _eventDao.persist(event); _itMgr.stateTransitTo(router, VirtualMachine.Event.OperationFailed, router.getHostId()); @@ -1751,7 +1751,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute } completeStopCommand(router, VirtualMachine.Event.OperationSucceeded); - event.setDescription("successfully stopped Domain Router : " + router.getHostName()); + event.setDescription("successfully stopped Domain Router : " + router.getName()); _eventDao.persist(event); if (s_logger.isDebugEnabled()) { s_logger.debug("Router " + router.toString() + " is stopped"); @@ -1804,8 +1804,8 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute } if( ! _storageMgr.share(router, vols, routingHost, false) ) { - s_logger.warn("Can not share " + vol.getPath() + " to " + router.getHostName() ); - throw new StorageUnavailableException("Can not share " + vol.getPath() + " to " + router.getHostName(), sp.getId()); + s_logger.warn("Can not share " + vol.getPath() + " to " + router.getName() ); + throw new StorageUnavailableException("Can not share " + vol.getPath() + " to " + router.getName(), sp.getId()); } final Answer answer = _agentMgr.easySend(routingHost.getId(), cmd); @@ -1901,7 +1901,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute try { DomainRouterVO router = start(vm.getDomainRouterId(), 0); if (router == null) { - s_logger.error("Can't find a domain router to start VM: " + vm.getHostName()); + s_logger.error("Can't find a domain router to start VM: " + vm.getName()); return null; } @@ -1927,10 +1927,10 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute int cmdIndex = 0; int passwordIndex = -1; int vmDataIndex = -1; - cmds.addCommand(new DhcpEntryCommand(vm.getGuestMacAddress(), vm.getGuestIpAddress(), router.getPrivateIpAddress(), vm.getHostName())); + cmds.addCommand(new DhcpEntryCommand(vm.getGuestMacAddress(), vm.getGuestIpAddress(), router.getPrivateIpAddress(), vm.getName())); if (password != null) { final String encodedPassword = rot13(password); - cmds.addCommand(new SavePasswordCommand(encodedPassword, vm.getPrivateIpAddress(), router.getPrivateIpAddress(), vm.getHostName())); + cmds.addCommand(new SavePasswordCommand(encodedPassword, vm.getPrivateIpAddress(), router.getPrivateIpAddress(), vm.getName())); passwordIndex = cmdIndex; } @@ -1939,22 +1939,22 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute String zoneName = _dcDao.findById(vm.getDataCenterId()).getName(); String routerPublicIpAddress = (router.getPublicIpAddress() != null) ? router.getPublicIpAddress() : vm.getGuestIpAddress(); - cmds.addCommand(generateVmDataCommand(router.getPrivateIpAddress(), routerPublicIpAddress, vm.getPrivateIpAddress(), userData, serviceOffering, zoneName, vm.getGuestIpAddress(), vm.getHostName(), vm.getInstanceName(), vm.getId())); + cmds.addCommand(generateVmDataCommand(router.getPrivateIpAddress(), routerPublicIpAddress, vm.getPrivateIpAddress(), userData, serviceOffering, zoneName, vm.getGuestIpAddress(), vm.getName(), vm.getInstanceName(), vm.getId())); vmDataIndex = cmdIndex; Answer[] answers = _agentMgr.send(router.getHostId(), cmds); if (!answers[0].getResult()) { - s_logger.error("Unable to set dhcp entry for " + vm.getId() + " - " + vm.getHostName() +" on domR: " + router.getHostName() + " due to " + answers[0].getDetails()); + s_logger.error("Unable to set dhcp entry for " + vm.getId() + " - " + vm.getName() +" on domR: " + router.getName() + " due to " + answers[0].getDetails()); return null; } if (password != null && !answers[passwordIndex].getResult()) { - s_logger.error("Unable to set password for " + vm.getId() + " - " + vm.getHostName() + " due to " + answers[passwordIndex].getDetails()); + s_logger.error("Unable to set password for " + vm.getId() + " - " + vm.getName() + " due to " + answers[passwordIndex].getDetails()); return null; } if (vmDataIndex > 0 && !answers[vmDataIndex].getResult()) { - s_logger.error("Unable to set VM data for " + vm.getId() + " - " + vm.getHostName() + " due to " + answers[vmDataIndex].getDetails()); + s_logger.error("Unable to set VM data for " + vm.getId() + " - " + vm.getName() + " due to " + answers[vmDataIndex].getDetails()); return null; } return router; @@ -1962,10 +1962,10 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute s_logger.error("Unable to start router " + vm.getDomainRouterId() + " because storage is unavailable."); return null; } catch (AgentUnavailableException e) { - s_logger.error("Unable to setup the router " + vm.getDomainRouterId() + " for vm " + vm.getId() + " - " + vm.getHostName() + " because agent is unavailable"); + s_logger.error("Unable to setup the router " + vm.getDomainRouterId() + " for vm " + vm.getId() + " - " + vm.getName() + " because agent is unavailable"); return null; } catch (OperationTimedoutException e) { - s_logger.error("Unable to setup the router " + vm.getDomainRouterId() + " for vm " + vm.getId() + " - " + vm.getHostName() + " because agent is too busy"); + s_logger.error("Unable to setup the router " + vm.getDomainRouterId() + " for vm " + vm.getId() + " - " + vm.getName() + " because agent is too busy"); return null; } } @@ -2001,7 +2001,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute final CreateZoneVlanCommand cmdCreateZoneVlan = new CreateZoneVlanCommand(router); CreateZoneVlanAnswer answer = (CreateZoneVlanAnswer) _agentMgr.easySend(router.getHostId(), cmdCreateZoneVlan); if(!answer.getResult()){ - s_logger.error("Unable to create zone vlan for router: "+router.getHostName()+ " zoneVlan: "+zoneVlan); + s_logger.error("Unable to create zone vlan for router: "+router.getName()+ " zoneVlan: "+zoneVlan); return null; } return zoneVlan; @@ -2020,7 +2020,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute for (DomainRouterVO router : routers) { String privateIP = router.getPrivateIpAddress(); if(privateIP != null){ - final NetworkUsageCommand usageCmd = new NetworkUsageCommand(privateIP, router.getHostName()); + final NetworkUsageCommand usageCmd = new NetworkUsageCommand(privateIP, router.getName()); final NetworkUsageAnswer answer = (NetworkUsageAnswer)_agentMgr.easySend(router.getHostId(), usageCmd); if(answer != null){ Transaction txn = Transaction.open(Transaction.CLOUD_DB); @@ -2416,17 +2416,17 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute } } - cmds.addCommand("dhcp", new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), routerControlIpAddress, profile.getVirtualMachine().getHostName())); + cmds.addCommand("dhcp", new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), routerControlIpAddress, profile.getVirtualMachine().getName())); if (password != null) { final String encodedPassword = rot13(password); - cmds.addCommand("password", new SavePasswordCommand(encodedPassword, nic.getIp4Address(), routerControlIpAddress, profile.getVirtualMachine().getHostName())); + cmds.addCommand("password", new SavePasswordCommand(encodedPassword, nic.getIp4Address(), routerControlIpAddress, profile.getVirtualMachine().getName())); } String serviceOffering = _serviceOfferingDao.findById(profile.getServiceOfferingId()).getDisplayText(); String zoneName = _dcDao.findById(config.getDataCenterId()).getName(); - cmds.addCommand("vmdata", generateVmDataCommand(routerControlIpAddress, routerPublicIpAddress, nic.getIp4Address(), userData, serviceOffering, zoneName, nic.getIp4Address(), profile.getVirtualMachine().getHostName(), profile.getVirtualMachine().getHostName(), profile.getId())); + cmds.addCommand("vmdata", generateVmDataCommand(routerControlIpAddress, routerPublicIpAddress, nic.getIp4Address(), userData, serviceOffering, zoneName, nic.getIp4Address(), profile.getVirtualMachine().getName(), profile.getVirtualMachine().getName(), profile.getId())); try { _agentMgr.send(router.getHostId(), cmds); @@ -2438,7 +2438,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute Answer answer = cmds.getAnswer("dhcp"); if (!answer.getResult()) { - s_logger.error("Unable to set dhcp entry for " + profile +" on domR: " + router.getHostName() + " due to " + answer.getDetails()); + s_logger.error("Unable to set dhcp entry for " + profile +" on domR: " + router.getName() + " due to " + answer.getDetails()); throw new ResourceUnavailableException("Unable to set dhcp entry for " + profile + " due to " + answer.getDetails()); } @@ -2687,10 +2687,10 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute final List vms = _vmDao.listBy(router.getId(), State.Creating, State.Starting, State.Running, State.Stopping, State.Stopped, State.Migrating); Commands cmds = new Commands(OnError.Continue); for (UserVmVO vm: vms) { - if (vm.getGuestIpAddress() == null || vm.getGuestMacAddress() == null || vm.getHostName() == null) { + if (vm.getGuestIpAddress() == null || vm.getGuestMacAddress() == null || vm.getName() == null) { continue; } - DhcpEntryCommand decmd = new DhcpEntryCommand(vm.getGuestMacAddress(), vm.getGuestIpAddress(), router.getPrivateIpAddress(), vm.getHostName()); + DhcpEntryCommand decmd = new DhcpEntryCommand(vm.getGuestMacAddress(), vm.getGuestIpAddress(), router.getPrivateIpAddress(), vm.getName()); cmds.addCommand(decmd); } if (cmds.size() > 0) { diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 16bb10a9419..29bfd3ecb7c 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -2141,7 +2141,7 @@ public class ManagementServerImpl implements ManagementServer { sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); sb.and("accountIdEQ", sb.entity().getAccountId(), SearchCriteria.Op.EQ); sb.and("accountIdIN", sb.entity().getAccountId(), SearchCriteria.Op.IN); - sb.and("name", sb.entity().getHostName(), SearchCriteria.Op.LIKE); + sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE); sb.and("stateEQ", sb.entity().getState(), SearchCriteria.Op.EQ); sb.and("stateNEQ", sb.entity().getState(), SearchCriteria.Op.NEQ); sb.and("stateNIN", sb.entity().getState(), SearchCriteria.Op.NIN); @@ -2452,7 +2452,7 @@ public class ManagementServerImpl implements ManagementServer { Object keyword = cmd.getKeyword(); SearchBuilder sb = _routerDao.createSearchBuilder(); - sb.and("name", sb.entity().getHostName(), SearchCriteria.Op.LIKE); + sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE); sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.IN); sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ); sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ); @@ -2518,10 +2518,7 @@ public class ManagementServerImpl implements ManagementServer { if (keyword != null) { SearchCriteria ssc = _consoleProxyDao.createSearchCriteria(); - ssc.addOr("displayName", SearchCriteria.Op.LIKE, "%" + keyword + "%"); ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%"); - ssc.addOr("group", SearchCriteria.Op.LIKE, "%" + keyword + "%"); - ssc.addOr("instanceName", SearchCriteria.Op.LIKE, "%" + keyword + "%"); ssc.addOr("state", SearchCriteria.Op.LIKE, "%" + keyword + "%"); sc.addAnd("name", SearchCriteria.Op.SC, ssc); @@ -3017,12 +3014,12 @@ public class ManagementServerImpl implements ManagementServer { @Override public Pair getVncPort(VirtualMachine vm) { if (vm.getHostId() == null) { - s_logger.warn("VM " + vm.getHostName() + " does not have host, return -1 for its VNC port"); + s_logger.warn("VM " + vm.getName() + " does not have host, return -1 for its VNC port"); return new Pair(null, -1); } if(s_logger.isTraceEnabled()) { - s_logger.trace("Trying to retrieve VNC port from agent about VM " + vm.getHostName()); + s_logger.trace("Trying to retrieve VNC port from agent about VM " + vm.getName()); } GetVncPortAnswer answer = (GetVncPortAnswer) _agentMgr.easySend(vm.getHostId(), new GetVncPortCommand(vm.getId(), vm.getInstanceName())); @@ -4142,8 +4139,6 @@ public class ManagementServerImpl implements ManagementServer { if (keyword != null) { SearchCriteria ssc = _secStorageVmDao.createSearchCriteria(); ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%"); - ssc.addOr("displayName", SearchCriteria.Op.LIKE, "%" + keyword + "%"); - ssc.addOr("instanceName", SearchCriteria.Op.LIKE, "%" + keyword + "%"); ssc.addOr("state", SearchCriteria.Op.LIKE, "%" + keyword + "%"); sc.addAnd("name", SearchCriteria.Op.SC, ssc); @@ -4884,7 +4879,7 @@ public class ManagementServerImpl implements ManagementServer { } for(ConsoleProxyVO cp : cpList) { - Long cpHostId = hostNameToHostIdMap.get(cp.getHostName()); + Long cpHostId = hostNameToHostIdMap.get(cp.getName()); //now send a command to each console proxy host UpdateCertificateCommand certCmd = new UpdateCertificateCommand(_certDao.findById(certVOId).getCertificate(), false); try { diff --git a/server/src/com/cloud/servlet/ConsoleProxyServlet.java b/server/src/com/cloud/servlet/ConsoleProxyServlet.java index ba50ba38337..f71f257a4c4 100644 --- a/server/src/com/cloud/servlet/ConsoleProxyServlet.java +++ b/server/src/com/cloud/servlet/ConsoleProxyServlet.java @@ -221,7 +221,7 @@ public class ConsoleProxyServlet extends HttpServlet { return; } - String vmName = vm.getHostName(); + String vmName = vm.getName(); if(vmName == null) vmName = vm.getInstanceName(); diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 9cf63453e0d..57d24540f8b 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -929,7 +929,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag List avoids, long size) { List volumes = create(account, vm, template, dc, pod, offering, diskOffering, avoids, size); if( volumes == null || volumes.size() == 0) { - throw new CloudRuntimeException("Unable to create volume for " + vm.getHostName()); + throw new CloudRuntimeException("Unable to create volume for " + vm.getName()); } for (VolumeVO v : volumes) { diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java index 6e32d1244bf..a653171d0de 100644 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java @@ -343,7 +343,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V if (state == State.Running) { if (s_logger.isTraceEnabled()) { s_logger.trace("Secondary storage vm is already started: " - + secStorageVm.getHostName()); + + secStorageVm.getName()); } saveFailedEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_SSVM_START, "Secondary storage vm is already started", startEventId); return secStorageVm; @@ -368,7 +368,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V if (s_logger.isDebugEnabled()) { SecondaryStorageVmVO temp = _secStorageVmDao.findById(secStorageVmId); s_logger.debug("Unable to start secondary storage vm " - + secStorageVm.getHostName() + + secStorageVm.getName() + " because it is not in a startable state : " + ((temp != null) ? temp.getState().toString() : "null")); } @@ -391,7 +391,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V secStorageVm.getDataCenterId(), routingHost.getPodId(), secStorageVm.getId(), secStorageVm.getPrivateMacAddress()); if (privateIpAddress == null && (_IpAllocator != null && !_IpAllocator.exteralIpAddressAllocatorEnabled())) { - String msg = "Unable to allocate private ip addresses for " + secStorageVm.getHostName() + " in pod " + pod.getId(); + String msg = "Unable to allocate private ip addresses for " + secStorageVm.getName() + " in pod " + pod.getId(); s_logger.debug(msg); throw new CloudRuntimeException(msg); } @@ -404,7 +404,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V List vols = _storageMgr.prepare(secStorageVm, routingHost); if (vols == null || vols.size() == 0) { - String msg = "Unable to prepare storage for " + secStorageVm.getHostName() + " in pod " + pod.getId(); + String msg = "Unable to prepare storage for " + secStorageVm.getName() + " in pod " + pod.getId(); s_logger.debug(msg); throw new CloudRuntimeException(msg); } @@ -415,7 +415,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V GuestOSVO guestOS = _guestOSDao.findById(secStorageVm.getGuestOSId()); if (guestOS == null) { String msg = "Could not find guest OS description for OSId " - + secStorageVm.getGuestOSId() + " for vm: " + secStorageVm.getHostName(); + + secStorageVm.getGuestOSId() + " for vm: " + secStorageVm.getName(); s_logger.debug(msg); throw new CloudRuntimeException(msg); } else { @@ -426,11 +426,11 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V // need to configure agent on this StartSecStorageVmCommand cmdStart = new StartSecStorageVmCommand(_networkRate, _multicastRate, _secStorageVmCmdPort, secStorageVm, - secStorageVm.getHostName(), "", vols, _mgmt_host, _mgmt_port, _useSSlCopy, guestOSDescription); + secStorageVm.getName(), "", vols, _mgmt_host, _mgmt_port, _useSSlCopy, guestOSDescription); if (s_logger.isDebugEnabled()) { s_logger.debug("Sending start command for secondary storage vm " - + secStorageVm.getHostName() + + secStorageVm.getName() + " to " + routingHost.getName()); } @@ -441,14 +441,14 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V if (s_logger.isDebugEnabled()) { s_logger.debug("Received answer on starting secondary storage vm " - + secStorageVm.getHostName() + + secStorageVm.getName() + " on " + routingHost.getName()); } if ( answer != null && answer.getResult() ) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Secondary storage vm " + secStorageVm.getHostName() + s_logger.debug("Secondary storage vm " + secStorageVm.getName() + " started on " + routingHost.getName()); } @@ -466,7 +466,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V event.setType(EventTypes.EVENT_SSVM_START); event.setLevel(EventVO.LEVEL_INFO); event.setStartId(startEventId); - event.setDescription("Secondary Storage VM started - " + secStorageVm.getHostName()); + event.setDescription("Secondary Storage VM started - " + secStorageVm.getName()); _eventDao.persist(event); } break; @@ -474,13 +474,13 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V s_logger.debug("Unable to start " + secStorageVm.toString() + " on host " + routingHost.toString() + " due to " + answer.getDetails()); } catch (OperationTimedoutException e) { if (e.isActive()) { - s_logger.debug("Unable to start vm " + secStorageVm.getHostName() + " due to operation timed out and it is active so scheduling a restart."); + s_logger.debug("Unable to start vm " + secStorageVm.getName() + " due to operation timed out and it is active so scheduling a restart."); saveFailedEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_SSVM_START, "Unable to start vm due to operation timed out", startEventId); _haMgr.scheduleRestart(secStorageVm, true); return null; } } catch (AgentUnavailableException e) { - s_logger.debug("Agent " + routingHost.toString() + " was unavailable to start VM " + secStorageVm.getHostName()); + s_logger.debug("Agent " + routingHost.toString() + " was unavailable to start VM " + secStorageVm.getName()); } avoid.add(routingHost); @@ -508,7 +508,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V event.setType(EventTypes.EVENT_SSVM_START); event.setLevel(EventVO.LEVEL_ERROR); event.setStartId(startEventId); - event.setDescription("Starting secondary storage vm failed due to unable to find a host - " + secStorageVm.getHostName()); + event.setDescription("Starting secondary storage vm failed due to unable to find a host - " + secStorageVm.getName()); _eventDao.persist(event); throw new ExecutionException( "Couldn't find a routingHost to run secondary storage vm"); @@ -543,7 +543,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V event.setType(EventTypes.EVENT_SSVM_START); event.setLevel(EventVO.LEVEL_ERROR); event.setStartId(startEventId); - event.setDescription("Starting secondary storage vm failed due to unhandled exception - " + secStorageVm.getHostName()); + event.setDescription("Starting secondary storage vm failed due to unhandled exception - " + secStorageVm.getName()); _eventDao.persist(event); Transaction txn = Transaction.currentTxn(); @@ -629,12 +629,12 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V Answer answer = _agentMgr.easySend(storageHost.getId(), setupCmd); if (answer != null) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully programmed http auth into " + secStorageVm.getHostName()); + s_logger.debug("Successfully programmed http auth into " + secStorageVm.getName()); } return true; } else { if (s_logger.isDebugEnabled()) { - s_logger.debug("failed to program http auth into secondary storage vm : " + secStorageVm.getHostName()); + s_logger.debug("failed to program http auth into secondary storage vm : " + secStorageVm.getName()); } return false; } @@ -673,12 +673,12 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V Answer answer = _agentMgr.easySend(storageHost.getId(), cpc); if (answer != null) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully programmed firewall rules into " + secStorageVm.getHostName()); + s_logger.debug("Successfully programmed firewall rules into " + secStorageVm.getName()); } return true; } else { if (s_logger.isDebugEnabled()) { - s_logger.debug("failed to program firewall rules into secondary storage vm : " + secStorageVm.getHostName()); + s_logger.debug("failed to program firewall rules into secondary storage vm : " + secStorageVm.getName()); } return false; } @@ -874,7 +874,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V event.setType(EventTypes.EVENT_SSVM_CREATE); event.setLevel(EventVO.LEVEL_INFO); event.setStartId(startEventId); - event.setDescription("New Secondary Storage VM created - " + secStorageVm.getHostName()); + event.setDescription("New Secondary Storage VM created - " + secStorageVm.getName()); _eventDao.persist(event); txn.commit(); success = true; @@ -1014,7 +1014,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V } } else { if (s_logger.isInfoEnabled()) { - s_logger.info("Unable to acquire synchronization lock to start secondary storage vm : " + readysecStorageVm.getHostName()); + s_logger.info("Unable to acquire synchronization lock to start secondary storage vm : " + readysecStorageVm.getName()); } } } finally { @@ -1138,7 +1138,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V if (s_logger.isTraceEnabled()) { s_logger.trace("Running secondary storage vm pool size : " + runningList.size()); for (SecondaryStorageVmVO secStorageVm : runningList) { - s_logger.trace("Running secStorageVm instance : " + secStorageVm.getHostName()); + s_logger.trace("Running secStorageVm instance : " + secStorageVm.getName()); } } @@ -1227,7 +1227,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V } } else { if (s_logger.isInfoEnabled()) { - s_logger.info("Secondary storage vm " + secStorageVm.getHostName() + " is started"); + s_logger.info("Secondary storage vm " + secStorageVm.getName() + " is started"); } } } @@ -1645,7 +1645,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V return stop(secStorageVm, startEventId); } catch (AgentUnavailableException e) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Stopping secondary storage vm " + secStorageVm.getHostName() + " faled : exception " + e.toString()); + s_logger.debug("Stopping secondary storage vm " + secStorageVm.getName() + " faled : exception " + e.toString()); } return false; } @@ -1681,7 +1681,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V if (answer != null) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully reboot secondary storage vm " + secStorageVm.getHostName()); + s_logger.debug("Successfully reboot secondary storage vm " + secStorageVm.getName()); } SubscriptionMgr.getInstance().notifySubscribers( @@ -1697,11 +1697,11 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V event.setType(EventTypes.EVENT_SSVM_REBOOT); event.setLevel(EventVO.LEVEL_INFO); event.setStartId(startEventId); - event.setDescription("Secondary Storage Vm rebooted - " + secStorageVm.getHostName()); + event.setDescription("Secondary Storage Vm rebooted - " + secStorageVm.getName()); _eventDao.persist(event); return true; } else { - String msg = "Rebooting Secondary Storage VM failed - " + secStorageVm.getHostName(); + String msg = "Rebooting Secondary Storage VM failed - " + secStorageVm.getName(); saveFailedEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_SSVM_REBOOT, msg, startEventId); if (s_logger.isDebugEnabled()) { s_logger.debug(msg); @@ -1786,7 +1786,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V event.setType(EventTypes.EVENT_SSVM_DESTROY); event.setLevel(EventVO.LEVEL_INFO); event.setStartId(startEventId); - event.setDescription("Secondary Storage Vm destroyed - " + vm.getHostName()); + event.setDescription("Secondary Storage Vm destroyed - " + vm.getName()); _eventDao.persist(event); txn.commit(); } catch (Exception e) { @@ -1795,7 +1795,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V return false; } finally { s_logger.debug("secondary storage vm vm is destroyed : " - + vm.getHostName()); + + vm.getName()); } } } @@ -1819,7 +1819,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V event.setAccountId(Account.ACCOUNT_ID_SYSTEM); event.setType(EventTypes.EVENT_SSVM_DESTROY); event.setLevel(EventVO.LEVEL_INFO); - event.setDescription("Secondary Storage Vm destroyed - " + secStorageVm.getHostName()); + event.setDescription("Secondary Storage Vm destroyed - " + secStorageVm.getName()); _eventDao.persist(event); } txn.commit(); @@ -1876,12 +1876,12 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V event.setType(EventTypes.EVENT_SSVM_STOP); event.setLevel(EventVO.LEVEL_INFO); event.setStartId(startEventId); - event.setDescription("Secondary Storage Vm stopped - " + secStorageVm.getHostName()); + event.setDescription("Secondary Storage Vm stopped - " + secStorageVm.getName()); _eventDao.persist(event); return true; } catch (OperationTimedoutException e) { saveFailedEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_SSVM_STOP, - "Stopping secondary storage vm failed due to operation time out - " + secStorageVm.getHostName(), startEventId); + "Stopping secondary storage vm failed due to operation time out - " + secStorageVm.getName(), startEventId); throw new AgentUnavailableException(secStorageVm.getHostId()); } } finally { @@ -1964,7 +1964,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V storageIps[1] = vols.get(1).getHostIp(); } - PrepareForMigrationCommand cmd = new PrepareForMigrationCommand(secStorageVm.getHostName(), null, storageIps, vols, mirroredVols); + PrepareForMigrationCommand cmd = new PrepareForMigrationCommand(secStorageVm.getName(), null, storageIps, vols, mirroredVols); HostVO routingHost = null; HashSet avoid = new HashSet(); @@ -1984,8 +1984,8 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V } if( !_storageMgr.share(secStorageVm, vols, routingHost, false) ) { - s_logger.warn("Can not share " + vol.getPath() + " to " + secStorageVm.getHostName()); - throw new StorageUnavailableException("Can not share " + vol.getPath() + " to " + secStorageVm.getHostName(), vol.getPoolId()); + s_logger.warn("Can not share " + vol.getPath() + " to " + secStorageVm.getName()); + throw new StorageUnavailableException("Can not share " + vol.getPath() + " to " + secStorageVm.getName(), vol.getPoolId()); } Answer answer = _agentMgr.easySend(routingHost.getId(), cmd); @@ -2088,7 +2088,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V buf.append(" template=domP type=secstorage"); buf.append(" host=").append(_mgmt_host); buf.append(" port=").append(_mgmt_port); - buf.append(" name=").append(profile.getVirtualMachine().getHostName()); + buf.append(" name=").append(profile.getVirtualMachine().getName()); buf.append(" zone=").append(dest.getDataCenter().getId()); buf.append(" pod=").append(dest.getPod().getId()); diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index 7b0fdc7011e..888a49e7a6b 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -225,7 +225,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma VMInstanceVO vmInstance = _vmDao.findById(volume.getInstanceId()); String vmDisplayName = "detached"; if (vmInstance != null) { - vmDisplayName = vmInstance.getHostName(); + vmDisplayName = vmInstance.getName(); } String snapshotName = vmDisplayName + "_" + volume.getName() + "_" + timeString; diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index 4c8b332c9e7..83c5c95d0a3 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -978,7 +978,7 @@ public class AccountManagerImpl implements AccountManager, AccountService { try { success = (success && _vmMgr.stop(vm, 0)); } catch (AgentUnavailableException aue) { - s_logger.warn("Agent running on host " + vm.getHostId() + " is unavailable, unable to stop vm " + vm.getHostName()); + s_logger.warn("Agent running on host " + vm.getHostId() + " is unavailable, unable to stop vm " + vm.getName()); success = false; } } diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 052972154e5..83d0492241f 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -315,9 +315,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager if (result) { userVm.setPassword(password); - EventUtils.saveEvent(userId, userVm.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_VM_RESETPASSWORD, "successfully reset password for VM : " + userVm.getHostName(), null); + EventUtils.saveEvent(userId, userVm.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_VM_RESETPASSWORD, "successfully reset password for VM : " + userVm.getName(), null); } else { - EventUtils.saveEvent(userId, userVm.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_RESETPASSWORD, "unable to reset password for VM : " + userVm.getHostName(), null); + EventUtils.saveEvent(userId, userVm.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_RESETPASSWORD, "unable to reset password for VM : " + userVm.getName(), null); } return userVm; @@ -454,7 +454,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager VolumeVO rootVolumeOfVm = null; List rootVolumesOfVm = _volsDao.findByInstanceAndType(vmId, VolumeType.ROOT); if (rootVolumesOfVm.size() != 1) { - throw new CloudRuntimeException("The VM " + vm.getHostName() + " has more than one ROOT volume and is in an invalid state. Please contact Cloud Support."); + throw new CloudRuntimeException("The VM " + vm.getName() + " has more than one ROOT volume and is in an invalid state. Please contact Cloud Support."); } else { rootVolumeOfVm = rootVolumesOfVm.get(0); } @@ -473,7 +473,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager volume = _storageMgr.createVolume(volume, vm, rootDiskTmplt, dcVO, pod, rootDiskPool.getClusterId(), svo, diskVO, new ArrayList(), volume.getSize(), rootDiskHyperType); if (volume == null) { - throw new CloudRuntimeException("Failed to create volume when attaching it to VM: " + vm.getHostName()); + throw new CloudRuntimeException("Failed to create volume when attaching it to VM: " + vm.getName()); } } @@ -489,7 +489,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager } for (VolumeVO vol : vols) { if (vol.getDeviceId().equals(deviceId)) { - throw new RuntimeException("deviceId " + deviceId + " is used by VM " + vm.getHostName()); + throw new RuntimeException("deviceId " + deviceId + " is used by VM " + vm.getName()); } } } else { @@ -555,7 +555,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager _asyncMgr.updateAsyncJobStatus(job.getId(), BaseCmd.PROGRESS_INSTANCE_CREATED, volumeId); } - String errorMsg = "Failed to attach volume: " + volume.getName() + " to VM: " + vm.getHostName(); + String errorMsg = "Failed to attach volume: " + volume.getName() + " to VM: " + vm.getName(); boolean sendCommand = (vm.getState() == State.Running); AttachVolumeAnswer answer = null; Long hostId = vm.getHostId(); @@ -592,10 +592,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager } else { _volsDao.attachVolume(volume.getId(), vmId, deviceId); } - if(!vm.getHostName().equals(vm.getDisplayName())) { - event.setDescription("Volume: " +volume.getName()+ " successfully attached to VM: "+vm.getHostName()+"("+vm.getDisplayName()+")"); + if(!vm.getName().equals(vm.getDisplayName())) { + event.setDescription("Volume: " +volume.getName()+ " successfully attached to VM: "+vm.getName()+"("+vm.getDisplayName()+")"); } else { - event.setDescription("Volume: " +volume.getName()+ " successfully attached to VM: "+vm.getHostName()); + event.setDescription("Volume: " +volume.getName()+ " successfully attached to VM: "+vm.getName()); } event.setLevel(EventVO.LEVEL_INFO); _eventDao.persist(event); @@ -697,7 +697,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager _asyncMgr.updateAsyncJobStatus(job.getId(), BaseCmd.PROGRESS_INSTANCE_CREATED, volumeId); } - String errorMsg = "Failed to detach volume: " + volume.getName() + " from VM: " + vm.getHostName(); + String errorMsg = "Failed to detach volume: " + volume.getName() + " from VM: " + vm.getName(); boolean sendCommand = (vm.getState() == State.Running); Answer answer = null; @@ -729,10 +729,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager _volsDao.update(volume.getId(), volume); } - if(!vm.getHostName().equals(vm.getDisplayName())) { - event.setDescription("Volume: " +volume.getName()+ " successfully detached from VM: "+vm.getHostName()+"("+vm.getDisplayName()+")"); + if(!vm.getName().equals(vm.getDisplayName())) { + event.setDescription("Volume: " +volume.getName()+ " successfully detached from VM: "+vm.getName()+"("+vm.getDisplayName()+")"); } else { - event.setDescription("Volume: " +volume.getName()+ " successfully detached from VM: "+vm.getHostName()); + event.setDescription("Volume: " +volume.getName()+ " successfully detached from VM: "+vm.getName()); } event.setLevel(EventVO.LEVEL_INFO); _eventDao.persist(event); @@ -881,11 +881,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager State state = vm.getState(); if (state == State.Running) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Starting an already started VM: " + vm.getId() + " - " + vm.getHostName() + "; state = " + vm.getState().toString()); + s_logger.debug("Starting an already started VM: " + vm.getId() + " - " + vm.getName() + "; state = " + vm.getState().toString()); } return vm; } - String eventParams = "id=" + vm.getId() + "\nvmName=" + vm.getHostName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId(); + String eventParams = "id=" + vm.getId() + "\nvmName=" + vm.getName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId(); event = new EventVO(); event.setType(EventTypes.EVENT_VM_START); event.setUserId(userId); @@ -894,7 +894,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager event.setState(Event.State.Completed); event.setStartId(startEventId); if (state.isTransitional()) { - String description = "Concurrent operations on the vm " + vm.getId() + " - " + vm.getHostName() + "; state = " + state.toString(); + String description = "Concurrent operations on the vm " + vm.getId() + " - " + vm.getName() + "; state = " + state.toString(); event.setDescription(description); event.setLevel(EventVO.LEVEL_ERROR); _eventDao.persist(event); @@ -925,7 +925,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager GuestOSVO guestOS = _guestOSDao.findById(vm.getGuestOSId()); if (guestOS == null) { String msg = "Could not find guest OS description for OSId " - + vm.getGuestOSId() + " for vm: " + vm.getHostName(); + + vm.getGuestOSId() + " for vm: " + vm.getName(); s_logger.debug(msg); throw new CloudRuntimeException(msg); } else { @@ -974,12 +974,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager if (vm.getDomainRouterId() != null) { router = _routerMgr.addVirtualMachineToGuestNetwork(vm, password, startEventId); if (router == null) { - s_logger.error("Unable to add vm " + vm.getId() + " - " + vm.getHostName()); + s_logger.error("Unable to add vm " + vm.getId() + " - " + vm.getName()); _itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationFailed, null); - if(!vm.getHostName().equals(vm.getDisplayName())) { - event.setDescription("Unable to start VM: " + vm.getHostName()+"("+vm.getDisplayName()+")" + "; Unable to add VM to guest network"); + if(!vm.getName().equals(vm.getDisplayName())) { + event.setDescription("Unable to start VM: " + vm.getName()+"("+vm.getDisplayName()+")" + "; Unable to add VM to guest network"); } else { - event.setDescription("Unable to start VM: " + vm.getHostName() + "; Unable to add VM to guest network"); + event.setDescription("Unable to start VM: " + vm.getName() + "; Unable to add VM to guest network"); } event.setLevel(EventVO.LEVEL_ERROR); @@ -988,7 +988,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager } vnet = router.getVnet(); - s_logger.debug("VM: " + vm.getHostName() + " discovered vnet: " + vnet + " from router: " + router.getHostName()); + s_logger.debug("VM: " + vm.getName() + " discovered vnet: " + vnet + " from router: " + router.getName()); if(NetworkManager.USE_POD_VLAN){ if(vm.getPodId() != router.getPodId()){ @@ -997,7 +997,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager //Create Zone Vlan if not created already vnet = _routerMgr.createZoneVlan(router); if (vnet == null) { - s_logger.error("Vlan creation failed. Unable to add vm " + vm.getId() + " - " + vm.getHostName()); + s_logger.error("Vlan creation failed. Unable to add vm " + vm.getId() + " - " + vm.getName()); return null; } } else { @@ -1029,7 +1029,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager do { if (s_logger.isDebugEnabled()) { - s_logger.debug("Trying to start vm " + vm.getHostName() + " on host " + host.toString()); + s_logger.debug("Trying to start vm " + vm.getName() + " on host " + host.toString()); } txn.start(); @@ -1096,7 +1096,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager answer = _agentMgr.send(host.getId(), cmdStart); if (answer.getResult()) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Started vm " + vm.getHostName() + " on host " + host.toString()); + s_logger.debug("Started vm " + vm.getName() + " on host " + host.toString()); } started = true; break; @@ -1105,7 +1105,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager s_logger.debug("Unable to start " + vm.toString() + " on host " + host.toString() + " due to " + answer.getDetails()); } catch (OperationTimedoutException e) { if (e.isActive()) { - String description = "Unable to start vm " + vm.getHostName() + " due to operation timed out and it is active so scheduling a restart."; + String description = "Unable to start vm " + vm.getName() + " due to operation timed out and it is active so scheduling a restart."; _haMgr.scheduleRestart(vm, true); host = null; s_logger.debug(description); @@ -1115,7 +1115,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager return null; } } catch (AgentUnavailableException e) { - s_logger.debug("Agent " + host.toString() + " was unavailable to start VM " + vm.getHostName()); + s_logger.debug("Agent " + host.toString() + " was unavailable to start VM " + vm.getName()); } avoid.add(host); @@ -1124,36 +1124,36 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager } while (--retry > 0 && (host = (HostVO)_agentMgr.findHost(Host.Type.Routing, dc, pod, sp, offering, template, vm, null, avoid)) != null); if (host == null || retry <= 0) { - if(!vm.getHostName().equals(vm.getDisplayName())) { - event.setDescription("Unable to start VM: " + vm.getHostName()+"("+vm.getDisplayName()+")"+ " Reason: "+answer.getDetails()); + if(!vm.getName().equals(vm.getDisplayName())) { + event.setDescription("Unable to start VM: " + vm.getName()+"("+vm.getDisplayName()+")"+ " Reason: "+answer.getDetails()); } else { - event.setDescription("Unable to start VM: " + vm.getHostName()+ " Reason: "+answer.getDetails()); + event.setDescription("Unable to start VM: " + vm.getName()+ " Reason: "+answer.getDetails()); } event.setLevel(EventVO.LEVEL_ERROR); _eventDao.persist(event); - throw new ExecutionException("Unable to start VM: " + vm.getHostName()+ " Reason: "+answer.getDetails()); + throw new ExecutionException("Unable to start VM: " + vm.getName()+ " Reason: "+answer.getDetails()); } if (!_itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationSucceeded, host.getId())) { - if(!vm.getHostName().equals(vm.getDisplayName())) { - event.setDescription("unable to start VM: " + vm.getHostName()+"("+vm.getDisplayName()+")"); + if(!vm.getName().equals(vm.getDisplayName())) { + event.setDescription("unable to start VM: " + vm.getName()+"("+vm.getDisplayName()+")"); } else { - event.setDescription("unable to start VM: " + vm.getHostName()); + event.setDescription("unable to start VM: " + vm.getName()); } event.setLevel(EventVO.LEVEL_ERROR); _eventDao.persist(event); - throw new ConcurrentOperationException("Starting vm " + vm.getHostName() + " didn't work."); + throw new ConcurrentOperationException("Starting vm " + vm.getName() + " didn't work."); } if (s_logger.isDebugEnabled()) { - s_logger.debug("Started vm " + vm.getHostName()); + s_logger.debug("Started vm " + vm.getName()); } - if(!vm.getHostName().equals(vm.getDisplayName())) { - event.setDescription("successfully started VM: " + vm.getHostName()+"("+vm.getDisplayName()+")"); + if(!vm.getName().equals(vm.getDisplayName())) { + event.setDescription("successfully started VM: " + vm.getName()+"("+vm.getDisplayName()+")"); } else { - event.setDescription("successfully started VM: " + vm.getHostName()); + event.setDescription("successfully started VM: " + vm.getName()); } _eventDao.persist(event); @@ -1162,7 +1162,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager return _vmDao.findById(vm.getId()); } catch (Throwable th) { txn.rollback(); - s_logger.error("While starting vm " + vm.getHostName() + ", caught throwable: ", th); + s_logger.error("While starting vm " + vm.getName() + ", caught throwable: ", th); if (!started) { vm.setVnet(null); @@ -1183,7 +1183,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager s_logger.warn(th.getMessage()); throw (ExecutionException)th; } - String description = "Unable to start VM " + vm.getHostName() + " because of an unknown exception"; + String description = "Unable to start VM " + vm.getName() + " because of an unknown exception"; event.setDescription(description); event.setLevel(EventVO.LEVEL_ERROR); _eventDao.persist(event); @@ -1344,25 +1344,25 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager event.setUserId(userId); event.setAccountId(vm.getAccountId()); event.setType(EventTypes.EVENT_VM_REBOOT); - event.setParameters("id="+vm.getId() + "\nvmName=" + vm.getHostName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId()); + event.setParameters("id="+vm.getId() + "\nvmName=" + vm.getName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId()); if (vm.getState() == State.Running && vm.getHostId() != null) { RebootCommand cmd = new RebootCommand(vm.getInstanceName()); RebootAnswer answer = (RebootAnswer)_agentMgr.easySend(vm.getHostId(), cmd); if (answer != null) { - if(!vm.getHostName().equals(vm.getDisplayName())) { - event.setDescription("Successfully rebooted VM instance : " + vm.getHostName()+"("+vm.getDisplayName()+")"); + if(!vm.getName().equals(vm.getDisplayName())) { + event.setDescription("Successfully rebooted VM instance : " + vm.getName()+"("+vm.getDisplayName()+")"); } else { - event.setDescription("Successfully rebooted VM instance : " + vm.getHostName()); + event.setDescription("Successfully rebooted VM instance : " + vm.getName()); } _eventDao.persist(event); return true; } else { - if(!vm.getHostName().equals(vm.getDisplayName())) { - event.setDescription("failed to reboot VM instance : " + vm.getHostName()+"("+vm.getDisplayName()+")"); + if(!vm.getName().equals(vm.getDisplayName())) { + event.setDescription("failed to reboot VM instance : " + vm.getName()+"("+vm.getDisplayName()+")"); } else { - event.setDescription("failed to reboot VM instance : " + vm.getHostName()); + event.setDescription("failed to reboot VM instance : " + vm.getName()); } event.setLevel(EventVO.LEVEL_ERROR); _eventDao.persist(event); @@ -1563,13 +1563,13 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager IPAddressVO guestIP = (userVm.getGuestIpAddress() == null) ? null : _ipAddressDao.findById(userVm.getGuestIpAddress()); if (guestIP != null && guestIP.getAllocatedTime() != null) { _ipAddressDao.unassignIpAddress(userVm.getGuestIpAddress()); - s_logger.debug("Released guest IP address=" + userVm.getGuestIpAddress() + " vmName=" + userVm.getHostName() + " dcId=" + userVm.getDataCenterId()); + s_logger.debug("Released guest IP address=" + userVm.getGuestIpAddress() + " vmName=" + userVm.getName() + " dcId=" + userVm.getDataCenterId()); EventVO event = new EventVO(); event.setUserId(User.UID_SYSTEM); event.setAccountId(userVm.getAccountId()); event.setType(EventTypes.EVENT_NET_IP_RELEASE); - event.setParameters("guestIPaddress=" + userVm.getGuestIpAddress() + "\nvmName=" + userVm.getHostName() + "\ndcId=" + userVm.getDataCenterId()); + event.setParameters("guestIPaddress=" + userVm.getGuestIpAddress() + "\nvmName=" + userVm.getName() + "\ndcId=" + userVm.getDataCenterId()); event.setDescription("released a public ip: " + userVm.getGuestIpAddress()); _eventDao.persist(event); } else { @@ -1710,12 +1710,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager } txn.start(); - if(vm != null && vm.getHostName() != null && vm.getDisplayName() != null) + if(vm != null && vm.getName() != null && vm.getDisplayName() != null) { - if(!vm.getHostName().equals(vm.getDisplayName())) { - event.setDescription("successfully created VM instance : " + vm.getHostName()+"("+vm.getDisplayName()+")"); + if(!vm.getName().equals(vm.getDisplayName())) { + event.setDescription("successfully created VM instance : " + vm.getName()+"("+vm.getDisplayName()+")"); } else { - event.setDescription("successfully created VM instance : " + vm.getHostName()); + event.setDescription("successfully created VM instance : " + vm.getName()); } } else @@ -1744,8 +1744,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager if (vm == null) { eventDescription += "new instance"; } else { - eventDescription += vm.getHostName(); - if (!vm.getHostName().equals(vm.getDisplayName())) { + eventDescription += vm.getName(); + if (!vm.getName().equals(vm.getDisplayName())) { eventDescription += " (" + vm.getDisplayName() + ")"; } } @@ -1785,11 +1785,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager event.setUserId(userId); event.setAccountId(vm.getAccountId()); event.setType(EventTypes.EVENT_VM_DESTROY); - event.setParameters("id="+vm.getId() + "\nvmName=" + vm.getHostName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId()); - if(!vm.getHostName().equals(vm.getDisplayName())) { - event.setDescription("Successfully destroyed VM instance : " + vm.getHostName()+"("+vm.getDisplayName()+")"); + event.setParameters("id="+vm.getId() + "\nvmName=" + vm.getName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId()); + if(!vm.getName().equals(vm.getDisplayName())) { + event.setDescription("Successfully destroyed VM instance : " + vm.getName()+"("+vm.getDisplayName()+")"); } else { - event.setDescription("Successfully destroyed VM instance : " + vm.getHostName()); + event.setDescription("Successfully destroyed VM instance : " + vm.getName()); } _eventDao.persist(event); @@ -1856,7 +1856,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager event.setUserId(1L); event.setAccountId(vm.getAccountId()); event.setType(EventTypes.EVENT_VM_CREATE); - event.setParameters("id="+vm.getId() + "\nvmName=" + vm.getHostName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId()); + event.setParameters("id="+vm.getId() + "\nvmName=" + vm.getName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId()); Transaction txn = Transaction.currentTxn(); AccountVO account = null; @@ -1874,10 +1874,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager ResourceAllocationException rae = new ResourceAllocationException("Maximum number of virtual machines for account: " + account.getAccountName() + " has been exceeded."); rae.setResourceType("vm"); event.setLevel(EventVO.LEVEL_ERROR); - if(!vm.getHostName().equals(vm.getDisplayName())) { - event.setDescription("Failed to recover VM instance : " + vm.getHostName()+"("+vm.getDisplayName()+")" + "; the resource limit for account: " + account.getAccountName() + " has been exceeded."); + if(!vm.getName().equals(vm.getDisplayName())) { + event.setDescription("Failed to recover VM instance : " + vm.getName()+"("+vm.getDisplayName()+")" + "; the resource limit for account: " + account.getAccountName() + " has been exceeded."); } else { - event.setDescription("Failed to recover VM instance : " + vm.getHostName() + "; the resource limit for account: " + account.getAccountName() + " has been exceeded."); + event.setDescription("Failed to recover VM instance : " + vm.getName() + "; the resource limit for account: " + account.getAccountName() + " has been exceeded."); } _eventDao.persist(event); txn.commit(); @@ -1919,10 +1919,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager _accountMgr.incrementResourceCount(account.getId(), ResourceType.volume, new Long(volumes.size())); event.setLevel(EventVO.LEVEL_INFO); - if(!vm.getHostName().equals(vm.getDisplayName())) { - event.setDescription("successfully recovered VM instance : " + vm.getHostName()+"("+vm.getDisplayName()+")"); + if(!vm.getName().equals(vm.getDisplayName())) { + event.setDescription("successfully recovered VM instance : " + vm.getName()+"("+vm.getDisplayName()+")"); } else { - event.setDescription("successfully recovered VM instance : " + vm.getHostName()); + event.setDescription("successfully recovered VM instance : " + vm.getName()); } _eventDao.persist(event); @@ -2069,11 +2069,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager event.setType(EventTypes.EVENT_VM_STOP); event.setState(Event.State.Completed); event.setStartId(startEventId); - event.setParameters("id="+vm.getId() + "\n" + "vmName=" + vm.getHostName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId()); - if(!vm.getHostName().equals(vm.getDisplayName())) { - event.setDescription("Successfully stopped VM instance : " + vm.getHostName()+"("+vm.getDisplayName()+")"); + event.setParameters("id="+vm.getId() + "\n" + "vmName=" + vm.getName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId()); + if(!vm.getName().equals(vm.getDisplayName())) { + event.setDescription("Successfully stopped VM instance : " + vm.getName()+"("+vm.getDisplayName()+")"); } else { - event.setDescription("Successfully stopped VM instance : " + vm.getHostName()); + event.setDescription("Successfully stopped VM instance : " + vm.getName()); } _eventDao.persist(event); @@ -2138,7 +2138,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager event.setAccountId(vm.getAccountId()); event.setType(EventTypes.EVENT_VM_STOP); event.setStartId(startEventId); - event.setParameters("id="+vm.getId() + "\n" + "vmName=" + vm.getHostName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId()); + event.setParameters("id="+vm.getId() + "\n" + "vmName=" + vm.getName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId()); StopCommand stop = new StopCommand(vm, vm.getInstanceName(), vm.getVnet()); @@ -2146,7 +2146,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager try { Answer answer = _agentMgr.send(vm.getHostId(), stop); if (!answer.getResult()) { - s_logger.warn("Unable to stop vm " + vm.getHostName() + " due to " + answer.getDetails()); + s_logger.warn("Unable to stop vm " + vm.getName() + " due to " + answer.getDetails()); } else { stopped = true; } @@ -2160,15 +2160,15 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager completeStopCommand(userId, vm, VirtualMachine.Event.OperationSucceeded, 0); } else { - if(!vm.getHostName().equals(vm.getDisplayName())) { - event.setDescription("failed to stop VM instance : " + vm.getHostName()+"("+vm.getDisplayName()+")"); + if(!vm.getName().equals(vm.getDisplayName())) { + event.setDescription("failed to stop VM instance : " + vm.getName()+"("+vm.getDisplayName()+")"); } else { - event.setDescription("failed to stop VM instance : " + vm.getHostName()); + event.setDescription("failed to stop VM instance : " + vm.getName()); } event.setLevel(EventVO.LEVEL_ERROR); _eventDao.persist(event); _itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationFailed, vm.getHostId()); - s_logger.error("Unable to stop vm " + vm.getHostName()); + s_logger.error("Unable to stop vm " + vm.getName()); } return stopped; @@ -2283,7 +2283,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager continue; } - if(VirtualMachineName.isValidRouterName(vm.getHostName()) && !vm.getState().equals(State.Running)){ + if(VirtualMachineName.isValidRouterName(vm.getName()) && !vm.getState().equals(State.Running)){ deleteRules = false; } @@ -2632,7 +2632,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager VMInstanceVO vm = _vmDao.findById(instanceId); State vmState = vm.getState(); if( !vmState.equals(State.Stopped) && !vmState.equals(State.Destroyed)) { - throw new CloudRuntimeException("Please put VM " + vm.getHostName() + " into Stopped state first"); + throw new CloudRuntimeException("Please put VM " + vm.getName() + " into Stopped state first"); } } cmd = new CreatePrivateTemplateFromVolumeCommand(secondaryStorageURL, templateId, volume.getAccountId(), @@ -2904,7 +2904,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager event.setUserId(userId); event.setAccountId(accountId); event.setType(EventTypes.EVENT_NET_IP_ASSIGN); - event.setParameters("guestIPaddress=" + guestIp + "\nvmName=" + vm.getHostName() + "\ndcId=" + vm.getDataCenterId()); + event.setParameters("guestIPaddress=" + guestIp + "\nvmName=" + vm.getName() + "\ndcId=" + vm.getDataCenterId()); event.setDescription("acquired a public ip: " + guestIp); _eventDao.persist(event); @@ -2912,9 +2912,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager } if (poolId == 0) { - if(vm != null && vm.getHostName()!=null && vm.getDisplayName() != null) + if(vm != null && vm.getName()!=null && vm.getDisplayName() != null) { - if(!vm.getHostName().equals(vm.getDisplayName())) { + if(!vm.getName().equals(vm.getDisplayName())) { s_logger.debug("failed to create VM instance : " + name+"("+vm.getInstanceName()+")"); } else { s_logger.debug("failed to create VM instance : " + name); @@ -2939,12 +2939,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager event.setStartId(startEventId); event.setState(Event.State.Completed); String diskOfferingIdentifier = (diskOffering != null) ? String.valueOf(diskOffering.getId()) : "-1"; - String eventParams = "id=" + vm.getId() + "\nvmName=" + vm.getHostName() + "\nsoId=" + vm.getServiceOfferingId() + "\ndoId=" + diskOfferingIdentifier + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId(); + String eventParams = "id=" + vm.getId() + "\nvmName=" + vm.getName() + "\nsoId=" + vm.getServiceOfferingId() + "\ndoId=" + diskOfferingIdentifier + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId(); event.setParameters(eventParams); - if(!vm.getHostName().equals(vm.getDisplayName())) { - event.setDescription("successfully created VM instance : " + vm.getHostName()+"("+vm.getInstanceName()+")"); + if(!vm.getName().equals(vm.getDisplayName())) { + event.setDescription("successfully created VM instance : " + vm.getName()+"("+vm.getInstanceName()+")"); } else { - event.setDescription("successfully created VM instance : " + vm.getHostName()); + event.setDescription("successfully created VM instance : " + vm.getName()); } _eventDao.persist(event); @@ -3081,9 +3081,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager } if (poolId == 0) { - if(vm != null && vm.getHostName()!=null && vm.getDisplayName() != null) + if(vm != null && vm.getName()!=null && vm.getDisplayName() != null) { - if(!vm.getHostName().equals(vm.getDisplayName())) { + if(!vm.getName().equals(vm.getDisplayName())) { s_logger.debug("failed to create VM instance : " + name+"("+vm.getDisplayName()+")"); } else { s_logger.debug("failed to create VM instance : " + name); @@ -3108,12 +3108,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager event.setStartId(startEventId); event.setState(Event.State.Completed); String diskOfferingIdentifier = (diskOffering != null) ? String.valueOf(diskOffering.getId()) : "-1"; - String eventParams = "id=" + vm.getId() + "\nvmName=" + vm.getHostName() + "\nsoId=" + vm.getServiceOfferingId() + "\ndoId=" + diskOfferingIdentifier + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId(); + String eventParams = "id=" + vm.getId() + "\nvmName=" + vm.getName() + "\nsoId=" + vm.getServiceOfferingId() + "\ndoId=" + diskOfferingIdentifier + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId(); event.setParameters(eventParams); - if(!vm.getHostName().equals(vm.getDisplayName())) { - event.setDescription("successfully created VM instance : " + vm.getHostName()+"("+vm.getDisplayName()+")"); + if(!vm.getName().equals(vm.getDisplayName())) { + event.setDescription("successfully created VM instance : " + vm.getName()+"("+vm.getDisplayName()+")"); } else { - event.setDescription("successfully created VM instance : " + vm.getHostName()); + event.setDescription("successfully created VM instance : " + vm.getName()); } _eventDao.persist(event); @@ -3242,7 +3242,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager _vmDao.updateVM(id, displayName, ha); // create a event for the change in HA Enabled flag - EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_INFO, EventTypes.EVENT_VM_UPDATE, "Successfully updated virtual machine: "+vm.getHostName()+". "+description, null); + EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_INFO, EventTypes.EVENT_VM_UPDATE, "Successfully updated virtual machine: "+vm.getName()+". "+description, null); return _vmDao.findById(id); } diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index d576f4b96c1..fcad8e0dd63 100644 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -495,7 +495,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster event.setAccountId(vm.getAccountId()); event.setType(EventTypes.EVENT_VM_STOP); event.setStartId(1); // FIXME: - event.setParameters("id="+vm.getId() + "\n" + "vmName=" + vm.getHostName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId()); + event.setParameters("id="+vm.getId() + "\n" + "vmName=" + vm.getName() + "\nsoId=" + vm.getServiceOfferingId() + "\ntId=" + vm.getTemplateId() + "\ndcId=" + vm.getDataCenterId()); StopCommand stop = new StopCommand(vm, vm.getInstanceName(), null); diff --git a/server/src/com/cloud/vm/VirtualMachineProfileImpl.java b/server/src/com/cloud/vm/VirtualMachineProfileImpl.java index 96d847ecaed..60b7135e000 100644 --- a/server/src/com/cloud/vm/VirtualMachineProfileImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineProfileImpl.java @@ -218,7 +218,7 @@ public class VirtualMachineProfileImpl implements Virtua @Override public String getHostName() { - return _vm.getHostName(); + return _vm.getName(); } @Override diff --git a/server/src/com/cloud/vm/dao/UserVmDaoImpl.java b/server/src/com/cloud/vm/dao/UserVmDaoImpl.java index e3f6c210b02..03f7648d01b 100755 --- a/server/src/com/cloud/vm/dao/UserVmDaoImpl.java +++ b/server/src/com/cloud/vm/dao/UserVmDaoImpl.java @@ -80,7 +80,7 @@ public class UserVmDaoImpl extends GenericDaoBase implements Use HostRunningSearch.done(); NameSearch = createSearchBuilder(); - NameSearch.and("name", NameSearch.entity().getHostName(), SearchCriteria.Op.EQ); + NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ); NameSearch.done(); RouterStateSearch = createSearchBuilder(); diff --git a/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java b/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java index e927a8dea49..630307a3814 100644 --- a/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java +++ b/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java @@ -94,7 +94,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase implem ZoneTemplateNonExpungedSearch.done(); NameLikeSearch = createSearchBuilder(); - NameLikeSearch.and("name", NameLikeSearch.entity().getHostName(), SearchCriteria.Op.LIKE); + NameLikeSearch.and("name", NameLikeSearch.entity().getName(), SearchCriteria.Op.LIKE); NameLikeSearch.done(); StateChangeSearch = createSearchBuilder();