Skip to content

Commit 70fed9f

Browse files
committed
Add a new method on datastoredriver: getCapabilities, which will be called by liststoragepoolcmd. UI can make decision based on the capabilities of the storage.
And also add a new table: snapshotdetails Conflicts: plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
1 parent 44a8151 commit 70fed9f

15 files changed

Lines changed: 232 additions & 35 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ public class ApiConstants {
222222
public static final String STATUS = "status";
223223
public static final String STORAGE_TYPE = "storagetype";
224224
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
225+
public static final String STORAGE_CAPABILITIES = "storagecapabilities";
225226
public static final String SYSTEM_VM_TYPE = "systemvmtype";
226227
public static final String TAGS = "tags";
227228
public static final String TARGET_IQN = "targetiqn";

api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.cloudstack.api.EntityReference;
2626

2727
import java.util.Date;
28+
import java.util.Map;
2829

2930
@EntityReference(value=StoragePool.class)
3031
public class StoragePoolResponse extends BaseResponse {
@@ -93,6 +94,16 @@ public class StoragePoolResponse extends BaseResponse {
9394
" false otherwise")
9495
private Boolean suitableForMigration;
9596

97+
@SerializedName(ApiConstants.STORAGE_CAPABILITIES) @Param(description="the storage pool capabilities")
98+
private Map<String, String> caps;
99+
100+
public Map<String, String> getCaps() {
101+
return caps;
102+
}
103+
104+
public void setCaps(Map<String, String> cap) {
105+
this.caps = cap;
106+
}
96107
/**
97108
* @return the scope
98109
*/
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
package org.apache.cloudstack.engine.subsystem.api.storage;
20+
21+
public enum DataStoreCapabilities {
22+
VOLUME_SNAPSHOT_QUIESCEVM
23+
}

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
2424
import org.apache.cloudstack.storage.command.CommandResult;
2525

26+
import java.util.Map;
27+
2628
public interface DataStoreDriver {
29+
Map<String, String> getCapabilities();
2730
DataTO getTO(DataObject data);
2831
DataStoreTO getStoreTO(DataStore store);
2932
void createAsync(DataStore store, DataObject data, AsyncCompletionCallback<CreateCmdResult> callback);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
package com.cloud.storage.dao;
20+
21+
import com.cloud.utils.db.GenericDao;
22+
import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
23+
24+
public interface SnapshotDetailsDao extends GenericDao<SnapshotDetailsVO, Long>, ResourceDetailsDao<SnapshotDetailsVO> {
25+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
package com.cloud.storage.dao;
20+
21+
import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
22+
23+
public class SnapshotDetailsDaoImpl extends ResourceDetailsDaoBase<SnapshotDetailsVO> implements SnapshotDetailsDao {
24+
@Override
25+
public void addDetail(long resourceId, String key, String value) {
26+
super.addDetail(new SnapshotDetailsVO(resourceId, key, value));
27+
}
28+
}
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+
package com.cloud.storage.dao;
20+
21+
import org.apache.cloudstack.api.ResourceDetail;
22+
23+
import javax.persistence.*;
24+
25+
@Entity
26+
@Table(name = "snapshot_details")
27+
public class SnapshotDetailsVO implements ResourceDetail {
28+
@Id
29+
@GeneratedValue(strategy= GenerationType.IDENTITY)
30+
@Column(name = "id")
31+
private long id;
32+
33+
@Column(name = "snapshot_id")
34+
private long resourceId;
35+
36+
@Column(name = "name")
37+
String name;
38+
39+
@Column(name = "value")
40+
String value;
41+
42+
public SnapshotDetailsVO(Long resourceId, String name, String value) {
43+
this.resourceId = resourceId;
44+
this.name = name;
45+
this.value = value;
46+
}
47+
48+
@Override
49+
public long getResourceId() {
50+
return resourceId;
51+
}
52+
53+
@Override
54+
public String getName() {
55+
return name;
56+
}
57+
58+
@Override
59+
public String getValue() {
60+
return value;
61+
}
62+
63+
@Override
64+
public boolean isDisplay() {
65+
return false;
66+
}
67+
68+
@Override
69+
public long getId() {
70+
return id;
71+
}
72+
}

engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import javax.inject.Inject;
2323

24+
import com.cloud.storage.*;
2425
import org.apache.log4j.Logger;
2526
import org.springframework.stereotype.Component;
2627

@@ -41,10 +42,6 @@
4142
import org.apache.cloudstack.storage.to.SnapshotObjectTO;
4243

4344
import com.cloud.exception.InvalidParameterValueException;
44-
import com.cloud.storage.DataStoreRole;
45-
import com.cloud.storage.Snapshot;
46-
import com.cloud.storage.SnapshotVO;
47-
import com.cloud.storage.Volume;
4845
import com.cloud.storage.dao.SnapshotDao;
4946
import com.cloud.storage.snapshot.SnapshotManager;
5047
import com.cloud.utils.NumbersUtil;
@@ -260,6 +257,14 @@ public boolean revertSnapshot(Long snapshotId) {
260257
@Override
261258
@DB
262259
public SnapshotInfo takeSnapshot(SnapshotInfo snapshot) {
260+
Object payload = snapshot.getPayload();
261+
if (payload != null) {
262+
CreateSnapshotPayload createSnapshotPayload = (CreateSnapshotPayload)payload;
263+
if (createSnapshotPayload.getQuiescevm()) {
264+
throw new InvalidParameterValueException("can't handle quiescevm equal true for volume snapshot");
265+
}
266+
}
267+
263268
SnapshotVO snapshotVO = snapshotDao.acquireInLockTable(snapshot.getId());
264269
if (snapshotVO == null) {
265270
throw new CloudRuntimeException("Failed to get lock on snapshot:" + snapshot.getId());

engine/storage/src/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,14 @@
2121
import java.net.URI;
2222
import java.net.URISyntaxException;
2323
import java.util.Date;
24+
import java.util.HashMap;
25+
import java.util.Map;
2426

2527
import javax.inject.Inject;
2628

29+
import org.apache.cloudstack.engine.subsystem.api.storage.*;
2730
import org.apache.log4j.Logger;
2831

29-
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
30-
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
31-
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
32-
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
33-
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
34-
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
3532
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
3633
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
3734
import org.apache.cloudstack.framework.async.AsyncRpcContext;
@@ -86,6 +83,11 @@ protected Proxy getHttpProxy() {
8683
}
8784
}
8885

86+
@Override
87+
public Map<String, String> getCapabilities() {
88+
return null;
89+
}
90+
8991
@Override
9092
public DataTO getTO(DataObject data) {
9193
return null;

plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@
1818
*/
1919
package org.apache.cloudstack.storage.datastore.driver;
2020

21+
import java.util.HashMap;
22+
import java.util.Map;
2123
import java.util.UUID;
2224

2325
import javax.inject.Inject;
2426

27+
import org.apache.cloudstack.engine.subsystem.api.storage.*;
2528
import org.apache.log4j.Logger;
2629

27-
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
28-
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
29-
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
30-
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
3130
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
3231
import org.apache.cloudstack.storage.image.BaseImageStoreDriverImpl;
3332
import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
@@ -49,7 +48,6 @@ public class CloudStackImageStoreDriverImpl extends BaseImageStoreDriverImpl {
4948
@Inject
5049
EndPointSelector _epSelector;
5150

52-
5351
@Override
5452
public DataStoreTO getStoreTO(DataStore store) {
5553
ImageStoreImpl nfsStore = (ImageStoreImpl) store;

0 commit comments

Comments
 (0)