mirror of https://github.com/apache/cloudstack.git
Merge branch '4.20' into 4.20-fiberchannel-patches
This commit is contained in:
commit
fdfc05108f
|
|
@ -29,7 +29,7 @@ permissions:
|
|||
jobs:
|
||||
build:
|
||||
if: github.repository == 'apache/cloudstack'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
|
@ -232,7 +232,25 @@ jobs:
|
|||
- name: Install Build Dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y git uuid-runtime genisoimage netcat ipmitool build-essential libgcrypt20 libgpg-error-dev libgpg-error0 libopenipmi0 ipmitool libpython3-dev libssl-dev libffi-dev python3-openssl python3-dev python3-setuptools
|
||||
sudo apt-get install -y git uuid-runtime genisoimage netcat-openbsd ipmitool build-essential libgcrypt20 libgpg-error-dev libgpg-error0 libopenipmi0 ipmitool libpython3-dev libssl-dev libffi-dev python3-openssl python3-dev python3-setuptools
|
||||
|
||||
- name: Setup IPMI Tool for CloudStack
|
||||
run: |
|
||||
# Create cloudstack-common directory if it doesn't exist
|
||||
sudo mkdir -p /usr/share/cloudstack-common
|
||||
|
||||
# Copy ipmitool to cloudstack-common directory if it doesn't exist
|
||||
if [ ! -f /usr/share/cloudstack-common/ipmitool ]; then
|
||||
sudo cp /usr/bin/ipmitool /usr/share/cloudstack-common/ipmitool
|
||||
sudo chmod 755 /usr/share/cloudstack-common/ipmitool
|
||||
fi
|
||||
|
||||
# Create ipmitool-C3 wrapper script
|
||||
sudo tee /usr/bin/ipmitool > /dev/null << 'EOF'
|
||||
#!/bin/bash
|
||||
/usr/share/cloudstack-common/ipmitool -C3 $@
|
||||
EOF
|
||||
sudo chmod 755 /usr/bin/ipmitool
|
||||
|
||||
- name: Install Python dependencies
|
||||
run: |
|
||||
|
|
@ -271,7 +289,7 @@ jobs:
|
|||
- name: Setup Simulator Prerequisites
|
||||
run: |
|
||||
sudo python3 -m pip install --upgrade netaddr mysql-connector-python
|
||||
python3 -m pip install --user --upgrade tools/marvin/dist/Marvin-*.tar.gz
|
||||
python3 -m pip install --user --upgrade tools/marvin/dist/[mM]arvin-*.tar.gz
|
||||
mvn -q -Pdeveloper -pl developer -Ddeploydb
|
||||
mvn -q -Pdeveloper -pl developer -Ddeploydb-simulator
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -93,7 +93,6 @@ import com.cloud.utils.nio.Link;
|
|||
import com.cloud.utils.nio.NioClient;
|
||||
import com.cloud.utils.nio.NioConnection;
|
||||
import com.cloud.utils.nio.Task;
|
||||
import com.cloud.utils.script.OutputInterpreter;
|
||||
import com.cloud.utils.script.Script;
|
||||
|
||||
/**
|
||||
|
|
@ -598,9 +597,9 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
|
|||
}
|
||||
|
||||
protected String getAgentArch() {
|
||||
final Script command = new Script("/usr/bin/arch", 500, logger);
|
||||
final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
|
||||
return command.execute(parser);
|
||||
String arch = Script.runSimpleBashScript(Script.getExecutableAbsolutePath("arch"), 2000);
|
||||
logger.debug("Arch for agent: {} found: {}", _name, arch);
|
||||
return arch;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -31,20 +31,22 @@ import java.util.stream.Collectors;
|
|||
import static com.cloud.hypervisor.Hypervisor.HypervisorType.Functionality.DirectDownloadTemplate;
|
||||
import static com.cloud.hypervisor.Hypervisor.HypervisorType.Functionality.RootDiskSizeOverride;
|
||||
import static com.cloud.hypervisor.Hypervisor.HypervisorType.Functionality.VmStorageMigration;
|
||||
import static com.cloud.hypervisor.Hypervisor.HypervisorType.Functionality.VmStorageMigrationWithSnapshots;
|
||||
|
||||
public class Hypervisor {
|
||||
public static class HypervisorType {
|
||||
public enum Functionality {
|
||||
DirectDownloadTemplate,
|
||||
RootDiskSizeOverride,
|
||||
VmStorageMigration
|
||||
VmStorageMigration,
|
||||
VmStorageMigrationWithSnapshots
|
||||
}
|
||||
|
||||
private static final Map<String, HypervisorType> hypervisorTypeMap = new LinkedHashMap<>();
|
||||
public static final HypervisorType None = new HypervisorType("None"); //for storage hosts
|
||||
public static final HypervisorType XenServer = new HypervisorType("XenServer", ImageFormat.VHD, EnumSet.of(RootDiskSizeOverride, VmStorageMigration));
|
||||
public static final HypervisorType KVM = new HypervisorType("KVM", ImageFormat.QCOW2, EnumSet.of(DirectDownloadTemplate, RootDiskSizeOverride, VmStorageMigration));
|
||||
public static final HypervisorType VMware = new HypervisorType("VMware", ImageFormat.OVA, EnumSet.of(RootDiskSizeOverride, VmStorageMigration));
|
||||
public static final HypervisorType VMware = new HypervisorType("VMware", ImageFormat.OVA, EnumSet.of(RootDiskSizeOverride, VmStorageMigration, VmStorageMigrationWithSnapshots));
|
||||
public static final HypervisorType Hyperv = new HypervisorType("Hyperv");
|
||||
public static final HypervisorType VirtualBox = new HypervisorType("VirtualBox");
|
||||
public static final HypervisorType Parralels = new HypervisorType("Parralels");
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.user.UserData;
|
||||
import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd;
|
||||
import org.apache.cloudstack.api.command.admin.config.ListCfgGroupsByCmd;
|
||||
import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd;
|
||||
|
|
@ -66,6 +65,7 @@ import org.apache.cloudstack.api.command.user.vm.GetVMPasswordCmd;
|
|||
import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd;
|
||||
import org.apache.cloudstack.config.Configuration;
|
||||
import org.apache.cloudstack.config.ConfigurationGroup;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
|
||||
import com.cloud.alert.Alert;
|
||||
import com.cloud.capacity.Capacity;
|
||||
|
|
@ -85,6 +85,7 @@ import com.cloud.storage.GuestOSHypervisor;
|
|||
import com.cloud.storage.GuestOsCategory;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.user.SSHKeyPair;
|
||||
import com.cloud.user.UserData;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.Ternary;
|
||||
import com.cloud.vm.InstanceGroup;
|
||||
|
|
@ -98,6 +99,14 @@ import com.cloud.vm.VirtualMachine.Type;
|
|||
public interface ManagementService {
|
||||
static final String Name = "management-server";
|
||||
|
||||
ConfigKey<Boolean> JsInterpretationEnabled = new ConfigKey<>("Hidden"
|
||||
, Boolean.class
|
||||
, "js.interpretation.enabled"
|
||||
, "false"
|
||||
, "Enable/Disable all JavaScript interpretation related functionalities to create or update Javascript rules."
|
||||
, false
|
||||
, ConfigKey.Scope.Global);
|
||||
|
||||
/**
|
||||
* returns the a map of the names/values in the configuration table
|
||||
*
|
||||
|
|
@ -481,4 +490,6 @@ public interface ManagementService {
|
|||
|
||||
Pair<Boolean, String> patchSystemVM(PatchSystemVMCmd cmd);
|
||||
|
||||
void checkJsInterpretationAllowedIfNeededForParameterValue(String paramName, boolean paramValue);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package com.cloud.server;
|
|||
|
||||
public interface ResourceManagerUtil {
|
||||
long getResourceId(String resourceId, ResourceTag.ResourceObjectType resourceType);
|
||||
long getResourceId(String resourceId, ResourceTag.ResourceObjectType resourceType, boolean checkAccess);
|
||||
String getUuid(String resourceId, ResourceTag.ResourceObjectType resourceType);
|
||||
ResourceTag.ResourceObjectType getResourceType(String resourceTypeStr);
|
||||
void checkResourceAccessible(Long accountId, Long domainId, String exceptionMessage);
|
||||
|
|
|
|||
|
|
@ -503,7 +503,31 @@ public interface UserVmService {
|
|||
|
||||
void collectVmNetworkStatistics (UserVm userVm);
|
||||
|
||||
UserVm importVM(final DataCenter zone, final Host host, final VirtualMachineTemplate template, final String instanceName, final String displayName, final Account owner, final String userData, final Account caller, final Boolean isDisplayVm, final String keyboard,
|
||||
/**
|
||||
* Import VM into CloudStack
|
||||
* @param zone importing zone
|
||||
* @param host importing host
|
||||
* @param template template for the imported VM
|
||||
* @param instanceNameInternal set to null to CloudStack to autogenerate from the next available VM ID on database
|
||||
* @param displayName display name for the imported VM
|
||||
* @param owner owner of the imported VM
|
||||
* @param userData user data for the imported VM
|
||||
* @param caller caller account
|
||||
* @param isDisplayVm true to display the imported VM
|
||||
* @param keyboard keyboard distribution for the imported VM
|
||||
* @param accountId account ID
|
||||
* @param userId user ID
|
||||
* @param serviceOffering service offering for the imported VM
|
||||
* @param sshPublicKey ssh key for the imported VM
|
||||
* @param hostName the name for the imported VM
|
||||
* @param hypervisorType hypervisor type for the imported VM
|
||||
* @param customParameters details for the imported VM
|
||||
* @param powerState power state of the imported VM
|
||||
* @param networkNicMap network to nic mapping
|
||||
* @return the imported VM
|
||||
* @throws InsufficientCapacityException in case of errors
|
||||
*/
|
||||
UserVm importVM(final DataCenter zone, final Host host, final VirtualMachineTemplate template, final String instanceNameInternal, final String displayName, final Account owner, final String userData, final Account caller, final Boolean isDisplayVm, final String keyboard,
|
||||
final long accountId, final long userId, final ServiceOffering serviceOffering, final String sshPublicKey,
|
||||
final String hostName, final HypervisorType hypervisorType, final Map<String, String> customParameters,
|
||||
final VirtualMachine.PowerState powerState, final LinkedHashMap<String, List<NicProfile>> networkNicMap) throws InsufficientCapacityException;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package com.cloud.vm.snapshot;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
|
|
@ -53,4 +54,6 @@ public interface VMSnapshotService {
|
|||
* @param id vm id
|
||||
*/
|
||||
boolean deleteVMSnapshotsFromDB(Long vmId, boolean unmanage);
|
||||
|
||||
void updateOperationFailed(VMSnapshot vmSnapshot) throws NoTransitionException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ public class ApiConstants {
|
|||
public static final String ACTIVATION_RULE = "activationrule";
|
||||
public static final String ACTIVITY = "activity";
|
||||
public static final String ADAPTER_TYPE = "adaptertype";
|
||||
public static final String ADDITONAL_CONFIG_ENABLED = "additionalconfigenabled";
|
||||
public static final String ADDRESS = "address";
|
||||
public static final String ALGORITHM = "algorithm";
|
||||
public static final String ALIAS = "alias";
|
||||
|
|
|
|||
|
|
@ -153,6 +153,8 @@ public class UpdateStoragePoolCmd extends BaseCmd {
|
|||
if (ObjectUtils.anyNotNull(name, capacityIops, capacityBytes, url, isTagARule, tags) ||
|
||||
MapUtils.isNotEmpty(details)) {
|
||||
result = _storageService.updateStoragePool(this);
|
||||
} else {
|
||||
result = _storageService.getStoragePool(getId());
|
||||
}
|
||||
|
||||
if (enabled != null) {
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ public class ListCapabilitiesCmd extends BaseCmd {
|
|||
response.setSharedFsVmMinCpuCount((Integer)capabilities.get(ApiConstants.SHAREDFSVM_MIN_CPU_COUNT));
|
||||
response.setSharedFsVmMinRamSize((Integer)capabilities.get(ApiConstants.SHAREDFSVM_MIN_RAM_SIZE));
|
||||
response.setDynamicScalingEnabled((Boolean) capabilities.get(ApiConstants.DYNAMIC_SCALING_ENABLED));
|
||||
response.setAdditionalConfigEnabled((Boolean) capabilities.get(ApiConstants.ADDITONAL_CONFIG_ENABLED));
|
||||
response.setObjectName("capability");
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
|
|
|
|||
|
|
@ -209,4 +209,9 @@ public class CreateSnapshotFromVMSnapshotCmd extends BaseAsyncCreateCmd {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getApiResourceId() {
|
||||
return getEntityId();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -464,7 +464,7 @@ public class AccountResponse extends BaseResponse implements ResourceLimitAndCou
|
|||
|
||||
@Override
|
||||
public void setVpcLimit(String vpcLimit) {
|
||||
this.vpcLimit = networkLimit;
|
||||
this.vpcLimit = vpcLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -140,6 +140,10 @@ public class CapabilitiesResponse extends BaseResponse {
|
|||
@Param(description = "true if dynamically scaling for instances is enabled", since = "4.21.0")
|
||||
private Boolean dynamicScalingEnabled;
|
||||
|
||||
@SerializedName(ApiConstants.ADDITONAL_CONFIG_ENABLED)
|
||||
@Param(description = "true if additional configurations or extraconfig can be passed to Instances", since = "4.20.2")
|
||||
private Boolean additionalConfigEnabled;
|
||||
|
||||
public void setSecurityGroupsEnabled(boolean securityGroupsEnabled) {
|
||||
this.securityGroupsEnabled = securityGroupsEnabled;
|
||||
}
|
||||
|
|
@ -255,4 +259,8 @@ public class CapabilitiesResponse extends BaseResponse {
|
|||
public void setDynamicScalingEnabled(Boolean dynamicScalingEnabled) {
|
||||
this.dynamicScalingEnabled = dynamicScalingEnabled;
|
||||
}
|
||||
|
||||
public void setAdditionalConfigEnabled(Boolean additionalConfigEnabled) {
|
||||
this.additionalConfigEnabled = additionalConfigEnabled;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,15 @@
|
|||
cloudstack (4.20.3.0-SNAPSHOT) unstable; urgency=low
|
||||
|
||||
* Update the version to 4.20.3.0-SNAPSHOT
|
||||
|
||||
-- the Apache CloudStack project <dev@cloudstack.apache.org> Fri, 24 Oct 2025 08:36:00 +0200
|
||||
|
||||
cloudstack (4.20.2.0) unstable; urgency=low
|
||||
|
||||
* Update the version to 4.20.2.0
|
||||
|
||||
-- the Apache CloudStack project <dev@cloudstack.apache.org> Thu, 16 Oct 2025 11:42:56 +0200
|
||||
|
||||
cloudstack (4.20.2.0-SNAPSHOT) unstable; urgency=low
|
||||
|
||||
* Update the version to 4.20.2.0-SNAPSHOT
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
|
|||
import java.util.List;
|
||||
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
|
||||
public interface SnapshotDataFactory {
|
||||
SnapshotInfo getSnapshot(long snapshotId, DataStore store);
|
||||
|
|
@ -42,4 +43,6 @@ public interface SnapshotDataFactory {
|
|||
List<SnapshotInfo> listSnapshotOnCache(long snapshotId);
|
||||
|
||||
SnapshotInfo getReadySnapshotOnCache(long snapshotId);
|
||||
|
||||
void updateOperationFailed(long snapshotId) throws NoTransitionException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
import com.cloud.vm.snapshot.VMSnapshot;
|
||||
|
||||
public interface VMSnapshotStrategy {
|
||||
|
|
@ -44,4 +45,6 @@ public interface VMSnapshotStrategy {
|
|||
* @return true if vm snapshot removed from DB, false if not.
|
||||
*/
|
||||
boolean deleteVMSnapshotFromDB(VMSnapshot vmSnapshot, boolean unmanage);
|
||||
|
||||
void updateOperationFailed(VMSnapshot vmSnapshot) throws NoTransitionException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ public interface StorageManager extends StorageService {
|
|||
ConfigKey<Boolean> MountDisabledStoragePool = new ConfigKey<>(Boolean.class,
|
||||
"mount.disabled.storage.pool",
|
||||
"Storage",
|
||||
"false",
|
||||
Boolean.TRUE.toString(),
|
||||
"Mount all zone-wide or cluster-wide disabled storage pools after node reboot",
|
||||
true,
|
||||
ConfigKey.Scope.Cluster,
|
||||
|
|
@ -294,6 +294,8 @@ public interface StorageManager extends StorageService {
|
|||
|
||||
Answer sendToPool(StoragePool pool, long[] hostIdsToTryFirst, Command cmd) throws StorageUnavailableException;
|
||||
|
||||
void updateStoragePoolHostVOAndBytes(StoragePool pool, long hostId, ModifyStoragePoolAnswer mspAnswer);
|
||||
|
||||
CapacityVO getSecondaryStorageUsedStats(Long hostId, Long zoneId);
|
||||
|
||||
CapacityVO getStoragePoolUsedStats(Long poolId, Long clusterId, Long podId, Long zoneId);
|
||||
|
|
|
|||
|
|
@ -56,6 +56,13 @@ public interface TemplateManager {
|
|||
+ "will validate if the provided URL is resolvable during the register of templates/ISOs before persisting them in the database.",
|
||||
true);
|
||||
|
||||
ConfigKey<Boolean> TemplateDeleteFromPrimaryStorage = new ConfigKey<Boolean>("Advanced",
|
||||
Boolean.class,
|
||||
"template.delete.from.primary.storage", "true",
|
||||
"Template when deleted will be instantly deleted from the Primary Storage",
|
||||
true,
|
||||
ConfigKey.Scope.Global);
|
||||
|
||||
static final String VMWARE_TOOLS_ISO = "vmware-tools.iso";
|
||||
static final String XS_TOOLS_ISO = "xs-tools.iso";
|
||||
|
||||
|
|
@ -103,6 +110,8 @@ public interface TemplateManager {
|
|||
*/
|
||||
List<VMTemplateStoragePoolVO> getUnusedTemplatesInPool(StoragePoolVO pool);
|
||||
|
||||
void evictTemplateFromStoragePoolsForZones(Long templateId, List<Long> zoneId);
|
||||
|
||||
/**
|
||||
* Deletes a template in the specified storage pool.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -54,5 +54,4 @@ public interface VMSnapshotManager extends VMSnapshotService, Manager {
|
|||
boolean hasActiveVMSnapshotTasks(Long vmId);
|
||||
|
||||
RestoreVMSnapshotCommand createRestoreCommand(UserVmVO userVm, List<VMSnapshotVO> vmSnapshotVOs);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -710,7 +710,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
|
|||
if (ObjectUtils.anyNotNull(uefiEnabled, virtv2vVersion, ovftoolVersion)) {
|
||||
_hostDao.loadDetails(host);
|
||||
boolean updateNeeded = false;
|
||||
if (!uefiEnabled.equals(host.getDetails().get(Host.HOST_UEFI_ENABLE))) {
|
||||
if (StringUtils.isNotBlank(uefiEnabled) && !uefiEnabled.equals(host.getDetails().get(Host.HOST_UEFI_ENABLE))) {
|
||||
host.getDetails().put(Host.HOST_UEFI_ENABLE, uefiEnabled);
|
||||
updateNeeded = true;
|
||||
}
|
||||
|
|
@ -1571,7 +1571,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
|
|||
}
|
||||
}
|
||||
} catch (final Throwable th) {
|
||||
logger.warn("Caught: ", th);
|
||||
logger.error("Caught: ", th);
|
||||
answer = new Answer(cmd, false, th.getMessage());
|
||||
}
|
||||
answers[i] = answer;
|
||||
|
|
@ -1586,7 +1586,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
|
|||
try {
|
||||
link.send(response.toBytes());
|
||||
} catch (final ClosedChannelException e) {
|
||||
logger.warn("Unable to send response because connection is closed: {}", response);
|
||||
logger.error("Unable to send response because connection is closed: {}", response);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4772,6 +4772,18 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
|||
}
|
||||
});
|
||||
|
||||
if (selectedIp != null && GuestType.Shared.equals(network.getGuestType())) {
|
||||
IPAddressVO ipAddressVO = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(), selectedIp);
|
||||
if (ipAddressVO != null && IpAddress.State.Free.equals(ipAddressVO.getState())) {
|
||||
ipAddressVO.setState(IPAddressVO.State.Allocated);
|
||||
ipAddressVO.setAllocatedTime(new Date());
|
||||
Account account = _accountDao.findById(vm.getAccountId());
|
||||
ipAddressVO.setAllocatedInDomainId(account.getDomainId());
|
||||
ipAddressVO.setAllocatedToAccountId(account.getId());
|
||||
_ipAddressDao.update(ipAddressVO.getId(), ipAddressVO);
|
||||
}
|
||||
}
|
||||
|
||||
final Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId());
|
||||
final NicProfile vmNic = new NicProfile(vo, network, vo.getBroadcastUri(), vo.getIsolationUri(), networkRate, _networkModel.isSecurityGroupSupportedInNetwork(network),
|
||||
_networkModel.getNetworkTag(vm.getHypervisorType(), network));
|
||||
|
|
@ -4783,15 +4795,15 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
|||
if (network.getGuestType() == GuestType.L2) {
|
||||
return null;
|
||||
}
|
||||
return dataCenter.getNetworkType() == NetworkType.Basic ?
|
||||
getSelectedIpForNicImportOnBasicZone(ipAddresses.getIp4Address(), network, dataCenter):
|
||||
return GuestType.Shared.equals(network.getGuestType()) ?
|
||||
getSelectedIpForNicImportOnSharedNetwork(ipAddresses.getIp4Address(), network, dataCenter):
|
||||
_ipAddrMgr.acquireGuestIpAddress(network, ipAddresses.getIp4Address());
|
||||
}
|
||||
|
||||
protected String getSelectedIpForNicImportOnBasicZone(String requestedIp, Network network, DataCenter dataCenter) {
|
||||
protected String getSelectedIpForNicImportOnSharedNetwork(String requestedIp, Network network, DataCenter dataCenter) {
|
||||
IPAddressVO ipAddressVO = StringUtils.isBlank(requestedIp) ?
|
||||
_ipAddressDao.findBySourceNetworkIdAndDatacenterIdAndState(network.getId(), dataCenter.getId(), IpAddress.State.Free):
|
||||
_ipAddressDao.findByIp(requestedIp);
|
||||
_ipAddressDao.findByIpAndSourceNetworkId(network.getId(), requestedIp);
|
||||
if (ipAddressVO == null || ipAddressVO.getState() != IpAddress.State.Free) {
|
||||
String msg = String.format("Cannot find a free IP to assign to VM NIC on network %s", network.getName());
|
||||
logger.error(msg);
|
||||
|
|
|
|||
|
|
@ -177,6 +177,7 @@ import com.cloud.vm.dao.SecondaryStorageVmDao;
|
|||
import com.cloud.vm.dao.UserVmCloneSettingDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.UserVmDetailsDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrationService, Configurable {
|
||||
|
||||
|
|
@ -257,6 +258,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||
StoragePoolHostDao storagePoolHostDao;
|
||||
@Inject
|
||||
DiskOfferingDao diskOfferingDao;
|
||||
@Inject
|
||||
VMInstanceDao vmInstanceDao;
|
||||
|
||||
@Inject
|
||||
protected SnapshotHelper snapshotHelper;
|
||||
|
|
@ -933,9 +936,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||
|
||||
// Create event and update resource count for volumes if vm is a user vm
|
||||
if (vm.getType() == VirtualMachine.Type.User) {
|
||||
|
||||
Long offeringId = null;
|
||||
|
||||
if (!offering.isComputeOnly()) {
|
||||
offeringId = offering.getId();
|
||||
}
|
||||
|
|
@ -1868,14 +1869,18 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||
|
||||
if (newSize != vol.getSize()) {
|
||||
DiskOfferingVO diskOffering = diskOfferingDao.findByIdIncludingRemoved(vol.getDiskOfferingId());
|
||||
if (newSize > vol.getSize()) {
|
||||
_resourceLimitMgr.checkPrimaryStorageResourceLimit(_accountMgr.getActiveAccountById(vol.getAccountId()),
|
||||
vol.isDisplay(), newSize - vol.getSize(), diskOffering);
|
||||
_resourceLimitMgr.incrementVolumePrimaryStorageResourceCount(vol.getAccountId(), vol.isDisplay(),
|
||||
newSize - vol.getSize(), diskOffering);
|
||||
} else {
|
||||
_resourceLimitMgr.decrementVolumePrimaryStorageResourceCount(vol.getAccountId(), vol.isDisplay(),
|
||||
vol.getSize() - newSize, diskOffering);
|
||||
VMInstanceVO vm = vol.getInstanceId() != null ? vmInstanceDao.findById(vol.getInstanceId()) : null;
|
||||
if (vm == null || vm.getType() == VirtualMachine.Type.User) {
|
||||
// Update resource count for user vm volumes when volume is attached
|
||||
if (newSize > vol.getSize()) {
|
||||
_resourceLimitMgr.checkPrimaryStorageResourceLimit(_accountMgr.getActiveAccountById(vol.getAccountId()),
|
||||
vol.isDisplay(), newSize - vol.getSize(), diskOffering);
|
||||
_resourceLimitMgr.incrementVolumePrimaryStorageResourceCount(vol.getAccountId(), vol.isDisplay(),
|
||||
newSize - vol.getSize(), diskOffering);
|
||||
} else {
|
||||
_resourceLimitMgr.decrementVolumePrimaryStorageResourceCount(vol.getAccountId(), vol.isDisplay(),
|
||||
vol.getSize() - newSize, diskOffering);
|
||||
}
|
||||
}
|
||||
vol.setSize(newSize);
|
||||
_volsDao.persist(vol);
|
||||
|
|
|
|||
|
|
@ -822,7 +822,7 @@ public class NetworkOrchestratorTest extends TestCase {
|
|||
Mockito.when(network.getId()).thenReturn(networkId);
|
||||
Mockito.when(dataCenter.getId()).thenReturn(dataCenterId);
|
||||
Mockito.when(ipAddresses.getIp4Address()).thenReturn(requestedIp);
|
||||
Mockito.when(testOrchestrator._ipAddressDao.findByIp(requestedIp)).thenReturn(ipAddressVO);
|
||||
Mockito.when(testOrchestrator._ipAddressDao.findByIpAndSourceNetworkId(networkId, requestedIp)).thenReturn(ipAddressVO);
|
||||
String ipAddress = testOrchestrator.getSelectedIpForNicImport(network, dataCenter, ipAddresses);
|
||||
Assert.assertEquals(requestedIp, ipAddress);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ public interface VMTemplatePoolDao extends GenericDao<VMTemplateStoragePoolVO, L
|
|||
|
||||
List<VMTemplateStoragePoolVO> listByPoolIdAndState(long poolId, ObjectInDataStoreStateMachine.State state);
|
||||
|
||||
List<VMTemplateStoragePoolVO> listByPoolIdsAndTemplate(List<Long> poolIds, Long templateId);
|
||||
|
||||
List<VMTemplateStoragePoolVO> listByTemplateStatus(long templateId, VMTemplateStoragePoolVO.Status downloadState);
|
||||
|
||||
List<VMTemplateStoragePoolVO> listByTemplateStatus(long templateId, VMTemplateStoragePoolVO.Status downloadState, long poolId);
|
||||
|
|
|
|||
|
|
@ -150,6 +150,16 @@ public class VMTemplatePoolDaoImpl extends GenericDaoBase<VMTemplateStoragePoolV
|
|||
return findOneIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VMTemplateStoragePoolVO> listByPoolIdsAndTemplate(List<Long> poolIds, Long templateId) {
|
||||
SearchCriteria<VMTemplateStoragePoolVO> sc = PoolTemplateSearch.create();
|
||||
if (CollectionUtils.isNotEmpty(poolIds)) {
|
||||
sc.setParameters("pool_id", poolIds.toArray());
|
||||
}
|
||||
sc.setParameters("template_id", templateId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VMTemplateStoragePoolVO> listByTemplateStatus(long templateId, VMTemplateStoragePoolVO.Status downloadState) {
|
||||
SearchCriteria<VMTemplateStoragePoolVO> sc = TemplateStatusSearch.create();
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
|||
ReservationDao reservationDao;
|
||||
|
||||
private static final String LIST_PODS_HAVING_VMS_FOR_ACCOUNT =
|
||||
"SELECT pod_id FROM cloud.vm_instance WHERE data_center_id = ? AND account_id = ? AND pod_id IS NOT NULL AND (state = 'Running' OR state = 'Stopped') "
|
||||
"SELECT pod_id FROM cloud.vm_instance WHERE data_center_id = ? AND account_id = ? AND pod_id IS NOT NULL AND state IN ('Starting', 'Running', 'Stopped') "
|
||||
+ "GROUP BY pod_id HAVING count(id) > 0 ORDER BY count(id) DESC";
|
||||
|
||||
private static final String VM_DETAILS = "select vm_instance.id, "
|
||||
|
|
|
|||
|
|
@ -116,17 +116,17 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
|||
|
||||
protected Attribute _updateTimeAttr;
|
||||
|
||||
private static final String ORDER_CLUSTERS_NUMBER_OF_VMS_FOR_ACCOUNT_PART1 = "SELECT host.cluster_id, SUM(IF(vm.state='Running' AND vm.account_id = ?, 1, 0)) " +
|
||||
private static final String ORDER_CLUSTERS_NUMBER_OF_VMS_FOR_ACCOUNT_PART1 = "SELECT host.cluster_id, SUM(IF(vm.state IN ('Running', 'Starting') AND vm.account_id = ?, 1, 0)) " +
|
||||
"FROM `cloud`.`host` host LEFT JOIN `cloud`.`vm_instance` vm ON host.id = vm.host_id WHERE ";
|
||||
private static final String ORDER_CLUSTERS_NUMBER_OF_VMS_FOR_ACCOUNT_PART2 = " AND host.type = 'Routing' AND host.removed is null GROUP BY host.cluster_id " +
|
||||
"ORDER BY 2 ASC ";
|
||||
|
||||
private static final String ORDER_PODS_NUMBER_OF_VMS_FOR_ACCOUNT = "SELECT pod.id, SUM(IF(vm.state='Running' AND vm.account_id = ?, 1, 0)) FROM `cloud`.`" +
|
||||
private static final String ORDER_PODS_NUMBER_OF_VMS_FOR_ACCOUNT = "SELECT pod.id, SUM(IF(vm.state IN ('Running', 'Starting') AND vm.account_id = ?, 1, 0)) FROM `cloud`.`" +
|
||||
"host_pod_ref` pod LEFT JOIN `cloud`.`vm_instance` vm ON pod.id = vm.pod_id WHERE pod.data_center_id = ? AND pod.removed is null "
|
||||
+ " GROUP BY pod.id ORDER BY 2 ASC ";
|
||||
|
||||
private static final String ORDER_HOSTS_NUMBER_OF_VMS_FOR_ACCOUNT =
|
||||
"SELECT host.id, SUM(IF(vm.state='Running' AND vm.account_id = ?, 1, 0)) FROM `cloud`.`host` host LEFT JOIN `cloud`.`vm_instance` vm ON host.id = vm.host_id " +
|
||||
"SELECT host.id, SUM(IF(vm.state IN ('Running', 'Starting') AND vm.account_id = ?, 1, 0)) FROM `cloud`.`host` host LEFT JOIN `cloud`.`vm_instance` vm ON host.id = vm.host_id " +
|
||||
"WHERE host.data_center_id = ? AND host.type = 'Routing' AND host.removed is null ";
|
||||
|
||||
private static final String ORDER_HOSTS_NUMBER_OF_VMS_FOR_ACCOUNT_PART2 = " GROUP BY host.id ORDER BY 2 ASC ";
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ public interface VMSnapshotDao extends GenericDao<VMSnapshotVO, Long>, StateDao<
|
|||
VMSnapshotVO findByName(Long vmId, String name);
|
||||
|
||||
List<VMSnapshotVO> listByAccountId(Long accountId);
|
||||
|
||||
List<VMSnapshotVO> searchByVms(List<Long> vmIds);
|
||||
|
||||
List<VMSnapshotVO> searchRemovedByVms(List<Long> vmIds, Long batchSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,4 +154,6 @@ public interface PrimaryDataStoreDao extends GenericDao<StoragePoolVO, Long> {
|
|||
String keyword, Filter searchFilter);
|
||||
|
||||
List<StoragePoolVO> listByIds(List<Long> ids);
|
||||
|
||||
List<StoragePoolVO> listByDataCenterIds(List<Long> dataCenterIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long>
|
|||
private final GenericSearchBuilder<StoragePoolVO, Long> StatusCountSearch;
|
||||
private final SearchBuilder<StoragePoolVO> ClustersSearch;
|
||||
private final SearchBuilder<StoragePoolVO> IdsSearch;
|
||||
private final SearchBuilder<StoragePoolVO> DcsSearch;
|
||||
|
||||
@Inject
|
||||
private StoragePoolDetailsDao _detailsDao;
|
||||
|
|
@ -155,6 +156,9 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long>
|
|||
IdsSearch.and("ids", IdsSearch.entity().getId(), SearchCriteria.Op.IN);
|
||||
IdsSearch.done();
|
||||
|
||||
DcsSearch = createSearchBuilder();
|
||||
DcsSearch.and("dataCenterId", DcsSearch.entity().getDataCenterId(), SearchCriteria.Op.IN);
|
||||
DcsSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -733,6 +737,16 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long>
|
|||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> listByDataCenterIds(List<Long> dataCenterIds) {
|
||||
if (CollectionUtils.isEmpty(dataCenterIds)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
SearchCriteria<StoragePoolVO> sc = DcsSearch.create();
|
||||
sc.setParameters("dataCenterId", dataCenterIds.toArray());
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
private SearchCriteria<StoragePoolVO> createStoragePoolSearchCriteria(Long storagePoolId, String storagePoolName,
|
||||
Long zoneId, String path, Long podId, Long clusterId, String address, ScopeType scopeType,
|
||||
StoragePoolStatus status, String keyword) {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>cloud-engine-service</artifactId>
|
||||
<packaging>war</packaging>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -23,11 +23,16 @@ import java.util.List;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.utils.fsm.NoTransitionException;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
|
@ -73,7 +78,7 @@ public class SnapshotDataFactoryImpl implements SnapshotDataFactory {
|
|||
for (SnapshotDataStoreVO snapshotDataStoreVO : allSnapshotsFromVolumeAndDataStore) {
|
||||
DataStore store = storeMgr.getDataStore(snapshotDataStoreVO.getDataStoreId(), role);
|
||||
SnapshotVO snapshot = snapshotDao.findById(snapshotDataStoreVO.getSnapshotId());
|
||||
if (snapshot == null){ //snapshot may have been removed;
|
||||
if (snapshot == null) { //snapshot may have been removed;
|
||||
continue;
|
||||
}
|
||||
SnapshotObject info = SnapshotObject.getSnapshotObject(snapshot, store);
|
||||
|
|
@ -107,8 +112,6 @@ public class SnapshotDataFactoryImpl implements SnapshotDataFactory {
|
|||
return infos;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public SnapshotInfo getSnapshot(long snapshotId, long storeId, DataStoreRole role) {
|
||||
SnapshotVO snapshot = snapshotDao.findById(snapshotId);
|
||||
|
|
@ -202,4 +205,17 @@ public class SnapshotDataFactoryImpl implements SnapshotDataFactory {
|
|||
return snapObjs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOperationFailed(long snapshotId) throws NoTransitionException {
|
||||
List<SnapshotDataStoreVO> snapshotStoreRefs = snapshotStoreDao.findBySnapshotId(snapshotId);
|
||||
for (SnapshotDataStoreVO snapshotStoreRef : snapshotStoreRefs) {
|
||||
SnapshotInfo snapshotInfo = getSnapshot(snapshotStoreRef.getSnapshotId(), snapshotStoreRef.getDataStoreId(), snapshotStoreRef.getRole());
|
||||
if (snapshotInfo != null) {
|
||||
VolumeInfo volumeInfo = snapshotInfo.getBaseVolume();
|
||||
volumeInfo.stateTransit(Volume.Event.OperationFailed);
|
||||
((SnapshotObject)snapshotInfo).processEvent(Snapshot.Event.OperationFailed);
|
||||
snapshotInfo.processEvent(ObjectInDataStoreStateMachine.Event.OperationFailed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -481,4 +481,14 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot
|
|||
}
|
||||
return StrategyPriority.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOperationFailed(VMSnapshot vmSnapshot) throws NoTransitionException {
|
||||
try {
|
||||
vmSnapshotHelper.vmSnapshotStateTransitTo(vmSnapshot, VMSnapshot.Event.OperationFailed);
|
||||
} catch (NoTransitionException e) {
|
||||
logger.debug("Failed to change vm snapshot state with event OperationFailed");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -479,6 +479,16 @@ public class ScaleIOVMSnapshotStrategy extends ManagerBase implements VMSnapshot
|
|||
return vmSnapshotDao.remove(vmSnapshot.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOperationFailed(VMSnapshot vmSnapshot) throws NoTransitionException {
|
||||
try {
|
||||
vmSnapshotHelper.vmSnapshotStateTransitTo(vmSnapshot, VMSnapshot.Event.OperationFailed);
|
||||
} catch (NoTransitionException e) {
|
||||
logger.debug("Failed to change vm snapshot state with event OperationFailed");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private void publishUsageEvent(String type, VMSnapshot vmSnapshot, UserVm userVm, VolumeObjectTO volumeTo) {
|
||||
VolumeVO volume = volumeDao.findById(volumeTo.getId());
|
||||
Long diskOfferingId = volume.getDiskOfferingId();
|
||||
|
|
|
|||
|
|
@ -159,7 +159,9 @@ public class PrimaryDataStoreHelper {
|
|||
pool.setScope(scope.getScopeType());
|
||||
pool.setUsedBytes(existingInfo.getCapacityBytes() - existingInfo.getAvailableBytes());
|
||||
pool.setCapacityBytes(existingInfo.getCapacityBytes());
|
||||
pool.setStatus(StoragePoolStatus.Up);
|
||||
if (pool.getStatus() != StoragePoolStatus.Disabled) {
|
||||
pool.setStatus(StoragePoolStatus.Up);
|
||||
}
|
||||
this.dataStoreDao.update(pool.getId(), pool);
|
||||
this.storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE, pool.getUsedBytes());
|
||||
return dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<parent>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-engine</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<artifactId>cloudstack-framework</artifactId>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-framework</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-framework</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-framework</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-framework</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
<parent>
|
||||
<artifactId>cloudstack-framework</artifactId>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-framework</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-framework</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-framework</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@ import java.util.concurrent.TimeUnit;
|
|||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.storage.SnapshotVO;
|
||||
import com.cloud.vm.snapshot.VMSnapshot;
|
||||
import com.cloud.vm.snapshot.VMSnapshotService;
|
||||
import com.cloud.vm.snapshot.VMSnapshotVO;
|
||||
import com.cloud.vm.snapshot.dao.VMSnapshotDao;
|
||||
import org.apache.cloudstack.api.ApiCommandResourceType;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
|
@ -153,11 +158,15 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
|
|||
@Inject
|
||||
private SnapshotDao _snapshotDao;
|
||||
@Inject
|
||||
private VMSnapshotDao _vmSnapshotDao;
|
||||
@Inject
|
||||
private SnapshotService snapshotSrv;
|
||||
@Inject
|
||||
private SnapshotDataFactory snapshotFactory;
|
||||
@Inject
|
||||
private SnapshotDetailsDao _snapshotDetailsDao;
|
||||
@Inject
|
||||
private VMSnapshotService _vmSnapshotService;
|
||||
|
||||
@Inject
|
||||
private VolumeDataFactory volFactory;
|
||||
|
|
@ -1149,6 +1158,10 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
|
|||
return cleanupVirtualMachine(job.getInstanceId());
|
||||
case Network:
|
||||
return cleanupNetwork(job.getInstanceId());
|
||||
case Snapshot:
|
||||
return cleanupSnapshot(job.getInstanceId());
|
||||
case VmSnapshot:
|
||||
return cleanupVmSnapshot(job.getInstanceId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("Error while cleaning up resource: [" + job.getInstanceType().toString() + "] with Id: " + job.getInstanceId(), e);
|
||||
|
|
@ -1187,7 +1200,7 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
|
|||
return true;
|
||||
}
|
||||
|
||||
private boolean cleanupNetwork(final long networkId) throws Exception {
|
||||
private boolean cleanupNetwork(final long networkId) {
|
||||
NetworkVO networkVO = networkDao.findById(networkId);
|
||||
if (networkVO == null) {
|
||||
logger.warn("Network not found. Skip Cleanup. NetworkId: " + networkId);
|
||||
|
|
@ -1206,6 +1219,46 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
|
|||
return true;
|
||||
}
|
||||
|
||||
private boolean cleanupSnapshot(final long snapshotId) {
|
||||
SnapshotVO snapshotVO = _snapshotDao.findById(snapshotId);
|
||||
if (snapshotVO == null) {
|
||||
logger.warn("Snapshot not found. Skip Cleanup. SnapshotId: " + snapshotId);
|
||||
return true;
|
||||
}
|
||||
if (Snapshot.State.Allocated.equals(snapshotVO.getState())) {
|
||||
_snapshotDao.remove(snapshotId);
|
||||
}
|
||||
if (Snapshot.State.Creating.equals(snapshotVO.getState())) {
|
||||
try {
|
||||
snapshotFactory.updateOperationFailed(snapshotId);
|
||||
} catch (NoTransitionException e) {
|
||||
snapshotVO.setState(Snapshot.State.Error);
|
||||
_snapshotDao.update(snapshotVO.getId(), snapshotVO);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean cleanupVmSnapshot(final long vmSnapshotId) {
|
||||
VMSnapshotVO vmSnapshotVO = _vmSnapshotDao.findById(vmSnapshotId);
|
||||
if (vmSnapshotVO == null) {
|
||||
logger.warn("VM Snapshot not found. Skip Cleanup. VMSnapshotId: " + vmSnapshotId);
|
||||
return true;
|
||||
}
|
||||
if (VMSnapshot.State.Allocated.equals(vmSnapshotVO.getState())) {
|
||||
_vmSnapshotDao.remove(vmSnapshotId);
|
||||
}
|
||||
if (VMSnapshot.State.Creating.equals(vmSnapshotVO.getState())) {
|
||||
try {
|
||||
_vmSnapshotService.updateOperationFailed(vmSnapshotVO);
|
||||
} catch (NoTransitionException e) {
|
||||
vmSnapshotVO.setState(VMSnapshot.State.Error);
|
||||
_vmSnapshotDao.update(vmSnapshotVO.getId(), vmSnapshotVO);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cleanupFailedVolumesCreatedFromSnapshots(final long volumeId) {
|
||||
try {
|
||||
VolumeDetailVO volumeDetail = _volumeDetailsDao.findDetail(volumeId, VolumeService.SNAPSHOT_ID);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<build>
|
||||
<plugins>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-framework</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import java.util.stream.Collectors;
|
|||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.user.Account;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.quota.activationrule.presetvariables.GenericPresetVariable;
|
||||
import org.apache.cloudstack.quota.activationrule.presetvariables.PresetVariableHelper;
|
||||
|
|
@ -62,6 +61,7 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import com.cloud.usage.UsageVO;
|
||||
import com.cloud.usage.dao.UsageDao;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.DateUtil;
|
||||
|
|
@ -467,7 +467,7 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager {
|
|||
|
||||
}
|
||||
|
||||
jsInterpreter.injectStringVariable("resourceType", presetVariables.getResourceType());
|
||||
jsInterpreter.injectVariable("resourceType", presetVariables.getResourceType());
|
||||
jsInterpreter.injectVariable("value", presetVariables.getValue().toString());
|
||||
jsInterpreter.injectVariable("zone", presetVariables.getZone().toString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ public class QuotaManagerImplTest {
|
|||
Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("account"), Mockito.anyString());
|
||||
Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("domain"), Mockito.anyString());
|
||||
Mockito.verify(jsInterpreterMock, Mockito.never()).injectVariable(Mockito.eq("project"), Mockito.anyString());
|
||||
Mockito.verify(jsInterpreterMock).injectStringVariable(Mockito.eq("resourceType"), Mockito.anyString());
|
||||
Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("resourceType"), Mockito.anyString());
|
||||
Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("value"), Mockito.anyString());
|
||||
Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("zone"), Mockito.anyString());
|
||||
}
|
||||
|
|
@ -291,7 +291,7 @@ public class QuotaManagerImplTest {
|
|||
Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("account"), Mockito.anyString());
|
||||
Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("domain"), Mockito.anyString());
|
||||
Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("project"), Mockito.anyString());
|
||||
Mockito.verify(jsInterpreterMock).injectStringVariable(Mockito.eq("resourceType"), Mockito.anyString());
|
||||
Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("resourceType"), Mockito.anyString());
|
||||
Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("value"), Mockito.anyString());
|
||||
Mockito.verify(jsInterpreterMock).injectVariable(Mockito.eq("zone"), Mockito.anyString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-framework</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>cloud-framework-rest</artifactId>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-framework</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<parent>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<parent>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<parent>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<parent>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,8 @@ public class VeeamClient {
|
|||
private static final String REPOSITORY_REFERENCE = "RepositoryReference";
|
||||
private static final String RESTORE_POINT_REFERENCE = "RestorePointReference";
|
||||
private static final String BACKUP_FILE_REFERENCE = "BackupFileReference";
|
||||
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||
private static final ObjectMapper OBJECT_MAPPER = new XmlMapper();
|
||||
|
||||
|
||||
private String veeamServerIp;
|
||||
|
|
@ -127,6 +128,8 @@ public class VeeamClient {
|
|||
this.taskPollInterval = taskPollInterval;
|
||||
this.taskPollMaxRetry = taskPollMaxRetry;
|
||||
|
||||
OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
|
||||
final RequestConfig config = RequestConfig.custom()
|
||||
.setConnectTimeout(timeout * 1000)
|
||||
.setConnectionRequestTimeout(timeout * 1000)
|
||||
|
|
@ -236,8 +239,7 @@ public class VeeamClient {
|
|||
private HttpResponse post(final String path, final Object obj) throws IOException {
|
||||
String xml = null;
|
||||
if (obj != null) {
|
||||
XmlMapper xmlMapper = new XmlMapper();
|
||||
xml = xmlMapper.writer()
|
||||
xml = OBJECT_MAPPER.writer()
|
||||
.with(ToXmlGenerator.Feature.WRITE_XML_DECLARATION)
|
||||
.writeValueAsString(obj);
|
||||
// Remove invalid/empty xmlns
|
||||
|
|
@ -280,8 +282,7 @@ public class VeeamClient {
|
|||
try {
|
||||
final HttpResponse response = get("/hierarchyRoots");
|
||||
checkResponseOK(response);
|
||||
final ObjectMapper objectMapper = new XmlMapper();
|
||||
final EntityReferences references = objectMapper.readValue(response.getEntity().getContent(), EntityReferences.class);
|
||||
final EntityReferences references = OBJECT_MAPPER.readValue(response.getEntity().getContent(), EntityReferences.class);
|
||||
for (final Ref ref : references.getRefs()) {
|
||||
if (ref.getName().equals(vmwareDcName) && ref.getType().equals(HIERARCHY_ROOT_REFERENCE)) {
|
||||
return ref.getUid();
|
||||
|
|
@ -300,8 +301,7 @@ public class VeeamClient {
|
|||
try {
|
||||
final HttpResponse response = get(String.format("/lookup?host=%s&type=Vm&name=%s", hierarchyId, vmName));
|
||||
checkResponseOK(response);
|
||||
final ObjectMapper objectMapper = new XmlMapper();
|
||||
final HierarchyItems items = objectMapper.readValue(response.getEntity().getContent(), HierarchyItems.class);
|
||||
final HierarchyItems items = OBJECT_MAPPER.readValue(response.getEntity().getContent(), HierarchyItems.class);
|
||||
if (items == null || items.getItems() == null || items.getItems().isEmpty()) {
|
||||
throw new CloudRuntimeException("Could not find VM " + vmName + " in Veeam, please ask administrator to check Veeam B&R manager");
|
||||
}
|
||||
|
|
@ -319,14 +319,12 @@ public class VeeamClient {
|
|||
|
||||
private Task parseTaskResponse(HttpResponse response) throws IOException {
|
||||
checkResponseOK(response);
|
||||
final ObjectMapper objectMapper = new XmlMapper();
|
||||
return objectMapper.readValue(response.getEntity().getContent(), Task.class);
|
||||
return OBJECT_MAPPER.readValue(response.getEntity().getContent(), Task.class);
|
||||
}
|
||||
|
||||
protected RestoreSession parseRestoreSessionResponse(HttpResponse response) throws IOException {
|
||||
checkResponseOK(response);
|
||||
final ObjectMapper objectMapper = new XmlMapper();
|
||||
return objectMapper.readValue(response.getEntity().getContent(), RestoreSession.class);
|
||||
return OBJECT_MAPPER.readValue(response.getEntity().getContent(), RestoreSession.class);
|
||||
}
|
||||
|
||||
private boolean checkTaskStatus(final HttpResponse response) throws IOException {
|
||||
|
|
@ -413,8 +411,7 @@ public class VeeamClient {
|
|||
String repositoryName = getRepositoryNameFromJob(backupName);
|
||||
final HttpResponse response = get(String.format("/backupServers/%s/repositories", backupServerId));
|
||||
checkResponseOK(response);
|
||||
final ObjectMapper objectMapper = new XmlMapper();
|
||||
final EntityReferences references = objectMapper.readValue(response.getEntity().getContent(), EntityReferences.class);
|
||||
final EntityReferences references = OBJECT_MAPPER.readValue(response.getEntity().getContent(), EntityReferences.class);
|
||||
for (final Ref ref : references.getRefs()) {
|
||||
if (ref.getType().equals(REPOSITORY_REFERENCE) && ref.getName().equals(repositoryName)) {
|
||||
return ref;
|
||||
|
|
@ -450,8 +447,7 @@ public class VeeamClient {
|
|||
try {
|
||||
final HttpResponse response = get("/backups");
|
||||
checkResponseOK(response);
|
||||
final ObjectMapper objectMapper = new XmlMapper();
|
||||
final EntityReferences entityReferences = objectMapper.readValue(response.getEntity().getContent(), EntityReferences.class);
|
||||
final EntityReferences entityReferences = OBJECT_MAPPER.readValue(response.getEntity().getContent(), EntityReferences.class);
|
||||
for (final Ref ref : entityReferences.getRefs()) {
|
||||
logger.debug("Veeam Backup found, name: " + ref.getName() + ", uid: " + ref.getUid() + ", type: " + ref.getType());
|
||||
}
|
||||
|
|
@ -466,8 +462,7 @@ public class VeeamClient {
|
|||
try {
|
||||
final HttpResponse response = get("/jobs");
|
||||
checkResponseOK(response);
|
||||
final ObjectMapper objectMapper = new XmlMapper();
|
||||
final EntityReferences entityReferences = objectMapper.readValue(response.getEntity().getContent(), EntityReferences.class);
|
||||
final EntityReferences entityReferences = OBJECT_MAPPER.readValue(response.getEntity().getContent(), EntityReferences.class);
|
||||
final List<BackupOffering> policies = new ArrayList<>();
|
||||
if (entityReferences == null || entityReferences.getRefs() == null) {
|
||||
return policies;
|
||||
|
|
@ -489,9 +484,7 @@ public class VeeamClient {
|
|||
final HttpResponse response = get(String.format("/jobs/%s?format=Entity",
|
||||
jobId.replace("urn:veeam:Job:", "")));
|
||||
checkResponseOK(response);
|
||||
final ObjectMapper objectMapper = new XmlMapper();
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
return objectMapper.readValue(response.getEntity().getContent(), Job.class);
|
||||
return OBJECT_MAPPER.readValue(response.getEntity().getContent(), Job.class);
|
||||
} catch (final IOException e) {
|
||||
logger.error("Failed to list Veeam jobs due to:", e);
|
||||
checkResponseTimeOut(e);
|
||||
|
|
@ -571,9 +564,7 @@ public class VeeamClient {
|
|||
final String veeamVmRefId = lookupVM(hierarchyId, vmwareInstanceName);
|
||||
final HttpResponse response = get(String.format("/jobs/%s/includes", jobId));
|
||||
checkResponseOK(response);
|
||||
final ObjectMapper objectMapper = new XmlMapper();
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
final ObjectsInJob jobObjects = objectMapper.readValue(response.getEntity().getContent(), ObjectsInJob.class);
|
||||
final ObjectsInJob jobObjects = OBJECT_MAPPER.readValue(response.getEntity().getContent(), ObjectsInJob.class);
|
||||
if (jobObjects == null || jobObjects.getObjects() == null) {
|
||||
logger.warn("No objects found in the Veeam job " + jobId);
|
||||
return false;
|
||||
|
|
@ -715,8 +706,7 @@ public class VeeamClient {
|
|||
protected Map<String, Backup.Metric> processHttpResponseForBackupMetrics(final InputStream content) {
|
||||
Map<String, Backup.Metric> metrics = new HashMap<>();
|
||||
try {
|
||||
final ObjectMapper objectMapper = new XmlMapper();
|
||||
final BackupFiles backupFiles = objectMapper.readValue(content, BackupFiles.class);
|
||||
final BackupFiles backupFiles = OBJECT_MAPPER.readValue(content, BackupFiles.class);
|
||||
if (backupFiles == null || CollectionUtils.isEmpty(backupFiles.getBackupFiles())) {
|
||||
throw new CloudRuntimeException("Could not get backup metrics via Veeam B&R API");
|
||||
}
|
||||
|
|
@ -885,8 +875,7 @@ public class VeeamClient {
|
|||
public List<Backup.RestorePoint> processHttpResponseForVmRestorePoints(InputStream content, String vmInternalName) {
|
||||
List<Backup.RestorePoint> vmRestorePointList = new ArrayList<>();
|
||||
try {
|
||||
final ObjectMapper objectMapper = new XmlMapper();
|
||||
final VmRestorePoints vmRestorePoints = objectMapper.readValue(content, VmRestorePoints.class);
|
||||
final VmRestorePoints vmRestorePoints = OBJECT_MAPPER.readValue(content, VmRestorePoints.class);
|
||||
if (vmRestorePoints == null) {
|
||||
throw new CloudRuntimeException("Could not get VM restore points via Veeam B&R API");
|
||||
}
|
||||
|
|
@ -922,7 +911,7 @@ public class VeeamClient {
|
|||
}
|
||||
|
||||
private Date formatDate(String date) throws ParseException {
|
||||
return dateFormat.parse(StringUtils.substring(date, 0, 19));
|
||||
return DATE_FORMAT.parse(StringUtils.substring(date, 0, 19));
|
||||
}
|
||||
|
||||
public Pair<Boolean, String> restoreVMToDifferentLocation(String restorePointId, String hostIp, String dataStoreUuid) {
|
||||
|
|
|
|||
|
|
@ -475,7 +475,9 @@ public class VeeamClientTest {
|
|||
" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n" +
|
||||
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
|
||||
" xmlns=\"http://www.veeam.com/ent/v1.0\">\n" +
|
||||
" <VmRestorePoint Href=\"https://10.0.3.142:9398/api/vmRestorePoints/f6d504cf-eafe-4cd2-8dfc-e9cfe2f1e977?format=Entity\" Type=\"VmRestorePoint\" Name=\"i-2-4-VM@2023-11-03 16:26:12.209913\" UID=\"urn:veeam:VmRestorePoint:f6d504cf-eafe-4cd2-8dfc-e9cfe2f1e977\" VmDisplayName=\"i-2-4-VM\">\n" +
|
||||
" <VmRestorePoint Href=\"https://10.0.3.142:9398/api/vmRestorePoints/f6d504cf-eafe-4cd2-8dfc-e9cfe2f1e977?format=Entity\"" +
|
||||
" Type=\"VmRestorePoint\" Name=\"i-2-4-VM@2023-11-03 16:26:12.209913\" UID=\"urn:veeam:VmRestorePoint:f6d504cf-eafe-4cd2-8dfc-e9cfe2f1e977\"" +
|
||||
" VmDisplayName=\"i-2-4-VM\" SqlInfo=\"SqlInfo\">\n" +
|
||||
" <Links>\n" +
|
||||
" <Link Href=\"https://10.0.3.142:9398/api/vmRestorePoints/f6d504cf-eafe-4cd2-8dfc-e9cfe2f1e977?action=restore\" Rel=\"Restore\" />\n" +
|
||||
" <Link Href=\"https://10.0.3.142:9398/api/backupServers/18cc2a81-1ff0-42cd-8389-62f2bbcc6b7f\" Name=\"10.0.3.142\" Type=\"BackupServerReference\" Rel=\"Up\" />\n" +
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.20.2.0-SNAPSHOT</version>
|
||||
<version>4.20.3.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ import java.util.stream.Collectors;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.utils.DateUtil;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.command.QuotaBalanceCmd;
|
||||
|
|
@ -70,8 +69,8 @@ import org.apache.cloudstack.quota.dao.QuotaCreditsDao;
|
|||
import org.apache.cloudstack.quota.dao.QuotaEmailConfigurationDao;
|
||||
import org.apache.cloudstack.quota.dao.QuotaEmailTemplatesDao;
|
||||
import org.apache.cloudstack.quota.dao.QuotaTariffDao;
|
||||
import org.apache.cloudstack.quota.vo.QuotaAccountVO;
|
||||
import org.apache.cloudstack.quota.dao.QuotaUsageDao;
|
||||
import org.apache.cloudstack.quota.vo.QuotaAccountVO;
|
||||
import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
|
||||
import org.apache.cloudstack.quota.vo.QuotaCreditsVO;
|
||||
import org.apache.cloudstack.quota.vo.QuotaEmailConfigurationVO;
|
||||
|
|
@ -79,26 +78,28 @@ import org.apache.cloudstack.quota.vo.QuotaEmailTemplatesVO;
|
|||
import org.apache.cloudstack.quota.vo.QuotaTariffVO;
|
||||
import org.apache.cloudstack.quota.vo.QuotaUsageVO;
|
||||
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.ActionEvent;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.utils.DateUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.event.ActionEvent;
|
||||
import com.cloud.event.EventTypes;
|
||||
|
||||
@Component
|
||||
public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
|
||||
|
|
@ -139,6 +140,12 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
|
|||
@Inject
|
||||
private ApiDiscoveryService apiDiscoveryService;
|
||||
|
||||
protected void checkActivationRulesAllowed(String activationRule) {
|
||||
if (!_quotaService.isJsInterpretationEnabled() && StringUtils.isNotEmpty(activationRule)) {
|
||||
throw new PermissionDeniedException("Quota Tariff Activation Rule cannot be set, as Javascript interpretation is disabled in the configuration.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuotaTariffResponse createQuotaTariffResponse(QuotaTariffVO tariff, boolean returnActivationRule) {
|
||||
final QuotaTariffResponse response = new QuotaTariffResponse();
|
||||
|
|
@ -440,6 +447,8 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
|
|||
throw new InvalidParameterValueException(String.format("There is no quota tariffs with name [%s].", name));
|
||||
}
|
||||
|
||||
checkActivationRulesAllowed(activationRule);
|
||||
|
||||
Date currentQuotaTariffStartDate = currentQuotaTariff.getEffectiveOn();
|
||||
|
||||
currentQuotaTariff.setRemoved(now);
|
||||
|
|
@ -696,6 +705,8 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
|
|||
throw new InvalidParameterValueException(String.format("A quota tariff with name [%s] already exist.", name));
|
||||
}
|
||||
|
||||
checkActivationRulesAllowed(activationRule);
|
||||
|
||||
if (startDate.compareTo(now) < 0) {
|
||||
throw new InvalidParameterValueException(String.format("The value passed as Quota tariff's start date is in the past: [%s]. " +
|
||||
"Please, inform a date in the future or do not pass the parameter to use the current date and time.", startDate));
|
||||
|
|
|
|||
|
|
@ -16,15 +16,15 @@
|
|||
//under the License.
|
||||
package org.apache.cloudstack.quota;
|
||||
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
|
||||
import org.apache.cloudstack.quota.vo.QuotaUsageVO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
|
||||
public interface QuotaService extends PluggableService {
|
||||
|
||||
|
|
@ -40,4 +40,6 @@ public interface QuotaService extends PluggableService {
|
|||
|
||||
boolean saveQuotaAccount(AccountVO account, BigDecimal aggrUsage, Date endDate);
|
||||
|
||||
boolean isJsInterpretationEnabled();
|
||||
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue