Skip to content

Commit 373f017

Browse files
committed
Merge branch '4.19'
2 parents a9caee3 + 050ee44 commit 373f017

File tree

53 files changed

+1007
-441
lines changed

Some content is hidden

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

53 files changed

+1007
-441
lines changed

api/src/main/java/com/cloud/network/VpcVirtualNetworkApplianceService.java

+20-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public interface VpcVirtualNetworkApplianceService extends VirtualNetworkApplian
2929
/**
3030
* @param router
3131
* @param network
32-
* @param isRedundant
3332
* @param params TODO
3433
* @return
3534
* @throws ConcurrentOperationException
@@ -42,11 +41,30 @@ boolean addVpcRouterToGuestNetwork(VirtualRouter router, Network network, Map<Vi
4241
/**
4342
* @param router
4443
* @param network
45-
* @param isRedundant
4644
* @return
4745
* @throws ConcurrentOperationException
4846
* @throws ResourceUnavailableException
4947
*/
5048
boolean removeVpcRouterFromGuestNetwork(VirtualRouter router, Network network) throws ConcurrentOperationException, ResourceUnavailableException;
5149

50+
51+
/**
52+
* @param router
53+
* @param network
54+
* @return
55+
* @throws ConcurrentOperationException
56+
* @throws ResourceUnavailableException
57+
*/
58+
boolean stopKeepAlivedOnRouter(VirtualRouter router, Network network) throws ConcurrentOperationException, ResourceUnavailableException;
59+
60+
61+
/**
62+
* @param router
63+
* @param network
64+
* @return
65+
* @throws ConcurrentOperationException
66+
* @throws ResourceUnavailableException
67+
*/
68+
boolean startKeepAlivedOnRouter(VirtualRouter router, Network network) throws ConcurrentOperationException, ResourceUnavailableException;
69+
5270
}

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

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.apache.cloudstack.api.command.admin.storage.DeleteSecondaryStagingStoreCmd;
3030
import org.apache.cloudstack.api.command.admin.storage.SyncStoragePoolCmd;
3131
import org.apache.cloudstack.api.command.admin.storage.UpdateObjectStoragePoolCmd;
32+
import org.apache.cloudstack.api.command.admin.storage.UpdateImageStoreCmd;
3233
import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
3334

3435
import com.cloud.exception.DiscoveryException;
@@ -110,6 +111,8 @@ public interface StorageService {
110111
*/
111112
ImageStore migrateToObjectStore(String name, String url, String providerName, Map<String, String> details) throws DiscoveryException;
112113

114+
ImageStore updateImageStore(UpdateImageStoreCmd cmd);
115+
113116
ImageStore updateImageStoreStatus(Long id, Boolean readonly);
114117

115118
void updateStorageCapabilities(Long poolId, boolean failOnChecks);

api/src/main/java/org/apache/cloudstack/api/command/admin/storage/UpdateImageStoreCmd.java

+18-3
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,17 @@ public class UpdateImageStoreCmd extends BaseCmd {
3939
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = ImageStoreResponse.class, required = true, description = "Image Store UUID")
4040
private Long id;
4141

42-
@Parameter(name = ApiConstants.READ_ONLY, type = CommandType.BOOLEAN, required = true, description = "If set to true, it designates the corresponding image store to read-only, " +
43-
"hence not considering them during storage migration")
42+
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = false, description = "The new name for the Image Store.")
43+
private String name;
44+
45+
@Parameter(name = ApiConstants.READ_ONLY, type = CommandType.BOOLEAN, required = false,
46+
description = "If set to true, it designates the corresponding image store to read-only, hence not considering them during storage migration")
4447
private Boolean readonly;
4548

49+
@Parameter(name = ApiConstants.CAPACITY_BYTES, type = CommandType.LONG, required = false,
50+
description = "The number of bytes CloudStack can use on this image storage.\n\tNOTE: this will be overwritten by the StatsCollector as soon as there is a SSVM to query the storage.")
51+
private Long capacityBytes;
52+
4653
/////////////////////////////////////////////////////
4754
/////////////////// Accessors ///////////////////////
4855
/////////////////////////////////////////////////////
@@ -51,17 +58,25 @@ public Long getId() {
5158
return id;
5259
}
5360

61+
public String getName() {
62+
return name;
63+
}
64+
5465
public Boolean getReadonly() {
5566
return readonly;
5667
}
5768

69+
public Long getCapacityBytes() {
70+
return capacityBytes;
71+
}
72+
5873
/////////////////////////////////////////////////////
5974
/////////////// API Implementation///////////////////
6075
/////////////////////////////////////////////////////
6176

6277
@Override
6378
public void execute() {
64-
ImageStore result = _storageService.updateImageStoreStatus(getId(), getReadonly());
79+
ImageStore result = _storageService.updateImageStore(this);
6580
ImageStoreResponse storeResponse = null;
6681
if (result != null) {
6782
storeResponse = _responseGenerator.createImageStoreResponse(result);

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,39 @@
2727

2828
@EntityReference(value = ImageStore.class)
2929
public class ImageStoreResponse extends BaseResponseWithAnnotations {
30-
@SerializedName("id")
30+
@SerializedName(ApiConstants.ID)
3131
@Param(description = "the ID of the image store")
3232
private String id;
3333

34-
@SerializedName("zoneid")
34+
@SerializedName(ApiConstants.ZONE_ID)
3535
@Param(description = "the Zone ID of the image store")
3636
private String zoneId;
3737

3838
@SerializedName(ApiConstants.ZONE_NAME)
3939
@Param(description = "the Zone name of the image store")
4040
private String zoneName;
4141

42-
@SerializedName("name")
42+
@SerializedName(ApiConstants.NAME)
4343
@Param(description = "the name of the image store")
4444
private String name;
4545

46-
@SerializedName("url")
46+
@SerializedName(ApiConstants.URL)
4747
@Param(description = "the url of the image store")
4848
private String url;
4949

50-
@SerializedName("protocol")
50+
@SerializedName(ApiConstants.PROTOCOL)
5151
@Param(description = "the protocol of the image store")
5252
private String protocol;
5353

5454
@SerializedName("providername")
5555
@Param(description = "the provider name of the image store")
5656
private String providerName;
5757

58-
@SerializedName("scope")
58+
@SerializedName(ApiConstants.SCOPE)
5959
@Param(description = "the scope of the image store")
6060
private ScopeType scope;
6161

62-
@SerializedName("readonly")
62+
@SerializedName(ApiConstants.READ_ONLY)
6363
@Param(description = "defines if store is read-only")
6464
private Boolean readonly;
6565

core/src/main/java/com/cloud/agent/resource/virtualnetwork/VRScripts.java

+1
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,5 @@ public class VRScripts {
8181
public static final String VR_UPDATE_INTERFACE_CONFIG = "update_interface_config.sh";
8282

8383
public static final String ROUTER_FILESYSTEM_WRITABLE_CHECK = "filesystem_writable_check.py";
84+
public static final String MANAGE_SERVICE = "manage_service.sh";
8485
}

core/src/main/java/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java

+19
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import javax.naming.ConfigurationException;
3636

37+
import org.apache.cloudstack.agent.routing.ManageServiceCommand;
3738
import com.cloud.agent.api.routing.UpdateNetworkCommand;
3839
import com.cloud.agent.api.to.IpAddressTO;
3940
import com.cloud.network.router.VirtualRouter;
@@ -144,6 +145,10 @@ public Answer executeRequest(final NetworkElementCommand cmd) {
144145
return execute((UpdateNetworkCommand) cmd);
145146
}
146147

148+
if (cmd instanceof ManageServiceCommand) {
149+
return execute((ManageServiceCommand) cmd);
150+
}
151+
147152
if (_vrAggregateCommandsSet.containsKey(routerName)) {
148153
_vrAggregateCommandsSet.get(routerName).add(cmd);
149154
aggregated = true;
@@ -271,6 +276,20 @@ private Answer execute(UpdateNetworkCommand cmd) {
271276
return new Answer(cmd, new CloudRuntimeException("Failed to update interface mtu"));
272277
}
273278

279+
private Answer execute(ManageServiceCommand cmd) {
280+
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
281+
String args = cmd.getAction() + " " + cmd.getServiceName();
282+
ExecutionResult result = _vrDeployer.executeInVR(routerIp, VRScripts.MANAGE_SERVICE, args);
283+
if (result.isSuccess()) {
284+
return new Answer(cmd, true,
285+
String.format("Successfully executed action: %s on service: %s. Details: %s",
286+
cmd.getAction(), cmd.getServiceName(), result.getDetails()));
287+
} else {
288+
return new Answer(cmd, false, String.format("Failed to execute action: %s on service: %s. Details: %s",
289+
cmd.getAction(), cmd.getServiceName(), result.getDetails()));
290+
}
291+
}
292+
274293
private ExecutionResult applyConfigToVR(String routerAccessIp, ConfigItem c) {
275294
return applyConfigToVR(routerAccessIp, c, VRScripts.VR_SCRIPT_EXEC_TIMEOUT);
276295
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
20+
package org.apache.cloudstack.agent.routing;
21+
22+
import com.cloud.agent.api.routing.NetworkElementCommand;
23+
24+
public class ManageServiceCommand extends NetworkElementCommand {
25+
26+
String serviceName;
27+
String action;
28+
29+
@Override
30+
public boolean executeInSequence() {
31+
return true;
32+
}
33+
34+
protected ManageServiceCommand() {
35+
}
36+
37+
public ManageServiceCommand(String serviceName, String action) {
38+
this.serviceName = serviceName;
39+
this.action = action;
40+
}
41+
42+
public String getServiceName() {
43+
return serviceName;
44+
}
45+
46+
public String getAction() {
47+
return action;
48+
}
49+
}

engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/VolumeService.java

+2
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,6 @@ boolean copyPoliciesBetweenVolumesAndDestroySourceVolumeAfterMigration(ObjectInD
121121
Pair<String, String> checkAndRepairVolume(VolumeInfo volume);
122122

123123
void checkAndRepairVolumeBasedOnConfig(DataObject dataObject, Host host);
124+
125+
void validateChangeDiskOfferingEncryptionType(long existingDiskOfferingId, long newDiskOfferingId);
124126
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ static Boolean getFullCloneConfiguration(Long storeId) {
368368

369369
Long getDiskIopsWriteRate(ServiceOffering offering, DiskOffering diskOffering);
370370

371+
ImageStore updateImageStoreStatus(Long id, String name, Boolean readonly, Long capacityBytes);
372+
371373
void cleanupDownloadUrls();
372374

373375
void setDiskProfileThrottling(DiskProfile dskCh, ServiceOffering offering, DiskOffering diskOffering);

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

+2
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ public interface DomainDetailsDao extends GenericDao<DomainDetailVO, Long> {
3131
void deleteDetails(long domainId);
3232

3333
void update(long domainId, Map<String, String> details);
34+
35+
String getActualValue(DomainDetailVO domainDetailVO);
3436
}

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

+13-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import com.cloud.domain.DomainDetailVO;
2626
import com.cloud.domain.DomainVO;
27+
import com.cloud.utils.crypt.DBEncryptionUtil;
2728
import com.cloud.utils.db.GenericDaoBase;
2829
import com.cloud.utils.db.QueryBuilder;
2930
import com.cloud.utils.db.SearchBuilder;
@@ -34,6 +35,7 @@
3435
import org.apache.cloudstack.framework.config.ConfigKey.Scope;
3536
import org.apache.cloudstack.framework.config.ScopedConfigStorage;
3637
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
38+
import org.apache.cloudstack.framework.config.impl.ConfigurationVO;
3739

3840
public class DomainDetailsDaoImpl extends GenericDaoBase<DomainDetailVO, Long> implements DomainDetailsDao, ScopedConfigStorage {
3941
protected final SearchBuilder<DomainDetailVO> domainSearch;
@@ -111,7 +113,7 @@ public String getConfigValue(long id, ConfigKey<?> key) {
111113
String enableDomainSettingsForChildDomain = _configDao.getValue("enable.domain.settings.for.child.domain");
112114
if (!Boolean.parseBoolean(enableDomainSettingsForChildDomain)) {
113115
vo = findDetail(id, key.key());
114-
return vo == null ? null : vo.getValue();
116+
return vo == null ? null : getActualValue(vo);
115117
}
116118
DomainVO domain = _domainDao.findById(id);
117119
// if value is not configured in domain then check its parent domain till ROOT
@@ -125,6 +127,15 @@ public String getConfigValue(long id, ConfigKey<?> key) {
125127
break;
126128
}
127129
}
128-
return vo == null ? null : vo.getValue();
130+
return vo == null ? null : getActualValue(vo);
131+
}
132+
133+
@Override
134+
public String getActualValue(DomainDetailVO domainDetailVO) {
135+
ConfigurationVO configurationVO = _configDao.findByName(domainDetailVO.getName());
136+
if (configurationVO != null && configurationVO.isEncrypted()) {
137+
return DBEncryptionUtil.decrypt(domainDetailVO.getValue());
138+
}
139+
return domainDetailVO.getValue();
129140
}
130141
}

engine/schema/src/main/java/com/cloud/service/dao/ServiceOfferingDao.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ List<ServiceOfferingVO> createSystemServiceOfferings(String name, String uniqueN
5454

5555
List<ServiceOfferingVO> listPublicByCpuAndMemory(Integer cpus, Integer memory);
5656

57-
ServiceOfferingVO findServiceOfferingByComputeOnlyDiskOffering(long diskOfferingId);
58-
5957
List<ServiceOfferingVO> listByHostTag(String tag);
58+
59+
ServiceOfferingVO findServiceOfferingByComputeOnlyDiskOffering(long diskOfferingId, boolean includingRemoved);
6060
}

engine/schema/src/main/java/com/cloud/service/dao/ServiceOfferingDaoImpl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,10 @@ public List<ServiceOfferingVO> listPublicByCpuAndMemory(Integer cpus, Integer me
282282
}
283283

284284
@Override
285-
public ServiceOfferingVO findServiceOfferingByComputeOnlyDiskOffering(long diskOfferingId) {
285+
public ServiceOfferingVO findServiceOfferingByComputeOnlyDiskOffering(long diskOfferingId, boolean includingRemoved) {
286286
SearchCriteria<ServiceOfferingVO> sc = SearchComputeOfferingByComputeOnlyDiskOffering.create();
287287
sc.setParameters("disk_offering_id", diskOfferingId);
288-
List<ServiceOfferingVO> vos = listBy(sc);
288+
List<ServiceOfferingVO> vos = includingRemoved ? listIncludingRemovedBy(sc) : listBy(sc);
289289
if (vos.size() == 0) {
290290
return null;
291291
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ public interface AccountDetailsDao extends GenericDao<AccountDetailVO, Long> {
3434
* they will get created
3535
*/
3636
void update(long accountId, Map<String, String> details);
37+
38+
String getActualValue(AccountDetailVO accountDetailVO);
3739
}

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

+13-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import javax.inject.Inject;
2525

26+
import com.cloud.utils.crypt.DBEncryptionUtil;
2627
import org.apache.cloudstack.framework.config.ConfigKey;
2728
import org.apache.cloudstack.framework.config.ConfigKey.Scope;
2829
import org.apache.cloudstack.framework.config.ScopedConfigStorage;
@@ -40,6 +41,7 @@
4041
import com.cloud.utils.db.SearchCriteria.Op;
4142
import com.cloud.utils.db.TransactionLegacy;
4243
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
44+
import org.apache.cloudstack.framework.config.impl.ConfigurationVO;
4345

4446
public class AccountDetailsDaoImpl extends GenericDaoBase<AccountDetailVO, Long> implements AccountDetailsDao, ScopedConfigStorage {
4547
protected final SearchBuilder<AccountDetailVO> accountSearch;
@@ -119,7 +121,7 @@ public Scope getScope() {
119121
public String getConfigValue(long id, ConfigKey<?> key) {
120122
// check if account level setting is configured
121123
AccountDetailVO vo = findDetail(id, key.key());
122-
String value = vo == null ? null : vo.getValue();
124+
String value = vo == null ? null : getActualValue(vo);
123125
if (value != null) {
124126
return value;
125127
}
@@ -140,7 +142,7 @@ public String getConfigValue(long id, ConfigKey<?> key) {
140142
while (domain != null) {
141143
DomainDetailVO domainVO = _domainDetailsDao.findDetail(domain.getId(), key.key());
142144
if (domainVO != null) {
143-
value = domainVO.getValue();
145+
value = _domainDetailsDao.getActualValue(domainVO);
144146
break;
145147
} else if (domain.getParent() != null) {
146148
domain = _domainDao.findById(domain.getParent());
@@ -152,4 +154,13 @@ public String getConfigValue(long id, ConfigKey<?> key) {
152154
}
153155
return value;
154156
}
157+
158+
@Override
159+
public String getActualValue(AccountDetailVO accountDetailVO) {
160+
ConfigurationVO configurationVO = _configDao.findByName(accountDetailVO.getName());
161+
if (configurationVO != null && configurationVO.isEncrypted()) {
162+
return DBEncryptionUtil.decrypt(accountDetailVO.getValue());
163+
}
164+
return accountDetailVO.getValue();
165+
}
155166
}

0 commit comments

Comments
 (0)