|
26 | 26 | import java.util.Date; |
27 | 27 | import java.util.Enumeration; |
28 | 28 | import java.util.HashMap; |
29 | | -import java.util.HashSet; |
30 | 29 | import java.util.List; |
31 | 30 | import java.util.Map; |
32 | 31 | import java.util.concurrent.ExecutorService; |
|
42 | 41 | import com.cloud.agent.AgentManager; |
43 | 42 | import com.cloud.agent.api.AgentControlAnswer; |
44 | 43 | import com.cloud.agent.api.Answer; |
45 | | -import com.cloud.agent.api.CheckVirtualMachineAnswer; |
46 | | -import com.cloud.agent.api.CheckVirtualMachineCommand; |
47 | 44 | import com.cloud.agent.api.Command; |
48 | 45 | import com.cloud.agent.api.ConsoleAccessAuthenticationAnswer; |
49 | 46 | import com.cloud.agent.api.ConsoleAccessAuthenticationCommand; |
50 | 47 | import com.cloud.agent.api.ConsoleProxyLoadReportCommand; |
51 | | -import com.cloud.agent.api.MigrateCommand; |
52 | | -import com.cloud.agent.api.PrepareForMigrationCommand; |
53 | 48 | import com.cloud.agent.api.RebootCommand; |
54 | 49 | import com.cloud.agent.api.StartupCommand; |
55 | 50 | import com.cloud.agent.api.StartupProxyCommand; |
|
91 | 86 | import com.cloud.exception.ResourceUnavailableException; |
92 | 87 | import com.cloud.exception.StorageUnavailableException; |
93 | 88 | import com.cloud.ha.HighAvailabilityManager; |
94 | | -import com.cloud.host.Host; |
95 | 89 | import com.cloud.host.Host.Type; |
96 | 90 | import com.cloud.host.HostVO; |
97 | 91 | import com.cloud.host.dao.HostDao; |
|
115 | 109 | import com.cloud.service.dao.ServiceOfferingDao; |
116 | 110 | import com.cloud.servlet.ConsoleProxyServlet; |
117 | 111 | import com.cloud.storage.StorageManager; |
118 | | -import com.cloud.storage.StoragePoolVO; |
119 | 112 | import com.cloud.storage.VMTemplateHostVO; |
120 | 113 | import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; |
121 | 114 | import com.cloud.storage.VMTemplateVO; |
@@ -1464,11 +1457,6 @@ protected void completeStopCommand(ConsoleProxyVO proxy, VirtualMachine.Event ev |
1464 | 1457 | } |
1465 | 1458 | } |
1466 | 1459 |
|
1467 | | - @Override |
1468 | | - public ConsoleProxyVO get(long id) { |
1469 | | - return _consoleProxyDao.findById(id); |
1470 | | - } |
1471 | | - |
1472 | 1460 | @Override |
1473 | 1461 | public Long convertToId(String vmName) { |
1474 | 1462 | if (!VirtualMachineName.isValidConsoleProxyName(vmName, _instance)) { |
@@ -1649,100 +1637,100 @@ public boolean stop(ConsoleProxyVO proxy) throws AgentUnavailableException { |
1649 | 1637 | } |
1650 | 1638 | } |
1651 | 1639 |
|
1652 | | - @Override |
1653 | | - public boolean migrate(ConsoleProxyVO proxy, HostVO host) { |
1654 | | - HostVO fromHost = _hostDao.findById(proxy.getId()); |
1655 | | - |
1656 | | - if (! _itMgr.stateTransitTo(proxy, VirtualMachine.Event.MigrationRequested, proxy.getHostId())) { |
1657 | | - s_logger.debug("State for " + proxy.toString() + " has changed so migration can not take place."); |
1658 | | - return false; |
1659 | | - } |
1660 | | - |
1661 | | - MigrateCommand cmd = new MigrateCommand(proxy.getInstanceName(), host.getPrivateIpAddress(), false); |
1662 | | - Answer answer = _agentMgr.easySend(fromHost.getId(), cmd); |
1663 | | - if (answer == null || !answer.getResult()) { |
1664 | | - return false; |
1665 | | - } |
1666 | | - |
1667 | | - _storageMgr.unshare(proxy, fromHost); |
1668 | | - |
1669 | | - return true; |
1670 | | - } |
1671 | | - |
1672 | | - @Override |
1673 | | - public boolean completeMigration(ConsoleProxyVO proxy, HostVO host) throws AgentUnavailableException, OperationTimedoutException { |
1674 | | - |
1675 | | - CheckVirtualMachineCommand cvm = new CheckVirtualMachineCommand(proxy.getInstanceName()); |
1676 | | - CheckVirtualMachineAnswer answer = (CheckVirtualMachineAnswer) _agentMgr.send(host.getId(), cvm); |
1677 | | - if (!answer.getResult()) { |
1678 | | - s_logger.debug("Unable to complete migration for " + proxy.getId()); |
1679 | | - _itMgr.stateTransitTo(proxy, VirtualMachine.Event.AgentReportStopped, null); |
1680 | | - return false; |
1681 | | - } |
1682 | | - |
1683 | | - State state = answer.getState(); |
1684 | | - if (state == State.Stopped) { |
1685 | | - s_logger.warn("Unable to complete migration as we can not detect it on " + host.getId()); |
1686 | | - _itMgr.stateTransitTo(proxy, VirtualMachine.Event.AgentReportStopped, null); |
1687 | | - return false; |
1688 | | - } |
1689 | | - |
1690 | | - _itMgr.stateTransitTo(proxy, VirtualMachine.Event.OperationSucceeded, host.getId()); |
1691 | | - return true; |
1692 | | - } |
1693 | | - |
1694 | | - @Override |
1695 | | - public HostVO prepareForMigration(ConsoleProxyVO proxy) throws StorageUnavailableException { |
1696 | | - |
1697 | | - VMTemplateVO template = _templateDao.findById(proxy.getTemplateId()); |
1698 | | - long routerId = proxy.getId(); |
1699 | | - boolean mirroredVols = proxy.isMirroredVols(); |
1700 | | - DataCenterVO dc = _dcDao.findById(proxy.getDataCenterId()); |
1701 | | - HostPodVO pod = _podDao.findById(proxy.getPodId()); |
1702 | | - StoragePoolVO sp = _storageMgr.getStoragePoolForVm(proxy.getId()); |
1703 | | - |
1704 | | - List<VolumeVO> vols = _volsDao.findCreatedByInstance(routerId); |
1705 | | - |
1706 | | - String[] storageIps = new String[2]; |
1707 | | - VolumeVO vol = vols.get(0); |
1708 | | - storageIps[0] = vol.getHostIp(); |
1709 | | - if (mirroredVols && (vols.size() == 2)) { |
1710 | | - storageIps[1] = vols.get(1).getHostIp(); |
1711 | | - } |
1712 | | - |
1713 | | - PrepareForMigrationCommand cmd = new PrepareForMigrationCommand(proxy.getName(), null, storageIps, vols, mirroredVols); |
1714 | | - |
1715 | | - HostVO routingHost = null; |
1716 | | - HashSet<Host> avoid = new HashSet<Host>(); |
1717 | | - |
1718 | | - HostVO fromHost = _hostDao.findById(proxy.getHostId()); |
1719 | | - if (fromHost.getClusterId() == null) { |
1720 | | - s_logger.debug("The host is not in a cluster"); |
1721 | | - return null; |
1722 | | - } |
1723 | | - avoid.add(fromHost); |
1724 | | - |
1725 | | - while ((routingHost = (HostVO) _agentMgr.findHost(Host.Type.Routing, dc, pod, sp, _serviceOffering, template, proxy, fromHost, avoid)) != null) { |
1726 | | - avoid.add(routingHost); |
1727 | | - |
1728 | | - if (s_logger.isDebugEnabled()) { |
1729 | | - s_logger.debug("Trying to migrate router to host " + routingHost.getName()); |
1730 | | - } |
1731 | | - |
1732 | | - if (!_storageMgr.share(proxy, vols, routingHost, false)) { |
1733 | | - s_logger.warn("Can not share " + proxy.getName()); |
1734 | | - throw new StorageUnavailableException("Can not share " + proxy.getName(), vol.getPoolId()); |
1735 | | - } |
1736 | | - |
1737 | | - Answer answer = _agentMgr.easySend(routingHost.getId(), cmd); |
1738 | | - if (answer != null && answer.getResult()) { |
1739 | | - return routingHost; |
1740 | | - } |
1741 | | - _storageMgr.unshare(proxy, vols, routingHost); |
1742 | | - } |
1743 | | - |
1744 | | - return null; |
1745 | | - } |
| 1640 | +// @Override |
| 1641 | +// public boolean migrate(ConsoleProxyVO proxy, HostVO host) { |
| 1642 | +// HostVO fromHost = _hostDao.findById(proxy.getId()); |
| 1643 | +// |
| 1644 | +// if (! _itMgr.stateTransitTo(proxy, VirtualMachine.Event.MigrationRequested, proxy.getHostId())) { |
| 1645 | +// s_logger.debug("State for " + proxy.toString() + " has changed so migration can not take place."); |
| 1646 | +// return false; |
| 1647 | +// } |
| 1648 | +// |
| 1649 | +// MigrateCommand cmd = new MigrateCommand(proxy.getInstanceName(), host.getPrivateIpAddress(), false); |
| 1650 | +// Answer answer = _agentMgr.easySend(fromHost.getId(), cmd); |
| 1651 | +// if (answer == null || !answer.getResult()) { |
| 1652 | +// return false; |
| 1653 | +// } |
| 1654 | +// |
| 1655 | +// _storageMgr.unshare(proxy, fromHost); |
| 1656 | +// |
| 1657 | +// return true; |
| 1658 | +// } |
| 1659 | +// |
| 1660 | +// @Override |
| 1661 | +// public boolean completeMigration(ConsoleProxyVO proxy, HostVO host) throws AgentUnavailableException, OperationTimedoutException { |
| 1662 | +// |
| 1663 | +// CheckVirtualMachineCommand cvm = new CheckVirtualMachineCommand(proxy.getInstanceName()); |
| 1664 | +// CheckVirtualMachineAnswer answer = (CheckVirtualMachineAnswer) _agentMgr.send(host.getId(), cvm); |
| 1665 | +// if (!answer.getResult()) { |
| 1666 | +// s_logger.debug("Unable to complete migration for " + proxy.getId()); |
| 1667 | +// _itMgr.stateTransitTo(proxy, VirtualMachine.Event.AgentReportStopped, null); |
| 1668 | +// return false; |
| 1669 | +// } |
| 1670 | +// |
| 1671 | +// State state = answer.getState(); |
| 1672 | +// if (state == State.Stopped) { |
| 1673 | +// s_logger.warn("Unable to complete migration as we can not detect it on " + host.getId()); |
| 1674 | +// _itMgr.stateTransitTo(proxy, VirtualMachine.Event.AgentReportStopped, null); |
| 1675 | +// return false; |
| 1676 | +// } |
| 1677 | +// |
| 1678 | +// _itMgr.stateTransitTo(proxy, VirtualMachine.Event.OperationSucceeded, host.getId()); |
| 1679 | +// return true; |
| 1680 | +// } |
| 1681 | +// |
| 1682 | +// @Override |
| 1683 | +// public HostVO prepareForMigration(ConsoleProxyVO proxy) throws StorageUnavailableException { |
| 1684 | +// |
| 1685 | +// VMTemplateVO template = _templateDao.findById(proxy.getTemplateId()); |
| 1686 | +// long routerId = proxy.getId(); |
| 1687 | +// boolean mirroredVols = proxy.isMirroredVols(); |
| 1688 | +// DataCenterVO dc = _dcDao.findById(proxy.getDataCenterId()); |
| 1689 | +// HostPodVO pod = _podDao.findById(proxy.getPodId()); |
| 1690 | +// StoragePoolVO sp = _storageMgr.getStoragePoolForVm(proxy.getId()); |
| 1691 | +// |
| 1692 | +// List<VolumeVO> vols = _volsDao.findCreatedByInstance(routerId); |
| 1693 | +// |
| 1694 | +// String[] storageIps = new String[2]; |
| 1695 | +// VolumeVO vol = vols.get(0); |
| 1696 | +// storageIps[0] = vol.getHostIp(); |
| 1697 | +// if (mirroredVols && (vols.size() == 2)) { |
| 1698 | +// storageIps[1] = vols.get(1).getHostIp(); |
| 1699 | +// } |
| 1700 | +// |
| 1701 | +// PrepareForMigrationCommand cmd = new PrepareForMigrationCommand(proxy.getName(), null, storageIps, vols, mirroredVols); |
| 1702 | +// |
| 1703 | +// HostVO routingHost = null; |
| 1704 | +// HashSet<Host> avoid = new HashSet<Host>(); |
| 1705 | +// |
| 1706 | +// HostVO fromHost = _hostDao.findById(proxy.getHostId()); |
| 1707 | +// if (fromHost.getClusterId() == null) { |
| 1708 | +// s_logger.debug("The host is not in a cluster"); |
| 1709 | +// return null; |
| 1710 | +// } |
| 1711 | +// avoid.add(fromHost); |
| 1712 | +// |
| 1713 | +// while ((routingHost = (HostVO) _agentMgr.findHost(Host.Type.Routing, dc, pod, sp, _serviceOffering, template, proxy, fromHost, avoid)) != null) { |
| 1714 | +// avoid.add(routingHost); |
| 1715 | +// |
| 1716 | +// if (s_logger.isDebugEnabled()) { |
| 1717 | +// s_logger.debug("Trying to migrate router to host " + routingHost.getName()); |
| 1718 | +// } |
| 1719 | +// |
| 1720 | +// if (!_storageMgr.share(proxy, vols, routingHost, false)) { |
| 1721 | +// s_logger.warn("Can not share " + proxy.getName()); |
| 1722 | +// throw new StorageUnavailableException("Can not share " + proxy.getName(), vol.getPoolId()); |
| 1723 | +// } |
| 1724 | +// |
| 1725 | +// Answer answer = _agentMgr.easySend(routingHost.getId(), cmd); |
| 1726 | +// if (answer != null && answer.getResult()) { |
| 1727 | +// return routingHost; |
| 1728 | +// } |
| 1729 | +// _storageMgr.unshare(proxy, vols, routingHost); |
| 1730 | +// } |
| 1731 | +// |
| 1732 | +// return null; |
| 1733 | +// } |
1746 | 1734 |
|
1747 | 1735 | private String getCapacityScanLockName() { |
1748 | 1736 | // to improve security, it may be better to return a unique mashed |
|
0 commit comments