Skip to content
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

Add internal disk functions #272

Merged
merged 39 commits into from
Jan 13, 2020
Merged

Add internal disk functions #272

merged 39 commits into from
Jan 13, 2020

Conversation

vbauzys
Copy link
Contributor

@vbauzys vbauzys commented Dec 5, 2019

Changes needed for https://github.com/terraform-providers/terraform-provider-vcd/pull/412
Implement functions which helps work with internal disk of VM.

  • Add VM.AddInternalDisk
  • Add VM.GetInternalDisk
  • VM.DeleteInternalDisk
  • VM.UpdateInternalDisks
  • VM.UpdateInternalDisksAsync

Signed-off-by: Vaidotas Bauzys <[email protected]>
@vbauzys vbauzys requested review from dataclouder, lvirbalas and Didainius and removed request for dataclouder and lvirbalas December 5, 2019 09:25
@vbauzys vbauzys self-assigned this Dec 5, 2019
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Copy link
Collaborator

@Didainius Didainius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass.

govcd/vm.go Outdated
// GetInternalDisk returns a valid *types.DiskSettings if it exists.
// If it doesn't, returns nil and ErrorEntityNotFound or other err.
func (vm *VM) GetInternalDisk(diskId string) (*types.DiskSettings, error) {
if vm.VM.HREF == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HREF is validated, but it is not used anywhere. Also what about the "refresh" parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting me to thinking, not to have such option at all. User won't know details and get's to risk to messup no refreshing when needed and deleting disks which he wasn't expecting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added refresh handling. I made it implicit due big risk leave for user and he would forget to pass correct value.

Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Copy link
Contributor

@dataclouder dataclouder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some changes required

govcd/vm.go Outdated
}
}

if diskId == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check for valid ID before refreshing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved.

Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
@Kube-ASY Kube-ASY mentioned this pull request Dec 12, 2019
Signed-off-by: Vaidotas Bauzys <[email protected]>

# Conflicts:
#	CHANGELOG.md
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
govcd/vm.go Outdated
return nil
}

// GetInternalDiskById returns a valid *types.DiskSettings if it exists.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// GetInternalDiskById returns a valid *types.DiskSettings if it exists.
// GetInternalDiskById returns a *types.DiskSettings if one exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

govcd/vm.go Outdated
Comment on lines 993 to 994
// types.VmSpecSection requires consist of all disk entities which exist and not updated,
// as also new ones or changed ones. Returns new disk ID and error.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rephrase. I don't understand this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

govcd/vm.go Outdated
Comment on lines 1017 to 1018
// types.VmSpecSection requires consist of all disk entities which exist and not updated,
// as also new ones or changed ones.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


check.Assert(disk.StorageProfile.HREF, Equals, storageProfile.HREF)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a check for ID correspondence

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

govcd/vm_test.go Outdated
check.Assert(disk.AdapterType, Equals, diskSettings.AdapterType)
}

func (vcd *TestVCD) createInternalDisk(check *C, busNumber int) (*VM, types.Reference, *types.DiskSettings, string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment with the function purpose and the description of the returned values

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Copy link
Collaborator

@Didainius Didainius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test suites succeeded on 9.1, 9.5 and 10.

Copy link
Contributor

@dataclouder dataclouder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vbauzys vbauzys merged commit 4efd3e8 into vmware:master Jan 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants