-
Notifications
You must be signed in to change notification settings - Fork 120
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
Refactoring cloud vm retirement pre_retirement method #259
Refactoring cloud vm retirement pre_retirement method #259
Conversation
def main | ||
vm = @handle.root['vm'] | ||
if vm && vm.power_state == 'on' | ||
ems = vm.ext_management_system |
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.
@tinaafitz if the ems is missing and the vm is powered on, should we be raising an exception and stopping the workflow or should we keep continuing. I remember we had some corner cases that we were trying to solve where a failed retirement is restarted. If there is no ems should we log the fact that its an orphaned 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.
@mkanoor We should continue processing if the ems is nil and the VM will have the power state of "unknown" in that case
@pkomanek
|
end | ||
|
||
it 'does not stop a vm in \'powered_off\' state' do | ||
vm.update_attribute(:raw_power_state, "PowerOff") |
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.
Use: vm.update_attributes(:raw_power_state => "PowerOff")
def main | ||
vm = @handle.root['vm'] | ||
if vm && vm.power_state == 'on' | ||
ems = vm.ext_management_system |
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.
@mkanoor We should continue processing if the ems is nil and the VM will have the power state of "unknown" in that case
vm = @handle.root['vm'] | ||
if vm && vm.power_state == 'on' | ||
ems = vm.ext_management_system | ||
@handle.log('info', "Stopping Instance <#{vm.name}> in EMS <#{ems.try(: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.
@pkomanek Can you issue the log message only if there is an ems? You can remove the try from the log message in that case.
something like
if ems
@handle.log('info', "Stopping Instance <#{vm.name}> in EMS <#{ems.name}>")
vm.stop
end
Checked commits pkomanek/manageiq-content@04ce09a~...cc615ec with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
bump @mkanoor @gmcculloug |
Purpose or Intent
Refactoring Cloud/VM/Retirement/StateMachines/Methods.class/methods/pre_retirement.rb method with spec. This PR is based on the issue bellow.
Links
#8
@miq-bot add_label refactoring