forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 0
CSTACKEX-114: Delete volume or qcow2 file NFS #32
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
Open
piyush5netapp
wants to merge
4
commits into
main
Choose a base branch
from
feature/CSTACKEX-114
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ | |
| import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector; | ||
| import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo; | ||
| import org.apache.cloudstack.storage.command.CreateObjectCommand; | ||
| import org.apache.cloudstack.storage.command.DeleteCommand; | ||
| import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao; | ||
| import org.apache.cloudstack.storage.feign.FeignClientFactory; | ||
| import org.apache.cloudstack.storage.feign.client.JobFeignClient; | ||
|
|
@@ -93,12 +94,12 @@ public CloudStackVolume createCloudStackVolume(CloudStackVolume cloudstackVolume | |
| Answer answer = createVolumeOnKVMHost(cloudstackVolume.getVolumeInfo()); | ||
| if (answer == null || !answer.getResult()) { | ||
| String errMsg = answer != null ? answer.getDetails() : "Failed to create qcow2 on KVM host"; | ||
| s_logger.error("createCloudStackVolumeForTypeVolume: " + errMsg); | ||
| s_logger.error("createCloudStackVolume: " + errMsg); | ||
| throw new CloudRuntimeException(errMsg); | ||
| } | ||
| return cloudstackVolume; | ||
| }catch (Exception e) { | ||
| s_logger.error("createCloudStackVolumeForTypeVolume: error occured " + e); | ||
| s_logger.error("createCloudStackVolume: error occured " + e); | ||
| throw new CloudRuntimeException(e); | ||
| } | ||
| } | ||
|
|
@@ -111,7 +112,19 @@ CloudStackVolume updateCloudStackVolume(CloudStackVolume cloudstackVolume) { | |
|
|
||
| @Override | ||
| public void deleteCloudStackVolume(CloudStackVolume cloudstackVolume) { | ||
| //TODO | ||
| s_logger.info("deleteCloudStackVolume: Delete cloudstack volume " + cloudstackVolume); | ||
| try { | ||
| // Step 1: Send command to KVM host to delete qcow2 file using qemu-img | ||
| Answer answer = deleteVolumeOnKVMHost(cloudstackVolume.getVolumeInfo()); | ||
| if (answer == null || !answer.getResult()) { | ||
| String errMsg = answer != null ? answer.getDetails() : "Failed to delete qcow2 on KVM host"; | ||
| s_logger.error("deleteCloudStackVolume: " + errMsg); | ||
| throw new CloudRuntimeException(errMsg); | ||
| } | ||
| }catch (Exception e) { | ||
| s_logger.error("deleteCloudStackVolume: error occured " + e); | ||
| throw new CloudRuntimeException(e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -508,4 +521,31 @@ private Answer createVolumeOnKVMHost(DataObject volumeInfo) { | |
| return new Answer(null, false, e.toString()); | ||
| } | ||
| } | ||
|
|
||
| private Answer deleteVolumeOnKVMHost(DataObject volumeInfo) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way to include this in cloudstack core code, instead of having it here? |
||
| s_logger.info("deleteVolumeOnKVMHost called with volumeInfo: {} ", volumeInfo); | ||
|
|
||
| try { | ||
| s_logger.info("deleteVolumeOnKVMHost: Sending DeleteCommand to KVM agent for volume: {}", volumeInfo.getUuid()); | ||
| DeleteCommand cmd = new DeleteCommand(volumeInfo.getTO()); | ||
| EndPoint ep = epSelector.select(volumeInfo); | ||
| if (ep == null) { | ||
| String errMsg = "No remote endpoint to send DeleteCommand, check if host is up"; | ||
| s_logger.error(errMsg); | ||
| return new Answer(cmd, false, errMsg); | ||
| } | ||
| s_logger.info("deleteVolumeOnKVMHost: Sending command to endpoint: {}", ep.getHostAddr()); | ||
| Answer answer = ep.sendMessage(cmd); | ||
| if (answer != null && answer.getResult()) { | ||
| s_logger.info("deleteVolumeOnKVMHost: Successfully deleted qcow2 file on KVM host"); | ||
| } else { | ||
| s_logger.error("deleteVolumeOnKVMHost: Failed to delete qcow2 file: {}", | ||
| answer != null ? answer.getDetails() : "null answer"); | ||
| } | ||
| return answer; | ||
| } catch (Exception e) { | ||
| s_logger.error("deleteVolumeOnKVMHost: Exception sending DeleteCommand", e); | ||
| return new Answer(null, false, e.toString()); | ||
| } | ||
| } | ||
| } | ||
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
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.