Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Add support for matrix parameters to update memory #72

Merged
merged 2 commits into from
Nov 18, 2016
Merged

Add support for matrix parameters to update memory #72

merged 2 commits into from
Nov 18, 2016

Conversation

jhernand
Copy link
Contributor

@jhernand jhernand commented Nov 10, 2016

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

https://bugzilla.redhat.com/1356468
https://bugzilla.redhat.com/1356475

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]>
@jhernand
Copy link
Contributor Author

@jelkosz, @borod108, @masayag please review.

@jhernand
Copy link
Contributor Author

@jelkosz
Copy link
Contributor

jelkosz commented Nov 11, 2016

LGTM 👍

@masayag
Copy link
Contributor

masayag commented Nov 13, 2016

Looks good to me 👍

@jhernand
Copy link
Contributor Author

@bdunne, @durandom please review/merge.

Copy link
Member

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

Choose a reason for hiding this comment

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

typo amount

Copy link
Contributor Author

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.

@jhernand
Copy link
Contributor Author

Copy link
Member

@bdunne bdunne left a 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?
Copy link
Member

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

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

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

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

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]>
@jhernand
Copy link
Contributor Author

@bdunne this new version addresses your comments.

@miq-bot
Copy link
Member

miq-bot commented Nov 18, 2016

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
4 files checked, 1 offense detected

lib/ovirt/version.rb

@jhernand
Copy link
Contributor Author

@bdunne I have other two pull requests pending for this gem: /pull/69 and /pull/73. Would you like to merge this pull requests and those pull requests and then do the new release? Should I remove from this pull request the patch that bumps the release number?

@durandom
Copy link
Member

@miq-bot assign @bdunne

@bdunne are you able to merge this?

@@ -1,3 +1,3 @@
module Ovirt
VERSION = "0.13.0"
VERSION = "0.14.0"
Copy link
Member

@bdunne bdunne Nov 18, 2016

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.

@jhernand
Copy link
Contributor Author

@bdunne removed the commit that changes the version.

@bdunne bdunne merged commit 9a282bd into ManageIQ:master Nov 18, 2016
bdunne added a commit that referenced this pull request Nov 21, 2016
- Fix discovery of oVirt v4 [#69]
- Allow passing params to Base#update, Update Vm#memory & Vm#guaranteed in one call to Vm#update_memory [#72]
- Update event map [#71]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants