-
Notifications
You must be signed in to change notification settings - Fork 35
Add support for matrix parameters to update memory #72
Add support for matrix parameters to update memory #72
Conversation
The oVirt API supports matrix parameters that alter the meaning of some operations, including updates. For example, the operation to update a virtual machine can receive an optional 'next_run' parameter that controls if the update is applied to the state of the current running virtual machine (the default) or only to the next execution of the virtual machine, after rebooting it. For example, to update the memory of for the next boot of the virtual machine the following request should be used: PUT /ovirt-engine/api/vms/123;next_run=true This mechanism isn't currently supported by this gem. That patch adds support for it. Signed-off-by: Juan Hernandez <[email protected]>
LGTM 👍 |
Looks good to me 👍 |
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.
besides small typo LGTM
# @param memory [Integer] The virtual memory assigned to the virtual machine, in bytes. If it is `nil` then | ||
# the virtual memory won't be updated. | ||
# | ||
# @param guaranteed [Integer] The ammount of physical memory reserved for the virtual machine, in bytes. If |
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.
typo amount
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.
Fixed in the next version.
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.
Overall, looks good, just a couple minor comments. Thanks @jhernand
# | ||
def update_memory(memory, guaranteed, matrix = {}) | ||
update!(matrix) do |xml| | ||
unless memory.nil? |
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.
if memory
would be easier to follow
unless memory.nil? | ||
xml.memory memory | ||
end | ||
unless guaranteed.nil? |
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.
same
@@ -194,6 +219,110 @@ def expected_data(element) | |||
end | |||
end | |||
|
|||
context '#update_memory' do | |||
it 'updates only `memory` if `guaranteed` is nil' do |
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.
Please only use single and double quotes.
vm.update_memory(memory, guaranteed) | ||
end | ||
|
||
it 'updates only `guaranteed` if `memory` is nil' do |
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.
same
vm.update_memory(memory, guaranteed) | ||
end | ||
|
||
it "adds the `next_run=true` matrix parameter correctly" do |
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.
same
Currently the methods 'memory=' and 'memory_reserve=' of the 'Vm' class don't support adding matrix parameters, and thus they don't support adding the 'next_run' parameter which is very relevant when updating virtual machines. This patch adds a ne method named 'update_memory' that can update simultaneously the virtual and guaranteed memory, and that supports matrix parameters. The 'memory=' and 'memory_reserve=' methods are then re-implemented as simple calls to the new method. Signed-off-by: Juan Hernandez <[email protected]>
@bdunne this new version addresses your comments. |
Checked commits https://github.com/jhernand/ovirt/compare/440bd13a9a63a4fc7e6e879f404e93313d20af02~...e579b2c100719e1c1abed5d1e42b86685a4769b5 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 lib/ovirt/version.rb
|
@@ -1,3 +1,3 @@ | |||
module Ovirt | |||
VERSION = "0.13.0" | |||
VERSION = "0.14.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.
Please don't change the version in your PR.
@bdunne removed the commit that changes the version. |
Currently the methods
memory=
andmemory_reserve=
of theVm
classdon't support adding matrix parameters, and thus they don't support
adding the
next_run
parameter which is very relevant when updatingvirtual machines. This patch adds a new method named
update_memory
that can update simultaneously the virtual and guaranteed memory, and
that supports matrix parameters. The
memory=
andmemory_reserve=
methods are then re-implemented as simple calls to the new method.
https://bugzilla.redhat.com/1356468
https://bugzilla.redhat.com/1356475