-
Notifications
You must be signed in to change notification settings - Fork 118
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
V2V - State machines - Initial work #248
V2V - State machines - Initial work #248
Conversation
@miq-bot add_label v2v |
@fdupont-redhat Cannot apply the following label because they are not recognized: v2v |
@bzwei Please review |
…nly about the role enblement.
scope: instance | ||
language: ruby | ||
location: inline | ||
options: {} |
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.
@fdupont-redhat Is this missing the embedded methods data since your method is using the embedded methods
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.
Where do you see it using an embedded method ? That one doesn't. Anyway, I see I forgot to rename the module from ConversionHost to TransformationHost.
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.
@fdupont-redhat in your earlier ruby code you had
if @debug
ManageIQ::Automate::System::CommonMethods::MIQ_AE::Debug.new.dump_object
ManageIQ::Automate::System::CommonMethods::MIQ_AE::Debug.new.dump_root
end
which would have needed the embedded methods, now that you have removed it, its not relevant.
scope: instance | ||
language: ruby | ||
location: inline | ||
options: {} |
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.
@fdupont-redhat This might also be missing the embedded_methods names.
end | ||
|
||
def get_runners_count_by_host(host) | ||
return @handle.vmdb(:vm).all.select { |v| v.custom_get('Transformation Host') == host.name }.size |
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.
@fdupont-redhat dont need the return here
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.
@fdupont-redhat This can be an expensive call fetching all the vms and then fetching/comparing host name.
Its good in the sense that it doesn't require locking the host record to add/remove vms being transformed
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 you have a less expensive approach, I take.
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.
@fdupont-redhat You could lookup the CustomAttribute records that has the matching name
and value
properties and get the count from there. If needed you can limit the result set to just VMs by only returning ones with resource_type => VmOrTemplate
.
Maybe @handle.vmdb(:custom_attribute).where(:name => 'Transformation Host', :value => host.name).size
@fdupont-redhat It would be good if you could run through the rubocop warning/errors and address those as a first pass. |
return @handle.vmdb(:vm).all.select { |v| v.custom_get('Transformation Host') == host.name }.size | ||
end | ||
|
||
def get_runners_count_by_ems(ems) |
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.
@fdupont-redhat
def get_runners_count_by_ems
get_transformation_hosts.inject(0){|sum,host| sum + get_runners_count_by_host(host) }
end
@handle.log(:info, "No transformation host found.") | ||
else | ||
@handle.log(:info, "Least busy transformation host: #{transformation_host}") | ||
vm.custom_set('Transformation Host', transformation_host.guid) |
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.
@fdupont-redhat are transformation_host.guid and transformation_host.name the same, since in line # 19 you are using name.
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.
It will be changed, as the transformation host will be part of the options
hash of the transformation task, rather that the VM.
end | ||
|
||
def unset_transformation_host(vm) | ||
vm.custom_set('Transformation Host', 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.
@fdupont-redhat can the custom attribute be deleted instead of being set to nil. Will the nil logic be used elsewhere to compare completed transformations.
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.
This is how you do it. There are only three methods exposed custom_keys, custom_get
and custom_set
.
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.
It will be changed, as the transformation host will be part of the options hash of the transformation task, rather that the VM.
max_runners = factory_config['transformation_host_max_runners'] if max_runners.blank? | ||
next if runners_count == max_runners | ||
( transformation_host = host ; break ) if runners_count == 0 | ||
if transformation_host.nil? || runners_count < min_runners |
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.
@fdupont-redhat How is the min_runners being set, it starts out as nil and only gets set inside of the if block to the runner count. The || logic seems odd.
fields: | ||
- State1: | ||
value: "/Transformation/TransformationHost/${#transformation_host_type}/RoleCheck" | ||
on_error: "/Transformation/TransformationHost/${#transformation_host_type}/MarkAsDisabled" |
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.
@fdupont-redhat
We dont support paths in on_error/on_exit/on_entry slots?
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.
Well, a typo while copying. It should be /Transformation/TransformationHost/${#transformation_host_type}.MarkAsDisabled
.
datatype: string | ||
priority: 0 | ||
owner: | ||
default_value: bastion.v2v.example.com |
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.
@fdupont-redhat the default value should be empty
datatype: string | ||
priority: 1 | ||
owner: | ||
default_value: http://bastion.v2v.example.com/vddk/VMware-vix-disklib-6.5.2-6195444.x86_64.tar.gz |
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.
@fdupont-redhat please check default value
…sformation Host role.
@fdupont-redhat Can you cleanup the two Not sure why we are seeing the other rubocop about parameters at the moment. |
@gmcculloug These errors are strange, as this syntax is found in all the methods that implement the module layout. For example: https://github.com/ManageIQ/manageiq-content/blob/master/content/automate/ManageIQ/Cloud/Orchestration/Operations/Methods.class/__methods__/available_tenants.rb. |
Correct, the Ultimately we will want to go through and correct them all, but the goal is not to introduce more warnings. |
@gmcculloug WIP label removed and all lights green on rubocop side. |
@tinaafitz @mkanoor Can you give this another look after changes? |
Forgot to add the request entrypoints for the role check/enable/disable state machines. @tinaafitz @lfu What would you advise for the request names ? |
fields: | ||
- State1: | ||
value: "/Transformation/TransformationHosts/${#transformation_host_type}/RoleCheck" | ||
on_error: "/Transformation/TransformationHosts/${#transformation_host_type}.MarkAsDisabled" |
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.
Where is MarkAsDisabled
defined?
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.
There is a TagAsEnabled? Does this needs to be renamed.
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're right. It is TagAsDisabled. I have renamed it.
value: "/Transformation/TransformationHosts/${#transformation_host_type}/RoleCheck" | ||
on_error: "/Transformation/TransformationHosts/${#transformation_host_type}.MarkAsDisabled" | ||
- State2: | ||
value: "/Transformation/TransformationHosts/${#transformation_host_type}.MarkAsEnabled" |
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 here.
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.
@fdupont-redhat Does this need a METHOD:: since its a call to a class method
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.
@fdupont-redhat Also is this TagAsEnabled?
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're right. It is TagAsDisabled. I have renamed it.
@mkanoor METHOD::
is not needed because on_error
expects method(s). I don't know how it is coded internally, but experimentally it works without it. If you think I should make it explicit, I'll change it.
Checked commits fabiendupont/manageiq-content@2082d92~...8ef9427 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0 **
|
…dpoints for custom buttons.
@miq-bot remove_label wip |
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.
@fdupont-redhat Looks good.
…Q/manageiq-content/pull/248. Removed code for sysprep state, as we won't use them. Moved the code to a sub directory to ease import.
…machines_init V2V - State machines - Initial work (cherry picked from commit 15b3a0e)
Gaprindashvili backport details:
|
This is the initial work to integrate the state machines and methods required to transform virtual machines.
There are three main areas: