Skip to content

Commit 6fe835e

Browse files
committed
Merge branch '4.19'
2 parents 525c2c6 + b2ef53b commit 6fe835e

File tree

44 files changed

+843
-240
lines changed

Some content is hidden

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

44 files changed

+843
-240
lines changed

api/src/main/java/com/cloud/network/vpc/VpcService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName, String disp
132132
*/
133133
boolean startVpc(long vpcId, boolean destroyOnFailure) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
134134

135+
void startVpc(CreateVPCCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
136+
135137
/**
136138
* Shuts down the VPC which includes shutting down all VPC provider and rules cleanup on the backend
137139
*

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ public class ApiConstants {
266266
public static final String IS_CLEANUP_REQUIRED = "iscleanuprequired";
267267
public static final String IS_DYNAMIC = "isdynamic";
268268
public static final String IS_EDGE = "isedge";
269+
public static final String IS_ENCRYPTED = "isencrypted";
269270
public static final String IS_EXTRACTABLE = "isextractable";
270271
public static final String IS_FEATURED = "isfeatured";
271272
public static final String IS_IMPLICIT = "isimplicit";

api/src/main/java/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.cloudstack.api.response.HostResponse;
3232
import org.apache.cloudstack.api.response.ListResponse;
3333
import org.apache.cloudstack.api.response.PodResponse;
34+
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
3435
import org.apache.cloudstack.api.response.StoragePoolResponse;
3536
import org.apache.cloudstack.api.response.UserVmResponse;
3637
import org.apache.cloudstack.api.response.VolumeResponse;
@@ -80,6 +81,12 @@ public class ListVolumesCmd extends BaseListRetrieveOnlyResourceCountCmd impleme
8081
RoleType.Admin})
8182
private String storageId;
8283

84+
@Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.UUID,
85+
entityType = ServiceOfferingResponse.class,
86+
description = "list volumes by disk offering of a service offering. If both service offering and " +
87+
"disk offering are passed, service offering is ignored", since = "4.19.1")
88+
private Long serviceOfferingId;
89+
8390
@Parameter(name = ApiConstants.DISK_OFFERING_ID, type = CommandType.UUID, entityType = DiskOfferingResponse.class, description = "list volumes by disk offering", since = "4.4")
8491
private Long diskOfferingId;
8592

@@ -94,6 +101,9 @@ public class ListVolumesCmd extends BaseListRetrieveOnlyResourceCountCmd impleme
94101
@Parameter(name = ApiConstants.STATE, type = CommandType.STRING, description = "state of the volume. Possible values are: Ready, Allocated, Destroy, Expunging, Expunged.")
95102
private String state;
96103

104+
@Parameter(name = ApiConstants.IS_ENCRYPTED, type = CommandType.BOOLEAN, description = "list only volumes that are encrypted", since = "4.19.1",
105+
authorized = { RoleType.Admin })
106+
private Boolean encrypted;
97107
/////////////////////////////////////////////////////
98108
/////////////////// Accessors ///////////////////////
99109
/////////////////////////////////////////////////////
@@ -118,6 +128,10 @@ public Long getPodId() {
118128
return podId;
119129
}
120130

131+
public Long getServiceOfferingId() {
132+
return serviceOfferingId;
133+
}
134+
121135
public Long getDiskOfferingId() {
122136
return diskOfferingId;
123137
}
@@ -151,6 +165,10 @@ public String getState() {
151165
return state;
152166
}
153167

168+
public Boolean isEncrypted() {
169+
return encrypted;
170+
}
171+
154172
/////////////////////////////////////////////////////
155173
/////////////// API Implementation///////////////////
156174
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,7 @@ public void create() throws ResourceAllocationException {
208208
public void execute() {
209209
Vpc vpc = null;
210210
try {
211-
if (isStart()) {
212-
_vpcService.startVpc(getEntityId(), true);
213-
} else {
214-
logger.debug("Not starting VPC as " + ApiConstants.START + "=false was passed to the API");
215-
}
211+
_vpcService.startVpc(this);
216212
vpc = _entityMgr.findById(Vpc.class, getEntityId());
217213
} catch (ResourceUnavailableException ex) {
218214
logger.warn("Exception: ", ex);

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,17 @@ public class VolumeResponse extends BaseResponseWithTagInformation implements Co
290290
private String externalUuid;
291291

292292
@SerializedName(ApiConstants.VOLUME_CHECK_RESULT)
293-
@Param(description = "details for the volume check result, they may vary for different hypervisors, since = 4.19.1")
293+
@Param(description = "details for the volume check result, they may vary for different hypervisors", since = "4.19.1")
294294
private Map<String, String> volumeCheckResult;
295295

296296
@SerializedName(ApiConstants.VOLUME_REPAIR_RESULT)
297-
@Param(description = "details for the volume repair result, they may vary for different hypervisors, since = 4.19.1")
297+
@Param(description = "details for the volume repair result, they may vary for different hypervisors", since = "4.19.1")
298298
private Map<String, String> volumeRepairResult;
299299

300+
@SerializedName(ApiConstants.ENCRYPT_FORMAT)
301+
@Param(description = "the format of the disk encryption if applicable", since = "4.19.1")
302+
private String encryptionFormat;
303+
300304
public String getPath() {
301305
return path;
302306
}
@@ -842,4 +846,8 @@ public Map<String, String> getVolumeRepairResult() {
842846
public void setVolumeRepairResult(Map<String, String> volumeRepairResult) {
843847
this.volumeRepairResult = volumeRepairResult;
844848
}
849+
850+
public void setEncryptionFormat(String encryptionFormat) {
851+
this.encryptionFormat = encryptionFormat;
852+
}
845853
}

api/src/test/java/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmdTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,16 @@ public void testCreate() throws ResourceAllocationException {
167167

168168
@Test
169169
public void testExecute() throws ResourceUnavailableException, InsufficientCapacityException {
170-
ReflectionTestUtils.setField(cmd, "start", true);
171170
Vpc vpc = Mockito.mock(Vpc.class);
172171
VpcResponse response = Mockito.mock(VpcResponse.class);
173172

174173
ReflectionTestUtils.setField(cmd, "id", 1L);
175174
responseGenerator = Mockito.mock(ResponseGenerator.class);
176-
Mockito.when(_vpcService.startVpc(1L, true)).thenReturn(true);
175+
Mockito.doNothing().when(_vpcService).startVpc(cmd);
177176
Mockito.when(_entityMgr.findById(Mockito.eq(Vpc.class), Mockito.any(Long.class))).thenReturn(vpc);
178177
cmd._responseGenerator = responseGenerator;
179178
Mockito.when(responseGenerator.createVpcResponse(ResponseObject.ResponseView.Restricted, vpc)).thenReturn(response);
180179
cmd.execute();
181-
Mockito.verify(_vpcService, Mockito.times(1)).startVpc(Mockito.anyLong(), Mockito.anyBoolean());
180+
Mockito.verify(_vpcService, Mockito.times(1)).startVpc(cmd);
182181
}
183182
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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 com.cloud.agent.api;
21+
22+
import com.cloud.agent.api.LogLevel.Log4jLevel;
23+
import com.cloud.storage.Storage.StoragePoolType;
24+
25+
@LogLevel(Log4jLevel.Trace)
26+
public class GetVolumeStatAnswer extends Answer {
27+
String poolUuid;
28+
StoragePoolType poolType;
29+
String volumePath;
30+
long size = 0;
31+
long virtualSize = 0;
32+
33+
public GetVolumeStatAnswer(GetVolumeStatCommand cmd, long size, long virtualSize) {
34+
super(cmd, true, "");
35+
this.poolUuid = cmd.getPoolUuid();
36+
this.poolType = cmd.getPoolType();
37+
this.volumePath = cmd.getVolumePath();
38+
this.size = size;
39+
this.virtualSize = virtualSize;
40+
}
41+
42+
public GetVolumeStatAnswer(GetVolumeStatCommand cmd, boolean success, String details) {
43+
super(cmd, success, details);
44+
}
45+
46+
protected GetVolumeStatAnswer() {
47+
//no-args constructor for json serialization-deserialization
48+
}
49+
50+
public String getPoolUuid() {
51+
return poolUuid;
52+
}
53+
54+
public void setPoolUuid(String poolUuid) {
55+
this.poolUuid = poolUuid;
56+
}
57+
58+
public StoragePoolType getPoolType() {
59+
return poolType;
60+
}
61+
62+
public void setPoolType(StoragePoolType poolType) {
63+
this.poolType = poolType;
64+
}
65+
66+
public long getSize() {
67+
return size;
68+
}
69+
70+
public void setSize(long size) {
71+
this.size = size;
72+
}
73+
74+
public long getVirtualSize() {
75+
return virtualSize;
76+
}
77+
78+
public void setVirtualSize(long virtualSize) {
79+
this.virtualSize = virtualSize;
80+
}
81+
82+
public String getString() {
83+
return "GetVolumeStatAnswer [poolUuid=" + poolUuid + ", poolType=" + poolType + ", volumePath=" + volumePath + ", size=" + size + ", virtualSize=" + virtualSize + "]";
84+
}
85+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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 com.cloud.agent.api;
21+
22+
import com.cloud.agent.api.LogLevel.Log4jLevel;
23+
import com.cloud.storage.Storage.StoragePoolType;
24+
25+
@LogLevel(Log4jLevel.Trace)
26+
public class GetVolumeStatCommand extends Command {
27+
String volumePath;
28+
StoragePoolType poolType;
29+
String poolUuid;
30+
31+
protected GetVolumeStatCommand() {
32+
}
33+
34+
public GetVolumeStatCommand(String volumePath, StoragePoolType poolType, String poolUuid) {
35+
this.volumePath = volumePath;
36+
this.poolType = poolType;
37+
this.poolUuid = poolUuid;
38+
}
39+
40+
public String getVolumePath() {
41+
return volumePath;
42+
}
43+
44+
public void setVolumePath(String volumePath) {
45+
this.volumePath = volumePath;
46+
}
47+
48+
public StoragePoolType getPoolType() {
49+
return poolType;
50+
}
51+
52+
public void setPoolType(StoragePoolType poolType) {
53+
this.poolType = poolType;
54+
}
55+
56+
public String getPoolUuid() {
57+
return poolUuid;
58+
}
59+
60+
public void setPoolUuid(String storeUuid) {
61+
this.poolUuid = storeUuid;
62+
}
63+
64+
@Override
65+
public boolean executeInSequence() {
66+
return false;
67+
}
68+
69+
public String getString() {
70+
return "GetVolumeStatCommand [volumePath=" + volumePath + ", poolType=" + poolType + ", poolUuid=" + poolUuid + "]";
71+
}
72+
}

core/src/main/java/org/apache/cloudstack/storage/to/VolumeObjectTO.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class VolumeObjectTO extends DownloadableObjectTO implements DataTO {
3939
private DataStoreTO dataStore;
4040
private String name;
4141
private Long size;
42+
private Long usableSize;
4243
private String path;
4344
private Long volumeId;
4445
private String vmName;
@@ -161,6 +162,10 @@ public Long getSize() {
161162
return size;
162163
}
163164

165+
public Long getUsableSize() {
166+
return usableSize;
167+
}
168+
164169
@Override
165170
public DataObjectType getObjectType() {
166171
return DataObjectType.VOLUME;
@@ -178,6 +183,10 @@ public void setSize(long size) {
178183
this.size = size;
179184
}
180185

186+
public void setUsableSize(Long usableSize) {
187+
this.usableSize = usableSize;
188+
}
189+
181190
public void setPath(String path) {
182191
this.path = path;
183192
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.S
112112
/**
113113
* Gets the Total Primary Storage space allocated for an account
114114
*
115-
* @param list of ids of virtual router VMs under this account
115+
* @param accountId
116+
* @param virtualRouters list of ids of virtual router VMs under this account
116117
* @return total Primary Storage space (in bytes) used
117118
*/
118119
long primaryStorageUsedForAccount(long accountId, List<Long> virtualRouters);

0 commit comments

Comments
 (0)