-
Notifications
You must be signed in to change notification settings - Fork 69
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
Resize disk from reconfigure screen #164
Resize disk from reconfigure screen #164
Conversation
controller_key, key = vim_obj.getDeviceKeysByBacking(options[:disk_name], hardware) | ||
raise "resize_disk_config_spec: no virtual device associated with: #{options[:disk_name]}" unless key | ||
|
||
device = vim_obj.getDeviceByBacking(options[:disk_name]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah here's an example of where we can pass in the hardware hash and save an API call. If you call just this method you can get the controller_key and key from the device returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup I will fix that
vdcs.device = VimHash.new("VirtualDisk") do |dev| | ||
dev.key = key | ||
dev.capacityInKB = options[:disk_size_in_mb].to_i * 1024 | ||
dev.controllerKey = controller_key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need the rest of these? I think just key is required plus whatever you want to change (ref: https://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.vm.device.VirtualDevice.html)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some testing.
Removing dev.connectable --> No problem, removing this
Removing dev.backing --> Error: Incompatible device backing specified for device '0'., keeping this
Removing dev.unitNumber --> Error: Invalid configuration for device '0', keeping this
Removing dev.controllerKey --> Error: Device requires a controller., keeping this
Do you know a quicker way testing these option, currently I do a evm:stop / evm:start to test code changes in provider code, is there a quicker way (I tried killing some workers (generic, refesh or broker), they are restarted but I keep hitting the old code ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, so yes you can run in one console bin/rails s
to run the UI and bin/rails c
in another and run simulate_queue_worker
in the rails c terminal. That way you can just ctrl-C the worker Sim and reload!
the code when you change something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah cool. I will try this!
@agrare Is it possible to restart travis? I think it should work now, because ManageIQ/manageiq#16711 is merged now... |
add_device_config_spec(vmcs, VirtualDeviceConfigSpecOperation::Edit) do |vdcs| | ||
vdcs.device = VimHash.new("VirtualDisk") do |dev| | ||
dev.key = device.key | ||
dev.capacityInKB = options[:disk_size_in_mb].to_i * 1024 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're using options[:disk_size_in_mb].to_i * 1024
twice can you just save it as a local var e.g. new_capacity_in_kb
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️ I will improve this
dev.controllerKey = device.controllerKey | ||
dev.unitNumber = device.unitNumber | ||
|
||
dev.backing = VimHash.new("VirtualDiskFlatVer2BackingInfo") do |bck| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no guarantee that the backing type will be FlatVer2, you have the device so you could either do VimHash.new(device.backing.xsiType)
, or just use the backing dev.backing = device.backing
since you aren't changing anything in the backing.
I assume you tried not passing the backing in at all and it failed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, not passing the backing results in --> Error: Incompatible device backing specified for device '0'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
dev.backing = VimHash.new("VirtualDiskFlatVer2BackingInfo") do |bck| | ||
bck.diskMode = device.backing.diskMode | ||
bck.thinProvisioned = device.backing.thinProvisioned | ||
bck.fileName = device.backing.fileName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are tricky because they aren't defined for all backing types, not even all types that extend VirtualDeviceFileBackingInfo
. E.g. VirtualDiskRawDiskMappingVer1BackingInfo
doesn't have thinProvisioned
or fileName
.
If we have to send a backing I would prefer sending the entire backing from the existing disk so we don't have to worry about these issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes without the backing the call fails. SO I think something like
dev.backing = device.backing
I will try this tomorrow.
@evertmulder this is coming along :) Couple of comments, can you also add some tests to https://github.com/ManageIQ/manageiq-providers-vmware/blob/master/spec/models/manageiq/providers/vmware/infra_manager/vm/reconfigure_spec.rb ? |
I will try to write a test for this tomorrow. This will me my first in ruby so be gentle... |
Awesome, thanks for sticking with it @evertmulder ! I'm looking forward to this functionality |
Checked commits evertmulder/manageiq-providers-vmware@dc852d2~...ca1c96d with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0 |
Looking good, let me test this against a live system later today |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM, tested against a few live VMs and this worked perfectly
@evertmulder if you haven't gotten very far with specs I'll follow this up with some tests, it is difficult if you're not used to it |
Resize disk from reconfigure screen
This adds spec tests for the new #resize_disks and #resize_disk_config_spec methods added here ManageIQ#164
@agrare Thanks for writing the tests and the merge! |
@agrare can this be |
@simaishi sure, the required vmware_web_service change is already included in the G branch |
Resize disk from reconfigure screen (cherry picked from commit 5042944)
Gaprindashvili backport details:
|
Hi @simaishi, is there a PR to bring this functionality to RHV VMs as well, or is this limited to VMware VMs? |
Hey @dayleparker this is just for VMware, if Ovirt wants to implement this they will need to add it to their repo. |
Thanks for confirming @agrare! 👍 |
AWS DetachVolume event switchboard setting.
PR to support resize disk from reconfigure screen.
ManageIQ/manageiq-ui-classic#3127