mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
add global setting to allow parallel execution on vmware (#6413)
* add global setting to allow parallel execution on vmware * cleanup setting distribution for vmware.create.full.clone * query setting in vmware guru * don´t touch other hypervisor's commands * guru hierarchy cleanup
This commit is contained in:
parent
12ecfa88cd
commit
731a83babf
@ -20,7 +20,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.backup.Backup;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
@ -35,8 +34,7 @@ import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
public interface HypervisorGuru extends Adapter {
|
||||
ConfigKey<Boolean> VmwareFullClone = new ConfigKey<Boolean>("Advanced", Boolean.class, "vmware.create.full.clone", "true",
|
||||
"If set to true, creates guest VMs as full clones on ESX", false);
|
||||
|
||||
HypervisorType getHypervisorType();
|
||||
|
||||
/**
|
||||
|
||||
@ -40,57 +40,86 @@ public interface CapacityManager {
|
||||
static final String StorageCapacityDisableThresholdCK = "pool.storage.capacity.disablethreshold";
|
||||
static final String StorageOverprovisioningFactorCK = "storage.overprovisioning.factor";
|
||||
static final String StorageAllocatedCapacityDisableThresholdCK = "pool.storage.allocated.capacity.disablethreshold";
|
||||
static final String VmwareCreateCloneFullCK = "vmware.create.full.clone";
|
||||
|
||||
static final ConfigKey<Float> CpuOverprovisioningFactor = new ConfigKey<Float>(Float.class, CpuOverprovisioningFactorCK, "Advanced", "1.0",
|
||||
"Used for CPU overprovisioning calculation; available CPU will be (actualCpuCapacity * cpu.overprovisioning.factor)", true, ConfigKey.Scope.Cluster, null);
|
||||
static final ConfigKey<Float> MemOverprovisioningFactor = new ConfigKey<Float>(Float.class, MemOverprovisioningFactorCK, "Advanced", "1.0",
|
||||
"Used for memory overprovisioning calculation", true, ConfigKey.Scope.Cluster, null);
|
||||
static final ConfigKey<Double> StorageCapacityDisableThreshold = new ConfigKey<Double>("Alert", Double.class, StorageCapacityDisableThresholdCK, "0.85",
|
||||
"Percentage (as a value between 0 and 1) of storage utilization above which allocators will disable using the pool for low storage available.", true,
|
||||
ConfigKey.Scope.Zone);
|
||||
static final ConfigKey<Double> StorageOverprovisioningFactor = new ConfigKey<Double>("Storage", Double.class, StorageOverprovisioningFactorCK, "2",
|
||||
"Used for storage overprovisioning calculation; available storage will be (actualStorageSize * storage.overprovisioning.factor)", true, ConfigKey.Scope.StoragePool);
|
||||
static final String CATEGORY_ADVANCED = "Advanced";
|
||||
static final String CATEGORY_ALERT = "Alert";
|
||||
|
||||
static final ConfigKey<Float> CpuOverprovisioningFactor =
|
||||
new ConfigKey<>(
|
||||
Float.class,
|
||||
CpuOverprovisioningFactorCK,
|
||||
CATEGORY_ADVANCED,
|
||||
"1.0",
|
||||
"Used for CPU overprovisioning calculation; available CPU will be (actualCpuCapacity * cpu.overprovisioning.factor)",
|
||||
true,
|
||||
ConfigKey.Scope.Cluster,
|
||||
null);
|
||||
static final ConfigKey<Float> MemOverprovisioningFactor =
|
||||
new ConfigKey<>(
|
||||
Float.class,
|
||||
MemOverprovisioningFactorCK,
|
||||
CATEGORY_ADVANCED,
|
||||
"1.0",
|
||||
"Used for memory overprovisioning calculation",
|
||||
true,
|
||||
ConfigKey.Scope.Cluster,
|
||||
null);
|
||||
static final ConfigKey<Double> StorageCapacityDisableThreshold =
|
||||
new ConfigKey<>(
|
||||
CATEGORY_ALERT,
|
||||
Double.class,
|
||||
StorageCapacityDisableThresholdCK,
|
||||
"0.85",
|
||||
"Percentage (as a value between 0 and 1) of storage utilization above which allocators will disable using the pool for low storage available.",
|
||||
true,
|
||||
ConfigKey.Scope.Zone);
|
||||
static final ConfigKey<Double> StorageOverprovisioningFactor =
|
||||
new ConfigKey<>(
|
||||
"Storage",
|
||||
Double.class,
|
||||
StorageOverprovisioningFactorCK,
|
||||
"2",
|
||||
"Used for storage overprovisioning calculation; available storage will be (actualStorageSize * storage.overprovisioning.factor)",
|
||||
true,
|
||||
ConfigKey.Scope.StoragePool);
|
||||
static final ConfigKey<Double> StorageAllocatedCapacityDisableThreshold =
|
||||
new ConfigKey<Double>(
|
||||
"Alert",
|
||||
Double.class,
|
||||
StorageAllocatedCapacityDisableThresholdCK,
|
||||
"0.85",
|
||||
"Percentage (as a value between 0 and 1) of allocated storage utilization above which allocators will disable using the pool for low allocated storage available.",
|
||||
true, ConfigKey.Scope.Zone);
|
||||
new ConfigKey<>(
|
||||
CATEGORY_ALERT,
|
||||
Double.class,
|
||||
StorageAllocatedCapacityDisableThresholdCK,
|
||||
"0.85",
|
||||
"Percentage (as a value between 0 and 1) of allocated storage utilization above which allocators will disable using the pool for low allocated storage available.",
|
||||
true,
|
||||
ConfigKey.Scope.Zone);
|
||||
static final ConfigKey<Boolean> StorageOperationsExcludeCluster =
|
||||
new ConfigKey<Boolean>(
|
||||
new ConfigKey<>(
|
||||
Boolean.class,
|
||||
"cluster.storage.operations.exclude",
|
||||
"Advanced",
|
||||
CATEGORY_ADVANCED,
|
||||
"false",
|
||||
"Exclude cluster from storage operations",
|
||||
true,
|
||||
ConfigKey.Scope.Cluster,
|
||||
null);
|
||||
static final ConfigKey<Boolean> VmwareCreateCloneFull =
|
||||
new ConfigKey<Boolean>(
|
||||
"Storage",
|
||||
Boolean.class,
|
||||
VmwareCreateCloneFullCK,
|
||||
"false",
|
||||
"If set to true, creates VMs as full clones on ESX hypervisor",
|
||||
true,
|
||||
ConfigKey.Scope.StoragePool);
|
||||
static final ConfigKey<String> ImageStoreNFSVersion =
|
||||
new ConfigKey<String>(
|
||||
new ConfigKey<>(
|
||||
String.class,
|
||||
"secstorage.nfs.version",
|
||||
"Advanced",
|
||||
CATEGORY_ADVANCED,
|
||||
null,
|
||||
"Enforces specific NFS version when mounting Secondary Storage. If NULL default selection is performed",
|
||||
true,
|
||||
ConfigKey.Scope.ImageStore,
|
||||
null);
|
||||
|
||||
static final ConfigKey<Float> SecondaryStorageCapacityThreshold = new ConfigKey<Float>("Advanced", Float.class, "secondary.storage.capacity.threshold", "0.90",
|
||||
"Percentage (as a value between 0 and 1) of secondary storage capacity threshold.", true);
|
||||
static final ConfigKey<Float> SecondaryStorageCapacityThreshold =
|
||||
new ConfigKey<>(
|
||||
CATEGORY_ADVANCED,
|
||||
Float.class,
|
||||
"secondary.storage.capacity.threshold",
|
||||
"0.90",
|
||||
"Percentage (as a value between 0 and 1) of secondary storage capacity threshold.",
|
||||
true);
|
||||
|
||||
public boolean releaseVmCapacity(VirtualMachine vm, boolean moveFromReserved, boolean moveToReservered, Long hostId);
|
||||
|
||||
|
||||
@ -163,6 +163,44 @@ public interface StorageManager extends StorageService {
|
||||
true,
|
||||
ConfigKey.Scope.Cluster,
|
||||
null);
|
||||
ConfigKey<Boolean> VmwareCreateCloneFull = new ConfigKey<>(Boolean.class,
|
||||
"vmware.create.full.clone",
|
||||
"Storage",
|
||||
"false",
|
||||
"If set to true, creates VMs as full clones on ESX hypervisor",
|
||||
true,
|
||||
ConfigKey.Scope.StoragePool,
|
||||
null);
|
||||
ConfigKey<Boolean> VmwareAllowParallelExecution = new ConfigKey<>(Boolean.class,
|
||||
"vmware.allow.parallel.command.execution",
|
||||
"Advanced",
|
||||
"false",
|
||||
"allow commands to be executed in parallel in spite of 'vmware.create.full.clone' being set to true.",
|
||||
true,
|
||||
ConfigKey.Scope.Global,
|
||||
null);
|
||||
|
||||
/**
|
||||
* should we execute in sequence not involving any storages?
|
||||
* @return tru if commands should execute in sequence
|
||||
*/
|
||||
static boolean shouldExecuteInSequenceOnVmware() {
|
||||
return shouldExecuteInSequenceOnVmware(null, null);
|
||||
}
|
||||
|
||||
static boolean shouldExecuteInSequenceOnVmware(Long srcStoreId, Long dstStoreId) {
|
||||
final Boolean fullClone = getFullCloneConfiguration(srcStoreId) || getFullCloneConfiguration(dstStoreId);
|
||||
final Boolean allowParallel = getAllowParallelExecutionConfiguration();
|
||||
return fullClone && !allowParallel;
|
||||
}
|
||||
|
||||
static Boolean getAllowParallelExecutionConfiguration() {
|
||||
return VmwareAllowParallelExecution.value();
|
||||
}
|
||||
|
||||
static Boolean getFullCloneConfiguration(Long storeId) {
|
||||
return VmwareCreateCloneFull.valueIn(storeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a comma separated list of tags for the specified storage pool
|
||||
|
||||
@ -1557,8 +1557,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
case LXC:
|
||||
return false;
|
||||
case VMware:
|
||||
final Boolean fullClone = HypervisorGuru.VmwareFullClone.value();
|
||||
return fullClone;
|
||||
return StorageManager.shouldExecuteInSequenceOnVmware();
|
||||
default:
|
||||
return ExecuteInSequence.value();
|
||||
}
|
||||
|
||||
@ -85,7 +85,6 @@ import com.cloud.agent.api.to.DatadiskTO;
|
||||
import com.cloud.agent.api.to.DiskTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.agent.manager.allocator.PodAllocator;
|
||||
import com.cloud.capacity.CapacityManager;
|
||||
import com.cloud.cluster.ClusterManager;
|
||||
import com.cloud.configuration.Resource.ResourceType;
|
||||
import com.cloud.dc.DataCenter;
|
||||
@ -1704,7 +1703,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
||||
if (vm.getHypervisorType().equals(HypervisorType.VMware)) {
|
||||
// retrieve clone flag.
|
||||
UserVmCloneType cloneType = UserVmCloneType.linked;
|
||||
Boolean value = CapacityManager.VmwareCreateCloneFull.valueIn(vol.getPoolId());
|
||||
Boolean value = StorageManager.VmwareCreateCloneFull.valueIn(vol.getPoolId());
|
||||
if (value != null && value) {
|
||||
cloneType = UserVmCloneType.full;
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
@ -56,7 +57,6 @@ import com.cloud.deploy.DeploymentPlanner;
|
||||
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.HypervisorGuru;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
@ -209,9 +209,23 @@ public class VirtualMachineManagerImplTest {
|
||||
public void testExeceuteInSequence() {
|
||||
assertTrue(virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.XenServer) == false);
|
||||
assertTrue(virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.KVM) == false);
|
||||
assertTrue(virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.VMware) == HypervisorGuru.VmwareFullClone.value());
|
||||
assertTrue(virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.Ovm3) == VirtualMachineManager.ExecuteInSequence.value());
|
||||
}
|
||||
@Test
|
||||
public void testExeceuteInSequenceVmware() {
|
||||
when(StorageManager.getFullCloneConfiguration(anyLong())).thenReturn(Boolean.FALSE);
|
||||
when(StorageManager.getAllowParallelExecutionConfiguration()).thenReturn(Boolean.FALSE);
|
||||
assertFalse("no full clones so no need to execute in sequence", virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.VMware));
|
||||
when(StorageManager.getFullCloneConfiguration(anyLong())).thenReturn(Boolean.TRUE);
|
||||
when(StorageManager.getAllowParallelExecutionConfiguration()).thenReturn(Boolean.FALSE);
|
||||
assertTrue("full clones and no explicit parallel execution allowed, should execute in sequence", virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.VMware));
|
||||
when(StorageManager.getFullCloneConfiguration(anyLong())).thenReturn(Boolean.TRUE);
|
||||
when(StorageManager.getAllowParallelExecutionConfiguration()).thenReturn(Boolean.TRUE);
|
||||
assertFalse("execute in sequence should not be needed as parallel is allowed", virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.VMware));
|
||||
when(StorageManager.getFullCloneConfiguration(anyLong())).thenReturn(Boolean.FALSE);
|
||||
when(StorageManager.getAllowParallelExecutionConfiguration()).thenReturn(Boolean.TRUE);
|
||||
assertFalse("double reasons to allow parallel execution", virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.VMware));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckIfCanUpgrade() throws Exception {
|
||||
|
||||
@ -47,10 +47,6 @@ public interface NetworkDao extends GenericDao<NetworkVO, Long>, StateDao<State,
|
||||
|
||||
int getOtherPersistentNetworksCount(long id, String broadcastURI, boolean isPersistent);
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
NetworkVO persist(NetworkVO vo);
|
||||
|
||||
/**
|
||||
* Retrieves the next available mac address in this network configuration.
|
||||
*
|
||||
|
||||
@ -62,7 +62,6 @@ import com.cloud.agent.api.to.DataStoreTO;
|
||||
import com.cloud.agent.api.to.DataTO;
|
||||
import com.cloud.agent.api.to.NfsTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.capacity.CapacityManager;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
@ -226,7 +225,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
|
||||
DataStoreTO dataStoreTO = dataTO.getDataStore();
|
||||
if (dataStoreTO != null && dataStoreTO instanceof PrimaryDataStoreTO){
|
||||
PrimaryDataStoreTO primaryDataStoreTO = (PrimaryDataStoreTO) dataStoreTO;
|
||||
primaryDataStoreTO.setFullCloneFlag(CapacityManager.VmwareCreateCloneFull.valueIn(primaryDataStoreTO.getId()));
|
||||
primaryDataStoreTO.setFullCloneFlag(StorageManager.VmwareCreateCloneFull.valueIn(primaryDataStoreTO.getId()));
|
||||
StoragePool pool = storageManager.getStoragePool(primaryDataStoreTO.getId());
|
||||
primaryDataStoreTO.setDiskProvisioningStrictnessFlag(storageManager.DiskProvisioningStrictness.valueIn(pool.getDataCenterId()));
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ public class AncientDataMotionStrategyTest {
|
||||
}
|
||||
|
||||
private void replaceVmwareCreateCloneFullField() throws Exception {
|
||||
Field field = CapacityManager.class.getDeclaredField("VmwareCreateCloneFull");
|
||||
Field field = StorageManager.class.getDeclaredField("VmwareCreateCloneFull");
|
||||
field.setAccessible(true);
|
||||
// remove final modifier from field
|
||||
Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||
|
||||
@ -30,7 +30,6 @@ import javax.inject.Inject;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.HypervisorGuru;
|
||||
import com.cloud.hypervisor.HypervisorGuruBase;
|
||||
@ -38,16 +37,11 @@ import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.storage.dao.GuestOSDao;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
public class BareMetalGuru extends HypervisorGuruBase implements HypervisorGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(BareMetalGuru.class);
|
||||
@Inject
|
||||
GuestOSDao _guestOsDao;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
@Inject
|
||||
VMInstanceDao _vmDao;
|
||||
|
||||
protected BareMetalGuru() {
|
||||
super();
|
||||
@ -62,7 +56,7 @@ public class BareMetalGuru extends HypervisorGuruBase implements HypervisorGuru
|
||||
public VirtualMachineTO implement(VirtualMachineProfile vm) {
|
||||
VirtualMachineTO to = toVirtualMachineTO(vm);
|
||||
|
||||
VMInstanceVO vo = _vmDao.findById(vm.getId());
|
||||
VMInstanceVO vo = virtualMachineDao.findById(vm.getId());
|
||||
if (vo.getLastHostId() == null) {
|
||||
to.setBootArgs(BaremetalManager.DO_PXE);
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@ import com.cloud.hypervisor.hyperv.manager.HypervManager;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.storage.dao.GuestOSDao;
|
||||
@ -51,7 +50,6 @@ public class HypervGuru extends HypervisorGuruBase implements HypervisorGuru {
|
||||
@Inject
|
||||
private GuestOSDao _guestOsDao;
|
||||
@Inject HypervManager _hypervMgr;
|
||||
@Inject NetworkDao _networkDao;
|
||||
@Inject NetworkModel _networkMgr;
|
||||
int MaxNicSupported = 8;
|
||||
@Override
|
||||
@ -109,7 +107,7 @@ public class HypervGuru extends HypervisorGuruBase implements HypervisorGuru {
|
||||
profile = controlNicProfile;
|
||||
}
|
||||
|
||||
NetworkVO network = _networkDao.findById(networkId);
|
||||
NetworkVO network = networkDao.findById(networkId);
|
||||
// for Hyperv Hot Nic plug is not supported and it will support upto 8 nics.
|
||||
// creating the VR with extra nics (actual nics(3) + extra nics) will be 8
|
||||
for(; i < MaxNicSupported; i++) {
|
||||
|
||||
@ -27,6 +27,7 @@ import java.util.UUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePoolHostVO;
|
||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
@ -78,7 +79,6 @@ import com.cloud.event.UsageEventUtils;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.host.dao.HostDetailsDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.HypervisorGuru;
|
||||
@ -99,7 +99,6 @@ import com.cloud.network.Network;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao;
|
||||
@ -108,7 +107,6 @@ import com.cloud.network.dao.PhysicalNetworkVO;
|
||||
import com.cloud.secstorage.CommandExecLogDao;
|
||||
import com.cloud.secstorage.CommandExecLogVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
@ -140,9 +138,7 @@ import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.Type;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
import com.google.gson.Gson;
|
||||
import com.vmware.vim25.ManagedObjectReference;
|
||||
import com.vmware.vim25.VirtualDevice;
|
||||
@ -160,18 +156,13 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
|
||||
|
||||
@Inject VmwareVmImplementer vmwareVmImplementer;
|
||||
|
||||
@Inject NetworkDao _networkDao;
|
||||
@Inject GuestOSDao _guestOsDao;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject HostDetailsDao _hostDetailsDao;
|
||||
@Inject ClusterDetailsDao _clusterDetailsDao;
|
||||
@Inject CommandExecLogDao _cmdExecLogDao;
|
||||
@Inject VmwareManager _vmwareMgr;
|
||||
@Inject SecondaryStorageVmManager _secStorageMgr;
|
||||
@Inject NicDao _nicDao;
|
||||
@Inject PhysicalNetworkTrafficTypeDao _physicalNetworkTrafficTypeDao;
|
||||
@Inject VMInstanceDao _vmDao;
|
||||
@Inject VirtualMachineManager vmManager;
|
||||
@Inject ClusterManager _clusterMgr;
|
||||
@Inject VolumeDao _volumeDao;
|
||||
@ -180,7 +171,6 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
@Inject VolumeDataFactory _volFactory;
|
||||
@Inject VmwareDatacenterDao vmwareDatacenterDao;
|
||||
@Inject VmwareDatacenterZoneMapDao vmwareDatacenterZoneMapDao;
|
||||
@Inject ServiceOfferingDao serviceOfferingDao;
|
||||
@Inject VMTemplatePoolDao templateStoragePoolDao;
|
||||
@Inject VMTemplateDao vmTemplateDao;
|
||||
@Inject UserVmDao userVmDao;
|
||||
@ -215,11 +205,14 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
}
|
||||
|
||||
@Override @DB public Pair<Boolean, Long> getCommandHostDelegation(long hostId, Command cmd) {
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace(String.format("Finding delegation for command of type %s to host %d.", cmd.getClass(), hostId));
|
||||
}
|
||||
|
||||
boolean needDelegation = false;
|
||||
if (cmd instanceof StorageSubSystemCommand) {
|
||||
Boolean fullCloneEnabled = VmwareFullClone.value();
|
||||
StorageSubSystemCommand c = (StorageSubSystemCommand)cmd;
|
||||
c.setExecuteInSequence(fullCloneEnabled);
|
||||
c.setExecuteInSequence(StorageManager.shouldExecuteInSequenceOnVmware());
|
||||
}
|
||||
if (cmd instanceof DownloadCommand) {
|
||||
cmd.setContextParam(VmwareManager.s_vmwareOVAPackageTimeout.key(), String.valueOf(VmwareManager.s_vmwareOVAPackageTimeout.value()));
|
||||
@ -234,11 +227,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
DataStoreTO destStoreTO = destData.getDataStore();
|
||||
|
||||
boolean inSeq = true;
|
||||
if ((srcData.getObjectType() == DataObjectType.SNAPSHOT) || (destData.getObjectType() == DataObjectType.SNAPSHOT)) {
|
||||
inSeq = false;
|
||||
} else if ((destStoreTO.getRole() == DataStoreRole.Image) || (destStoreTO.getRole() == DataStoreRole.ImageCache)) {
|
||||
inSeq = false;
|
||||
} else if (!VmwareFullClone.value()) {
|
||||
if (parallelExecutionAllowed(srcData, destData, srcStoreTO, destStoreTO)) {
|
||||
inSeq = false;
|
||||
}
|
||||
cpyCommand.setExecuteInSequence(inSeq);
|
||||
@ -273,10 +262,15 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
}
|
||||
}
|
||||
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace(String.format("Command of type %s is going to be executed in sequence? %b", cmd.getClass(), cmd.executeInSequence()));
|
||||
s_logger.trace(String.format("Command of type %s is going to need delegation? %b", cmd.getClass(), needDelegation));
|
||||
}
|
||||
|
||||
if (!needDelegation) {
|
||||
return new Pair<Boolean, Long>(Boolean.FALSE, new Long(hostId));
|
||||
}
|
||||
HostVO host = _hostDao.findById(hostId);
|
||||
HostVO host = hostDao.findById(hostId);
|
||||
long dcId = host.getDataCenterId();
|
||||
Pair<HostVO, SecondaryStorageVmVO> cmdTarget = _secStorageMgr.assignSecStorageVm(dcId, cmd);
|
||||
if (cmdTarget != null) {
|
||||
@ -322,6 +316,16 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
return new Pair<Boolean, Long>(Boolean.FALSE, new Long(hostId));
|
||||
}
|
||||
|
||||
private boolean parallelExecutionAllowed(DataTO srcData, DataTO destData, DataStoreTO srcStoreTO, DataStoreTO destStoreTO) {
|
||||
Long srcId = srcStoreTO == null || srcStoreTO.getUuid() == null ? null : _storagePoolDao.findByUuid(srcStoreTO.getUuid()).getId();
|
||||
Long dstId = destStoreTO == null || destStoreTO.getUuid() == null ? null : _storagePoolDao.findByUuid(destStoreTO.getUuid()).getId();
|
||||
return (srcData.getObjectType() == DataObjectType.SNAPSHOT)
|
||||
|| (destData.getObjectType() == DataObjectType.SNAPSHOT)
|
||||
|| (destStoreTO != null && destStoreTO.getRole() == DataStoreRole.Image)
|
||||
|| (destStoreTO != null && destStoreTO.getRole() == DataStoreRole.ImageCache)
|
||||
|| !StorageManager.shouldExecuteInSequenceOnVmware(srcId, dstId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trackVmHostChange() {
|
||||
return true;
|
||||
@ -345,12 +349,12 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
|
||||
@Override public List<Command> finalizeExpungeNics(VirtualMachine vm, List<NicProfile> nics) {
|
||||
List<Command> commands = new ArrayList<Command>();
|
||||
List<NicVO> nicVOs = _nicDao.listByVmId(vm.getId());
|
||||
List<NicVO> nicVOs = nicDao.listByVmId(vm.getId());
|
||||
for (NicVO nic : nicVOs) {
|
||||
NetworkVO network = _networkDao.findById(nic.getNetworkId());
|
||||
NetworkVO network = networkDao.findById(nic.getNetworkId());
|
||||
if (network.getBroadcastDomainType() == BroadcastDomainType.Lswitch) {
|
||||
s_logger.debug("Nic " + nic.toString() + " is connected to an lswitch, cleanup required");
|
||||
NetworkVO networkVO = _networkDao.findById(nic.getNetworkId());
|
||||
NetworkVO networkVO = networkDao.findById(nic.getNetworkId());
|
||||
// We need the traffic label to figure out which vSwitch has the
|
||||
// portgroup
|
||||
PhysicalNetworkTrafficTypeVO trafficTypeVO = _physicalNetworkTrafficTypeDao.findBy(networkVO.getPhysicalNetworkId(), networkVO.getTrafficType());
|
||||
@ -488,7 +492,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
}
|
||||
VolumeVO volumeVO = disksMapping.get(disk);
|
||||
if (volumeVO == null) {
|
||||
final VMInstanceVO vm = _vmDao.findByIdIncludingRemoved(backup.getVmId());
|
||||
final VMInstanceVO vm = virtualMachineDao.findByIdIncludingRemoved(backup.getVmId());
|
||||
if (vm == null) {
|
||||
throw new CloudRuntimeException("Failed to find the volumes details from the VM backup");
|
||||
}
|
||||
@ -655,18 +659,18 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
private VMInstanceVO getVM(String vmInternalName, long templateId, long guestOsId, long serviceOfferingId, long zoneId, long accountId, long userId, long domainId) {
|
||||
s_logger.debug(String.format("Trying to get VM with specs: [vmInternalName: %s, templateId: %s, guestOsId: %s, serviceOfferingId: %s].", vmInternalName,
|
||||
templateId, guestOsId, serviceOfferingId));
|
||||
VMInstanceVO vm = _vmDao.findVMByInstanceNameIncludingRemoved(vmInternalName);
|
||||
VMInstanceVO vm = virtualMachineDao.findVMByInstanceNameIncludingRemoved(vmInternalName);
|
||||
if (vm != null) {
|
||||
s_logger.debug(String.format("Found an existing VM [id: %s, removed: %s] with internalName: [%s].", vm.getUuid(), vm.getRemoved() != null ? "yes" : "no", vmInternalName));
|
||||
vm.setState(VirtualMachine.State.Stopped);
|
||||
vm.setPowerState(VirtualMachine.PowerState.PowerOff);
|
||||
_vmDao.update(vm.getId(), vm);
|
||||
virtualMachineDao.update(vm.getId(), vm);
|
||||
if (vm.getRemoved() != null) {
|
||||
_vmDao.unremove(vm.getId());
|
||||
virtualMachineDao.unremove(vm.getId());
|
||||
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VM_CREATE, accountId, vm.getDataCenterId(), vm.getId(), vm.getHostName(), vm.getServiceOfferingId(), vm.getTemplateId(),
|
||||
vm.getHypervisorType().toString(), VirtualMachine.class.getName(), vm.getUuid(), vm.isDisplayVm());
|
||||
}
|
||||
return _vmDao.findById(vm.getId());
|
||||
return virtualMachineDao.findById(vm.getId());
|
||||
} else {
|
||||
long id = userVmDao.getNextInSequence(Long.class, "id");
|
||||
s_logger.debug(String.format("Can't find an existing VM with internalName: [%s]. Creating a new VM with: [id: %s, name: %s, templateId: %s, guestOsId: %s, serviceOfferingId: %s].",
|
||||
@ -783,7 +787,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
}
|
||||
|
||||
private VolumeVO createVolume(VirtualDisk disk, VirtualMachineMO vmToImport, long domainId, long zoneId, long accountId, long instanceId, Long poolId, long templateId, Backup backup, boolean isImport) throws Exception {
|
||||
VMInstanceVO vm = _vmDao.findByIdIncludingRemoved(backup.getVmId());
|
||||
VMInstanceVO vm = virtualMachineDao.findByIdIncludingRemoved(backup.getVmId());
|
||||
if (vm == null) {
|
||||
throw new CloudRuntimeException("Failed to find the backup volume information from the VM backup");
|
||||
}
|
||||
@ -832,13 +836,13 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
*/
|
||||
private NetworkVO createNetworkRecord(Long zoneId, String tag, String vlan, long accountId, long domainId) {
|
||||
Long physicalNetworkId = getPhysicalNetworkId(zoneId, tag);
|
||||
final long id = _networkDao.getNextInSequence(Long.class, "id");
|
||||
final long id = networkDao.getNextInSequence(Long.class, "id");
|
||||
NetworkVO networkVO = new NetworkVO(id, TrafficType.Guest, Networks.Mode.Dhcp, BroadcastDomainType.Vlan, 9L, domainId, accountId, id, "Imported-network-" + id,
|
||||
"Imported-network-" + id, null, Network.GuestType.Isolated, zoneId, physicalNetworkId, ControlledEntity.ACLType.Account, false, null, false);
|
||||
networkVO.setBroadcastUri(BroadcastDomainType.Vlan.toUri(vlan));
|
||||
networkVO.setGuruName("ExternalGuestNetworkGuru");
|
||||
networkVO.setState(Network.State.Implemented);
|
||||
return _networkDao.persist(networkVO);
|
||||
return networkDao.persist(networkVO);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -852,7 +856,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
String tag = parts[parts.length - 1];
|
||||
String[] tagSplit = tag.split("-");
|
||||
tag = tagSplit[tagSplit.length - 1];
|
||||
NetworkVO networkVO = _networkDao.findByVlan(vlan);
|
||||
NetworkVO networkVO = networkDao.findByVlan(vlan);
|
||||
if (networkVO == null) {
|
||||
networkVO = createNetworkRecord(zoneId, tag, vlan, accountId, domainId);
|
||||
}
|
||||
@ -894,13 +898,13 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
|
||||
private void syncVMNics(VirtualDevice[] nicDevices, DatacenterMO dcMo, Map<String, NetworkVO> networksMapping, VMInstanceVO vm) throws Exception {
|
||||
VmwareContext context = dcMo.getContext();
|
||||
List<NicVO> allNics = _nicDao.listByVmId(vm.getId());
|
||||
List<NicVO> allNics = nicDao.listByVmId(vm.getId());
|
||||
for (VirtualDevice nicDevice : nicDevices) {
|
||||
Pair<String, String> pair = getNicMacAddressAndNetworkName(nicDevice, context);
|
||||
String macAddress = pair.first();
|
||||
String networkName = pair.second();
|
||||
NetworkVO networkVO = networksMapping.get(networkName);
|
||||
NicVO nicVO = _nicDao.findByNetworkIdAndMacAddress(networkVO.getId(), macAddress);
|
||||
NicVO nicVO = nicDao.findByNetworkIdAndMacAddress(networkVO.getId(), macAddress);
|
||||
if (nicVO != null) {
|
||||
allNics.remove(nicVO);
|
||||
}
|
||||
@ -911,7 +915,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
}
|
||||
|
||||
private Map<VirtualDisk, VolumeVO> getDisksMapping(Backup backup, List<VirtualDisk> virtualDisks) {
|
||||
final VMInstanceVO vm = _vmDao.findByIdIncludingRemoved(backup.getVmId());
|
||||
final VMInstanceVO vm = virtualMachineDao.findByIdIncludingRemoved(backup.getVmId());
|
||||
if (vm == null) {
|
||||
throw new CloudRuntimeException("Failed to find the volumes details from the VM backup");
|
||||
}
|
||||
@ -1076,7 +1080,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
private String getHostGuidForLocalStorage(StoragePool pool) {
|
||||
List<StoragePoolHostVO> storagePoolHostVOs = storagePoolHostDao.listByPoolId(pool.getId());
|
||||
StoragePoolHostVO storagePoolHostVO = storagePoolHostVOs.get(0);
|
||||
HostVO hostVO = _hostDao.findById(storagePoolHostVO.getHostId());
|
||||
HostVO hostVO = hostDao.findById(storagePoolHostVO.getHostId());
|
||||
return hostVO.getGuid();
|
||||
}
|
||||
|
||||
@ -1087,7 +1091,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co
|
||||
// Without host vMotion might fail between non-shared storages with error similar to,
|
||||
// https://kb.vmware.com/s/article/1003795
|
||||
// As this is offline migration VM won't be started on this host
|
||||
List<HostVO> hosts = _hostDao.findHypervisorHostInCluster(destClusterId);
|
||||
List<HostVO> hosts = hostDao.findHypervisorHostInCluster(destClusterId);
|
||||
if (CollectionUtils.isNotEmpty(hosts)) {
|
||||
hostInTargetCluster = hosts.get(0);
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ package com.cloud.hypervisor.vmware.manager;
|
||||
import com.cloud.api.query.dao.TemplateJoinDao;
|
||||
import com.cloud.api.query.vo.TemplateJoinVO;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.hypervisor.HypervisorGuru;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.VMTemplateStoragePoolVO;
|
||||
import com.cloud.storage.dao.VMTemplatePoolDao;
|
||||
import com.cloud.template.TemplateManager;
|
||||
@ -74,7 +74,7 @@ public class CleanupFullyClonedTemplatesTask extends ManagedContextRunnable {
|
||||
mine = Thread.currentThread();
|
||||
s_logger.info("running job to mark fully cloned templates for gc in thread " + mine.getName());
|
||||
|
||||
if (HypervisorGuru.VmwareFullClone.value()) { // only run if full cloning is being used (might need to be more fine grained)
|
||||
if (StorageManager.VmwareCreateCloneFull.value()) { // only run if full cloning is being used (might need to be more fine grained)
|
||||
try {
|
||||
queryAllPools();
|
||||
} catch (Throwable t) {
|
||||
|
||||
@ -331,12 +331,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
||||
_storage.configure("StorageLayer", params);
|
||||
}
|
||||
|
||||
value = _configDao.getValue(Config.VmwareCreateFullClone.key());
|
||||
if (value == null) {
|
||||
_fullCloneFlag = false;
|
||||
} else {
|
||||
_fullCloneFlag = Boolean.parseBoolean(value);
|
||||
}
|
||||
_fullCloneFlag = StorageManager.VmwareCreateCloneFull.value();
|
||||
|
||||
value = _configDao.getValue(Config.SetVmInternalNameUsingDisplayName.key());
|
||||
if (value == null) {
|
||||
|
||||
@ -44,7 +44,6 @@ import com.cloud.agent.api.to.DiskTO;
|
||||
import com.cloud.agent.api.to.NfsTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.GuestOSHypervisorVO;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
@ -68,8 +67,6 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru,
|
||||
@Inject
|
||||
private GuestOSHypervisorDao guestOsHypervisorDao;
|
||||
@Inject
|
||||
private HostDao hostDao;
|
||||
@Inject
|
||||
private VolumeDao volumeDao;
|
||||
@Inject
|
||||
private PrimaryDataStoreDao storagePoolDao;
|
||||
@ -178,10 +175,6 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru,
|
||||
|
||||
@Override
|
||||
public Pair<Boolean, Long> getCommandHostDelegation(long hostId, Command cmd) {
|
||||
if (cmd instanceof StorageSubSystemCommand) {
|
||||
StorageSubSystemCommand c = (StorageSubSystemCommand)cmd;
|
||||
c.setExecuteInSequence(true);
|
||||
}
|
||||
boolean isCopyCommand = cmd instanceof CopyCommand;
|
||||
Pair<Boolean, Long> defaultHostToExecuteCommands = super.getCommandHostDelegation(hostId, cmd);
|
||||
if (!isCopyCommand) {
|
||||
@ -197,6 +190,14 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru,
|
||||
logger.debug("We are returning the default host to execute commands because the target hypervisor of the source data is not XenServer.");
|
||||
return defaultHostToExecuteCommands;
|
||||
}
|
||||
// only now can we decide, now we now we're only deciding for ourselves
|
||||
if (cmd instanceof StorageSubSystemCommand) {
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace(String.format("XenServer StrorageSubSystemCommand re always executed in sequence (command of type %s to host %l).", cmd.getClass(), hostId));
|
||||
}
|
||||
StorageSubSystemCommand c = (StorageSubSystemCommand)cmd;
|
||||
c.setExecuteInSequence(true);
|
||||
}
|
||||
DataStoreTO srcStore = srcData.getDataStore();
|
||||
DataStoreTO destStore = destData.getDataStore();
|
||||
boolean isSourceAndDestinationNfsObjects = srcStore instanceof NfsTO && destStore instanceof NfsTO;
|
||||
|
||||
@ -19,7 +19,6 @@ package com.cloud.hypervisor;
|
||||
|
||||
import org.apache.cloudstack.hypervisor.xenserver.XenserverConfigs;
|
||||
import org.apache.cloudstack.storage.command.CopyCommand;
|
||||
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.Assert;
|
||||
@ -41,6 +40,8 @@ import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
import static org.mockito.Mockito.times;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class XenServerGuruTest {
|
||||
|
||||
@ -102,13 +103,33 @@ public class XenServerGuruTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCommandHostDelegationTestCommanIsStorageSubSystemCommand() {
|
||||
StorageSubSystemCommand storageSubSystemCommandMock = Mockito.mock(StorageSubSystemCommand.class);
|
||||
Pair<Boolean, Long> pairHostToExecuteCommand = xenServerGuru.getCommandHostDelegation(defaultHostId, storageSubSystemCommandMock);
|
||||
public void getCommandHostDelegationTestCommandIsStorageSubSystemCommand() {
|
||||
CopyCommand copyCommand = Mockito.mock(CopyCommand.class);
|
||||
DataTO srcData = Mockito.mock(DataTO.class);
|
||||
DataTO dstData = Mockito.mock(DataTO.class);
|
||||
Mockito.when(copyCommand.getSrcTO()).thenReturn(srcData);
|
||||
Mockito.when(copyCommand.getDestTO()).thenReturn(dstData);
|
||||
Mockito.when(srcData.getHypervisorType()).thenReturn(HypervisorType.XenServer);
|
||||
|
||||
Pair<Boolean, Long> pairHostToExecuteCommand = xenServerGuru.getCommandHostDelegation(defaultHostId, copyCommand);
|
||||
|
||||
assertPairOfHostToExecuteCommandIsTheDefaultHostId(pairHostToExecuteCommand);
|
||||
|
||||
Mockito.verify(storageSubSystemCommandMock).setExecuteInSequence(true);
|
||||
Mockito.verify(copyCommand).setExecuteInSequence(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCommandHostDelegationTestCommandIsNotForXenHypervisor() {
|
||||
CopyCommand copyCommand = Mockito.mock(CopyCommand.class);
|
||||
DataTO srcData = Mockito.mock(DataTO.class);
|
||||
Mockito.when(copyCommand.getSrcTO()).thenReturn(srcData);
|
||||
Mockito.when(srcData.getHypervisorType()).thenReturn(HypervisorType.Any);
|
||||
|
||||
Pair<Boolean, Long> pairHostToExecuteCommand = xenServerGuru.getCommandHostDelegation(defaultHostId, copyCommand);
|
||||
|
||||
assertPairOfHostToExecuteCommandIsTheDefaultHostId(pairHostToExecuteCommand);
|
||||
|
||||
Mockito.verify(copyCommand, times(0)).setExecuteInSequence(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@ -1256,6 +1256,6 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
|
||||
@Override
|
||||
public ConfigKey<?>[] getConfigKeys() {
|
||||
return new ConfigKey<?>[] {CpuOverprovisioningFactor, MemOverprovisioningFactor, StorageCapacityDisableThreshold, StorageOverprovisioningFactor,
|
||||
StorageAllocatedCapacityDisableThreshold, StorageOperationsExcludeCluster, VmwareCreateCloneFull, ImageStoreNFSVersion, SecondaryStorageCapacityThreshold};
|
||||
StorageAllocatedCapacityDisableThreshold, StorageOperationsExcludeCluster, ImageStoreNFSVersion, SecondaryStorageCapacityThreshold};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1087,14 +1087,6 @@ public enum Config {
|
||||
"false",
|
||||
"Enable/Disable Nexus/Vmware dvSwitch in VMware environment",
|
||||
null),
|
||||
VmwareCreateFullClone(
|
||||
"Advanced",
|
||||
ManagementServer.class,
|
||||
Boolean.class,
|
||||
"vmware.create.full.clone",
|
||||
"true",
|
||||
"If set to true, creates guest VMs as full clones on ESX",
|
||||
null),
|
||||
VmwareServiceConsole(
|
||||
"Advanced",
|
||||
ManagementServer.class,
|
||||
|
||||
@ -71,13 +71,16 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
|
||||
public static final Logger s_logger = Logger.getLogger(HypervisorGuruBase.class);
|
||||
|
||||
@Inject
|
||||
private NicDao _nicDao;
|
||||
protected
|
||||
NicDao nicDao;
|
||||
@Inject
|
||||
private NetworkDao _networkDao;
|
||||
protected
|
||||
NetworkDao networkDao;
|
||||
@Inject
|
||||
private NetworkOfferingDetailsDao networkOfferingDetailsDao;
|
||||
@Inject
|
||||
private VMInstanceDao _virtualMachineDao;
|
||||
protected
|
||||
VMInstanceDao virtualMachineDao;
|
||||
@Inject
|
||||
private UserVmDetailsDao _userVmDetailsDao;
|
||||
@Inject
|
||||
@ -87,11 +90,12 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
|
||||
@Inject
|
||||
protected ServiceOfferingDetailsDao _serviceOfferingDetailsDao;
|
||||
@Inject
|
||||
private ServiceOfferingDao _serviceOfferingDao;
|
||||
protected ServiceOfferingDao serviceOfferingDao;
|
||||
@Inject
|
||||
private NetworkDetailsDao networkDetailsDao;
|
||||
@Inject
|
||||
private HostDao hostDao;
|
||||
protected
|
||||
HostDao hostDao;
|
||||
|
||||
public static ConfigKey<Boolean> VmMinMemoryEqualsMemoryDividedByMemOverprovisioningFactor = new ConfigKey<Boolean>("Advanced", Boolean.class, "vm.min.memory.equals.memory.divided.by.mem.overprovisioning.factor", "true",
|
||||
"If we set this to 'true', a minimum memory (memory/ mem.overprovisioning.factor) will be set to the VM, independent of using a scalable service offering or not.", true, ConfigKey.Scope.Cluster);
|
||||
@ -140,11 +144,11 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
|
||||
to.setIp6Gateway(profile.getIPv6Gateway());
|
||||
to.setIp6Cidr(profile.getIPv6Cidr());
|
||||
|
||||
NetworkVO network = _networkDao.findById(profile.getNetworkId());
|
||||
NetworkVO network = networkDao.findById(profile.getNetworkId());
|
||||
to.setNetworkUuid(network.getUuid());
|
||||
|
||||
// Workaround to make sure the TO has the UUID we need for Nicira integration
|
||||
NicVO nicVO = _nicDao.findById(profile.getId());
|
||||
NicVO nicVO = nicDao.findById(profile.getId());
|
||||
if (nicVO != null) {
|
||||
to.setUuid(nicVO.getUuid());
|
||||
// disable pxe on system vm nics to speed up boot time
|
||||
@ -199,7 +203,7 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
|
||||
}
|
||||
|
||||
protected VirtualMachineTO toVirtualMachineTO(VirtualMachineProfile vmProfile) {
|
||||
ServiceOffering offering = _serviceOfferingDao.findById(vmProfile.getId(), vmProfile.getServiceOfferingId());
|
||||
ServiceOffering offering = serviceOfferingDao.findById(vmProfile.getId(), vmProfile.getServiceOfferingId());
|
||||
VirtualMachine vm = vmProfile.getVirtualMachine();
|
||||
Long clusterId = findClusterOfVm(vm);
|
||||
boolean divideMemoryByOverprovisioning = true;
|
||||
@ -268,7 +272,7 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
|
||||
}
|
||||
|
||||
// Workaround to make sure the TO has the UUID we need for Niciri integration
|
||||
VMInstanceVO vmInstance = _virtualMachineDao.findById(to.getId());
|
||||
VMInstanceVO vmInstance = virtualMachineDao.findById(to.getId());
|
||||
to.setEnableDynamicallyScaleVm(vmInstance.isDynamicallyScalable());
|
||||
to.setUuid(vmInstance.getUuid());
|
||||
|
||||
|
||||
@ -22,11 +22,9 @@ import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.configuration.ConfigurationManagerImpl;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.kvm.dpdk.DpdkHelper;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.GuestOSHypervisorVO;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
@ -56,12 +54,8 @@ public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru {
|
||||
@Inject
|
||||
GuestOSHypervisorDao _guestOsHypervisorDao;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
@Inject
|
||||
DpdkHelper dpdkHelper;
|
||||
|
||||
@Inject
|
||||
ServiceOfferingDao serviceOfferingDao;
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(KVMGuru.class);
|
||||
|
||||
@ -93,7 +87,7 @@ public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru {
|
||||
protected void setVmQuotaPercentage(VirtualMachineTO to, VirtualMachineProfile vmProfile) {
|
||||
if (to.getLimitCpuUse()) {
|
||||
VirtualMachine vm = vmProfile.getVirtualMachine();
|
||||
HostVO host = _hostDao.findById(vm.getHostId());
|
||||
HostVO host = hostDao.findById(vm.getHostId());
|
||||
if (host == null) {
|
||||
throw new CloudRuntimeException("Host with id: " + vm.getHostId() + " not found");
|
||||
}
|
||||
@ -126,7 +120,7 @@ public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru {
|
||||
|
||||
VirtualMachine virtualMachine = vm.getVirtualMachine();
|
||||
Long hostId = virtualMachine.getHostId();
|
||||
HostVO host = hostId == null ? null : _hostDao.findById(hostId);
|
||||
HostVO host = hostId == null ? null : hostDao.findById(hostId);
|
||||
|
||||
// Determine the VM's OS description
|
||||
configureVmOsDescription(virtualMachine, to, host);
|
||||
@ -206,7 +200,7 @@ public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru {
|
||||
Long lastHostId = virtualMachine.getLastHostId();
|
||||
s_logger.info(String.format("%s is not running; therefore, we use the last host [%s] that the VM was running on to derive the unconstrained service offering max CPU and memory.", vmDescription, lastHostId));
|
||||
|
||||
HostVO lastHost = lastHostId == null ? null : _hostDao.findById(lastHostId);
|
||||
HostVO lastHost = lastHostId == null ? null : hostDao.findById(lastHostId);
|
||||
if (lastHost != null) {
|
||||
maxHostMemory = lastHost.getTotalMemory();
|
||||
maxHostCpuCore = lastHost.getCpus();
|
||||
|
||||
@ -22,7 +22,6 @@ import javax.inject.Inject;
|
||||
|
||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.storage.GuestOSHypervisorVO;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
@ -35,8 +34,6 @@ public class LXCGuru extends HypervisorGuruBase implements HypervisorGuru {
|
||||
GuestOSDao _guestOsDao;
|
||||
@Inject
|
||||
GuestOSHypervisorDao _guestOsHypervisorDao;
|
||||
@Inject
|
||||
HostDao _hostDao;
|
||||
|
||||
@Override
|
||||
public HypervisorType getHypervisorType() {
|
||||
@ -55,7 +52,7 @@ public class LXCGuru extends HypervisorGuruBase implements HypervisorGuru {
|
||||
GuestOSVO guestOS = _guestOsDao.findByIdIncludingRemoved(vm.getVirtualMachine().getGuestOSId());
|
||||
to.setOs(guestOS.getDisplayName());
|
||||
|
||||
HostVO host = _hostDao.findById(vm.getVirtualMachine().getHostId());
|
||||
HostVO host = hostDao.findById(vm.getVirtualMachine().getHostId());
|
||||
GuestOSHypervisorVO guestOsMapping = null;
|
||||
if (host != null) {
|
||||
guestOsMapping = _guestOsHypervisorDao.findByOsIdAndHypervisor(guestOS.getId(), getHypervisorType().toString(), host.getHypervisorVersion());
|
||||
|
||||
@ -3374,7 +3374,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
DiskProvisioningStrictness,
|
||||
PreferredStoragePool,
|
||||
SecStorageVMAutoScaleDown,
|
||||
MountDisabledStoragePool
|
||||
MountDisabledStoragePool,
|
||||
VmwareCreateCloneFull,
|
||||
VmwareAllowParallelExecution
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -274,7 +274,7 @@ public class KVMGuruTest {
|
||||
public void validateGetHostMaxMemoryAndCpuCoresHostNullAndLastHostIdNotNullAndLastHostNull(){
|
||||
Long maxMemory = Long.MAX_VALUE;
|
||||
Integer maxCpuCores = Integer.MAX_VALUE;
|
||||
guru._hostDao = hostDao;
|
||||
guru.hostDao = hostDao;
|
||||
|
||||
Mockito.when(virtualMachineMock.getLastHostId()).thenReturn(1l);
|
||||
Mockito.doReturn(null).when(hostDao).findById(Mockito.any());
|
||||
@ -288,7 +288,7 @@ public class KVMGuruTest {
|
||||
public void validateGetHostMaxMemoryAndCpuCoresHostNullAndLastHostIdNotNullAndLastHostNotNull(){
|
||||
Long maxMemory = 2048l;
|
||||
Integer maxCpuCores = 16;
|
||||
guru._hostDao = hostDao;
|
||||
guru.hostDao = hostDao;
|
||||
|
||||
Mockito.when(virtualMachineMock.getLastHostId()).thenReturn(1l);
|
||||
Mockito.doReturn(host).when(hostDao).findById(Mockito.any());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user