-
Notifications
You must be signed in to change notification settings - Fork 900
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 best fit logic for transformations moving vms to openstack #17880
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class TransformationMapping | ||
class CloudBestFit | ||
attr_reader :source_vm, :destination_manager | ||
def initialize(source_vm, destination_manager) | ||
@source_vm = source_vm | ||
@destination_manager = destination_manager | ||
end | ||
|
||
def available_fit_flavors | ||
@available_fit_flavors ||= destination_manager.flavors.where( | ||
:cpus => source_vm.cpu_total_cores..Float::INFINITY, | ||
:memory => (source_vm.hardware.memory_mb * 1.megabyte)..Float::INFINITY | ||
).order(:cpus, :memory) | ||
end | ||
|
||
def best_fit_flavor | ||
available_fit_flavors.first | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
describe TransformationMapping::CloudBestFit do | ||
let(:ems) { FactoryGirl.create(:ems_openstack) } | ||
let(:vm) { FactoryGirl.create(:vm_vmware, :hardware => vm_hardware) } | ||
let(:vm_hardware) { FactoryGirl.create(:hardware, :cpu1x2, :ram1GB) } | ||
|
||
subject { described_class.new(vm, ems) } | ||
|
||
it "no flavors on the provider" do | ||
expect(subject.available_fit_flavors).to match_array([]) | ||
expect(subject.best_fit_flavor).to be_nil | ||
end | ||
|
||
it "no flavors match" do | ||
ems.flavors.create!(:cpus => 1, :memory => 512.megabytes) | ||
|
||
expect(subject.available_fit_flavors).to match_array([]) | ||
expect(subject.best_fit_flavor).to be_nil | ||
end | ||
|
||
it "one flavor matches" do | ||
ems.flavors.create!(:cpus => 2, :memory => 512.megabytes) | ||
flavor = ems.flavors.create!(:cpus => 2, :memory => 1.gigabyte) | ||
|
||
expect(subject.available_fit_flavors).to match_array([flavor]) | ||
expect(subject.best_fit_flavor).to eq(flavor) | ||
end | ||
|
||
it "multiple flavors match" do | ||
ems.flavors.create!(:cpus => 2, :memory => 512.megabytes) | ||
flavor1 = ems.flavors.create!(:cpus => 2, :memory => 1.gigabyte) | ||
flavor2 = ems.flavors.create!(:cpus => 2, :memory => 2.gigabytes) | ||
flavor3 = ems.flavors.create!(:cpus => 4, :memory => 1.gigabyte) | ||
|
||
expect(subject.available_fit_flavors).to match_array([flavor1, flavor2, flavor3]) | ||
expect(subject.best_fit_flavor).to eq(flavor1) | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@agrare Are there any other attributes that we need to match up?
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.
@bdunne flavors just have a total number of CPUs so cpu_total_cores is the correct attribute 👍
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.
@agrare Do we need to worry about root disk or any of those attributes?
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.
Ohh thought you meant specifically about CPUs. I don't know how/if the flavor's root_disk_size is used by the virt-v2v migration tool. @aufi @fdupont-redhat do you know?
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.
ping @aufi @mansam @fdupont-redhat do you guy know what is required re: target flavor
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.
Unless we have this information from fleecing the VM
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.
So worst case, if we pick a flavor that has a root disk that is smaller than the VM that we're migrating from will the conversion fail?
/cc @rwmjones if you're reading this :D @fdupont-redhat because I know you get notifications
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.
@agrare TBH, I don't know. We should test it.
@rwjones do you have an environment to test it ?
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.
@bdunne I say we merge this as-is with cpu/memory and come back and revisit after we get clarity on the disk size issue.
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.
Sounds good, it's easy to add more later once we know what the right answer is.