Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions api/src/main/java/com/cloud/vm/VmDetailConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,5 @@ public interface VmDetailConstants {
String EXTERNAL_DETAIL_PREFIX = "External:";
String CLOUDSTACK_VM_DETAILS = "cloudstack.vm.details";
String CLOUDSTACK_VLAN = "cloudstack.vlan";
String KVM_GUEST_OS_MACHINE_TYPE = "kvm.guest.os.machine.type";
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
if (cluster == null) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find cluster by ID: " + getClusterId());
}
final boolean result = haConfigManager.disableHA(cluster);
final boolean result = haConfigManager.disableHA(cluster, includeHost());
CallContext.current().setEventDetails("Cluster ID:" + cluster.getUuid() + " HA enabled: false");
CallContext.current().putContextParameter(Cluster.class, cluster.getUuid());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find cluster by ID: " + getClusterId());
}

final boolean result = haConfigManager.enableHA(cluster);
final boolean result = haConfigManager.enableHA(cluster, includeHost());
CallContext.current().setEventDetails("Cluster ID:" + cluster.getUuid() + " HA enabled: true");
CallContext.current().putContextParameter(Cluster.class, cluster.getUuid());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public String getStorageAccessGroup() {
public ListHostsCmd(String storageAccessGroup) {
this.storageAccessGroup = storageAccessGroup;
}

public String getVersion() {
return version;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.api.response.VolumeResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.BooleanUtils;

import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
Expand All @@ -44,9 +41,6 @@
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.uservm.UserVm;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.Dhcp;
import com.cloud.utils.net.NetUtils;
import com.cloud.utils.StringUtils;
import com.cloud.vm.VirtualMachine;

@APICommand(name = "deployVirtualMachine", description = "Creates and automatically starts an Instance based on a service offering, disk offering, and Template.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
Expand Down Expand Up @@ -75,138 +69,6 @@ public class DeployVMCmd extends BaseDeployVMCmd {
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public String getAccountName() {
if (accountName == null) {
return CallContext.current().getCallingAccount().getAccountName();
}
return accountName;
}

public Long getDiskOfferingId() {
return diskOfferingId;
}

public String getDeploymentPlanner() {
return deploymentPlanner;
}

public String getDisplayName() {
if (StringUtils.isEmpty(displayName)) {
displayName = name;
}
return displayName;
}

public Long getDomainId() {
if (domainId == null) {
return CallContext.current().getCallingAccount().getDomainId();
}
return domainId;
}

public ApiConstants.BootType getBootType() {
if (StringUtils.isNotBlank(bootType)) {
try {
String type = bootType.trim().toUpperCase();
return ApiConstants.BootType.valueOf(type);
} catch (IllegalArgumentException e) {
String errMesg = "Invalid bootType " + bootType + "Specified for Instance " + getName()
+ " Valid values are: " + Arrays.toString(ApiConstants.BootType.values());
logger.warn(errMesg);
throw new InvalidParameterValueException(errMesg);
}
}
return null;
}

public ApiConstants.BootMode getBootMode() {
if (StringUtils.isNotBlank(bootMode)) {
try {
String mode = bootMode.trim().toUpperCase();
return ApiConstants.BootMode.valueOf(mode);
} catch (IllegalArgumentException e) {
String msg = String.format("Invalid %s: %s specified for Instance: %s. Valid values are: %s",
ApiConstants.BOOT_MODE, bootMode, getName(), Arrays.toString(ApiConstants.BootMode.values()));
logger.error(msg);
throw new InvalidParameterValueException(msg);
}
}
if (ApiConstants.BootType.UEFI.equals(getBootType())) {
String msg = String.format("%s must be specified for the Instance with boot type: %s. Valid values are: %s",
ApiConstants.BOOT_MODE, getBootType(), Arrays.toString(ApiConstants.BootMode.values()));
logger.error(msg);
throw new InvalidParameterValueException(msg);
}
return null;
}

public Map<String, String> getVmProperties() {
Map<String, String> map = new HashMap<>();
if (MapUtils.isNotEmpty(vAppProperties)) {
Collection parameterCollection = vAppProperties.values();
Iterator iterator = parameterCollection.iterator();
while (iterator.hasNext()) {
HashMap<String, String> entry = (HashMap<String, String>)iterator.next();
map.put(entry.get("key"), entry.get("value"));
}
}
return map;
}

public Map<Integer, Long> getVmNetworkMap() {
Map<Integer, Long> map = new HashMap<>();
if (MapUtils.isNotEmpty(vAppNetworks)) {
Collection parameterCollection = vAppNetworks.values();
Iterator iterator = parameterCollection.iterator();
while (iterator.hasNext()) {
HashMap<String, String> entry = (HashMap<String, String>) iterator.next();
Integer nic;
try {
nic = Integer.valueOf(entry.get(VmDetailConstants.NIC));
} catch (NumberFormatException nfe) {
nic = null;
}
String networkUuid = entry.get(VmDetailConstants.NETWORK);
if (logger.isTraceEnabled()) {
logger.trace(String.format("nic, '%s', goes on net, '%s'", nic, networkUuid));
}
if (nic == null || StringUtils.isEmpty(networkUuid) || _entityMgr.findByUuid(Network.class, networkUuid) == null) {
throw new InvalidParameterValueException(String.format("Network ID: %s for NIC ID: %s is invalid", networkUuid, nic));
}
map.put(nic, _entityMgr.findByUuid(Network.class, networkUuid).getId());
}
}
return map;
}

public String getGroup() {
return group;
}

public HypervisorType getHypervisor() {
return HypervisorType.getType(hypervisor);
}

public Boolean isDisplayVm() {
return displayVm;
}

@Override
public boolean isDisplay() {
if(displayVm == null)
return true;
else
return displayVm;
}

public List<String> getSecurityGroupNameList() {
return securityGroupNameList;
}

public List<Long> getSecurityGroupIdList() {
return securityGroupIdList;
}

public Long getServiceOfferingId() {
return serviceOfferingId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ public static String getResultObjectName() {

@Override
public long getEntityOwnerId() {
Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
Long accountId = _accountService.finalizeAccountId(accountName, domainId, projectId, true);
if (accountId == null) {
return CallContext.current().getCallingAccount().getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
import com.cloud.uservm.UserVm;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.cloud.utils.StringUtils;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.Dhcp;
import com.cloud.vm.VirtualMachine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public class LoginCmdResponse extends AuthenticationCmdResponse {
@SerializedName(value = ApiConstants.EXTERNAL_ENTITY)
@Param(description = "externalEntity")
private String externalEntity;

@SerializedName(value = ApiConstants.PASSWORD_CHANGE_REQUIRED)
@Param(description = "Indicates whether the User is required to change password on next login.", since = "4.23.0")
private Boolean passwordChangeRequired;
Expand Down Expand Up @@ -251,7 +251,7 @@ public String getExternalEntity() {
public void setExternalEntity(String externalEntity) {
this.externalEntity = externalEntity;
}

public Boolean getPasswordChangeRequired() {
return passwordChangeRequired;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public interface BackupManager extends BackupService, Configurable, PluggableSer
Capacity getBackupStorageUsedStats(Long zoneId);

void checkAndRemoveBackupOfferingBeforeExpunge(VirtualMachine vm);

static void validateBackupProviderConfig(String value) {
if (value != null && (value.contains(",") || value.trim().contains(" "))) {
throw new IllegalArgumentException("Multiple backup provider plugins are not supported. Please provide a single plugin value.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ public void setRestoreVolumePaths(List<String> restoreVolumePaths) {
this.restoreVolumePaths = restoreVolumePaths;
}

public List<String> getVolumePaths() {
return volumePaths;
}

public void setVolumePaths(List<String> volumePaths) {
this.volumePaths = volumePaths;
}

public List<String> getBackupFiles() {
return backupFiles;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public interface StorageManager extends StorageService {
ConfigKey<Boolean> COPY_PUBLIC_TEMPLATES_FROM_OTHER_STORAGES = new ConfigKey<>(Boolean.class, "copy.public.templates.from.other.storages",
"Storage", "true", "Allow SSVMs to try copying public templates from one secondary storage to another instead of downloading them from the source.",
true, ConfigKey.Scope.Zone, null);

ConfigKey<Boolean> COPY_TEMPLATES_FROM_OTHER_SECONDARY_STORAGES = new ConfigKey<>(Boolean.class, "copy.templates.from.other.secondary.storages",
"Storage", "true", "When enabled, this feature allows templates to be copied from existing Secondary Storage servers (within the same zone or across zones) " +
"while adding a new Secondary Storage. If the copy operation fails, the system falls back to downloading the template from the source URL.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
import com.cloud.upgrade.dao.VersionDaoImpl;
import com.cloud.upgrade.dao.VersionVO;
import com.cloud.upgrade.dao.VersionVO.Step;
import com.cloud.utils.FileUtil;
import com.cloud.utils.component.SystemIntegrityChecker;
import com.cloud.utils.crypt.DBEncryptionUtil;
import com.cloud.utils.db.GlobalLock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO
protected SearchBuilder<SnapshotDataStoreVO> searchFilteringStoreIdEqStateEqStoreRoleEqIdEqUpdateCountEqSnapshotIdEqVolumeIdEq;
private SearchBuilder<SnapshotDataStoreVO> stateSearch;
private SearchBuilder<SnapshotDataStoreVO> idStateNinSearch;
private SearchBuilder<SnapshotDataStoreVO> idStateNeqSearch;
protected SearchBuilder<SnapshotVO> snapshotVOSearch;
private SearchBuilder<SnapshotDataStoreVO> snapshotCreatedSearch;
private SearchBuilder<SnapshotDataStoreVO> dataStoreAndInstallPathSearch;
Expand Down Expand Up @@ -96,7 +97,7 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO
private static final String FIND_SNAPSHOT_IN_ZONE = "SELECT ssr.* FROM " +
"snapshot_store_ref ssr, snapshots s " +
"WHERE ssr.snapshot_id=? AND ssr.snapshot_id = s.id AND s.data_center_id=?;";

private static final String GET_PHYSICAL_SIZE_OF_SNAPSHOTS_ON_PRIMARY_BY_ACCOUNT = "SELECT SUM(s.physical_size) " +
"FROM cloud.snapshot_store_ref s " +
"LEFT JOIN cloud.snapshots ON s.snapshot_id = snapshots.id " +
Expand Down Expand Up @@ -151,7 +152,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
idStateNinSearch.and(SNAPSHOT_ID, idStateNinSearch.entity().getSnapshotId(), SearchCriteria.Op.EQ);
idStateNinSearch.and(STATE, idStateNinSearch.entity().getState(), SearchCriteria.Op.NOTIN);
idStateNinSearch.done();

idStateNeqSearch = createSearchBuilder();
idStateNeqSearch.and(SNAPSHOT_ID, idStateNeqSearch.entity().getSnapshotId(), SearchCriteria.Op.EQ);
idStateNeqSearch.and(STATE, idStateNeqSearch.entity().getState(), SearchCriteria.Op.NEQ);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
import org.apache.cloudstack.storage.to.TemplateObjectTO;
import org.mockito.Matchers;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
Expand Down Expand Up @@ -277,12 +277,12 @@ public void setUp() {
protected void injectMockito() {
List<HostVO> hosts = new ArrayList<HostVO>();
hosts.add(this.host);
Mockito.when(resourceMgr.listAllUpAndEnabledHosts((Type)Matchers.any(), Matchers.anyLong(), Matchers.anyLong(), Matchers.anyLong())).thenReturn(hosts);
Mockito.when(resourceMgr.listAllUpAndEnabledHosts((Type)ArgumentMatchers.any(), ArgumentMatchers.anyLong(), ArgumentMatchers.anyLong(), ArgumentMatchers.anyLong())).thenReturn(hosts);
remoteEp = RemoteHostEndPoint.getHypervisorHostEndPoint(this.host);
Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(remoteEp);
Mockito.when(epSelector.select(Matchers.any(DataObject.class))).thenReturn(remoteEp);
Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(remoteEp);
Mockito.when(hyGuruMgr.getGuruProcessedCommandTargetHost(Matchers.anyLong(), Matchers.any(Command.class))).thenReturn(this.host.getId());
Mockito.when(epSelector.select(ArgumentMatchers.any(DataObject.class), ArgumentMatchers.any(DataObject.class))).thenReturn(remoteEp);
Mockito.when(epSelector.select(ArgumentMatchers.any(DataObject.class))).thenReturn(remoteEp);
Mockito.when(epSelector.select(ArgumentMatchers.any(DataStore.class))).thenReturn(remoteEp);
Mockito.when(hyGuruMgr.getGuruProcessedCommandTargetHost(ArgumentMatchers.anyLong(), ArgumentMatchers.any(Command.class))).thenReturn(this.host.getId());

}

Expand Down Expand Up @@ -430,8 +430,8 @@ public void deleteSnapshot() throws InterruptedException, ExecutionException {

// create another snapshot
for (SnapshotStrategy strategy : this.snapshotStrategies) {
if (strategy.canHandle(snapshot, SnapshotOperation.DELETE) != StrategyPriority.CANT_HANDLE) {
strategy.deleteSnapshot(newSnapshot.getId());
if (strategy.canHandle(snapshot, null, SnapshotOperation.DELETE) != StrategyPriority.CANT_HANDLE) {
strategy.deleteSnapshot(newSnapshot.getId(), null);
}
}

Expand All @@ -453,17 +453,17 @@ public void createTemplateFromSnapshot() throws InterruptedException, ExecutionE
AssertJUnit.assertTrue(result);
LocalHostEndpoint ep = new LocalHostEndpoint();
ep.setResource(new MockLocalNfsSecondaryStorageResource());
Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(ep);
Mockito.when(epSelector.select(ArgumentMatchers.any(DataObject.class), ArgumentMatchers.any(DataObject.class))).thenReturn(ep);

try {
VMTemplateVO templateVO = createTemplateInDb();
TemplateInfo tmpl = this.templateFactory.getTemplate(templateVO.getId(), DataStoreRole.Image);
DataStore imageStore = this.dataStoreMgr.getImageStore(this.dcId);
DataStore imageStore = this.dataStoreMgr.getImageStoresByZoneIds(this.dcId).get(0);
AsyncCallFuture<TemplateApiResult> templateFuture = this.imageService.createTemplateFromSnapshotAsync(snapshot, tmpl, imageStore);
TemplateApiResult apiResult = templateFuture.get();
Assert.assertTrue(apiResult.isSuccess());
} finally {
Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(remoteEp);
Mockito.when(epSelector.select(ArgumentMatchers.any(DataObject.class), ArgumentMatchers.any(DataObject.class))).thenReturn(remoteEp);
}
}

Expand All @@ -483,17 +483,17 @@ public void createSnapshot() throws InterruptedException, ExecutionException {

LocalHostEndpoint ep = new MockLocalHostEndPoint();
ep.setResource(new MockLocalNfsSecondaryStorageResource());
Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(ep);
Mockito.when(epSelector.select(ArgumentMatchers.any(DataStore.class))).thenReturn(ep);

try {
for (SnapshotStrategy strategy : this.snapshotStrategies) {
if (strategy.canHandle(snapshot, SnapshotOperation.DELETE) != StrategyPriority.CANT_HANDLE) {
boolean res = strategy.deleteSnapshot(newSnapshot.getId());
if (strategy.canHandle(snapshot, null, SnapshotOperation.DELETE) != StrategyPriority.CANT_HANDLE) {
boolean res = strategy.deleteSnapshot(newSnapshot.getId(), null);
Assert.assertTrue(res);
}
}
} finally {
Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(remoteEp);
Mockito.when(epSelector.select(ArgumentMatchers.any(DataStore.class))).thenReturn(remoteEp);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import javax.inject.Inject;

import org.mockito.Matchers;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -123,8 +123,8 @@ public void setUp() {
// inject mockito
LocalHostEndpoint ep = new LocalHostEndpoint();
ep.setResource(new MockLocalNfsSecondaryStorageResource());
Mockito.when(epSelector.select(Matchers.any(DataObject.class))).thenReturn(ep);
Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(ep);
Mockito.when(epSelector.select(ArgumentMatchers.any(DataObject.class))).thenReturn(ep);
Mockito.when(epSelector.select(ArgumentMatchers.any(DataStore.class))).thenReturn(ep);
}

@Test
Expand Down
Loading
Loading