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

Resize disk from reconfigure screen #164

Merged
merged 3 commits into from
Jan 18, 2018
Merged

Resize disk from reconfigure screen #164

merged 3 commits into from
Jan 18, 2018

Conversation

evertmulder
Copy link

PR to support resize disk from reconfigure screen.

ManageIQ/manageiq-ui-classic#3127

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])
Copy link
Member

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.

Copy link
Author

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
Copy link
Member

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)

Copy link
Author

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 ...)

Copy link
Member

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.

Copy link
Author

@evertmulder evertmulder Jan 17, 2018

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!

@evertmulder
Copy link
Author

evertmulder commented Jan 12, 2018

@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
Copy link
Member

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?

Copy link
Author

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|
Copy link
Member

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?

Copy link
Author

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'.

Copy link
Member

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
Copy link
Member

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.

Copy link
Author

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.

@agrare
Copy link
Member

agrare commented Jan 15, 2018

@evertmulder
Copy link
Author

I will try to write a test for this tomorrow. This will me my first in ruby so be gentle...

@agrare
Copy link
Member

agrare commented Jan 17, 2018

Awesome, thanks for sticking with it @evertmulder ! I'm looking forward to this functionality

@miq-bot
Copy link
Member

miq-bot commented Jan 18, 2018

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
2 files checked, 0 offenses detected
Everything looks fine. ⭐

@agrare
Copy link
Member

agrare commented Jan 18, 2018

Looking good, let me test this against a live system later today

Copy link
Member

@agrare agrare left a 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

@agrare
Copy link
Member

agrare commented Jan 18, 2018

@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

@agrare agrare merged commit ca1c96d into ManageIQ:master Jan 18, 2018
agrare added a commit that referenced this pull request Jan 18, 2018
@agrare agrare added this to the Sprint 78 Ending Jan 29, 2018 milestone Jan 18, 2018
agrare added a commit to agrare/manageiq-providers-vmware that referenced this pull request Jan 18, 2018
This adds spec tests for the new #resize_disks and
 #resize_disk_config_spec methods added here ManageIQ#164
@evertmulder
Copy link
Author

@agrare Thanks for writing the tests and the merge!

@simaishi
Copy link
Contributor

simaishi commented Jun 1, 2018

@agrare can this be gaprindashvili/yes? We need reconfigure disk feature in G-branch (ManageIQ/manageiq#16711 (comment))

@agrare
Copy link
Member

agrare commented Jun 1, 2018

@simaishi sure, the required vmware_web_service change is already included in the G branch

simaishi pushed a commit that referenced this pull request Jun 1, 2018
Resize disk from reconfigure screen
(cherry picked from commit 5042944)
@simaishi
Copy link
Contributor

simaishi commented Jun 1, 2018

Gaprindashvili backport details:

$ git log -1
commit ba3cd6a289bbaca120aba68a9d6b99dff7500cd8
Author: Adam Grare <[email protected]>
Date:   Thu Jan 18 12:49:08 2018 -0500

    Merge pull request #164 from evertmulder/ResizeDisk_ReconfigureScreen
    
    Resize disk from reconfigure screen
    (cherry picked from commit 5042944e5b5e9743b8ab7ad1c24299c13005a3c0)

@dayleparker
Copy link

Hi @simaishi, is there a PR to bring this functionality to RHV VMs as well, or is this limited to VMware VMs?

@agrare
Copy link
Member

agrare commented Jul 16, 2018

Hey @dayleparker this is just for VMware, if Ovirt wants to implement this they will need to add it to their repo.

@dayleparker
Copy link

Thanks for confirming @agrare! 👍

agrare pushed a commit to agrare/manageiq-providers-vmware that referenced this pull request Apr 15, 2019
AWS DetachVolume event switchboard setting.
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