diff --git a/server/src/com/cloud/agent/AgentManager.java b/server/src/com/cloud/agent/AgentManager.java index ffc29722d4d..4211bd566a3 100755 --- a/server/src/com/cloud/agent/AgentManager.java +++ b/server/src/com/cloud/agent/AgentManager.java @@ -230,5 +230,4 @@ public interface AgentManager extends Manager { boolean isHostNativeHAEnabled(long hostId); Answer sendTo(Long dcId, HypervisorType type, Command cmd); - } diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java index f32b836842c..617e1fb2441 100755 --- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java @@ -86,11 +86,9 @@ import com.cloud.configuration.dao.ConfigurationDao; import com.cloud.dc.ClusterDetailsDao; import com.cloud.dc.ClusterDetailsVO; import com.cloud.dc.ClusterVO; -import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenterIpAddressVO; import com.cloud.dc.DataCenterVO; import com.cloud.dc.HostPodVO; -import com.cloud.dc.Pod; import com.cloud.dc.PodCluster; import com.cloud.dc.dao.ClusterDao; import com.cloud.dc.dao.DataCenterDao; @@ -108,8 +106,6 @@ import com.cloud.exception.DiscoveryException; import com.cloud.exception.InsufficientServerCapacityException; import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.OperationTimedoutException; -import com.cloud.exception.StorageUnavailableException; -import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.UnsupportedVersionException; import com.cloud.ha.HighAvailabilityManager; import com.cloud.ha.HighAvailabilityManager.WorkType; @@ -122,6 +118,7 @@ import com.cloud.host.Status; import com.cloud.host.Status.Event; import com.cloud.host.dao.DetailsDao; import com.cloud.host.dao.HostDao; +import com.cloud.host.dao.HostTagsDao; import com.cloud.hypervisor.Hypervisor; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.kvm.resource.KvmDummyResourceBase; @@ -140,11 +137,9 @@ import com.cloud.service.ServiceOfferingVO; import com.cloud.storage.GuestOSCategoryVO; import com.cloud.storage.Storage; import com.cloud.storage.StorageManager; -import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePoolVO; import com.cloud.storage.VMTemplateHostVO; import com.cloud.storage.VMTemplateVO; -import com.cloud.storage.Volume; import com.cloud.storage.dao.GuestOSCategoryDao; import com.cloud.storage.dao.StoragePoolDao; import com.cloud.storage.dao.StoragePoolHostDao; @@ -177,10 +172,8 @@ import com.cloud.utils.nio.Link; import com.cloud.utils.nio.NioServer; import com.cloud.utils.nio.Task; import com.cloud.vm.VMInstanceVO; -import com.cloud.vm.VirtualMachineProfile; import com.cloud.vm.VirtualMachineProfileImpl; import com.cloud.vm.dao.VMInstanceDao; -import com.cloud.host.dao.HostTagsDao; /** * Implementation of the Agent Manager. This class controls the connection to @@ -1790,21 +1783,6 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, return null; } - public Pod findPod(VirtualMachineProfile vm, DataCenter dc, - Set avoids) { - for (PodAllocator allocator : _podAllocators) { - Pod pod = allocator.allocateTo(vm, dc, avoids); - if (pod != null) { - s_logger.debug("Pod " + pod.getId() + " is found by " - + allocator.getName()); - return pod; - } - } - - s_logger.debug("Unable to find any pod for " + vm); - return null; - } - @Override public HostStats getHostStatistics(long hostId) { Answer answer = easySend(hostId, new GetHostStatsCommand(_hostDao diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 6695b2cb9b2..0fb5ebf0a26 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -920,12 +920,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag for (Pair network : networks) { NetworkVO config = network.first(); - NetworkGuru concierge = _networkGurus.get(config.getGuruName()); + NetworkGuru guru = _networkGurus.get(config.getGuruName()); NicProfile requested = network.second(); if (requested != null && requested.getMode() == null) { requested.setMode(config.getMode()); } - NicProfile profile = concierge.allocate(config, requested, vm); + NicProfile profile = guru.allocate(config, requested, vm); if (vm != null && vm.getVirtualMachine().getType() == Type.User && config.isDefault()) { profile.setDefaultNic(true); @@ -943,7 +943,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag vmType = Nic.VmType.System; } - NicVO vo = new NicVO(concierge.getName(), vm.getId(), config.getId(), vmType); + NicVO vo = new NicVO(guru.getName(), vm.getId(), config.getId(), vmType); while (deviceIds[deviceId] && deviceId < deviceIds.length) { deviceId++; @@ -1091,7 +1091,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } if (s_logger.isDebugEnabled()) { - s_logger.debug("Asking " + guru + " to implement " + network); + s_logger.debug("Asking " + guru.getName() + " to implement " + network); } NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId()); @@ -1160,7 +1160,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag List nics = _nicDao.listByVmId(vmProfile.getId()); for (NicVO nic : nics) { Pair implemented = implementNetwork(nic.getNetworkId(), dest, context); - NetworkGuru concierge = implemented.first(); + NetworkGuru guru = implemented.first(); NetworkVO network = implemented.second(); NetworkOffering no = _configMgr.getNetworkOffering(network.getNetworkOfferingId()); Integer networkRate = _configMgr.getNetworkRate(no.getId()); @@ -1177,13 +1177,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag URI isolationUri = nic.getIsolationUri(); profile = new NicProfile(nic, network, broadcastUri, isolationUri, networkRate); - concierge.reserve(profile, network, vmProfile, dest, context); + guru.reserve(profile, network, vmProfile, dest, context); nic.setIp4Address(profile.getIp4Address()); nic.setIp6Address(profile.getIp6Address()); nic.setMacAddress(profile.getMacAddress()); nic.setIsolationUri(profile.getIsolationUri()); nic.setBroadcastUri(profile.getBroadCastUri()); - nic.setReserver(concierge.getName()); + nic.setReserver(guru.getName()); nic.setState(Nic.State.Reserved); nic.setNetmask(profile.getNetmask()); nic.setGateway(profile.getGateway()); @@ -1202,7 +1202,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag element.prepare(network, profile, vmProfile, dest, context); } profile.setSecurityGroupEnabled(network.isSecurityGroupEnabled()); - concierge.updateNicProfile(profile, network); + guru.updateNicProfile(profile, network); vmProfile.addNic(profile); } } @@ -1215,9 +1215,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag NetworkOffering no = _configMgr.getNetworkOffering(network.getNetworkOfferingId()); Integer networkRate = _configMgr.getNetworkRate(no.getId()); - NetworkGuru concierge = _networkGurus.get(network.getGuruName()); + NetworkGuru guru = _networkGurus.get(network.getGuruName()); NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate); - concierge.updateNicProfile(profile, network); + guru.updateNicProfile(profile, network); vm.addNic(profile); } } @@ -1230,11 +1230,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (nic.getState() == Nic.State.Reserved || nic.getState() == Nic.State.Reserving) { Nic.State originalState = nic.getState(); if (nic.getReservationStrategy() == Nic.ReservationStrategy.Start) { - NetworkGuru concierge = _networkGurus.get(network.getGuruName()); + NetworkGuru guru = _networkGurus.get(network.getGuruName()); nic.setState(Nic.State.Releasing); _nicDao.update(nic.getId(), nic); NicProfile profile = new NicProfile(nic, network, null, null, null); - if (concierge.release(profile, vmProfile, nic.getReservationId())) { + if (guru.release(profile, vmProfile, nic.getReservationId())) { applyProfileToNicForRelease(nic, profile); nic.setState(Nic.State.Allocated); if (originalState == Nic.State.Reserved) { @@ -1280,9 +1280,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag NetworkOffering no = _configMgr.getNetworkOffering(network.getNetworkOfferingId()); Integer networkRate = _configMgr.getNetworkRate(no.getId()); - NetworkGuru concierge = _networkGurus.get(network.getGuruName()); + NetworkGuru guru = _networkGurus.get(network.getGuruName()); NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate); - concierge.updateNicProfile(profile, network); + guru.updateNicProfile(profile, network); profiles.add(profile); } } @@ -1870,7 +1870,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag for (NetworkElement element : _networkElements) { try { if (s_logger.isDebugEnabled()) { - s_logger.debug("Sending network shutdown to " + element); + s_logger.debug("Sending network shutdown to " + element.getName()); } element.shutdown(network, context); @@ -2479,9 +2479,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag @Override public NetworkProfile convertNetworkToNetworkProfile(long networkId) { NetworkVO network = _networksDao.findById(networkId); - NetworkGuru concierge = _networkGurus.get(network.getGuruName()); + NetworkGuru guru = _networkGurus.get(network.getGuruName()); NetworkProfile profile = new NetworkProfile(network); - concierge.updateNetworkProfile(profile); + guru.updateNetworkProfile(profile); return profile; } diff --git a/server/src/com/cloud/server/ManagementServer.java b/server/src/com/cloud/server/ManagementServer.java index 6cf123cb0ff..30569f9694a 100755 --- a/server/src/com/cloud/server/ManagementServer.java +++ b/server/src/com/cloud/server/ManagementServer.java @@ -31,7 +31,6 @@ import com.cloud.dc.VlanVO; import com.cloud.domain.DomainVO; import com.cloud.event.EventVO; import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InternalErrorException; import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.OperationTimedoutException; import com.cloud.exception.ResourceUnavailableException; @@ -297,17 +296,6 @@ public interface ManagementServer extends ManagementService { */ DataCenterVO findDataCenterById(long dataCenterId); - /** - * Copies a template from one secondary storage server to another - * @param userId - * @param templateId - * @param sourceZoneId - the source zone - * @param destZoneId - the destination zone - * @return true if success - * @throws InternalErrorException - */ - boolean copyTemplate(long userId, long templateId, long sourceZoneId, long destZoneId); - /** * Finds a template by the specified ID. * @param templateId diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index eadd6b75166..918e2e9447e 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -183,7 +183,6 @@ import com.cloud.host.dao.HostDao; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.info.ConsoleProxyInfo; import com.cloud.network.IPAddressVO; -import com.cloud.network.Network; import com.cloud.network.NetworkManager; import com.cloud.network.NetworkVO; import com.cloud.network.dao.IPAddressDao; @@ -1110,8 +1109,9 @@ public class ManagementServerImpl implements ManagementServer { while(true){ if(id != null) { ServiceOfferingVO so = _offeringsDao.findById((Long)id); - if(so != null) - sol.add(so); + if(so != null) { + sol.add(so); + } return sol; } @@ -1983,18 +1983,6 @@ public class ManagementServerImpl implements ManagementServer { return _templateDao.findById(id); } - @Override - public boolean copyTemplate(long userId, long templateId, long sourceZoneId, long destZoneId) { - boolean success = false; - try { - success = _tmpltMgr.copy(userId, templateId, sourceZoneId, destZoneId); - } catch (Exception e) { - s_logger.warn("Unable to copy template " + templateId + " from zone " + sourceZoneId + " to " + destZoneId , e); - success = false; - } - return success; - } - @Override public VMTemplateVO findTemplateById(long templateId) { return _templateDao.findById(templateId); diff --git a/server/src/com/cloud/upgrade/dao/Upgrade217to22.java b/server/src/com/cloud/upgrade/dao/Upgrade217to22.java index e4b3fffefbf..d8ac6e359cf 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade217to22.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade217to22.java @@ -143,7 +143,7 @@ public class Upgrade217to22 implements DbUpgrade { try { pstmt = conn.prepareStatement("SELECT value FROM configuration WHERE name='direct.attach.untagged.vlan.enabled'"); ResultSet rs = pstmt.executeQuery(); - _basicZone = !(rs.next() && Boolean.parseBoolean(rs.getString(1))); + _basicZone = !rs.next() || Boolean.parseBoolean(rs.getString(1)); rs.close(); pstmt.close(); pstmt = conn.prepareStatement("UPDATE data_center SET networktype=?, dns_provider=?, gateway_provider=?, firewall_provider=?, dhcp_provider=?, lb_provider=?, vpn_provider=?, userdata_provider=?"); diff --git a/server/src/com/cloud/upgrade/dao/VersionDaoImpl.java b/server/src/com/cloud/upgrade/dao/VersionDaoImpl.java index edae8c300bd..34ac93e8ec9 100644 --- a/server/src/com/cloud/upgrade/dao/VersionDaoImpl.java +++ b/server/src/com/cloud/upgrade/dao/VersionDaoImpl.java @@ -64,7 +64,7 @@ public class VersionDaoImpl extends GenericDaoBase implements V protected VersionDaoImpl() { super(); - _upgradeMap.put(new Pair("2.1.7", "2.2.1"), new DbUpgrade[] { new Upgrade217to22() }); + _upgradeMap.put(new Pair("2.1.7", "2.2.2"), new DbUpgrade[] { new Upgrade217to22(), new Upgrade221to222() }); CurrentVersionSearch = createSearchBuilder(String.class); CurrentVersionSearch.select(null, Func.FIRST, CurrentVersionSearch.entity().getVersion()); diff --git a/server/test/com/cloud/upgrade/dao/VersionDaoImplTest.java b/server/test/com/cloud/upgrade/dao/AdvanceZone217To221UpgradeTest.java similarity index 86% rename from server/test/com/cloud/upgrade/dao/VersionDaoImplTest.java rename to server/test/com/cloud/upgrade/dao/AdvanceZone217To221UpgradeTest.java index 300a3beb3d3..8e757c03263 100644 --- a/server/test/com/cloud/upgrade/dao/VersionDaoImplTest.java +++ b/server/test/com/cloud/upgrade/dao/AdvanceZone217To221UpgradeTest.java @@ -37,8 +37,8 @@ import com.cloud.utils.db.DbTestUtils; import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; -public class VersionDaoImplTest extends TestCase { - private static final Logger s_logger = Logger.getLogger(VersionDaoImplTest.class); +public class AdvanceZone217To221UpgradeTest extends TestCase { + private static final Logger s_logger = Logger.getLogger(AdvanceZone217To221UpgradeTest.class); @Override @Before @@ -56,7 +56,23 @@ public class VersionDaoImplTest extends TestCase { public void test217to22Upgrade() { s_logger.debug("Finding sample data from 2.1.7"); DbTestUtils.executeScript("VersionDaoImplTest/2.1.7/2.1.7.sample.sql", false, true); - + + Connection conn = Transaction.getStandaloneConnection(); + PreparedStatement pstmt; + try { + pstmt = conn.prepareStatement("UPDATE configuration set value='true' WHERE name = 'direct.attach.untagged.vlan.enabled'"); + pstmt.executeUpdate(); + pstmt.close(); + } catch(SQLException e) { + + } finally { + try { + conn.close(); + } catch(SQLException e) { + + } + } + VersionDaoImpl dao = ComponentLocator.inject(VersionDaoImpl.class); String version = dao.getCurrentVersion(); @@ -69,8 +85,7 @@ public class VersionDaoImplTest extends TestCase { assert false : "The test failed. Check logs"; } - Connection conn = Transaction.getStandaloneConnection(); - PreparedStatement pstmt; + conn = Transaction.getStandaloneConnection(); try { pstmt = conn.prepareStatement("SELECT version FROm version"); ResultSet rs = pstmt.executeQuery(); diff --git a/setup/db/schema-21to22.sql b/setup/db/schema-21to22.sql index 29ed5f5064a..e4f4e1781f1 100755 --- a/setup/db/schema-21to22.sql +++ b/setup/db/schema-21to22.sql @@ -192,6 +192,8 @@ ALTER TABLE `cloud`.`user_ip_address` ADD COLUMN `mac_address` bigint unsigned N ALTER TABLE `cloud`.`user_ip_address` ADD COLUMN `source_network_id` bigint unsigned NOT NULL; ALTER TABLE `cloud`.`user_ip_address` ADD COLUMN `network_id` bigint unsigned; +UPDATE `cloud`.`user_ip_address` set state=`Allocated` WHERE allocated IS NOT NULL; + CREATE TABLE `cloud`.`firewall_rules` ( `id` bigint unsigned NOT NULL auto_increment COMMENT 'id', `ip_address_id` bigint unsigned NOT NULL COMMENT 'id of the corresponding ip address', diff --git a/utils/src/com/cloud/utils/db/DataStore.java b/utils/src/com/cloud/utils/db/DataStore.java deleted file mode 100644 index 071322f35fd..00000000000 --- a/utils/src/com/cloud/utils/db/DataStore.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (C) 2010 Cloud.com, Inc. All rights reserved. - * - * This software is licensed under the GNU General Public License v3 or later. - * - * It is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -package com.cloud.utils.db; - -import java.util.HashMap; -import java.util.Map; - -public class DataStore { - - private final static Map, GenericDao> s_daos = new HashMap, GenericDao>(101); - -} diff --git a/utils/src/com/cloud/utils/db/Transaction.java b/utils/src/com/cloud/utils/db/Transaction.java index a641fd86284..9e7340db6f1 100755 --- a/utils/src/com/cloud/utils/db/Transaction.java +++ b/utils/src/com/cloud/utils/db/Transaction.java @@ -209,7 +209,6 @@ public class Transaction { @Override public String toString() { final StringBuilder str = new StringBuilder((_name != null ? _name : "")); - int count = 0; str.append(" : "); for (final StackElement se : _stack) { if (se.type == CURRENT_TXN) { @@ -651,7 +650,7 @@ public class Transaction { closePreviousStatement(); if (!_txn) { if (s_logger.isTraceEnabled()) { - s_logger.trace("Rollback called when there's no transaction: " + buildName()); + s_logger.trace("Rollback called for " + _name + " when there's no transaction: " + buildName()); } return; } @@ -660,7 +659,7 @@ public class Transaction { try { if (_conn != null) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Rolling back the transaction: Time = " + (System.currentTimeMillis() - _txnTime) + " Name = "+ buildName()); + s_logger.debug("Rolling back the transaction: Time = " + (System.currentTimeMillis() - _txnTime) + " Name = " + _name + "; called by " + buildName()); } _conn.rollback(); }