From 99bc15f64a00d6b2272e526fb6cf09843a0773de Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Thu, 28 Apr 2011 16:50:00 -0700 Subject: [PATCH] changed getName to getHostname --- api/src/com/cloud/vm/VirtualMachine.java | 4 +-- core/src/com/cloud/vm/UserVmVO.java | 2 +- core/src/com/cloud/vm/VMInstanceVO.java | 15 ++++------ .../cloud/alert/ConsoleProxyAlertAdapter.java | 28 ++++++++--------- .../alert/SecondaryStorageVmAlertAdapter.java | 28 ++++++++--------- .../src/com/cloud/api/ApiResponseHelper.java | 16 +++++----- .../AgentBasedConsoleProxyManager.java | 2 +- .../consoleproxy/ConsoleProxyManagerImpl.java | 16 +++++----- .../cloud/ha/HighAvailabilityManagerImpl.java | 30 +++++++++---------- .../com/cloud/ha/UserVmDomRInvestigator.java | 2 +- .../migration/Db20to21MigrationUtil.java | 14 ++++----- .../network/ovs/OvsNetworkManagerImpl.java | 22 +++++++------- .../VirtualNetworkApplianceManagerImpl.java | 18 +++++------ .../cloud/server/ManagementServerImpl.java | 6 ++-- .../SecondaryStorageManagerImpl.java | 22 +++++++------- .../storage/snapshot/SnapshotManagerImpl.java | 2 +- .../com/cloud/user/AccountManagerImpl.java | 6 ++-- .../src/com/cloud/vm/UserVmManagerImpl.java | 26 ++++++++-------- .../cloud/vm/VirtualMachineManagerImpl.java | 12 ++++---- .../cloud/vm/VirtualMachineProfileImpl.java | 2 +- .../com/cloud/vm/dao/VMInstanceDaoImpl.java | 2 +- utils/src/com/cloud/utils/net/NetUtils.java | 2 +- 22 files changed, 137 insertions(+), 140 deletions(-) diff --git a/api/src/com/cloud/vm/VirtualMachine.java b/api/src/com/cloud/vm/VirtualMachine.java index d0c70d3ad8b..58627f136d8 100755 --- a/api/src/com/cloud/vm/VirtualMachine.java +++ b/api/src/com/cloud/vm/VirtualMachine.java @@ -178,9 +178,9 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, StateObject /** * @return the host name of the virtual machine. If the user did not * specify the host name when creating the virtual machine then it is - * the name generated by cloud stack. + * defaults to the instance name. */ - public String getName(); + public String getHostName(); /** * @return the ip address of the virtual machine. diff --git a/core/src/com/cloud/vm/UserVmVO.java b/core/src/com/cloud/vm/UserVmVO.java index 43365b7da10..329d54eead7 100755 --- a/core/src/com/cloud/vm/UserVmVO.java +++ b/core/src/com/cloud/vm/UserVmVO.java @@ -88,7 +88,7 @@ public class UserVmVO extends VMInstanceVO implements UserVm { String name) { super(id, serviceOfferingId, name, instanceName, Type.User, templateId, hypervisorType, guestOsId, domainId, accountId, haEnabled, limitCpuUse); this.userData = userData; - this.displayName = displayName != null ? displayName : null; + this.displayName = displayName != null ? displayName : name != null ? name : instanceName; this.details = new HashMap(); } diff --git a/core/src/com/cloud/vm/VMInstanceVO.java b/core/src/com/cloud/vm/VMInstanceVO.java index 156eaf38c6b..8fae48a868b 100644 --- a/core/src/com/cloud/vm/VMInstanceVO.java +++ b/core/src/com/cloud/vm/VMInstanceVO.java @@ -52,7 +52,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject> 10) + _restartRetryInterval; } @@ -463,20 +463,20 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager, Clu } } 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.getName() + " which was running on host " + hostDesc, - "Insufficient capacity to restart VM, name: " + vm.getName() + ", id: " + vmId + " which was running on host " + hostDesc); + _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); } catch (final ResourceUnavailableException e) { s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage()); - _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); + _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); } 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.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); + _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); } catch (OperationTimedoutException e) { s_logger.warn("Unable to restart " + vm.toString() + " due to " + e.getMessage()); - _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); + _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); } vm = _itMgr.findById(vm.getType(), vm.getId()); work.setUpdateTime(vm.getUpdated()); diff --git a/server/src/com/cloud/ha/UserVmDomRInvestigator.java b/server/src/com/cloud/ha/UserVmDomRInvestigator.java index fe27a974952..98ca3f2c813 100644 --- a/server/src/com/cloud/ha/UserVmDomRInvestigator.java +++ b/server/src/com/cloud/ha/UserVmDomRInvestigator.java @@ -172,7 +172,7 @@ public class UserVmDomRInvestigator extends AbstractInvestigatorImpl { Answer pingTestAnswer = _agentMgr.send(hostId, new PingTestCommand(routerPrivateIp, privateIp), 30 * 1000); if (pingTestAnswer.getResult()) { if (s_logger.isDebugEnabled()) { - s_logger.debug("user vm " + vm.getName() + " has been successfully pinged, returning that it is alive"); + s_logger.debug("user vm " + vm.getHostName() + " has been successfully pinged, returning that it is alive"); } return Boolean.TRUE; } diff --git a/server/src/com/cloud/migration/Db20to21MigrationUtil.java b/server/src/com/cloud/migration/Db20to21MigrationUtil.java index 189ba849a49..6579a8da722 100644 --- a/server/src/com/cloud/migration/Db20to21MigrationUtil.java +++ b/server/src/com/cloud/migration/Db20to21MigrationUtil.java @@ -582,13 +582,13 @@ public class Db20to21MigrationUtil { String guestMacAddress = macAddresses[0]; if(proxy.getState() == State.Running || proxy.getState() == State.Starting) { - System.out.println("System VM " + proxy.getName() + " is in active state, mark it to Stopping state for migration"); + System.out.println("System VM " + proxy.getHostName() + " is in active state, mark it to Stopping state for migration"); proxy.setState(State.Stopping); } String guestIpAddress = _dcDao.allocateLinkLocalIpAddress(proxy.getDataCenterId(), proxy.getPodId(), proxy.getId(), null); - System.out.println("Assign link loal address to proxy " + proxy.getName() + ", link local address: " + guestIpAddress); + System.out.println("Assign link loal address to proxy " + proxy.getHostName() + ", link local address: " + guestIpAddress); _consoleProxyDao.update(proxy.getId(), proxy); } @@ -606,13 +606,13 @@ public class Db20to21MigrationUtil { String guestMacAddress = macAddresses[0]; if(secStorageVm.getState() == State.Running || secStorageVm.getState() == State.Starting) { - System.out.println("System VM " + secStorageVm.getName() + " is in active state, mark it to Stopping state for migration"); + System.out.println("System VM " + secStorageVm.getHostName() + " is in active state, mark it to Stopping state for migration"); secStorageVm.setState(State.Stopping); } String guestIpAddress = _dcDao.allocateLinkLocalIpAddress(secStorageVm.getDataCenterId(), secStorageVm.getPodId(), secStorageVm.getId(), null); - System.out.println("Assign link loal address to secondary storage VM " + secStorageVm.getName() + ", link local address: " + guestIpAddress); + System.out.println("Assign link loal address to secondary storage VM " + secStorageVm.getHostName() + ", link local address: " + guestIpAddress); _secStorageVmDao.update(secStorageVm.getId(), secStorageVm); } @@ -629,7 +629,7 @@ public class Db20to21MigrationUtil { if(router.getState() == State.Running || router.getState() == State.Starting) { router.setState(State.Stopping); - System.out.println("System VM " + router.getName() + " is in active state, mark it to Stopping state for migration"); + System.out.println("System VM " + router.getHostName() + " is in active state, mark it to Stopping state for migration"); _routerDao.update(router.getId(), router); } } @@ -693,11 +693,11 @@ public class Db20to21MigrationUtil { deviceId = 1; // reset for each VM iteration for(VolumeVO vol : volumes) { if(vol.getVolumeType() == Volume.Type.ROOT) { - System.out.println("Setting root volume device id to zero, vol: " + vol.getName() + ", instance: " + vm.getName()); + System.out.println("Setting root volume device id to zero, vol: " + vol.getName() + ", instance: " + vm.getHostName()); vol.setDeviceId(0L); } else if(vol.getVolumeType() == Volume.Type.DATADISK) { - System.out.println("Setting data volume device id, vol: " + vol.getName() + ", instance: " + vm.getName() + ", device id: " + deviceId); + System.out.println("Setting data volume device id, vol: " + vol.getName() + ", instance: " + vm.getHostName() + ", device id: " + deviceId); vol.setDeviceId(deviceId); diff --git a/server/src/com/cloud/network/ovs/OvsNetworkManagerImpl.java b/server/src/com/cloud/network/ovs/OvsNetworkManagerImpl.java index 4aef52ab263..2210088bcd1 100644 --- a/server/src/com/cloud/network/ovs/OvsNetworkManagerImpl.java +++ b/server/src/com/cloud/network/ovs/OvsNetworkManagerImpl.java @@ -272,7 +272,7 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager { vm.getAccountId(), vm.getHostId()).getVlan()); Commands cmds = new Commands(new OvsSetTagAndFlowCommand( - vm.getName(), tag, vlans, seqnum.toString(), + vm.getHostName(), tag, vlans, seqnum.toString(), vm.getId())); try { @@ -504,11 +504,11 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager { CheckAndUpdateDhcpFlow(instance); String vlans = getVlanInPortMapping(accountId, hostId); VmFlowLogVO log = _flowLogDao.findOrNewByVmId(instance.getId(), - instance.getName()); + instance.getHostName()); StringBuffer command = new StringBuffer(); command.append("vlan"); command.append("/"); - command.append(cmdPair("vmName", instance.getName())); + command.append(cmdPair("vmName", instance.getHostName())); command.append("/"); command.append(cmdPair("tag", tag)); command.append("/"); @@ -550,12 +550,12 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager { try { long hostId = router.getHostId(); String tag = Long.toString(_vlanMappingDao.findByAccountIdAndHostId(accountId, hostId).getVlan()); - VmFlowLogVO log = _flowLogDao.findOrNewByVmId(instance.getId(), instance.getName()); + VmFlowLogVO log = _flowLogDao.findOrNewByVmId(instance.getId(), instance.getHostName()); String vlans = getVlanInPortMapping(accountId, hostId); - s_logger.debug("ask router " + router.getName() + " on host " + s_logger.debug("ask router " + router.getHostName() + " on host " + hostId + " update vlan map to " + vlans); Commands cmds = new Commands(new OvsSetTagAndFlowCommand( - router.getName(), tag, vlans, Long.toString(log.getLogsequence()), instance.getId())); + router.getHostName(), tag, vlans, Long.toString(log.getLogsequence()), instance.getId())); _agentMgr.send(router.getHostId(), cmds, _ovsListener); } catch (Exception e) { s_logger.warn("apply flow to router failed", e); @@ -592,7 +592,7 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager { continue; } } - log = _flowLogDao.findOrNewByVmId(vmId, vm.getName()); + log = _flowLogDao.findOrNewByVmId(vmId, vm.getHostName()); if (log != null && updateSeqno){ log.incrLogsequence(); @@ -628,7 +628,7 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager { protected Set getAffectedVms(VMInstanceVO instance, boolean tellRouter) { long accountId = instance.getAccountId(); if (!_vlanMappingDirtyDao.isDirty(accountId)) { - s_logger.debug("OVSAFFECTED: no VM affected by " + instance.getName()); + s_logger.debug("OVSAFFECTED: no VM affected by " + instance.getHostName()); return null; } @@ -667,10 +667,10 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager { vo.setAccountId(0); _vlanMappingDirtyDao.markDirty(accountId); String s = String.format("%1$s is the last VM(host:%2$s, accountId:%3$s), remove vlan", - instance.getName(), hostId, accountId); + instance.getHostName(), hostId, accountId); s_logger.debug("OVSDIRTY:" + s); } else { - s_logger.debug(instance.getName() + s_logger.debug(instance.getHostName() + " reduces reference count of (account,host) = (" + accountId + "," + hostId + ") to " + vo.getRef()); } @@ -679,7 +679,7 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager { txn.commit(); try { - Commands cmds = new Commands(new OvsDeleteFlowCommand(instance.getName())); + Commands cmds = new Commands(new OvsDeleteFlowCommand(instance.getHostName())); _agentMgr.send(hostId, cmds, _ovsListener); } catch (Exception e) { s_logger.warn("remove flow failed", e); diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index bcff2b53f50..3fdc52397dc 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -408,7 +408,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian String encodedPassword = rot13(password); Commands cmds = new Commands(OnError.Continue); - SavePasswordCommand cmd = new SavePasswordCommand(encodedPassword, nic.getIp4Address(), userVm.getName()); + SavePasswordCommand cmd = new SavePasswordCommand(encodedPassword, nic.getIp4Address(), userVm.getHostName()); cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress()); cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName()); cmds.addCommand("password", cmd); @@ -710,7 +710,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian for (DomainRouterVO router : routers) { String privateIP = router.getPrivateIpAddress(); if (privateIP != null) { - final NetworkUsageCommand usageCmd = new NetworkUsageCommand(privateIP, router.getName()); + final NetworkUsageCommand usageCmd = new NetworkUsageCommand(privateIP, router.getHostName()); final NetworkUsageAnswer answer = (NetworkUsageAnswer) _agentMgr.easySend(router.getHostId(), usageCmd); if (answer != null) { Transaction txn = Transaction.open(Transaction.CLOUD_DB); @@ -1191,7 +1191,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian s_logger.debug("Reapplying vm data (userData and metaData) entries as a part of domR " + router + " start..."); createVmDataCommands(router, cmds); // Network usage command to create iptables rules - cmds.addCommand("networkUsage", new NetworkUsageCommand(controlNic.getIp4Address(), router.getName(), "create")); + cmds.addCommand("networkUsage", new NetworkUsageCommand(controlNic.getIp4Address(), router.getHostName(), "create")); return true; } @@ -1329,7 +1329,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian } } - DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), profile.getVirtualMachine().getName()); + DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), profile.getVirtualMachine().getHostName()); dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, routerControlIpAddress); dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName()); cmds.addCommand("dhcp", dhcpCommand); @@ -1337,7 +1337,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian // password should be set only on default network element if (password != null && network.isDefault()) { final String encodedPassword = rot13(password); - SavePasswordCommand cmd = new SavePasswordCommand(encodedPassword, nic.getIp4Address(), profile.getVirtualMachine().getName()); + SavePasswordCommand cmd = new SavePasswordCommand(encodedPassword, nic.getIp4Address(), profile.getVirtualMachine().getHostName()); cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress()); cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName()); cmds.addCommand("password", cmd); @@ -1348,7 +1348,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian cmds.addCommand( "vmdata", - generateVmDataCommand(router, nic.getIp4Address(), userData, serviceOffering, zoneName, nic.getIp4Address(), profile.getVirtualMachine().getName(), profile.getVirtualMachine() + generateVmDataCommand(router, nic.getIp4Address(), userData, serviceOffering, zoneName, nic.getIp4Address(), profile.getVirtualMachine().getHostName(), profile.getVirtualMachine() .getInstanceName(), profile.getId(), sshPublicKey)); try { @@ -1359,7 +1359,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian Answer answer = cmds.getAnswer("dhcp"); if (!answer.getResult()) { - s_logger.error("Unable to set dhcp entry for " + profile + " on domR: " + router.getName() + " due to " + answer.getDetails()); + s_logger.error("Unable to set dhcp entry for " + profile + " on domR: " + router.getHostName() + " due to " + answer.getDetails()); throw new ResourceUnavailableException("Unable to set dhcp entry for " + profile + " due to " + answer.getDetails(), DataCenter.class, router.getDataCenterId()); } @@ -1628,7 +1628,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian String serviceOffering = _serviceOfferingDao.findByIdIncludingRemoved(vm.getServiceOfferingId()).getDisplayText(); String zoneName = _dcDao.findById(router.getDataCenterId()).getName(); cmds.addCommand("vmdata", - generateVmDataCommand(router, nic.getIp4Address(), vm.getUserData(), serviceOffering, zoneName, nic.getIp4Address(), vm.getName(), vm.getInstanceName(), vm.getId(), null)); + generateVmDataCommand(router, nic.getIp4Address(), vm.getUserData(), serviceOffering, zoneName, nic.getIp4Address(), vm.getHostName(), vm.getInstanceName(), vm.getId(), null)); } } } @@ -1644,7 +1644,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian if (nic != null) { s_logger.debug("Creating dhcp entry for vm " + vm + " on domR " + router + "."); - DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getName()); + DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getHostName()); dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress()); dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName()); cmds.addCommand("dhcp", dhcpCommand); diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index e581146cfe3..8e410a44ba9 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -2191,7 +2191,7 @@ public class ManagementServerImpl implements ManagementServer { Object networkId = cmd.getNetworkId(); SearchBuilder sb = _routerDao.createSearchBuilder(); - sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE); + sb.and("name", sb.entity().getHostName(), SearchCriteria.Op.LIKE); sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.IN); sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ); @@ -2809,12 +2809,12 @@ public class ManagementServerImpl implements ManagementServer { @Override public Pair getVncPort(VirtualMachine vm) { if (vm.getHostId() == null) { - s_logger.warn("VM " + vm.getName() + " does not have host, return -1 for its VNC port"); + s_logger.warn("VM " + vm.getHostName() + " 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.getName()); + s_logger.trace("Trying to retrieve VNC port from agent about VM " + vm.getHostName()); } GetVncPortAnswer answer = (GetVncPortAnswer) _agentMgr.easySend(vm.getHostId(), new GetVncPortCommand(vm.getId(), vm.getInstanceName())); diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java index 4e84b5cd2a7..caecc2fde1d 100644 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java @@ -266,12 +266,12 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V Answer answer = _agentMgr.easySend(storageHost.getId(), setupCmd); if (answer != null && answer.getResult()) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully programmed http auth into " + secStorageVm.getName()); + s_logger.debug("Successfully programmed http auth into " + secStorageVm.getHostName()); } return true; } else { if (s_logger.isDebugEnabled()) { - s_logger.debug("failed to program http auth into secondary storage vm : " + secStorageVm.getName()); + s_logger.debug("failed to program http auth into secondary storage vm : " + secStorageVm.getHostName()); } return false; } @@ -316,12 +316,12 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V Answer answer = _agentMgr.easySend(storageHost.getId(), cpc); if (answer != null && answer.getResult()) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully programmed firewall rules into " + secStorageVm.getName()); + s_logger.debug("Successfully programmed firewall rules into " + secStorageVm.getHostName()); } return true; } else { if (s_logger.isDebugEnabled()) { - s_logger.debug("failed to program firewall rules into secondary storage vm : " + secStorageVm.getName()); + s_logger.debug("failed to program firewall rules into secondary storage vm : " + secStorageVm.getHostName()); } return false; } @@ -447,7 +447,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.getName()); + s_logger.trace("Running secStorageVm instance : " + secStorageVm.getHostName()); } } @@ -532,7 +532,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V } } else { if (s_logger.isInfoEnabled()) { - s_logger.info("Secondary storage vm " + secStorageVm.getName() + " is started"); + s_logger.info("Secondary storage vm " + secStorageVm.getHostName() + " is started"); } } } @@ -728,7 +728,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V return true; } catch (ResourceUnavailableException e) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Stopping secondary storage vm " + secStorageVm.getName() + " faled : exception " + e.toString()); + s_logger.debug("Stopping secondary storage vm " + secStorageVm.getHostName() + " faled : exception " + e.toString()); } return false; } @@ -748,7 +748,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V if (answer != null && answer.getResult()) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully reboot secondary storage vm " + secStorageVm.getName()); + s_logger.debug("Successfully reboot secondary storage vm " + secStorageVm.getHostName()); } SubscriptionMgr.getInstance().notifySubscribers(ALERT_SUBJECT, this, @@ -756,7 +756,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V return true; } else { - String msg = "Rebooting Secondary Storage VM failed - " + secStorageVm.getName(); + String msg = "Rebooting Secondary Storage VM failed - " + secStorageVm.getHostName(); if (s_logger.isDebugEnabled()) { s_logger.debug(msg); } @@ -821,7 +821,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().getName()); + buf.append(" name=").append(profile.getVirtualMachine().getHostName()); buf.append(" zone=").append(dest.getDataCenter().getId()); buf.append(" pod=").append(dest.getPod().getId()); @@ -829,7 +829,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V if (profile.getVirtualMachine().getRole() == SecondaryStorageVm.Role.templateProcessor) buf.append(" guid=").append(secHost.getGuid()); else - buf.append(" guid=").append(profile.getVirtualMachine().getName()); + buf.append(" guid=").append(profile.getVirtualMachine().getHostName()); String nfsMountPoint = null; try { diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index 66e579deafa..58c58946099 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -1198,7 +1198,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma VMInstanceVO vmInstance = _vmDao.findById(volume.getInstanceId()); String vmDisplayName = "detached"; if (vmInstance != null) { - vmDisplayName = vmInstance.getName(); + vmDisplayName = vmInstance.getHostName(); } 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 eefb5896019..17f9e7124d8 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -934,7 +934,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag s_logger.error("Unable to destroy vm: " + vm.getId()); accountCleanupNeeded = true; } - UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getName(), vm.getServiceOfferingId(), + UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getHostName(), vm.getServiceOfferingId(), vm.getTemplateId(), vm.getHypervisorType().toString()); _usageEventDao.persist(usageEvent); } @@ -1046,11 +1046,11 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag try { success = (success && _itMgr.advanceStop(vm, true, getSystemUser(), getSystemAccount())); } catch (OperationTimedoutException ote) { - s_logger.warn("Operation for stopping vm timed out, unable to stop vm " + vm.getName(), ote); + s_logger.warn("Operation for stopping vm timed out, unable to stop vm " + vm.getHostName(), ote); success = false; } } catch (AgentUnavailableException aue) { - s_logger.warn("Agent running on host " + vm.getHostId() + " is unavailable, unable to stop vm " + vm.getName(), aue); + s_logger.warn("Agent running on host " + vm.getHostId() + " is unavailable, unable to stop vm " + vm.getHostName(), aue); success = false; } } diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 6b07f8b9bc4..e34a4479398 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -540,7 +540,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager VolumeVO rootVolumeOfVm = null; List rootVolumesOfVm = _volsDao.findByInstanceAndType(vmId, Volume.Type.ROOT); if (rootVolumesOfVm.size() != 1) { - throw new CloudRuntimeException("The VM " + vm.getName() + " has more than one ROOT volume and is in an invalid state. Please contact Cloud Support."); + throw new CloudRuntimeException("The VM " + vm.getHostName() + " has more than one ROOT volume and is in an invalid state. Please contact Cloud Support."); } else { rootVolumeOfVm = rootVolumesOfVm.get(0); } @@ -559,7 +559,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.getName()); + throw new CloudRuntimeException("Failed to create volume when attaching it to VM: " + vm.getHostName()); } } @@ -575,7 +575,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.getName()); + throw new RuntimeException("deviceId " + deviceId + " is used by VM " + vm.getHostName()); } } } else { @@ -641,7 +641,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.getName(); + String errorMsg = "Failed to attach volume: " + volume.getName() + " to VM: " + vm.getHostName(); boolean sendCommand = (vm.getState() == State.Running); AttachVolumeAnswer answer = null; Long hostId = vm.getHostId(); @@ -767,7 +767,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.getName(); + String errorMsg = "Failed to detach volume: " + volume.getName() + " from VM: " + vm.getHostName(); boolean sendCommand = (vm.getState() == State.Running); Answer answer = null; @@ -1094,7 +1094,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager _accountMgr.incrementResourceCount(account.getId(), ResourceType.volume, new Long(volumes.size())); - UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_CREATE, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getName(), vm.getServiceOfferingId(), vm.getTemplateId(), vm + UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_CREATE, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getHostName(), vm.getServiceOfferingId(), vm.getTemplateId(), vm .getHypervisorType().toString()); _usageEventDao.persist(usageEvent); txn.commit(); @@ -1581,7 +1581,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager s_logger.warn("Unable to delete volume:" + volume.getId() + " for vm:" + vmId + " whilst transitioning to error state"); } } - UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getName()); + UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getHostName()); _usageEventDao.persist(usageEvent); } } @@ -2352,7 +2352,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager s_logger.debug("Successfully allocated DB entry for " + vm); } UserContext.current().setEventDetails("Vm Id: " + vm.getId()); - UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_CREATE, accountId, zone.getId(), vm.getId(), vm.getName(), offering.getId(), template.getId(), hypervisorType.toString()); + UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_CREATE, accountId, zone.getId(), vm.getId(), vm.getHostName(), offering.getId(), template.getId(), hypervisorType.toString()); _usageEventDao.persist(usageEvent); _accountMgr.incrementResourceCount(accountId, ResourceType.user_vm); @@ -2521,7 +2521,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager @Override public boolean finalizeStart(VirtualMachineProfile profile, long hostId, Commands cmds, ReservationContext context) { UserVmVO vm = profile.getVirtualMachine(); - UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_START, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getName(), vm.getServiceOfferingId(), vm.getTemplateId(), vm + UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_START, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getHostName(), vm.getServiceOfferingId(), vm.getTemplateId(), vm .getHypervisorType().toString()); _usageEventDao.persist(usageEvent); @@ -2529,7 +2529,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager for (NicVO nic : nics) { NetworkVO network = _networkDao.findById(nic.getNetworkId()); long isDefault = (nic.isDefaultNic()) ? 1 : 0; - usageEvent = new UsageEventVO(EventTypes.EVENT_NETWORK_OFFERING_ASSIGN, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getName(), network.getNetworkOfferingId(), null, isDefault); + usageEvent = new UsageEventVO(EventTypes.EVENT_NETWORK_OFFERING_ASSIGN, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getHostName(), network.getNetworkOfferingId(), null, isDefault); _usageEventDao.persist(usageEvent); } @@ -2593,7 +2593,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager @Override public void finalizeStop(VirtualMachineProfile profile, StopAnswer answer) { VMInstanceVO vm = profile.getVirtualMachine(); - UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_STOP, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getName()); + UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_STOP, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getHostName()); _usageEventDao.persist(usageEvent); List nics = _nicDao.listByVmId(vm.getId()); @@ -2661,7 +2661,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager _usageEventDao.persist(usageEvent); } } - UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getName()); + UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_DESTROY, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), vm.getHostName()); _usageEventDao.persist(usageEvent); if (vmState != State.Error) { @@ -2794,7 +2794,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager 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().getName(), SearchCriteria.Op.LIKE); + sb.and("name", sb.entity().getHostName(), 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); diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index ac9b0ad9f50..92f334731f9 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -1113,7 +1113,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene if (!migrated) { s_logger.info("Migration was unsuccessful. Cleaning up: " + vm); - _alertMgr.sendAlert(alertType, fromHost.getDataCenterId(), fromHost.getPodId(), "Unable to migrate vm " + vm.getName() + " from host " + fromHost.getName() + " in zone " + _alertMgr.sendAlert(alertType, fromHost.getDataCenterId(), fromHost.getPodId(), "Unable to migrate vm " + vm.getHostName() + " from host " + fromHost.getName() + " in zone " + dest.getDataCenter().getName() + " and pod " + dest.getPod().getName(), "Migrate Command failed. Please check logs."); try { _agentMgr.send(dstHostId, new Commands(cleanup(vm.getInstanceName())), null); @@ -1280,7 +1280,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene try { Commands cmds = new Commands(OnError.Revert); - cmds.addCommand(new RebootCommand(vm.getName())); + cmds.addCommand(new RebootCommand(vm.getHostName())); _agentMgr.send(host.getId(), cmds); Answer rebootAnswer = cmds.getAnswer(RebootAnswer.class); @@ -1375,7 +1375,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene State agentState = info.state; final String agentName = info.name; final State serverState = vm.getState(); - final String serverName = vm.getName(); + final String serverName = vm.getHostName(); VirtualMachineGuru vmGuru = getVmGuru(vm); @@ -1400,8 +1400,8 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene 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.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."); + _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."); } // if (serverState == State.Migrating) { @@ -1453,7 +1453,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene _haMgr.scheduleStop(vm, vm.getHostId(), WorkType.ForceStop); s_logger.debug("Scheduling a check stop for VM in stopping mode: " + vm); } else if (serverState == State.Starting) { - s_logger.debug("Ignoring VM in starting mode: " + vm.getName()); + s_logger.debug("Ignoring VM in starting mode: " + vm.getHostName()); _haMgr.scheduleRestart(vm, false); } command = cleanup(agentName); diff --git a/server/src/com/cloud/vm/VirtualMachineProfileImpl.java b/server/src/com/cloud/vm/VirtualMachineProfileImpl.java index 265e314870c..972832ea609 100644 --- a/server/src/com/cloud/vm/VirtualMachineProfileImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineProfileImpl.java @@ -212,7 +212,7 @@ public class VirtualMachineProfileImpl implements Virtua @Override public String getHostName() { - return _vm.getName(); + return _vm.getHostName(); } @Override diff --git a/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java b/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java index 14bc7af2b94..d4979cc6a10 100644 --- a/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java +++ b/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java @@ -79,7 +79,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase implem ZoneTemplateNonExpungedSearch.done(); NameLikeSearch = createSearchBuilder(); - NameLikeSearch.and("name", NameLikeSearch.entity().getName(), Op.LIKE); + NameLikeSearch.and("name", NameLikeSearch.entity().getHostName(), Op.LIKE); NameLikeSearch.done(); StateChangeSearch = createSearchBuilder(); diff --git a/utils/src/com/cloud/utils/net/NetUtils.java b/utils/src/com/cloud/utils/net/NetUtils.java index 13c07699cf0..93e0a6195c0 100755 --- a/utils/src/com/cloud/utils/net/NetUtils.java +++ b/utils/src/com/cloud/utils/net/NetUtils.java @@ -921,7 +921,7 @@ public class NetUtils { if (hostName.length() > 63 || hostName.length() < 1) { s_logger.warn("Domain name label must be between 1 and 63 characters long"); return false; - } else if (!hostName.toLowerCase().matches("[a-zA-z0-9-]*")) { + } else if (!hostName.toLowerCase().matches("[a-z0-9-]*")) { s_logger.warn("Domain name label may contain only the ASCII letters 'a' through 'z' (in a case-insensitive manner)"); return false; } else if (hostName.startsWith("-") || hostName.endsWith("-")) {