Skip to content

Commit fbe0496

Browse files
committed
Merge branch 'main' into cks-enhancements-upstream
2 parents ddaa65f + 48f890a commit fbe0496

File tree

58 files changed

+475
-296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+475
-296
lines changed

api/src/main/java/com/cloud/agent/api/to/RemoteInstanceTO.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class RemoteInstanceTO implements Serializable {
2727

2828
private Hypervisor.HypervisorType hypervisorType;
2929
private String instanceName;
30+
private String instancePath;
3031

3132
// VMware Remote Instances parameters (required for exporting OVA through ovftool)
3233
// TODO: cloud.agent.transport.Request#getCommands() cannot handle gsoc decode for polymorphic classes
@@ -44,9 +45,10 @@ public RemoteInstanceTO(String instanceName) {
4445
this.instanceName = instanceName;
4546
}
4647

47-
public RemoteInstanceTO(String instanceName, String vcenterHost, String vcenterUsername, String vcenterPassword, String datacenterName) {
48+
public RemoteInstanceTO(String instanceName, String instancePath, String vcenterHost, String vcenterUsername, String vcenterPassword, String datacenterName) {
4849
this.hypervisorType = Hypervisor.HypervisorType.VMware;
4950
this.instanceName = instanceName;
51+
this.instancePath = instancePath;
5052
this.vcenterHost = vcenterHost;
5153
this.vcenterUsername = vcenterUsername;
5254
this.vcenterPassword = vcenterPassword;
@@ -61,6 +63,10 @@ public String getInstanceName() {
6163
return this.instanceName;
6264
}
6365

66+
public String getInstancePath() {
67+
return this.instancePath;
68+
}
69+
6470
public String getVcenterUsername() {
6571
return vcenterUsername;
6672
}

api/src/main/java/com/cloud/storage/VolumeApiService.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222
import java.util.List;
2323
import java.util.Map;
2424

25+
import com.cloud.exception.ResourceAllocationException;
26+
import com.cloud.offering.DiskOffering;
27+
import com.cloud.user.Account;
2528
import com.cloud.utils.Pair;
29+
import com.cloud.utils.fsm.NoTransitionException;
30+
2631
import org.apache.cloudstack.api.command.user.volume.AssignVolumeCmd;
2732
import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
2833
import org.apache.cloudstack.api.command.user.volume.ChangeOfferingForVolumeCmd;
@@ -37,21 +42,17 @@
3742
import org.apache.cloudstack.api.response.GetUploadParamsResponse;
3843
import org.apache.cloudstack.framework.config.ConfigKey;
3944

40-
import com.cloud.exception.ResourceAllocationException;
41-
import com.cloud.user.Account;
42-
import com.cloud.utils.fsm.NoTransitionException;
43-
4445
public interface VolumeApiService {
4546

46-
ConfigKey<Long> ConcurrentMigrationsThresholdPerDatastore = new ConfigKey<Long>("Advanced"
47+
ConfigKey<Long> ConcurrentMigrationsThresholdPerDatastore = new ConfigKey<>("Advanced"
4748
, Long.class
4849
, "concurrent.migrations.per.target.datastore"
4950
, "0"
5051
, "Limits number of migrations that can be handled per datastore concurrently; default is 0 - unlimited"
5152
, true // not sure if this is to be dynamic
5253
, ConfigKey.Scope.Global);
5354

54-
ConfigKey<Boolean> UseHttpsToUpload = new ConfigKey<Boolean>("Advanced",
55+
ConfigKey<Boolean> UseHttpsToUpload = new ConfigKey<>("Advanced",
5556
Boolean.class,
5657
"use.https.to.upload",
5758
"true",
@@ -85,7 +86,7 @@ public interface VolumeApiService {
8586
* @param cmd
8687
* the API command wrapping the criteria
8788
* @return the volume object
88-
* @throws ResourceAllocationException
89+
* @throws ResourceAllocationException no capacity to allocate the new volume size
8990
*/
9091
Volume resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationException;
9192

@@ -139,13 +140,13 @@ Volume updateVolume(long volumeId, String path, String state, Long storageId,
139140
Snapshot allocSnapshotForVm(Long vmId, Long volumeId, String snapshotName) throws ResourceAllocationException;
140141

141142
/**
142-
* Checks if the target storage supports the disk offering.
143+
* Checks if the storage pool supports the disk offering tags.
143144
* This validation is consistent with the mechanism used to select a storage pool to deploy a volume when a virtual machine is deployed or when a data disk is allocated.
144145
*
145146
* The scenarios when this method returns true or false is presented in the following table.
146147
* <table border="1">
147148
* <tr>
148-
* <th>#</th><th>Disk offering tags</th><th>Storage tags</th><th>Does the storage support the disk offering?</th>
149+
* <th>#</th><th>Disk offering diskOfferingTags</th><th>Storage diskOfferingTags</th><th>Does the storage support the disk offering?</th>
149150
* </tr>
150151
* <body>
151152
* <tr>
@@ -169,7 +170,8 @@ Volume updateVolume(long volumeId, String path, String state, Long storageId,
169170
* </body>
170171
* </table>
171172
*/
172-
boolean doesTargetStorageSupportDiskOffering(StoragePool destPool, String diskOfferingTags);
173+
boolean doesStoragePoolSupportDiskOffering(StoragePool destPool, DiskOffering diskOffering);
174+
boolean doesStoragePoolSupportDiskOfferingTags(StoragePool destPool, String diskOfferingTags);
173175

174176
Volume destroyVolume(long volumeId, Account caller, boolean expunge, boolean forceExpunge);
175177

api/src/main/java/org/apache/cloudstack/api/command/admin/offering/IsAccountAllowedToCreateOfferingsWithTagsCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
responseObject = IsAccountAllowedToCreateOfferingsWithTagsResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
3030
public class IsAccountAllowedToCreateOfferingsWithTagsCmd extends BaseCmd {
3131

32-
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "Account UUID")
32+
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "Account UUID", required = true)
3333
private Long id;
3434

3535
@Override

api/src/main/java/org/apache/cloudstack/backup/BackupProvider.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,39 +49,38 @@ public interface BackupProvider {
4949

5050
/**
5151
* Assign a VM to a backup offering or policy
52-
* @param vm
53-
* @param backup
54-
* @param policy
55-
* @return
52+
* @param vm the machine to back up
53+
* @param backupOffering the SLA definition for the backup
54+
* @return succeeded?
5655
*/
5756
boolean assignVMToBackupOffering(VirtualMachine vm, BackupOffering backupOffering);
5857

5958
/**
6059
* Removes a VM from a backup offering or policy
61-
* @param vm
62-
* @return
60+
* @param vm the machine to stop backing up
61+
* @return succeeded?
6362
*/
6463
boolean removeVMFromBackupOffering(VirtualMachine vm);
6564

6665
/**
67-
* Whether the provide will delete backups on removal of VM from the offfering
66+
* Whether the provider will delete backups on removal of VM from the offering
6867
* @return boolean result
6968
*/
7069
boolean willDeleteBackupsOnOfferingRemoval();
7170

7271
/**
7372
* Starts and creates an adhoc backup process
7473
* for a previously registered VM backup
75-
* @param backup
76-
* @return
74+
* @param vm the machine to make a backup of
75+
* @return the result and {code}Backup{code} {code}Object{code}
7776
*/
7877
Pair<Boolean, Backup> takeBackup(VirtualMachine vm);
7978

8079
/**
8180
* Delete an existing backup
82-
* @param backuo The backup to exclude
81+
* @param backup The backup to exclude
8382
* @param forced Indicates if backup will be force removed or not
84-
* @return
83+
* @return succeeded?
8584
*/
8685
boolean deleteBackup(Backup backup, boolean forced);
8786

@@ -97,23 +96,23 @@ public interface BackupProvider {
9796

9897
/**
9998
* Returns backup metrics for a list of VMs in a zone
100-
* @param zoneId
101-
* @param vms
102-
* @return
99+
* @param zoneId the zone for which to return metrics
100+
* @param vms a list of machines to get measurements for
101+
* @return a map of machine -> backup metrics
103102
*/
104103
Map<VirtualMachine, Backup.Metric> getBackupMetrics(Long zoneId, List<VirtualMachine> vms);
105104

106105
/**
107106
* This method should TODO
108-
* @param
107+
* @param vm the machine to get restore point for
109108
*/
110-
public List<Backup.RestorePoint> listRestorePoints(VirtualMachine vm);
109+
List<Backup.RestorePoint> listRestorePoints(VirtualMachine vm);
111110

112111
/**
113112
* This method should TODO
114-
* @param
115-
* @param
116-
* @param metric
113+
* @param restorePoint the restore point to create a backup for
114+
* @param vm The machine for which to create a backup
115+
* @param metric the metric object to update with the new backup data
117116
*/
118117
Backup createNewBackupEntryForRestorePoint(Backup.RestorePoint restorePoint, VirtualMachine vm, Backup.Metric metric);
119118
}

api/src/main/java/org/apache/cloudstack/vm/UnmanagedInstanceTO.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public enum PowerState {
3333

3434
private String internalCSName;
3535

36+
private String path;
37+
3638
private PowerState powerState;
3739

3840
private PowerState cloneSourcePowerState;
@@ -75,6 +77,14 @@ public void setInternalCSName(String internalCSName) {
7577
this.internalCSName = internalCSName;
7678
}
7779

80+
public String getPath() {
81+
return path;
82+
}
83+
84+
public void setPath(String path) {
85+
this.path = path;
86+
}
87+
7888
public PowerState getPowerState() {
7989
return powerState;
8090
}

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ protected void advanceExpunge(VMInstanceVO vm) throws ResourceUnavailableExcepti
707707

708708
private void handleUnsuccessfulExpungeOperation(List<Command> finalizeExpungeCommands, List<Command> nicExpungeCommands,
709709
VMInstanceVO vm, Long hostId) throws OperationTimedoutException, AgentUnavailableException {
710-
if (CollectionUtils.isNotEmpty(finalizeExpungeCommands) || CollectionUtils.isNotEmpty(nicExpungeCommands) && (hostId != null)) {
710+
if ((CollectionUtils.isNotEmpty(finalizeExpungeCommands) || CollectionUtils.isNotEmpty(nicExpungeCommands)) && hostId != null) {
711711
final Commands cmds = new Commands(Command.OnError.Stop);
712712
addAllExpungeCommandsFromList(finalizeExpungeCommands, cmds, vm);
713713
addAllExpungeCommandsFromList(nicExpungeCommands, cmds, vm);

engine/schema/src/main/java/com/cloud/usage/dao/UsageNetworksDaoImpl.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
// under the License.
1717
package com.cloud.usage.dao;
1818

19-
import com.cloud.network.Network;
2019
import com.cloud.usage.UsageNetworksVO;
2120
import com.cloud.utils.DateUtil;
2221
import com.cloud.utils.db.GenericDaoBase;
@@ -70,11 +69,10 @@ public void remove(long networkId, Date removed) {
7069
SearchCriteria<UsageNetworksVO> sc = this.createSearchCriteria();
7170
sc.addAnd("networkId", SearchCriteria.Op.EQ, networkId);
7271
sc.addAnd("removed", SearchCriteria.Op.NULL);
73-
UsageNetworksVO vo = findOneBy(sc);
74-
if (vo != null) {
75-
vo.setRemoved(removed);
76-
vo.setState(Network.State.Destroy.name());
77-
update(vo.getId(), vo);
72+
List<UsageNetworksVO> usageNetworksVOs = listBy(sc);
73+
for (UsageNetworksVO entry : usageNetworksVOs) {
74+
entry.setRemoved(removed);
75+
update(entry.getId(), entry);
7876
}
7977
} catch (final Exception e) {
8078
txn.rollback();

engine/schema/src/main/java/com/cloud/usage/dao/UsageVpcDaoImpl.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
// under the License.
1717
package com.cloud.usage.dao;
1818

19-
import com.cloud.network.vpc.Vpc;
2019
import com.cloud.usage.UsageVpcVO;
2120
import com.cloud.utils.DateUtil;
2221
import com.cloud.utils.db.GenericDaoBase;
@@ -64,11 +63,10 @@ public void remove(long vpcId, Date removed) {
6463
SearchCriteria<UsageVpcVO> sc = this.createSearchCriteria();
6564
sc.addAnd("vpcId", SearchCriteria.Op.EQ, vpcId);
6665
sc.addAnd("removed", SearchCriteria.Op.NULL);
67-
UsageVpcVO vo = findOneBy(sc);
68-
if (vo != null) {
69-
vo.setRemoved(removed);
70-
vo.setState(Vpc.State.Inactive.name());
71-
update(vo.getId(), vo);
66+
List<UsageVpcVO> usageVpcVOs = listBy(sc);
67+
for (UsageVpcVO entry : usageVpcVOs) {
68+
entry.setRemoved(removed);
69+
update(entry.getId(), entry);
7270
}
7371
} catch (final Exception e) {
7472
txn.rollback();

plugins/backup/dummy/src/main/java/org/apache/cloudstack/backup/DummyBackupProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public Backup createNewBackupEntryForRestorePoint(Backup.RestorePoint restorePoi
112112

113113
@Override
114114
public boolean removeVMFromBackupOffering(VirtualMachine vm) {
115-
logger.debug(String.format("Removing VM %s from backup offering by the Dummy Backup Provider", vm));
115+
logger.debug("Removing VM {} from backup offering by the Dummy Backup Provider", vm);
116116
return true;
117117
}
118118

@@ -123,15 +123,15 @@ public boolean willDeleteBackupsOnOfferingRemoval() {
123123

124124
@Override
125125
public Pair<Boolean, Backup> takeBackup(VirtualMachine vm) {
126-
logger.debug(String.format("Starting backup for VM %s on Dummy provider", vm));
126+
logger.debug("Starting backup for VM {} on Dummy provider", vm);
127127

128128
BackupVO backup = new BackupVO();
129129
backup.setVmId(vm.getId());
130130
backup.setExternalId("dummy-external-id");
131131
backup.setType("FULL");
132132
backup.setDate(new Date());
133133
backup.setSize(1024000L);
134-
backup.setProtectedSize(1 * Resource.ResourceType.bytesToGiB);
134+
backup.setProtectedSize(Resource.ResourceType.bytesToGiB);
135135
backup.setStatus(Backup.Status.BackedUp);
136136
backup.setBackupOfferingId(vm.getBackupOfferingId());
137137
backup.setAccountId(vm.getAccountId());

0 commit comments

Comments
 (0)