Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0602c7d
Added disk provisioning type support for VMWare
Spaceman1984 Feb 2, 2021
ec5682b
Review changes
Spaceman1984 Feb 8, 2021
362e45c
Fixed unit test
Spaceman1984 Feb 8, 2021
e4b7f03
Review changes
Spaceman1984 Feb 9, 2021
6c14400
Added missing licenses
Spaceman1984 Feb 10, 2021
299c3de
Review changes
Spaceman1984 Feb 11, 2021
280cd67
Update StoragePoolInfo.java
Spaceman1984 Feb 10, 2021
426d37c
Review change - Getting disk provisioning strictness setting using th…
Spaceman1984 Feb 12, 2021
c96505b
Delete __init__.py
Spaceman1984 Feb 12, 2021
7ff9850
Merge fix
Spaceman1984 Feb 12, 2021
e423075
Fixed failing test
Spaceman1984 Feb 12, 2021
429aaaf
Added comment about parameters
Spaceman1984 Feb 22, 2021
f7dbb10
Added error log when update fails
Spaceman1984 Feb 23, 2021
382b9eb
Added exception when using API
Spaceman1984 Feb 23, 2021
67726ee
Ordering storage pool selection to prefer thick disk capable pools if…
Spaceman1984 Feb 25, 2021
bbd8516
Removed unused parameter
Spaceman1984 Feb 25, 2021
a511fd1
Reordering changes
Spaceman1984 Feb 26, 2021
3838035
Returning storage pool details after update
Spaceman1984 Mar 5, 2021
b59da6b
Removed multiple pool update, updated marvin test, removed duplicate …
Spaceman1984 Mar 8, 2021
dbc7671
Removed comment
Spaceman1984 Mar 8, 2021
416231f
Removed unused import
Spaceman1984 Mar 8, 2021
f32162a
Removed for loop
Spaceman1984 Mar 8, 2021
35a7311
Added missing return statements for failed checks
Spaceman1984 Mar 8, 2021
29de816
Class name change
Spaceman1984 Mar 17, 2021
8447cb8
Null pointer
Spaceman1984 Apr 28, 2021
2486db7
Added more info when a deployment fails
Spaceman1984 May 28, 2021
990caed
Null pointer
Spaceman1984 Jun 1, 2021
5dd3838
Update api/src/main/java/org/apache/cloudstack/api/BaseListCmd.java
Spaceman1984 Jun 15, 2021
396f89c
Small bug fix on API response and added missing bracket
Spaceman1984 Jun 16, 2021
72e7e8c
Removed datastore cluster code
Spaceman1984 Jul 6, 2021
bcb1731
Removed unused imports, added missing signature
Spaceman1984 Jul 13, 2021
63cbc88
Removed duplicate config key
Spaceman1984 Jul 13, 2021
ec8cc4d
Merge branch 'main' into disk_provision_type_vmware
Spaceman1984 Jul 15, 2021
9c55d28
Revert "Added more info when a deployment fails"
Spaceman1984 Jul 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions api/src/main/java/com/cloud/storage/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ public String getFileExtension() {

}

public static enum Capability {
HARDWARE_ACCELERATION("HARDWARE_ACCELERATION");

private final String capability;

private Capability(String capability) {
this.capability = capability;
}
}

public static enum ProvisioningType {
THIN("thin"),
SPARSE("sparse"),
Expand Down
4 changes: 3 additions & 1 deletion api/src/main/java/com/cloud/storage/StorageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import org.apache.cloudstack.api.command.admin.storage.DeleteImageStoreCmd;
import org.apache.cloudstack.api.command.admin.storage.DeletePoolCmd;
import org.apache.cloudstack.api.command.admin.storage.DeleteSecondaryStagingStoreCmd;
import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
import org.apache.cloudstack.api.command.admin.storage.SyncStoragePoolCmd;
import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;

import com.cloud.exception.DiscoveryException;
import com.cloud.exception.InsufficientCapacityException;
Expand Down Expand Up @@ -105,6 +105,8 @@ public interface StorageService {

ImageStore updateImageStoreStatus(Long id, Boolean readonly);

void updateStorageCapabilities(Long poolId, boolean failOnChecks);

StoragePool syncStoragePool(SyncStoragePoolCmd cmd);

}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public Long getPageSizeVal() {
if (pageSizeInt != null) {
defaultPageSize = pageSizeInt.longValue();
}
if (defaultPageSize.longValue() == s_pageSizeUnlimited) {
if (s_pageSizeUnlimited.equals(defaultPageSize)) {
defaultPageSize = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ public Long getId() {
return id;
}

/////////////////////////////////////////////////////
public void setId(Long id) {
this.id = id;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api.command.admin.storage;

import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.StoragePoolResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;

import java.util.Locale;

@APICommand(name = UpdateStorageCapabilitiesCmd.APINAME, description = "Syncs capabilities of storage pools",
responseObject = StoragePoolResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, since = "4.16.0")
public class UpdateStorageCapabilitiesCmd extends BaseCmd {
public static final String APINAME = "updateStorageCapabilities";
private static final Logger LOG = Logger.getLogger(UpdateStorageCapabilitiesCmd.class.getName());

/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////

@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = StoragePoolResponse.class, required = true, description = "Storage pool id")
private Long poolId;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public Long getPoolId() {
return poolId;
}

public void setPoolId(Long poolId) {
this.poolId = poolId;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////


@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
_storageService.updateStorageCapabilities(poolId, true);
ListStoragePoolsCmd listStoragePoolCmd = new ListStoragePoolsCmd();
listStoragePoolCmd.setId(poolId);
ListResponse<StoragePoolResponse> listResponse = _queryService.searchForStoragePools(listStoragePoolCmd);
listResponse.setResponseName(getCommandName());
this.setResponseObject(listResponse);
}

@Override
public String getCommandName() {
return APINAME.toLowerCase(Locale.ROOT) + "response" ;
}

@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccountId();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.api;

import java.util.HashMap;
import java.util.Map;

public class GetStoragePoolCapabilitiesAnswer extends Answer {

private Map<String, String> poolDetails;

public GetStoragePoolCapabilitiesAnswer(GetStoragePoolCapabilitiesCommand cmd) {
super(cmd);
poolDetails = new HashMap<>();
}

public void setResult(boolean result){
this.result = result;
}

public void setDetails(String details){
this.details = details;
}

public Map<String, String> getPoolDetails() {
return poolDetails;
}

public void setPoolDetails(Map<String, String> poolDetails) {
this.poolDetails = poolDetails;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.api;

import com.cloud.agent.api.to.StorageFilerTO;

public class GetStoragePoolCapabilitiesCommand extends Command {

public StorageFilerTO getPool() {
return pool;
}

public void setPool(StorageFilerTO pool) {
this.pool = pool;
}

private StorageFilerTO pool;

@Override
public boolean executeInSequence() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class PrimaryDataStoreTO implements DataStoreTO {
private Map<String, String> details;
private static final String pathSeparator = "/";
private Boolean fullCloneFlag;
private Boolean diskProvisioningStrictnessFlag;
private final boolean isManaged;

public PrimaryDataStoreTO(PrimaryDataStore dataStore) {
Expand Down Expand Up @@ -163,4 +164,12 @@ public void setFullCloneFlag(Boolean fullCloneFlag) {
public boolean isManaged() {
return isManaged;
}

public Boolean getDiskProvisioningStrictnessFlag() {
return diskProvisioningStrictnessFlag;
}

public void setDiskProvisioningStrictnessFlag(Boolean diskProvisioningStrictnessFlag) {
this.diskProvisioningStrictnessFlag = diskProvisioningStrictnessFlag;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ public interface StoragePoolAllocator extends Adapter {

static int RETURN_UPTO_ALL = -1;

List<StoragePool> reorderPools(List<StoragePool> pools, VirtualMachineProfile vmProfile, DeploymentPlan plan);
List<StoragePool> reorderPools(List<StoragePool> pools, VirtualMachineProfile vmProfile, DeploymentPlan plan, DiskProfile dskCh);
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ public interface StorageManager extends StorageService {

ConfigKey<Integer> MaxDataMigrationWaitTime = new ConfigKey<Integer>("Advanced", Integer.class, "max.data.migration.wait.time", "15",
"Maximum wait time for a data migration task before spawning a new SSVM", false, ConfigKey.Scope.Global);

ConfigKey<Boolean> DiskProvisioningStrictness = new ConfigKey<Boolean>("Storage", Boolean.class, "disk.provisioning.type.strictness", "false",
"If set to true, the disk is created only when there is a suitable storage pool that supports the disk provisioning type specified by the service/disk offering. " +
"If set to false, the disk is created with a disk provisioning type supported by the pool. Default value is false, and this is currently supported for VMware only.",
true, ConfigKey.Scope.Zone);
/**
* Returns a comma separated list of tags for the specified storage pool
* @param poolId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public StoragePool findChildDataStoreInDataStoreCluster(DataCenter dc, Pod pod,
VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
for (StoragePoolAllocator allocator : _storagePoolAllocators) {
DataCenterDeployment plan = new DataCenterDeployment(dc.getId(), podId, clusterId, hostId, null, null);
final List<StoragePool> poolList = allocator.reorderPools(suitablePools, profile, plan);
final List<StoragePool> poolList = allocator.reorderPools(suitablePools, profile, plan, null);

if (poolList != null && !poolList.isEmpty()) {
return (StoragePool)dataStoreMgr.getDataStore(poolList.get(0).getId(), DataStoreRole.Primary);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public String getName() {
return name;
}

public void setValue(String value) {
this.value = value;
}

@Override
public String getValue() {
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
@Inject
StorageCacheManager cacheMgr;

@Inject
StorageManager storageManager;

@Override
public StrategyPriority canHandle(DataObject srcData, DataObject destData) {
return StrategyPriority.DEFAULT;
Expand Down Expand Up @@ -156,7 +159,7 @@ protected Answer copyObject(DataObject srcData, DataObject destData, Host destHo
srcForCopy = cacheData = cacheMgr.createCacheObject(srcData, destScope);
}

CopyCommand cmd = new CopyCommand(srcForCopy.getTO(), addFullCloneFlagOnVMwareDest(destData.getTO()), primaryStorageDownloadWait,
CopyCommand cmd = new CopyCommand(srcForCopy.getTO(), addFullCloneAndDiskprovisiongStrictnessFlagOnVMwareDest(destData.getTO()), primaryStorageDownloadWait,
VirtualMachineManager.ExecuteInSequence.value());
EndPoint ep = destHost != null ? RemoteHostEndPoint.getHypervisorHostEndPoint(destHost) : selector.select(srcForCopy, destData);
if (ep == null) {
Expand Down Expand Up @@ -210,18 +213,20 @@ protected Answer copyObject(DataObject srcData, DataObject destData, Host destHo
* @param dataTO Dest data store TO
* @return dataTO including fullCloneFlag, if provided
*/
protected DataTO addFullCloneFlagOnVMwareDest(DataTO dataTO) {
protected DataTO addFullCloneAndDiskprovisiongStrictnessFlagOnVMwareDest(DataTO dataTO) {
if (dataTO != null && dataTO.getHypervisorType().equals(Hypervisor.HypervisorType.VMware)){
DataStoreTO dataStoreTO = dataTO.getDataStore();
if (dataStoreTO != null && dataStoreTO instanceof PrimaryDataStoreTO){
PrimaryDataStoreTO primaryDataStoreTO = (PrimaryDataStoreTO) dataStoreTO;
Boolean value = CapacityManager.VmwareCreateCloneFull.valueIn(primaryDataStoreTO.getId());
primaryDataStoreTO.setFullCloneFlag(value);
primaryDataStoreTO.setFullCloneFlag(CapacityManager.VmwareCreateCloneFull.valueIn(primaryDataStoreTO.getId()));
StoragePool pool = storageManager.getStoragePool(primaryDataStoreTO.getId());
primaryDataStoreTO.setDiskProvisioningStrictnessFlag(storageManager.DiskProvisioningStrictness.valueIn(pool.getDataCenterId()));
}
}
return dataTO;
}


protected Answer copyObject(DataObject srcData, DataObject destData) {
return copyObject(srcData, destData, null);
}
Expand Down Expand Up @@ -278,7 +283,7 @@ protected Answer copyVolumeFromSnapshot(DataObject snapObj, DataObject volObj) {
ep = selector.select(srcData, volObj);
}

CopyCommand cmd = new CopyCommand(srcData.getTO(), addFullCloneFlagOnVMwareDest(volObj.getTO()), _createVolumeFromSnapshotWait, VirtualMachineManager.ExecuteInSequence.value());
CopyCommand cmd = new CopyCommand(srcData.getTO(), addFullCloneAndDiskprovisiongStrictnessFlagOnVMwareDest(volObj.getTO()), _createVolumeFromSnapshotWait, VirtualMachineManager.ExecuteInSequence.value());
Answer answer = null;
if (ep == null) {
String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
Expand All @@ -301,7 +306,7 @@ protected Answer copyVolumeFromSnapshot(DataObject snapObj, DataObject volObj) {
}

protected Answer cloneVolume(DataObject template, DataObject volume) {
CopyCommand cmd = new CopyCommand(template.getTO(), addFullCloneFlagOnVMwareDest(volume.getTO()), 0, VirtualMachineManager.ExecuteInSequence.value());
CopyCommand cmd = new CopyCommand(template.getTO(), addFullCloneAndDiskprovisiongStrictnessFlagOnVMwareDest(volume.getTO()), 0, VirtualMachineManager.ExecuteInSequence.value());
try {
EndPoint ep = selector.select(volume.getDataStore());
Answer answer = null;
Expand Down Expand Up @@ -373,7 +378,7 @@ protected Answer copyVolumeBetweenPools(DataObject srcData, DataObject destData)

objOnImageStore.processEvent(Event.CopyingRequested);

CopyCommand cmd = new CopyCommand(objOnImageStore.getTO(), addFullCloneFlagOnVMwareDest(destData.getTO()), _copyvolumewait, VirtualMachineManager.ExecuteInSequence.value());
CopyCommand cmd = new CopyCommand(objOnImageStore.getTO(), addFullCloneAndDiskprovisiongStrictnessFlagOnVMwareDest(destData.getTO()), _copyvolumewait, VirtualMachineManager.ExecuteInSequence.value());
EndPoint ep = selector.select(objOnImageStore, destData);
if (ep == null) {
String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
Expand Down Expand Up @@ -526,7 +531,7 @@ protected Answer createTemplateFromSnapshot(DataObject srcData, DataObject destD
ep = selector.select(srcData, destData);
}

CopyCommand cmd = new CopyCommand(srcData.getTO(), addFullCloneFlagOnVMwareDest(destData.getTO()), _createprivatetemplatefromsnapshotwait, VirtualMachineManager.ExecuteInSequence.value());
CopyCommand cmd = new CopyCommand(srcData.getTO(), addFullCloneAndDiskprovisiongStrictnessFlagOnVMwareDest(destData.getTO()), _createprivatetemplatefromsnapshotwait, VirtualMachineManager.ExecuteInSequence.value());
Answer answer = null;
if (ep == null) {
String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
Expand Down Expand Up @@ -562,7 +567,7 @@ protected Answer copySnapshot(DataObject srcData, DataObject destData) {
Scope selectedScope = pickCacheScopeForCopy(srcData, destData);
cacheData = cacheMgr.getCacheObject(srcData, selectedScope);

CopyCommand cmd = new CopyCommand(srcData.getTO(), addFullCloneFlagOnVMwareDest(destData.getTO()), _backupsnapshotwait, VirtualMachineManager.ExecuteInSequence.value());
CopyCommand cmd = new CopyCommand(srcData.getTO(), addFullCloneAndDiskprovisiongStrictnessFlagOnVMwareDest(destData.getTO()), _backupsnapshotwait, VirtualMachineManager.ExecuteInSequence.value());
cmd.setCacheTO(cacheData.getTO());
cmd.setOptions(options);
EndPoint ep = selector.select(srcData, destData);
Expand All @@ -574,7 +579,7 @@ protected Answer copySnapshot(DataObject srcData, DataObject destData) {
answer = ep.sendMessage(cmd);
}
} else {
addFullCloneFlagOnVMwareDest(destData.getTO());
addFullCloneAndDiskprovisiongStrictnessFlagOnVMwareDest(destData.getTO());
CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _backupsnapshotwait, VirtualMachineManager.ExecuteInSequence.value());
cmd.setOptions(options);
EndPoint ep = selector.select(srcData, destData, StorageAction.BACKUPSNAPSHOT);
Expand Down
Loading