Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e1a903d
Init for storage browser
vishesh92 Aug 7, 2023
1576be8
Add browser for secondary storage
vishesh92 Aug 15, 2023
8de7906
Allow listing for storage pools on KVM
vishesh92 Sep 1, 2023
8e977db
Allow listing for storage pools on Xen
vishesh92 Sep 5, 2023
869b22a
Fix folderExists & fileExists methods in vmware-base
vishesh92 Sep 6, 2023
ecf2bf2
Allow listing for storage pools on VMWare
vishesh92 Sep 6, 2023
7f7a7f8
Add checks for path to prevent path traversal attacks
vishesh92 Sep 6, 2023
a22c78d
Add volumeid & template for primary storage to response
vishesh92 Sep 7, 2023
d8a7194
fix some edge cases and format code
vishesh92 Sep 8, 2023
8e1e8ed
Make browserPath as a query param in UI
vishesh92 Sep 8, 2023
8cde11e
Setup pagination for storage browser
vishesh92 Sep 10, 2023
9557fc1
Add command to migrate templates and/or snapshots to another secondar…
vishesh92 Sep 11, 2023
77fda17
Fixups
vishesh92 Sep 11, 2023
31e643d
Fixups
vishesh92 Sep 11, 2023
0d232e3
Add pagination in UI
vishesh92 Sep 11, 2023
a66b745
fix pagination
vishesh92 Sep 11, 2023
79c0e57
Handle edge case for storage migration
vishesh92 Sep 11, 2023
3dd358b
Add action button in UI to migrate templates & snapshots on an image …
vishesh92 Sep 13, 2023
3b09332
Add filter on datastore id for templates & ISOs
vishesh92 Sep 13, 2023
5c75d47
Add tests & UI fixes
vishesh92 Sep 14, 2023
fe0ea64
Add unit tests for StorageBrowserImpl.java
vishesh92 Sep 15, 2023
a46e654
Add unit tests
vishesh92 Sep 18, 2023
4d52d72
Remove unused imports
vishesh92 Sep 18, 2023
1c60c46
Add e2e tests
vishesh92 Sep 19, 2023
d3bb9a8
Add license
vishesh92 Sep 19, 2023
9258612
Add e2e test for template migration from one image store to another
vishesh92 Sep 20, 2023
3882efb
Add indexes
vishesh92 Sep 20, 2023
5ddd536
Fix test class name
vishesh92 Sep 21, 2023
9cc04c5
fix e2e test
vishesh92 Sep 22, 2023
5180173
Resolve comments
vishesh92 Sep 21, 2023
8254e23
Merge branch 'main' into storage-mgmt
vishesh92 Sep 23, 2023
8e2776b
fixup
vishesh92 Sep 23, 2023
4016943
Link volumes on imagestore & speed up listing for xen & vmware
vishesh92 Sep 25, 2023
4868e34
resolve comments
vishesh92 Sep 26, 2023
50b9e71
Add command to download files from imagestore
vishesh92 Sep 26, 2023
4a1a5f6
Download files via UI
vishesh92 Sep 26, 2023
7bf02de
Add additional checks for xenserver
vishesh92 Sep 26, 2023
1dfee9e
Fix tests
vishesh92 Sep 26, 2023
059454e
Fixes
vishesh92 Sep 27, 2023
93a7af9
Merge branch 'main' into storage-mgmt
vishesh92 Sep 27, 2023
3889595
fixup
vishesh92 Sep 27, 2023
8cbf4c4
Add some more tests
vishesh92 Oct 1, 2023
36dcaff
Merge branch 'main' into storage-mgmt
vishesh92 Oct 2, 2023
b72f9cd
Add tests for vmware resource
vishesh92 Oct 2, 2023
7b58d1b
Add missing license
vishesh92 Oct 2, 2023
677ca07
Fix test
vishesh92 Oct 2, 2023
fc54f48
Add test for citrixResourceBase
vishesh92 Oct 2, 2023
5fbbb72
Fix bugs
vishesh92 Oct 4, 2023
7b2e853
List primary datastore in response and fix in vmware listing
vishesh92 Oct 5, 2023
46de46e
Merge branch 'main' into storage-mgmt
vishesh92 Oct 5, 2023
c35e694
Fix migrate resource event description
vishesh92 Oct 5, 2023
a793c16
UI fixups
vishesh92 Oct 12, 2023
cc7ac9d
Merge remote-tracking branch 'origin/main' into storage-mgmt
vishesh92 Oct 23, 2023
e3cb541
Fix skip for e2e test
vishesh92 Oct 23, 2023
d112c75
Merge branch 'main' into storage-mgmt
vishesh92 Oct 23, 2023
24a2bec
Fix build errors
vishesh92 Oct 23, 2023
1a22455
Add filtering by stores for snapshot
vishesh92 Oct 23, 2023
86c82af
Merge remote-tracking branch 'origin/main' into storage-mgmt
vishesh92 Oct 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api/src/main/java/com/cloud/agent/api/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ public int getWait() {
return wait;
}

/**
* This is the time in seconds that the agent will wait before waiting for an answer from the endpoint.
* The actual wait time is twice the value of this variable.
* See {@link com.cloud.agent.manager.AgentAttache#send(com.cloud.agent.transport.Request, int) AgentAttache#send} implementation for more details.
*
* @param wait
**/
public void setWait(int wait) {
this.wait = wait;
}
Expand Down
3 changes: 3 additions & 0 deletions api/src/main/java/com/cloud/event/EventTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ public class EventTypes {
public static final String EVENT_STORAGE_IP_RANGE_UPDATE = "STORAGE.IP.RANGE.UPDATE";

public static final String EVENT_IMAGE_STORE_DATA_MIGRATE = "IMAGE.STORE.MIGRATE.DATA";
public static final String EVENT_IMAGE_STORE_RESOURCES_MIGRATE = "IMAGE.STORE.MIGRATE.RESOURCES";
public static final String EVENT_IMAGE_STORE_OBJECT_DOWNLOAD = "IMAGE.STORE.OBJECT.DOWNLOAD";

// Configuration Table
public static final String EVENT_CONFIGURATION_VALUE_EDIT = "CONFIGURATION.VALUE.EDIT";
Expand Down Expand Up @@ -1147,6 +1149,7 @@ public class EventTypes {
entityEventDetails.put(EVENT_IMPORT_VCENTER_STORAGE_POLICIES, "StoragePolicies");

entityEventDetails.put(EVENT_IMAGE_STORE_DATA_MIGRATE, ImageStore.class);
entityEventDetails.put(EVENT_IMAGE_STORE_OBJECT_DOWNLOAD, ImageStore.class);
entityEventDetails.put(EVENT_LIVE_PATCH_SYSTEMVM, "SystemVMs");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,7 @@ public class ApiConstants {
public static final String TARGET_ID = "targetid";
public static final String FILES = "files";
public static final String SRC_POOL = "srcpool";
public static final String DEST_POOL = "destpool";
public static final String DEST_POOLS = "destpools";
public static final String VOLUME_IDS = "volumeids";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,33 @@
package org.apache.cloudstack.api.command.admin.iso;

import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.command.admin.AdminCmd;
import org.apache.cloudstack.api.command.user.iso.ListIsosCmd;
import org.apache.cloudstack.api.response.ImageStoreResponse;
import org.apache.cloudstack.api.response.StoragePoolResponse;
import org.apache.cloudstack.api.response.TemplateResponse;

@APICommand(name = "listIsos", description = "Lists all available ISO files.", responseObject = TemplateResponse.class, responseView = ResponseView.Full,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ListIsosCmdByAdmin extends ListIsosCmd implements AdminCmd {
@Parameter(name = ApiConstants.IMAGE_STORE_ID, type = CommandType.UUID, entityType = ImageStoreResponse.class,
description = "ID of the image or image cache store", since = "4.19")
private Long imageStoreId;

@Parameter(name = ApiConstants.STORAGE_ID, type = CommandType.UUID, entityType = StoragePoolResponse.class,
description = "ID of the storage pool", since = "4.19")
private Long storagePoolId;

@Override
public Long getImageStoreId() {
return imageStoreId;
}

@Override
public Long getStoragePoolId() {
return storagePoolId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// 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.ApiConstants;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject;
import org.apache.cloudstack.api.command.admin.AdminCmd;
import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotsCmd;
import org.apache.cloudstack.api.response.ImageStoreResponse;
import org.apache.cloudstack.api.response.SnapshotResponse;
import org.apache.cloudstack.api.response.StoragePoolResponse;

@APICommand(name = "listSnapshots", description = "Lists all available snapshots for the account.", responseObject = SnapshotResponse.class, entityType = {
Snapshot.class }, responseView = ResponseObject.ResponseView.Full, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ListSnapshotsCmdByAdmin extends ListSnapshotsCmd implements AdminCmd {
@Parameter(name = ApiConstants.IMAGE_STORE_ID, type = CommandType.UUID, entityType = ImageStoreResponse.class,
description = "ID of the image or image cache store", since = "4.19")
private Long imageStoreId;

@Parameter(name = ApiConstants.STORAGE_ID, type = CommandType.UUID, entityType = StoragePoolResponse.class,
description = "ID of the storage pool", since = "4.19")
private Long storagePoolId;

@Override
public Long getImageStoreId() {
return imageStoreId;
}

@Override
public Long getStoragePoolId() {
return storagePoolId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// 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.storage;

import com.cloud.event.EventTypes;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.ExtractResponse;
import org.apache.cloudstack.api.response.ImageStoreResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.storage.browser.StorageBrowser;

import javax.inject.Inject;
import java.nio.file.Path;

@APICommand(name = "downloadImageStoreObject", description = "Download object at a specified path on an image store.",
responseObject = ExtractResponse.class, since = "4.19.0", requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false)
public class DownloadImageStoreObjectCmd extends BaseAsyncCmd {

@Inject
StorageBrowser storageBrowser;

/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////

@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = ImageStoreResponse.class, required = true,
description = "id of the image store")
private Long storeId;

@Parameter(name = ApiConstants.PATH, type = CommandType.STRING, description = "path to download on image store")
private String path;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public Long getStoreId() {
return storeId;
}

public String getPath() {
if (path == null) {
path = "/";
}
// We prepend "/" to path and normalize to prevent path traversal attacks
return Path.of(String.format("/%s", path)).normalize().toString().substring(1);
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

@Override
public void execute() {
ExtractResponse response = storageBrowser.downloadImageStoreObject(this);
response.setResponseName(getCommandName());
response.setObjectName(getCommandName());
this.setResponseObject(response);
}

/**
* For commands the API framework needs to know the owner of the object being acted upon. This method is
* used to determine that information.
*
* @return the id of the account that owns the object being acted upon
*/
@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccount().getId();
}

@Override
public String getEventType() {
return EventTypes.EVENT_IMAGE_STORE_OBJECT_DOWNLOAD;
}

@Override
public String getEventDescription() {
return "Downloading object at path " + getPath() + " on image store " + getStoreId();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// 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.storage;

import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.ImageStoreResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.storage.browser.DataStoreObjectResponse;
import org.apache.cloudstack.storage.browser.StorageBrowser;

import javax.inject.Inject;
import java.nio.file.Path;

@APICommand(name = "listImageStoreObjects", description = "Lists objects at specified path on an image store.",
responseObject = DataStoreObjectResponse.class, since = "4.19.0", requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false)
public class ListImageStoreObjectsCmd extends BaseListCmd {

@Inject
StorageBrowser storageBrowser;

/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////

@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = ImageStoreResponse.class, required = true,
description = "id of the image store")
private Long storeId;

@Parameter(name = ApiConstants.PATH, type = CommandType.STRING, description = "path to list on image store")
private String path;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public Long getStoreId() {
return storeId;
}

public String getPath() {
if (path == null) {
path = "/";
}
// We prepend "/" to path and normalize to prevent path traversal attacks
return Path.of(String.format("/%s", path)).normalize().toString().substring(1);
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

@Override
public void execute() {
ListResponse<DataStoreObjectResponse> response = storageBrowser.listImageStoreObjects(this);
response.setResponseName(getCommandName());
response.setObjectName(getCommandName());
this.setResponseObject(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// 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.storage;

import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.StoragePoolResponse;
import org.apache.cloudstack.storage.browser.DataStoreObjectResponse;
import org.apache.cloudstack.storage.browser.StorageBrowser;

import javax.inject.Inject;
import java.nio.file.Path;


@APICommand(name = "listStoragePoolObjects", description = "Lists objects at specified path on a storage pool.",
responseObject = DataStoreObjectResponse.class, since = "4.19.0", requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false)
public class ListStoragePoolObjectsCmd extends BaseListCmd {

@Inject
StorageBrowser storageBrowser;

/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////

@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = StoragePoolResponse.class, required = true,
description = "id of the storage pool")
private Long storeId;

@Parameter(name = ApiConstants.PATH, type = CommandType.STRING, description = "path to list on storage pool")
private String path;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public Long getStoreId() {
return storeId;
}

public String getPath() {
if (path == null) {
path = "/";
}
// We prepend "/" to path and normalize to prevent path traversal attacks
return Path.of(String.format("/%s", path)).normalize().toString().substring(1);
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

@Override
public void execute() {
ListResponse<DataStoreObjectResponse> response = storageBrowser.listPrimaryStoreObjects(this);
response.setResponseName(getCommandName());
response.setObjectName(getCommandName());
this.setResponseObject(response);
}
}
Loading