Skip to content

Commit eedd329

Browse files
committed
Merge remote-tracking branch 'apache/4.22'
2 parents c465caf + 425c4e3 commit eedd329

File tree

15 files changed

+145
-36
lines changed

15 files changed

+145
-36
lines changed

api/src/main/java/org/apache/cloudstack/api/command/user/backup/repository/AddBackupRepositoryCmd.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.apache.cloudstack.api.command.user.backup.repository;
1919

20+
import com.cloud.utils.StringUtils;
2021
import org.apache.cloudstack.acl.RoleType;
2122
import org.apache.cloudstack.api.APICommand;
2223
import org.apache.cloudstack.api.ApiConstants;
@@ -100,7 +101,7 @@ public String getProvider() {
100101
}
101102

102103
public String getMountOptions() {
103-
return mountOptions == null ? "" : mountOptions;
104+
return StringUtils.isBlank(mountOptions) ? "" : mountOptions;
104105
}
105106

106107
public Long getZoneId() {

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public class BackupRepositoryResponse extends BaseResponse {
5757
@Param(description = "backup type")
5858
private String type;
5959

60+
@SerializedName(ApiConstants.MOUNT_OPTIONS)
61+
@Param(description = "mount options", since = "4.22.1")
62+
private String mountOptions;
63+
6064
@SerializedName(ApiConstants.CAPACITY_BYTES)
6165
@Param(description = "capacity of the backup repository")
6266
private Long capacityBytes;
@@ -128,6 +132,14 @@ public void setType(String type) {
128132
this.type = type;
129133
}
130134

135+
public String getMountOptions() {
136+
return mountOptions;
137+
}
138+
139+
public void setMountOptions(String mountOptions) {
140+
this.mountOptions = mountOptions;
141+
}
142+
131143
public Long getCapacityBytes() {
132144
return capacityBytes;
133145
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ public interface BackupRepositoryService {
3232
BackupRepository updateBackupRepository(UpdateBackupRepositoryCmd cmd);
3333
boolean deleteBackupRepository(DeleteBackupRepositoryCmd cmd);
3434
Pair<List<BackupRepository>, Integer> listBackupRepositories(ListBackupRepositoriesCmd cmd);
35-
3635
}

core/src/main/java/com/cloud/storage/template/HttpTemplateDownloader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private void checkCredentials(String user, String password) {
151151
client.getParams().setAuthenticationPreemptive(true);
152152
Credentials defaultcreds = new UsernamePasswordCredentials(user, password);
153153
client.getState().setCredentials(new AuthScope(hostAndPort.first(), hostAndPort.second(), AuthScope.ANY_REALM), defaultcreds);
154-
logger.info("Added username=" + user + ", password=" + password + "for host " + hostAndPort.first() + ":" + hostAndPort.second());
154+
logger.info("Added username={}, password=****** for host {}:{}", user, hostAndPort.first(), hostAndPort.second());
155155
} else {
156156
logger.info("No credentials configured for host=" + hostAndPort.first() + ":" + hostAndPort.second());
157157
}

engine/schema/src/main/java/com/cloud/storage/dao/VolumeDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,7 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.S
163163

164164
VolumeVO findOneByIScsiName(String iScsiName);
165165

166+
int getVolumeCountByOfferingId(long diskOfferingId);
167+
166168
VolumeVO findByLastIdAndState(long lastVolumeId, Volume.State...states);
167169
}

engine/schema/src/main/java/com/cloud/storage/dao/VolumeDaoImpl.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
7878
protected GenericSearchBuilder<VolumeVO, SumCount> primaryStorageSearch2;
7979
protected GenericSearchBuilder<VolumeVO, SumCount> secondaryStorageSearch;
8080
private final SearchBuilder<VolumeVO> poolAndPathSearch;
81+
final GenericSearchBuilder<VolumeVO, Integer> CountByOfferingId;
8182

8283
@Inject
8384
ReservationDao reservationDao;
@@ -506,6 +507,11 @@ public VolumeDaoImpl() {
506507
poolAndPathSearch.and("poolId", poolAndPathSearch.entity().getPoolId(), Op.EQ);
507508
poolAndPathSearch.and("path", poolAndPathSearch.entity().getPath(), Op.EQ);
508509
poolAndPathSearch.done();
510+
511+
CountByOfferingId = createSearchBuilder(Integer.class);
512+
CountByOfferingId.select(null, Func.COUNT, CountByOfferingId.entity().getId());
513+
CountByOfferingId.and("diskOfferingId", CountByOfferingId.entity().getDiskOfferingId(), Op.EQ);
514+
CountByOfferingId.done();
509515
}
510516

511517
@Override
@@ -914,6 +920,14 @@ public VolumeVO findOneByIScsiName(String iScsiName) {
914920
return findOneIncludingRemovedBy(sc);
915921
}
916922

923+
@Override
924+
public int getVolumeCountByOfferingId(long diskOfferingId) {
925+
SearchCriteria<Integer> sc = CountByOfferingId.create();
926+
sc.setParameters("diskOfferingId", diskOfferingId);
927+
List<Integer> results = customSearch(sc, null);
928+
return results.get(0);
929+
}
930+
917931
@Override
918932
public VolumeVO findByLastIdAndState(long lastVolumeId, State ...states) {
919933
QueryBuilder<VolumeVO> sc = QueryBuilder.create(VolumeVO.class);

engine/schema/src/main/java/com/cloud/upgrade/DatabaseCreator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private static void initDB(String dbPropsFile, String rootPassword, String[] dat
9999
String username = dbProperties.getProperty(String.format("db.%s.username", database));
100100
String password = dbProperties.getProperty(String.format("db.%s.password", database));
101101
String dbName = dbProperties.getProperty(String.format("db.%s.name", database));
102-
System.out.println(String.format("========> Initializing database=%s with host=%s port=%s username=%s password=%s", dbName, host, port, username, password));
102+
System.out.println(String.format("========> Initializing database=%s with host=%s port=%s username=%s password=******", dbName, host, port, username));
103103

104104
List<String> queries = new ArrayList<String>();
105105
queries.add(String.format("drop database if exists `%s`", dbName));

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,9 @@ List<VMInstanceVO> searchRemovedByRemoveDate(final Date startDate, final Date en
187187

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

190+
int getVmCountByOfferingId(Long serviceOfferingId);
191+
192+
int getVmCountByOfferingNotInDomain(Long serviceOfferingId, List<Long> domainIds);
193+
190194
List<VMInstanceVO> listByIdsIncludingRemoved(List<Long> ids);
191195
}

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
104104
protected SearchBuilder<VMInstanceVO> LastHostAndStatesSearch;
105105
protected SearchBuilder<VMInstanceVO> VmsNotInClusterUsingPool;
106106
protected SearchBuilder<VMInstanceVO> IdsPowerStateSelectSearch;
107+
GenericSearchBuilder<VMInstanceVO, Integer> CountByOfferingId;
108+
GenericSearchBuilder<VMInstanceVO, Integer> CountUserVmNotInDomain;
107109

108110
@Inject
109111
ResourceTagDao tagsDao;
@@ -354,6 +356,18 @@ protected void init() {
354356
IdsPowerStateSelectSearch.entity().getPowerStateUpdateCount(),
355357
IdsPowerStateSelectSearch.entity().getPowerStateUpdateTime());
356358
IdsPowerStateSelectSearch.done();
359+
360+
CountByOfferingId = createSearchBuilder(Integer.class);
361+
CountByOfferingId.select(null, Func.COUNT, CountByOfferingId.entity().getId());
362+
CountByOfferingId.and("serviceOfferingId", CountByOfferingId.entity().getServiceOfferingId(), Op.EQ);
363+
CountByOfferingId.done();
364+
365+
CountUserVmNotInDomain = createSearchBuilder(Integer.class);
366+
CountUserVmNotInDomain.select(null, Func.COUNT, CountUserVmNotInDomain.entity().getId());
367+
CountUserVmNotInDomain.and("serviceOfferingId", CountUserVmNotInDomain.entity().getServiceOfferingId(), Op.EQ);
368+
CountUserVmNotInDomain.and("domainIdsNotIn", CountUserVmNotInDomain.entity().getDomainId(), Op.NIN);
369+
CountUserVmNotInDomain.done();
370+
357371
}
358372

359373
@Override
@@ -1247,6 +1261,29 @@ public Map<String, Long> getNameIdMapForVmIds(Collection<Long> ids) {
12471261
.collect(Collectors.toMap(VMInstanceVO::getInstanceName, VMInstanceVO::getId));
12481262
}
12491263

1264+
@Override
1265+
public int getVmCountByOfferingId(Long serviceOfferingId) {
1266+
if (serviceOfferingId == null) {
1267+
return 0;
1268+
}
1269+
SearchCriteria<Integer> sc = CountByOfferingId.create();
1270+
sc.setParameters("serviceOfferingId", serviceOfferingId);
1271+
List<Integer> count = customSearch(sc, null);
1272+
return count.get(0);
1273+
}
1274+
1275+
@Override
1276+
public int getVmCountByOfferingNotInDomain(Long serviceOfferingId, List<Long> domainIds) {
1277+
if (serviceOfferingId == null || CollectionUtils.isEmpty(domainIds)) {
1278+
return 0;
1279+
}
1280+
SearchCriteria<Integer> sc = CountUserVmNotInDomain.create();
1281+
sc.setParameters("serviceOfferingId", serviceOfferingId);
1282+
sc.setParameters("domainIdsNotIn", domainIds.toArray());
1283+
List<Integer> count = customSearch(sc, null);
1284+
return count.get(0);
1285+
}
1286+
12501287
@Override
12511288
public List<VMInstanceVO> listByIdsIncludingRemoved(List<Long> ids) {
12521289
SearchBuilder<VMInstanceVO> idsSearch = createSearchBuilder();

server/src/main/java/com/cloud/api/ApiResponseHelper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5530,6 +5530,9 @@ public BackupRepositoryResponse createBackupRepositoryResponse(BackupRepository
55305530
response.setAddress(backupRepository.getAddress());
55315531
response.setProviderName(backupRepository.getProvider());
55325532
response.setType(backupRepository.getType());
5533+
if (StringUtils.isNotBlank(backupRepository.getMountOptions())) {
5534+
response.setMountOptions(backupRepository.getMountOptions());
5535+
}
55335536
response.setCapacityBytes(backupRepository.getCapacityBytes());
55345537
response.setCrossZoneInstanceCreation(backupRepository.crossZoneInstanceCreationEnabled());
55355538
response.setObjectName("backuprepository");

0 commit comments

Comments
 (0)