Skip to content

Commit 3ebe4cc

Browse files
authored
Merge branch 'apache:main' into main
2 parents 2b4c8c4 + ea643a6 commit 3ebe4cc

File tree

26 files changed

+908
-159
lines changed

26 files changed

+908
-159
lines changed

api/src/main/java/com/cloud/projects/ProjectService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public interface ProjectService {
5555
* - project id
5656
* @return true if the project was deleted successfully, false otherwise
5757
*/
58-
boolean deleteProject(long id);
58+
boolean deleteProject(long id, Boolean cleanup);
5959

6060
/**
6161
* Gets a project by id

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public class ApiConstants {
137137
public static final String IP6_DNS1 = "ip6dns1";
138138
public static final String IP6_DNS2 = "ip6dns2";
139139
public static final String DOMAIN = "domain";
140+
public static final String DOMAIN_DETAILS = "domaindetails";
140141
public static final String DOMAIN_PATH = "domainpath";
141142
public static final String DOMAIN_ID = "domainid";
142143
public static final String DOMAIN__ID = "domainId";

api/src/main/java/org/apache/cloudstack/api/command/user/project/DeleteProjectCmd.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public class DeleteProjectCmd extends BaseAsyncCmd {
4848
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = ProjectResponse.class, required = true, description = "id of the project to be deleted")
4949
private Long id;
5050

51+
@Parameter(name = ApiConstants.CLEANUP, type = CommandType.BOOLEAN, since = "4.16.0", description = "true if all project resources have to be cleaned up, false otherwise")
52+
private Boolean cleanup;
53+
5154
/////////////////////////////////////////////////////
5255
/////////////////// Accessors ///////////////////////
5356
/////////////////////////////////////////////////////
@@ -56,6 +59,10 @@ public Long geId() {
5659
return id;
5760
}
5861

62+
public Boolean isCleanup() {
63+
return cleanup;
64+
}
65+
5966
@Override
6067
public String getCommandName() {
6168
return s_name;
@@ -68,7 +75,7 @@ public String getCommandName() {
6875
@Override
6976
public void execute() {
7077
CallContext.current().setEventDetails("Project Id: " + id);
71-
boolean result = _projectService.deleteProject(id);
78+
boolean result = _projectService.deleteProject(id, isCleanup());
7279
if (result) {
7380
SuccessResponse response = new SuccessResponse(getCommandName());
7481
this.setResponseObject(response);

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.cloud.serializer.Param;
2727

2828
import java.util.Date;
29+
import java.util.Map;
2930

3031
@EntityReference(value = Domain.class)
3132
public class DomainResponse extends BaseResponseWithAnnotations implements ResourceLimitAndCountResponse, SetResourceIconResponse {
@@ -179,6 +180,10 @@ public class DomainResponse extends BaseResponseWithAnnotations implements Resou
179180
@Param(description = "Base64 string representation of the resource icon", since = "4.16.0.0")
180181
ResourceIconResponse icon;
181182

183+
@SerializedName(ApiConstants.DOMAIN_DETAILS)
184+
@Param(description = "details for the domain")
185+
private Map<String, String> details;
186+
182187
public String getId() {
183188
return this.id;
184189
}
@@ -438,4 +443,8 @@ public void setVmRunning(Integer vmRunning) {
438443
public void setResourceIconResponse(ResourceIconResponse icon) {
439444
this.icon = icon;
440445
}
446+
447+
public void setDetails(Map<String, String> details) {
448+
this.details = details;
449+
}
441450
}

engine/schema/src/main/java/com/cloud/domain/dao/DomainDetailsDaoImpl.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
import java.util.List;
2121
import java.util.Map;
2222

23+
import javax.inject.Inject;
24+
2325
import com.cloud.domain.DomainDetailVO;
26+
import com.cloud.domain.DomainVO;
2427
import com.cloud.utils.db.GenericDaoBase;
2528
import com.cloud.utils.db.QueryBuilder;
2629
import com.cloud.utils.db.SearchBuilder;
@@ -30,10 +33,16 @@
3033
import org.apache.cloudstack.framework.config.ConfigKey;
3134
import org.apache.cloudstack.framework.config.ConfigKey.Scope;
3235
import org.apache.cloudstack.framework.config.ScopedConfigStorage;
36+
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
3337

3438
public class DomainDetailsDaoImpl extends GenericDaoBase<DomainDetailVO, Long> implements DomainDetailsDao, ScopedConfigStorage {
3539
protected final SearchBuilder<DomainDetailVO> domainSearch;
3640

41+
@Inject
42+
protected DomainDao _domainDao;
43+
@Inject
44+
private ConfigurationDao _configDao;
45+
3746
protected DomainDetailsDaoImpl() {
3847
domainSearch = createSearchBuilder();
3948
domainSearch.and("domainId", domainSearch.entity().getDomainId(), Op.EQ);
@@ -98,7 +107,24 @@ public Scope getScope() {
98107

99108
@Override
100109
public String getConfigValue(long id, ConfigKey<?> key) {
101-
DomainDetailVO vo = findDetail(id, key.key());
110+
DomainDetailVO vo = null;
111+
String enableDomainSettingsForChildDomain = _configDao.getValue("enable.domain.settings.for.child.domain");
112+
if (!Boolean.parseBoolean(enableDomainSettingsForChildDomain)) {
113+
vo = findDetail(id, key.key());
114+
return vo == null ? null : vo.getValue();
115+
}
116+
DomainVO domain = _domainDao.findById(id);
117+
// if value is not configured in domain then check its parent domain till ROOT
118+
while (domain != null) {
119+
vo = findDetail(domain.getId(), key.key());
120+
if (vo != null) {
121+
break;
122+
} else if (domain.getParent() != null) {
123+
domain = _domainDao.findById(domain.getParent());
124+
} else {
125+
break;
126+
}
127+
}
102128
return vo == null ? null : vo.getValue();
103129
}
104130
}

engine/schema/src/main/java/com/cloud/host/dao/HostDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
8585
+ "GROUP BY host_id "
8686
+ "HAVING tag_count = %s ";
8787
private static final String SEPARATOR = ",";
88-
private static final String LIST_CLUSTERID_FOR_HOST_TAG = "select distinct cluster_id from host join host_tags on host.id = host_tags.host_id and host_tags.tag = ?";
88+
private static final String LIST_CLUSTERID_FOR_HOST_TAG = "select distinct cluster_id from host join ( %s ) AS selected_hosts ON host.id = selected_hosts.host_id";
8989
private static final String GET_HOSTS_OF_ACTIVE_VMS = "select h.id " +
9090
"from vm_instance vm " +
9191
"join host h on (vm.host_id=h.id) " +

engine/schema/src/main/java/com/cloud/user/AccountDetailsDaoImpl.java

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,40 @@
1919
import java.util.HashMap;
2020
import java.util.List;
2121
import java.util.Map;
22+
import java.util.Optional;
2223

24+
import javax.inject.Inject;
2325

2426
import org.apache.cloudstack.framework.config.ConfigKey;
2527
import org.apache.cloudstack.framework.config.ConfigKey.Scope;
2628
import org.apache.cloudstack.framework.config.ScopedConfigStorage;
2729

30+
import com.cloud.domain.DomainDetailVO;
31+
import com.cloud.domain.DomainVO;
32+
import com.cloud.domain.dao.DomainDetailsDao;
33+
import com.cloud.domain.dao.DomainDao;
34+
import com.cloud.user.dao.AccountDao;
35+
2836
import com.cloud.utils.db.GenericDaoBase;
2937
import com.cloud.utils.db.QueryBuilder;
3038
import com.cloud.utils.db.SearchBuilder;
3139
import com.cloud.utils.db.SearchCriteria;
3240
import com.cloud.utils.db.SearchCriteria.Op;
3341
import com.cloud.utils.db.TransactionLegacy;
42+
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
3443

3544
public class AccountDetailsDaoImpl extends GenericDaoBase<AccountDetailVO, Long> implements AccountDetailsDao, ScopedConfigStorage {
3645
protected final SearchBuilder<AccountDetailVO> accountSearch;
3746

47+
@Inject
48+
protected AccountDao _accountDao;
49+
@Inject
50+
protected DomainDao _domainDao;
51+
@Inject
52+
protected DomainDetailsDao _domainDetailsDao;
53+
@Inject
54+
private ConfigurationDao _configDao;
55+
3856
protected AccountDetailsDaoImpl() {
3957
accountSearch = createSearchBuilder();
4058
accountSearch.and("accountId", accountSearch.entity().getAccountId(), Op.EQ);
@@ -99,7 +117,39 @@ public Scope getScope() {
99117

100118
@Override
101119
public String getConfigValue(long id, ConfigKey<?> key) {
120+
// check if account level setting is configured
102121
AccountDetailVO vo = findDetail(id, key.key());
103-
return vo == null ? null : vo.getValue();
122+
String value = vo == null ? null : vo.getValue();
123+
if (value != null) {
124+
return value;
125+
}
126+
127+
// if account level setting is not configured then check if
128+
// we can take value from domain
129+
String enableAccountSettingsForDomain = _configDao.getValue("enable.account.settings.for.domain");
130+
if (! Boolean.parseBoolean(enableAccountSettingsForDomain)) {
131+
return null;
132+
}
133+
134+
// check if we can traverse till ROOT domain to get the value
135+
String enableDomainSettingsForChildDomain = _configDao.getValue("enable.domain.settings.for.child.domain");
136+
if (Boolean.parseBoolean(enableDomainSettingsForChildDomain)) {
137+
Optional<AccountVO> account = Optional.ofNullable(_accountDao.findById(id));
138+
if (account.isPresent()) {
139+
DomainVO domain = _domainDao.findById(account.get().getDomainId());
140+
while (domain != null) {
141+
DomainDetailVO domainVO = _domainDetailsDao.findDetail(domain.getId(), key.key());
142+
if (domainVO != null) {
143+
value = domainVO.getValue();
144+
break;
145+
} else if (domain.getParent() != null) {
146+
domain = _domainDao.findById(domain.getParent());
147+
} else {
148+
break;
149+
}
150+
}
151+
}
152+
}
153+
return value;
104154
}
105155
}

framework/config/src/main/java/org/apache/cloudstack/framework/config/ConfigKey.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,19 @@ public T valueIn(Long id) {
160160
}
161161
}
162162

163+
public T valueInDomain(Long domainId) {
164+
if (domainId == null) {
165+
return value();
166+
}
167+
168+
String value = s_depot != null ? s_depot.getDomainScope(this).getConfigValue(domainId, this) : null;
169+
if (value == null) {
170+
return value();
171+
} else {
172+
return valueOf(value);
173+
}
174+
}
175+
163176
@SuppressWarnings("unchecked")
164177
protected T valueOf(String value) {
165178
Number multiplier = 1;

framework/config/src/main/java/org/apache/cloudstack/framework/config/impl/ConfigDepotImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,16 @@ public ScopedConfigStorage findScopedConfigStorage(ConfigKey<?> config) {
186186
throw new CloudRuntimeException("Unable to find config storage for this scope: " + config.scope() + " for " + config.key());
187187
}
188188

189+
public ScopedConfigStorage getDomainScope(ConfigKey<?> config) {
190+
for (ScopedConfigStorage storage : _scopedStorages) {
191+
if (storage.getScope() == ConfigKey.Scope.Domain) {
192+
return storage;
193+
}
194+
}
195+
196+
throw new CloudRuntimeException("Unable to find config storage for this scope: " + ConfigKey.Scope.Domain + " for " + config.key());
197+
}
198+
189199
public List<ScopedConfigStorage> getScopedStorages() {
190200
return _scopedStorages;
191201
}

plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,6 +1956,9 @@ protected void setVmBootDetails(final VM vm, final Connection conn, String bootT
19561956
if (!ApiConstants.BootType.UEFI.toString().equals(bootType)) {
19571957
bootType = ApiConstants.BootType.BIOS.toString();
19581958
}
1959+
if (s_logger.isDebugEnabled()) {
1960+
s_logger.debug(String.format("Setting boottype=%s and bootmode=%s for VM: %s", bootType, bootMode, vm.getUuid(conn)));
1961+
}
19591962
Boolean isSecure = bootType.equals(ApiConstants.BootType.UEFI.toString()) &&
19601963
ApiConstants.BootMode.SECURE.toString().equals(bootMode);
19611964
final Map<String, String> bootParams = vm.getHVMBootParams(conn);

0 commit comments

Comments
 (0)