Skip to content

Commit eb4b132

Browse files
committed
Addressed last set of review comments from Wei.
1 parent 1241252 commit eb4b132

File tree

11 files changed

+30
-25
lines changed

11 files changed

+30
-25
lines changed

api/src/main/java/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityG
151151
@Parameter(name = ApiConstants.DATADISKS_DETAILS,
152152
type = CommandType.MAP,
153153
since = "4.21.0",
154-
description = "Disk offering details for creating multiple data volumes. Mutually exclusibe with diskOfferingId." +
155-
" Example: datadisksdetails[0].diskofferingid=1&datadisksdetails[0].size=10&datadisksdetails[0].miniops=100&datadisksdetails[0].maxiops=200")
154+
description = "Disk offering details for creating multiple data volumes. Mutually exclusive with diskOfferingId." +
155+
" Example: datadisksdetails[0].diskofferingid=a2a73a84-19db-4852-8930-dfddef053341&datadisksdetails[0].size=10&datadisksdetails[0].miniops=100&datadisksdetails[0].maxiops=200")
156156
private Map dataDisksDetails;
157157

158158
@Parameter(name = ApiConstants.GROUP, type = CommandType.STRING, description = "an optional group for the virtual machine")

api/src/main/java/org/apache/cloudstack/api/response/ObjectStoreResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class ObjectStoreResponse extends BaseResponseWithAnnotations {
4747
private Long storageTotal;
4848

4949
@SerializedName("storageallocated")
50-
@Param(description = "the object store currently allocated size")
50+
@Param(description = "the allocated size of the object store")
5151
private Long storageAllocated;
5252

5353
@SerializedName("storageused")

engine/components-api/src/main/java/com/cloud/storage/StorageManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public interface StorageManager extends StorageService {
221221
"Number of worker threads to be used to connect hosts to a primary storage", true);
222222

223223
ConfigKey<Float> ObjectStorageCapacityThreshold = new ConfigKey<>("Alert", Float.class,
224-
"zone.objectStorage.capacity.notificationthreshold",
224+
"objectStorage.capacity.notificationthreshold",
225225
"0.75",
226226
"Percentage (as a value between 0 and 1) of object storage utilization above which alerts will be sent about low storage available.",
227227
true,

engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,5 @@ List<VMInstanceVO> searchRemovedByRemoveDate(final Date startDate, final Date en
187187

188188
Map<String, Long> getNameIdMapForVmIds(Collection<Long> ids);
189189

190-
List<VMInstanceVO> listByIds(List<Long> ids);
190+
List<VMInstanceVO> listByIdsIncludingRemoved(List<Long> ids);
191191
}

engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ public Map<String, Long> getNameIdMapForVmIds(Collection<Long> ids) {
12261226
}
12271227

12281228
@Override
1229-
public List<VMInstanceVO> listByIds(List<Long> ids) {
1229+
public List<VMInstanceVO> listByIdsIncludingRemoved(List<Long> ids) {
12301230
SearchBuilder<VMInstanceVO> idsSearch = createSearchBuilder();
12311231
idsSearch.and("ids", idsSearch.entity().getId(), SearchCriteria.Op.IN);
12321232
idsSearch.done();

engine/schema/src/main/java/org/apache/cloudstack/backup/BackupDetailVO.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class BackupDetailVO implements ResourceDetail {
3939
@Column(name = "name")
4040
private String name;
4141

42-
@Column(name = "value", length = 1024)
42+
@Column(name = "value", length = 65536)
4343
private String value;
4444

4545
@Column(name = "display")
@@ -48,8 +48,8 @@ public class BackupDetailVO implements ResourceDetail {
4848
public BackupDetailVO() {
4949
}
5050

51-
public BackupDetailVO(long templateId, String name, String value, boolean display) {
52-
this.resourceId = templateId;
51+
public BackupDetailVO(long backupId, String name, String value, boolean display) {
52+
this.resourceId = backupId;
5353
this.name = name;
5454
this.value = value;
5555
this.display = display;

engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupDaoImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public BackupVO persist(BackupVO backup) {
210210
public boolean update(Long id, BackupVO backup) {
211211
return Transaction.execute((TransactionCallback<Boolean>) status -> {
212212
boolean result = super.update(id, backup);
213-
if (result == true) {
213+
if (result) {
214214
saveDetails(backup);
215215
}
216216
return result;
@@ -295,7 +295,7 @@ public BackupResponse newBackupResponse(Backup backup, Boolean listVmDetails) {
295295
if (vm.getState() != VirtualMachine.State.Expunging) {
296296
response.setVmId(vm.getUuid());
297297
}
298-
if (vm.getBackupOfferingId() != backup.getBackupOfferingId()) {
298+
if (vm.getBackupOfferingId() == null || vm.getBackupOfferingId() != backup.getBackupOfferingId()) {
299299
response.setVmOfferingRemoved(true);
300300
}
301301
response.setExternalId(backup.getExternalId());

engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ AND NOT EXISTS(SELECT 1 FROM cloud.role_permissions rp_ WHERE rp.role_id = rp_.r
3535
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.host', 'last_mgmt_server_id', 'bigint unsigned DEFAULT NULL COMMENT "last management server this host is connected to" AFTER `mgmt_server_id`');
3636

3737
-- Add column max_backup to backup_schedule table
38-
ALTER TABLE `cloud`.`backup_schedule` ADD COLUMN `max_backups` int(8) default NULL COMMENT 'maximum number of backups to maintain';
38+
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.backup_schedule', 'max_backups', 'int(8) default NULL COMMENT "maximum number of backups to maintain"');
3939

4040
-- Add columns name, description and backup_interval_type to backup table
4141
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.backups', 'name', 'VARCHAR(255) NOT NULL COMMENT "name of the backup"');
@@ -50,7 +50,7 @@ CREATE TABLE `cloud`.`backup_details` (
5050
`id` bigint unsigned NOT NULL auto_increment,
5151
`backup_id` bigint unsigned NOT NULL COMMENT 'backup id',
5252
`name` varchar(255) NOT NULL,
53-
`value` varchar(1024) NOT NULL,
53+
`value` varchar(65536) NOT NULL,
5454
`display` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should detail be displayed to the end user',
5555
PRIMARY KEY (`id`),
5656
CONSTRAINT `fk_backup_details__backup_id` FOREIGN KEY `fk_backup_details__backup_id`(`backup_id`) REFERENCES `backups`(`id`) ON DELETE CASCADE

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import com.cloud.storage.dao.VolumeDao;
2828

2929
import org.apache.cloudstack.backup.dao.BackupDao;
30-
import org.apache.logging.log4j.LogManager;
31-
import org.apache.logging.log4j.Logger;
3230

3331
import com.cloud.utils.Pair;
3432
import com.cloud.utils.component.AdapterBase;
@@ -37,8 +35,6 @@
3735
import com.cloud.vm.VirtualMachine;
3836

3937
public class DummyBackupProvider extends AdapterBase implements BackupProvider {
40-
private static final Logger LOG = LogManager.getLogger(DummyBackupProvider.class);
41-
4238
@Inject
4339
private BackupDao backupDao;
4440
@Inject

plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/veeam/VeeamClient.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,10 @@ protected Map<String, Backup.Metric> processHttpResponseForBackupMetrics(final I
716716
throw new CloudRuntimeException("Could not get backup metrics via Veeam B&R API");
717717
}
718718
for (final BackupFile backupFile : backupFiles.getBackupFiles()) {
719-
String backupFileId = backupFile.getUid().substring(backupFile.getUid().lastIndexOf(':') + 1);
719+
String backupFileId = StringUtils.substringAfterLast(backupFile.getUid(), ":");
720+
if (backupFileId.isEmpty()) {
721+
continue;
722+
}
720723
Long backupSize = null;
721724
Long dataSize = null;
722725
if (backupFile.getBackupSize() != null) {
@@ -795,7 +798,13 @@ private Backup.RestorePoint getRestorePointFromBlock(String[] parts, Map<String,
795798
}
796799
}
797800
Backup.Metric metric = metricsMap.get(id);
798-
return new Backup.RestorePoint(id, created, type, metric.getBackupSize(), metric.getDataSize());
801+
Long backupSize = null;
802+
Long dataSize = null;
803+
if (metric != null) {
804+
backupSize = metric.getBackupSize();
805+
dataSize = metric.getDataSize();
806+
}
807+
return new Backup.RestorePoint(id, created, type, backupSize, dataSize);
799808
}
800809

801810
public List<Backup.RestorePoint> listRestorePointsLegacy(String backupName, String vmInternalName, Map<String, Backup.Metric> metricsMap) {
@@ -849,7 +858,7 @@ public List<Backup.RestorePoint> processHttpResponseForVmRestorePoints(InputStre
849858
final ObjectMapper objectMapper = new XmlMapper();
850859
final VmRestorePoints vmRestorePoints = objectMapper.readValue(content, VmRestorePoints.class);
851860
final String hierarchyId = findDCHierarchy(vmwareDcName);
852-
final String hierarchyUuid = hierarchyId.substring(hierarchyId.lastIndexOf(":") + 1);
861+
final String hierarchyUuid = StringUtils.substringAfterLast(hierarchyId, ":");
853862
if (vmRestorePoints == null) {
854863
throw new CloudRuntimeException("Could not get VM restore points via Veeam B&R API");
855864
}
@@ -860,7 +869,7 @@ public List<Backup.RestorePoint> processHttpResponseForVmRestorePoints(InputStre
860869
continue;
861870
}
862871
boolean isReady = true;
863-
String backupFileId = null;
872+
String backupFileId = "";
864873
List<Link> links = vmRestorePoint.getLink();
865874
for (Link link : links) {
866875
if (Arrays.asList(BACKUP_FILE_REFERENCE, RESTORE_POINT_REFERENCE).contains(link.getType()) && !link.getRel().equals("Up")) {
@@ -869,19 +878,19 @@ public List<Backup.RestorePoint> processHttpResponseForVmRestorePoints(InputStre
869878
break;
870879
}
871880
if (link.getType() != null && link.getType().equals(BACKUP_FILE_REFERENCE)) {
872-
backupFileId = link.getHref().substring(link.getHref().lastIndexOf('/') + 1);
881+
backupFileId = StringUtils.substringAfterLast(link.getHref(), "/");
873882
}
874883
}
875884
if (!isReady) {
876885
continue;
877886
}
878-
String vmRestorePointId = vmRestorePoint.getUid().substring(vmRestorePoint.getUid().lastIndexOf(':') + 1);
887+
String vmRestorePointId = StringUtils.substringAfterLast(vmRestorePoint.getUid(), ":");
879888
Date created = formatDate(vmRestorePoint.getCreationTimeUtc());
880889
String type = vmRestorePoint.getPointType();
881890
logger.debug(String.format("Adding restore point %s, %s, %s", vmRestorePointId, created, type));
882891
Long backupSize = null;
883892
Long dataSize = null;
884-
if (backupFileId != null) {
893+
if (!backupFileId.isEmpty()) {
885894
Backup.Metric metric = metricsMap.get(backupFileId);
886895
if (metric != null) {
887896
backupSize = metric.getBackupSize();

0 commit comments

Comments
 (0)