-
Notifications
You must be signed in to change notification settings - Fork 1.2k
backup: simple NAS backup plugin for KVM #9451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rohityadavcloud
merged 75 commits into
apache:main
from
shapeblue:kvm-backup-plugin-shared-storage
Sep 5, 2024
Merged
Changes from 61 commits
Commits
Show all changes
75 commits
Select commit
Hold shift + click to select a range
f2baa68
backup: Simple NAS backup plugin for KVM
rohityadavcloud 2604f81
cleanup and leave TODOs
rohityadavcloud b961a4d
cleanup, refactor; add plugin config keys
rohityadavcloud 9a8bbbb
WIP B&R tool
rohityadavcloud aa90b6d
Merge remote-tracking branch 'origin/main' into kvm-backup-plugin-sha…
rohityadavcloud d5503e7
add cmd-answer classes
rohityadavcloud f3bc039
barebone take backup implementation
rohityadavcloud f13769d
prototype backup e2e
rohityadavcloud 1933f9e
fix backup script
rohityadavcloud e066c5a
fix command execution handling
rohityadavcloud 50e407c
implement backup delete
rohityadavcloud 9b0be25
fix nasbackup script
rohityadavcloud 11cbea2
fix op typo
rohityadavcloud 18e0589
add todos
rohityadavcloud 97ce34c
introduce backup repository concept for NAS & other backups
rohityadavcloud 0b9db75
complete poc
rohityadavcloud 00b22d4
fix backup script
rohityadavcloud 7db5178
ui tweaks
rohityadavcloud 452bc10
fix listbackups to return their original offering
rohityadavcloud 67821d7
Merge branch 'main' of https://github.com/apache/cloudstack into kvm-…
Pearl1594 fe5c9d7
add APIs for management of backup repositories and backing up from lo…
Pearl1594 90b9981
add license
Pearl1594 0cf5046
support to backup stopped vms
Pearl1594 427d89b
license
Pearl1594 e38baa7
support restoring VMs
Pearl1594 90a45f9
add license
Pearl1594 119f5ac
support recover volume from backup and attach to VM
Pearl1594 6483284
fix issues identified during dev testing
Pearl1594 ed9956f
Merge remote-tracking branch 'origin/main' into kvm-backup-plugin-sha…
rohityadavcloud 9889c44
fix list API bugs
rohityadavcloud 123c911
remove unused import
rohityadavcloud 0d217f5
api: restrict API to only root admin
rohityadavcloud 5cb4f75
ui: add ability to list & delete specific backup repository
rohityadavcloud fc75705
fixes
rohityadavcloud 1d7b2c0
nasbackup: implement restore backup
rohityadavcloud da5fe8d
fixes
rohityadavcloud e765ddb
fix issues
rohityadavcloud 5c3894d
Update tools/marvin/setup.py
rohityadavcloud e51dedf
Update ui/src/views/AutogenView.vue
rohityadavcloud c27d1ca
fix pool ID issue in restored volume
rohityadavcloud 8b6bb80
fix potential NPE
rohityadavcloud 25dd780
Update ui/src/components/view/ListView.vue
rohityadavcloud a1e1980
Update server/src/main/java/org/apache/cloudstack/backup/BackupManage…
rohityadavcloud 0dc00d1
fix unused import
shwstppr c09a977
Update plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm…
rohityadavcloud 26e48cf
Update core/src/main/java/org/apache/cloudstack/backup/DeleteBackupCo…
rohityadavcloud 958049d
remove/fix weird spacing and newline
rohityadavcloud 5b68e9c
Merge remote-tracking branch 'origin/main' into kvm-backup-plugin-sha…
rohityadavcloud c50ca68
Missing import
Pearl1594 93cb33a
Fix created time to after the answer is recieved from the host and ad…
Pearl1594 1ee025e
fix lint
Pearl1594 8f04bec
Allow multiple backup schedules to be created
Pearl1594 a476a94
update setup.py file
Pearl1594 4764327
fix linter
Pearl1594 37316f3
Perform virsh attach-disk operation for running VMs when restore volu…
Pearl1594 f632820
fix linter
Pearl1594 9011353
address comments
Pearl1594 d3450b9
cleanup restore op from script as its done via Java - using rsync
Pearl1594 5bd9eac
fix unit test
Pearl1594 7e94bfa
1. adds backed_volumes column to the backups table to track volumes b…
Pearl1594 ae9634d
remove unused import
Pearl1594 1c28d98
Allow attaching volumes to a VM with backup offering but with No backups
Pearl1594 e065b4e
Prevent deletion of backup repository if it contains backups
Pearl1594 414943b
Prevent normal user's from seeing offering that doesnt allow user dri…
Pearl1594 b7d64e2
fix unit test
Pearl1594 fbe3c18
address comments provided - rename variable and add some defensive co…
Pearl1594 265466d
Merge branch 'main' into kvm-backup-plugin-shared-storage
rohityadavcloud 7213eb2
Update schema-41910to42000.sql
rohityadavcloud 8476fd4
Update tools/marvin/setup.py
rohityadavcloud ee0c5b3
Update engine/schema/src/main/resources/META-INF/db/schema-41910to420…
rohityadavcloud 42e7319
Update engine/schema/src/main/resources/META-INF/db/schema-41910to420…
rohityadavcloud 9bffa4d
add rsync as dependnecy for cloudstack-agent
rohityadavcloud 11c369e
Merge remote-tracking branch 'origin/main' into kvm-backup-plugin-sha…
rohityadavcloud 7423f5f
Merge branch 'main' into kvm-backup-plugin-shared-storage
rohityadavcloud 9efdb57
fix db schema setup issue
rohityadavcloud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
...java/org/apache/cloudstack/api/command/user/backup/repository/AddBackupRepositoryCmd.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| // 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.user.backup.repository; | ||
|
|
||
| import org.apache.cloudstack.acl.RoleType; | ||
| import org.apache.cloudstack.api.APICommand; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import org.apache.cloudstack.api.ApiErrorCode; | ||
| import org.apache.cloudstack.api.BaseCmd; | ||
| import org.apache.cloudstack.api.Parameter; | ||
| import org.apache.cloudstack.api.ServerApiException; | ||
| import org.apache.cloudstack.api.response.BackupRepositoryResponse; | ||
| import org.apache.cloudstack.api.response.ZoneResponse; | ||
| import org.apache.cloudstack.backup.BackupRepository; | ||
| import org.apache.cloudstack.backup.BackupRepositoryService; | ||
| import org.apache.cloudstack.context.CallContext; | ||
|
|
||
| import javax.inject.Inject; | ||
|
|
||
| @APICommand(name = "addBackupRepository", | ||
| description = "Adds a backup repository to store NAS backups", | ||
| responseObject = BackupRepositoryResponse.class, since = "4.20.0", | ||
| authorized = {RoleType.Admin}) | ||
| public class AddBackupRepositoryCmd extends BaseCmd { | ||
|
|
||
| @Inject | ||
| private BackupRepositoryService backupRepositoryService; | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| //////////////// API parameters ///////////////////// | ||
| ///////////////////////////////////////////////////// | ||
| @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the backup repository") | ||
| private String name; | ||
|
|
||
| @Parameter(name = ApiConstants.ADDRESS, type = CommandType.STRING, required = true, description = "address of the backup repository") | ||
| private String address; | ||
|
|
||
| @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, required = true, description = "type of the backup repository storage. Supported values: nfs, cephfs, cifs") | ||
| private String type; | ||
|
|
||
| @Parameter(name = ApiConstants.PROVIDER, type = CommandType.STRING, description = "backup repository provider") | ||
| private String provider; | ||
|
|
||
| @Parameter(name = ApiConstants.MOUNT_OPTIONS, type = CommandType.STRING, description = "shared storage mount options") | ||
| private String mountOptions; | ||
|
|
||
| @Parameter(name = ApiConstants.ZONE_ID, | ||
| type = CommandType.UUID, | ||
| entityType = ZoneResponse.class, | ||
| required = true, | ||
| description = "ID of the zone where the backup repository is to be added") | ||
| private Long zoneId; | ||
|
|
||
| @Parameter(name = ApiConstants.CAPACITY_BYTES, type = CommandType.LONG, description = "capacity of this backup repository") | ||
| private Long capacityBytes; | ||
|
|
||
|
|
||
| ///////////////////////////////////////////////////// | ||
| /////////////////// Accessors /////////////////////// | ||
| ///////////////////////////////////////////////////// | ||
|
|
||
| public BackupRepositoryService getBackupRepositoryService() { | ||
| return backupRepositoryService; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public String getType() { | ||
| if ("cephfs".equalsIgnoreCase(type)) { | ||
| return "ceph"; | ||
| } | ||
| return type.toLowerCase(); | ||
| } | ||
|
|
||
| public String getAddress() { | ||
| return address; | ||
| } | ||
|
|
||
| public String getProvider() { | ||
| return provider; | ||
| } | ||
|
|
||
| public String getMountOptions() { | ||
| return mountOptions == null ? "" : mountOptions; | ||
| } | ||
|
|
||
| public Long getZoneId() { | ||
| return zoneId; | ||
| } | ||
|
|
||
| public Long getCapacityBytes() { | ||
| return capacityBytes; | ||
| } | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| /////////////////// Accessors /////////////////////// | ||
| ///////////////////////////////////////////////////// | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| try { | ||
| BackupRepository result = backupRepositoryService.addBackupRepository(this); | ||
| if (result != null) { | ||
| BackupRepositoryResponse response = _responseGenerator.createBackupRepositoryResponse(result); | ||
| response.setResponseName(getCommandName()); | ||
| this.setResponseObject(response); | ||
| } else { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add backup repository"); | ||
| } | ||
| } catch (Exception ex4) { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex4.getMessage()); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public long getEntityOwnerId() { | ||
| return CallContext.current().getCallingAccount().getId(); | ||
| } | ||
| } |
76 changes: 76 additions & 0 deletions
76
...a/org/apache/cloudstack/api/command/user/backup/repository/DeleteBackupRepositoryCmd.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| // 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.user.backup.repository; | ||
|
|
||
| import org.apache.cloudstack.acl.RoleType; | ||
| import org.apache.cloudstack.api.APICommand; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import org.apache.cloudstack.api.ApiErrorCode; | ||
| import org.apache.cloudstack.api.BaseCmd; | ||
| import org.apache.cloudstack.api.Parameter; | ||
| import org.apache.cloudstack.api.ServerApiException; | ||
| import org.apache.cloudstack.api.response.BackupRepositoryResponse; | ||
| import org.apache.cloudstack.api.response.SuccessResponse; | ||
| import org.apache.cloudstack.backup.BackupRepositoryService; | ||
|
|
||
| import javax.inject.Inject; | ||
|
|
||
| @APICommand(name = "deleteBackupRepository", | ||
| description = "delete a backup repository", | ||
| responseObject = SuccessResponse.class, since = "4.20.0", | ||
| authorized = {RoleType.Admin}) | ||
| public class DeleteBackupRepositoryCmd extends BaseCmd { | ||
|
|
||
| @Inject | ||
| BackupRepositoryService backupRepositoryService; | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| //////////////// API parameters ///////////////////// | ||
| ///////////////////////////////////////////////////// | ||
| @Parameter(name = ApiConstants.ID, | ||
| type = CommandType.UUID, | ||
| entityType = BackupRepositoryResponse.class, | ||
| required = true, | ||
| description = "ID of the backup repository to be deleted") | ||
| private Long id; | ||
|
|
||
|
|
||
| ///////////////////////////////////////////////////// | ||
| //////////////// Accessors ////////////////////////// | ||
| ///////////////////////////////////////////////////// | ||
|
|
||
| public Long getId() { | ||
| return id; | ||
| } | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| boolean result = backupRepositoryService.deleteBackupRepository(this); | ||
| if (result) { | ||
| SuccessResponse response = new SuccessResponse(getCommandName()); | ||
| this.setResponseObject(response); | ||
| } else { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete backup repository"); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public long getEntityOwnerId() { | ||
| return 0; | ||
| } | ||
| } |
110 changes: 110 additions & 0 deletions
110
...a/org/apache/cloudstack/api/command/user/backup/repository/ListBackupRepositoriesCmd.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| // 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.user.backup.repository; | ||
|
|
||
| import com.cloud.exception.ConcurrentOperationException; | ||
| import com.cloud.exception.InsufficientCapacityException; | ||
| import com.cloud.exception.NetworkRuleConflictException; | ||
| import com.cloud.exception.ResourceAllocationException; | ||
| import com.cloud.exception.ResourceUnavailableException; | ||
| import com.cloud.utils.Pair; | ||
| import org.apache.cloudstack.acl.RoleType; | ||
| import org.apache.cloudstack.api.APICommand; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import org.apache.cloudstack.api.ApiErrorCode; | ||
| import org.apache.cloudstack.api.BaseListCmd; | ||
| import org.apache.cloudstack.api.Parameter; | ||
| import org.apache.cloudstack.api.ServerApiException; | ||
| import org.apache.cloudstack.api.response.BackupRepositoryResponse; | ||
| import org.apache.cloudstack.api.response.ListResponse; | ||
| import org.apache.cloudstack.api.response.ZoneResponse; | ||
| import org.apache.cloudstack.backup.BackupRepository; | ||
| import org.apache.cloudstack.backup.BackupRepositoryService; | ||
|
|
||
| import javax.inject.Inject; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| @APICommand(name = "listBackupRepositories", | ||
| description = "Lists all backup repositories", | ||
| responseObject = BackupRepositoryResponse.class, since = "4.20.0", | ||
| authorized = {RoleType.Admin}) | ||
| public class ListBackupRepositoriesCmd extends BaseListCmd { | ||
|
|
||
| @Inject | ||
| BackupRepositoryService backupRepositoryService; | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| //////////////// API parameters ///////////////////// | ||
| ///////////////////////////////////////////////////// | ||
| @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "name of the backup repository") | ||
| private String name; | ||
|
|
||
| @Parameter(name = ApiConstants.ZONE_ID, | ||
| type = CommandType.UUID, | ||
| entityType = ZoneResponse.class, | ||
| description = "ID of the zone where the backup repository is to be added") | ||
| private Long zoneId; | ||
|
|
||
| @Parameter(name = ApiConstants.PROVIDER, type = CommandType.STRING, description = "the backup repository provider") | ||
| private String provider; | ||
|
|
||
| @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = BackupRepositoryResponse.class, description = "ID of the backup repository") | ||
| private Long id; | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| //////////////// Accessors ////////////////////////// | ||
| ///////////////////////////////////////////////////// | ||
|
|
||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public Long getZoneId() { | ||
| return zoneId; | ||
| } | ||
|
|
||
| public String getProvider() { | ||
| return provider; | ||
| } | ||
|
|
||
| public Long getId() { | ||
| return id; | ||
| } | ||
|
|
||
| @Override | ||
| public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException { | ||
| try { | ||
| Pair<List<BackupRepository>, Integer> repositoriesPair = backupRepositoryService.listBackupRepositories(this); | ||
| List<BackupRepository> backupRepositories = repositoriesPair.first(); | ||
| ListResponse<BackupRepositoryResponse> response = new ListResponse<>(); | ||
| List<BackupRepositoryResponse> responses = new ArrayList<>(); | ||
| for (BackupRepository repository : backupRepositories) { | ||
| responses.add(_responseGenerator.createBackupRepositoryResponse(repository)); | ||
| } | ||
| response.setResponses(responses, repositoriesPair.second()); | ||
| response.setResponseName(getCommandName()); | ||
| setResponseObject(response); | ||
| } catch (Exception e) { | ||
| String msg = String.format("Error listing backup repositories, due to: %s", e.getMessage()); | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, msg); | ||
| } | ||
|
|
||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.