Skip to content

Commit 45aa0df

Browse files
Return details of the storage pool in the response including url, and update capacityBytes and capacityIops if applicable while creating storage pool
1 parent 9317a46 commit 45aa0df

File tree

6 files changed

+142
-4
lines changed

6 files changed

+142
-4
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.upgrade.dao;
18+
19+
import com.cloud.utils.exception.CloudRuntimeException;
20+
21+
import java.io.InputStream;
22+
import java.sql.Connection;
23+
24+
public class Upgrade41920to41930 implements DbUpgrade {
25+
26+
@Override
27+
public String[] getUpgradableVersionRange() {
28+
return new String[]{"4.19.2.0", "4.19.3.0"};
29+
}
30+
31+
@Override
32+
public String getUpgradedVersion() {
33+
return "4.19.3.0";
34+
}
35+
36+
@Override
37+
public boolean supportsRollingUpgrade() {
38+
return false;
39+
}
40+
41+
@Override
42+
public InputStream[] getPrepareScripts() {
43+
final String scriptFile = "META-INF/db/schema-41920to41930.sql";
44+
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
45+
if (script == null) {
46+
throw new CloudRuntimeException("Unable to find " + scriptFile);
47+
}
48+
49+
return new InputStream[]{script};
50+
}
51+
52+
@Override
53+
public void performDataMigration(Connection conn) {
54+
}
55+
56+
@Override
57+
public InputStream[] getCleanupScripts() {
58+
final String scriptFile = "META-INF/db/schema-41920to41930-cleanup.sql";
59+
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
60+
if (script == null) {
61+
throw new CloudRuntimeException("Unable to find " + scriptFile);
62+
}
63+
64+
return new InputStream[]{script};
65+
}
66+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
--;
19+
-- Schema upgrade cleanup from 4.19.2.0 to 4.19.3.0
20+
--;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
--;
19+
-- Schema upgrade from 4.19.2.0 to 4.19.3.0
20+
--;
21+
22+
-- Updated display to false for password detail of the storage pool details
23+
UPDATE `cloud`.`storage_pool_details` SET display = 0 WHERE name LIKE '%password%';

plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,19 +148,42 @@ public DataStore initialize(Map<String, Object> dsInfos) {
148148

149149
PrimaryDataStoreParameters parameters = new PrimaryDataStoreParameters();
150150

151-
String tags = (String)dsInfos.get("tags");
152-
String storageAccessGroups = (String)dsInfos.get(ApiConstants.STORAGE_ACCESS_GROUPS);
153151
Map<String, String> details = (Map<String, String>)dsInfos.get("details");
152+
if (dsInfos.get("capacityBytes") != null) {
153+
Long capacityBytes = (Long)dsInfos.get("capacityBytes");
154+
if (capacityBytes <= 0) {
155+
throw new IllegalArgumentException("'capacityBytes' must be greater than 0.");
156+
}
157+
if (details == null) {
158+
details = new HashMap<>();
159+
}
160+
details.put(PrimaryDataStoreLifeCycle.CAPACITY_BYTES, String.valueOf(capacityBytes));
161+
parameters.setCapacityBytes(capacityBytes);
162+
}
163+
164+
if (dsInfos.get("capacityIops") != null) {
165+
Long capacityIops = (Long)dsInfos.get("capacityIops");
166+
if (capacityIops <= 0) {
167+
throw new IllegalArgumentException("'capacityIops' must be greater than 0.");
168+
}
169+
if (details == null) {
170+
details = new HashMap<>();
171+
}
172+
details.put(PrimaryDataStoreLifeCycle.CAPACITY_IOPS, String.valueOf(capacityIops));
173+
parameters.setCapacityIops(capacityIops);
174+
}
175+
176+
parameters.setDetails(details);
154177

178+
String tags = (String)dsInfos.get("tags");
155179
parameters.setTags(tags);
180+
String storageAccessGroups = (String)dsInfos.get(ApiConstants.STORAGE_ACCESS_GROUPS);
156181
parameters.setStorageAccessGroups(storageAccessGroups);
157182
parameters.setIsTagARule((Boolean)dsInfos.get("isTagARule"));
158-
parameters.setDetails(details);
159183

160184
String scheme = dsInfos.get("scheme").toString();
161185
String storageHost = dsInfos.get("host").toString();
162186
String hostPath = dsInfos.get("hostPath").toString();
163-
String uri = String.format("%s://%s%s", scheme, storageHost, hostPath);
164187

165188
Object localStorage = dsInfos.get("localStorage");
166189
if (localStorage != null) {

server/src/main/java/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import com.cloud.api.ApiDBUtils;
4141
import com.cloud.api.query.vo.StoragePoolJoinVO;
4242
import com.cloud.capacity.CapacityManager;
43+
import com.cloud.server.ResourceTag;
4344
import com.cloud.storage.DataStoreRole;
4445
import com.cloud.storage.ScopeType;
4546
import com.cloud.storage.Storage;
@@ -180,6 +181,8 @@ public StoragePoolResponse newStoragePoolResponse(StoragePoolJoinVO pool, boolea
180181
poolResponse.setIsTagARule(pool.getIsTagARule());
181182
poolResponse.setOverProvisionFactor(Double.toString(CapacityManager.StorageOverprovisioningFactor.valueIn(pool.getId())));
182183
poolResponse.setManaged(storagePool.isManaged());
184+
Map<String, String> details = ApiDBUtils.getResourceDetails(pool.getId(), ResourceTag.ResourceObjectType.Storage);
185+
poolResponse.setDetails(details);
183186

184187
// set async job
185188
if (pool.getJobId() != null) {

server/src/main/java/com/cloud/storage/StorageManagerImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,9 @@ public PrimaryDataStoreInfo createPool(CreateStoragePoolCmd cmd) throws Resource
10201020

10211021
Map<String, String> details = extractApiParamAsMap(cmd.getDetails());
10221022
checkNFSMountOptionsForCreate(details, hypervisorType, uriParams.get("scheme"));
1023+
if (StringUtils.isNotBlank(cmd.getUrl())) {
1024+
details.put("url", cmd.getUrl());
1025+
}
10231026

10241027
DataCenterVO zone = _dcDao.findById(cmd.getZoneId());
10251028
if (zone == null) {

0 commit comments

Comments
 (0)