-
Notifications
You must be signed in to change notification settings - Fork 897
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 methods to conversion_host to build virt-v2v wrapper options #18033
Changes from 2 commits
289c53f
02b51cc
4e00a40
9adf783
b2e4f75
4cc9a2a
fba16e2
a94f7c5
4e65f07
670f3dc
531e98f
3e5e83c
5f683be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,104 @@ class ConversionHost < ApplicationRecord | |
acts_as_miq_taggable | ||
|
||
belongs_to :resource, :polymorphic => true | ||
has_many :service_template_transformation_plan_tasks, :dependent => :nullify | ||
|
||
def active_tasks | ||
service_template_transformation_plan_tasks { active } | ||
end | ||
|
||
def eligible? | ||
return true if concurrent_transformation_limit.nil? | ||
active_tasks.size < concurrent_transformation_limit.to_i | ||
end | ||
|
||
def source_transport_method | ||
return 'vddk' if vddk_transport_supported | ||
return 'ssh' if ssh_transport_supported | ||
end | ||
|
||
def conversion_options(task) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you do change the task to a true relationship, then this method could probably be replaced with a number of delegate methods. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely. What release are we targeting there ? Hammer or I-release ? Given that we're past code freeze for Hammer, I'd say, we're aiming I-release, unless we've got a derogation 😜 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, the relationship is made so task belongs to conversion_host. Then, I'm not sure how I can delegate from conversion_host to task, as it has many tasks. That would require that the task is passed to the conversion. Is there a way to do it ? I'm a delegation newbie. |
||
source_vm = task.source | ||
source_ems = source_vm.ext_management_system | ||
source_cluster = source_vm.ems_cluster | ||
source_storage = source_vm.hardware.disks.select { |d| d.device_type == 'disk' }.first.storage | ||
|
||
destination_cluster = task.transformation_destination(source_cluster) | ||
destination_storage = task.transformation_destination(source_storage) | ||
destination_ems = destination_cluster.ext_management_system | ||
|
||
source_provider_options = send( | ||
"conversion_options_source_provider_#{source_ems.emstype}_#{source_transport_method}", | ||
source_vm, | ||
source_storage | ||
) | ||
destination_provider_options = send( | ||
"conversion_options_destination_provider_#{destination_ems.emstype}", | ||
task, | ||
destination_ems, | ||
destination_cluster, | ||
destination_storage | ||
) | ||
options = { | ||
:source_disks => task.source_disks.map { |disk| disk[:path] }, | ||
:network_mappings => task.network_mappings | ||
} | ||
options.merge(source_provider_options).merge(destination_provider_options) | ||
end | ||
|
||
def conversion_options_source_provider_vmwarews_vddk(vm, _storage) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fdupont-redhat should these below methods be on the conversion_task model? What from the conversion_host do they use? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, they should be in the task... And that also answers #18033 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 awesome, if there is anything that the task needs from the conversion_host we can delegate those to the conversion_host as @blomquisg said above |
||
{ | ||
:vm_name => vm.name, | ||
:transport_method => 'vddk', | ||
:vmware_fingerprint => vm.host.fingerprint, | ||
:vmware_uri => URI::Generic.build( | ||
:scheme => 'esx', | ||
:userinfo => CGI.escape(vm.host.authentication_userid), | ||
:host => vm.host.ipaddress, | ||
:path => '/', | ||
:query => { :no_verify => 1 }.to_query | ||
).to_s, | ||
:vmware_password => vm.host.authentication_password | ||
} | ||
end | ||
|
||
def conversion_options_source_provider_vmwarews_ssh(vm, storage) | ||
{ | ||
:vm_name => URI::Generic.build(:scheme => 'ssh', :userinfo => 'root', :host => vm.host.ipaddress, :path => "/vmfs/volumes").to_s + "/#{storage.name}/#{vm.location}", | ||
:transport_method => 'ssh' | ||
} | ||
end | ||
|
||
def conversion_options_destination_provider_rhevm(_task, ems, cluster, storage) | ||
{ | ||
:rhv_url => URI::Generic.build(:scheme => 'https', :host => ems.hostname, :path => '/ovirt-engine/api').to_s, | ||
:rhv_cluster => cluster.name, | ||
:rhv_storage => storage.name, | ||
:rhv_password => ems.authentication_password, | ||
:install_drivers => true, | ||
:insecure_connection => true | ||
} | ||
end | ||
|
||
def conversion_options_destination_provider_openstack(task, ems, cluster, storage) | ||
{ | ||
:osp_environment => { | ||
:os_no_cache => true, | ||
:os_auth_url => URI::Generic.build( | ||
:scheme => ems.security_protocol == 'non-ssl' ? 'http' : 'https', | ||
:host => ems.hostname, | ||
:port => ems.port, | ||
:path => ems.api_version | ||
), | ||
:os_user_domain_name => ems.uid_ems, | ||
:os_username => ems.authentication_userid, | ||
:os_password => ems.authentication_password, | ||
:os_project_name => cluster.name | ||
}, | ||
:osp_destination_project_id => cluster.ems_ref, | ||
:osp_volume_type_id => storage.ems_ref, | ||
:osp_flavor_id => task.destination_flavor.ems_ref, | ||
:osp_security_groups_ids => [task.destination_security_group.ems_ref] | ||
} | ||
end | ||
end |
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.
You have to define the scope in miq_request_task:
Then here it will look like:
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.
Tried it but it fails during tests.