DaanHoogland commented on code in PR #7803:
URL: https://github.com/apache/cloudstack/pull/7803#discussion_r1281795725
##########
server/src/main/java/com/cloud/api/ApiResponseHelper.java:
##########
@@ -672,17 +672,25 @@ public SnapshotResponse createSnapshotResponse(Snapshot
snapshot) {
snapshotInfo = snapshotfactory.getSnapshot(snapshot.getId(),
dataStoreRole);
}
+ if (view.equals(ResponseView.Full)) {
+ SnapshotDataStoreVO snapshotStore =
_snapshotStoreDao.findBySnapshot(snapshot.getId(), DataStoreRole.Image);
+ long storagePoolId = snapshotStore.getDataStoreId();
+ DataStore dataStore = _dataStoreMgr.getDataStore(storagePoolId,
DataStoreRole.Image);
+ snapshotResponse.setStore(dataStore.getName());
+ snapshotResponse.setStoreId(dataStore.getUuid());
+ }
Review Comment:
can be a separate method
##########
server/src/main/java/com/cloud/api/query/QueryManagerImpl.java:
##########
@@ -3639,8 +3646,25 @@ private Pair<List<TemplateJoinVO>, Integer>
searchForTemplatesInternal(ListTempl
boolean showDomr = ((templateFilter != TemplateFilter.selfexecutable)
&& (templateFilter != TemplateFilter.featured));
HypervisorType hypervisorType =
HypervisorType.getType(cmd.getHypervisor());
- return searchForTemplatesInternal(id, cmd.getTemplateName(),
cmd.getKeyword(), templateFilter, false, null, cmd.getPageSizeVal(),
cmd.getStartIndex(), cmd.getZoneId(), hypervisorType,
- showDomr, cmd.listInReadyState(), permittedAccounts, caller,
listProjectResourcesCriteria, tags, showRemovedTmpl, cmd.getIds(),
parentTemplateId, cmd.getShowUnique());
+ List<Long> ids = cmd.getIds();
+ Long imageStoreId = cmd.getDataStoreId();
+ if (imageStoreId != null) {
+ List<TemplateDataStoreVO> templatesInStore =
templateDataStoreDao.listByStoreId(imageStoreId);
+
+ if (templatesInStore == null || templatesInStore.isEmpty()) {
+ return new Pair<>(new ArrayList<>(), 0);
+ }
+ if (ids.isEmpty()) {
+ ids =
templatesInStore.stream().map(TemplateDataStoreVO::getTemplateId).collect(Collectors.toList());
+ } else {
+
ids.retainAll(templatesInStore.stream().map(TemplateDataStoreVO::getTemplateId).collect(Collectors.toList()));
+ }
+ }
Review Comment:
can this be a separate method as well?
##########
api/src/main/java/org/apache/cloudstack/api/command/admin/snapshot/CreateSnapshotFromVMSnapshotCmdByAdmin.java:
##########
@@ -0,0 +1,32 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.snapshot;
+
+import com.cloud.storage.Snapshot;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ResponseObject;
+import org.apache.cloudstack.api.command.admin.AdminCmd;
+import
org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotFromVMSnapshotCmd;
+import org.apache.cloudstack.api.response.SnapshotResponse;
+
+@APICommand(name = "createSnapshotFromVMSnapshot",
+ description = "Creates an instant snapshot of a volume from
existing vm snapshot.",
+ responseObject = SnapshotResponse.class, entityType =
{Snapshot.class}, since = "4.10.0",
Review Comment:
```suggestion
responseObject = SnapshotResponse.class, entityType =
{Snapshot.class},
```
##########
server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java:
##########
@@ -685,6 +686,21 @@ public Pair<List<? extends Snapshot>, Integer>
listSnapshots(ListSnapshotsCmd cm
List<Long> ids = getIdsListFromCmd(cmd.getId(), cmd.getIds());
+ Long imageStoreId = cmd.getImageStoreId();
+
+ if (imageStoreId != null) {
+ List<SnapshotDataStoreVO> snapshotsInStore =
_snapshotStoreDao.listByStoreId(imageStoreId, DataStoreRole.Image);
+ if (snapshotsInStore == null || snapshotsInStore.isEmpty()) {
+ return new Pair<>(new ArrayList<>(), 0);
+ }
+ List<Long> snapshotIdsInStore =
snapshotsInStore.stream().map(SnapshotDataStoreVO::getSnapshotId).collect(Collectors.toList());
+ if (ids.isEmpty()) {
+ ids = snapshotIdsInStore;
+ } else {
+ ids.retainAll(snapshotIdsInStore);
+ }
+ }
Review Comment:
safe the poorly placed return, this can be separate method
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]