Closed ksagle77 closed 6 years ago
changing
options.delete_if { |o| o.start_with? '_' }
to
options.delete_if { |o| o.to_s.start_with? '_' }
also allows me to click and see VM details (still with N/A state.)
Oh dear, another stupid mistake that should've never been committed in the first place. There should indeed be a to_s
there.
I'll try and have a look at the enum issue tomorrow, I have an idea of exactly where the problem might lay, but I'll need to get to my test setup before I can verify it.
Thanks for testing and reporting the issues. :heart:
Enum handling should work now, so no more state being N/A.
Could you test if this also solves the capitalize issue for you? I think the error comes from Foreman's own compute resource controller, which tries to run notice _("%{vm} is now %{vm_state}") % {:vm => @vm, :vm_state => @vm.state.capitalize}
for state changes.
Hey,
Enum issue seems to be corrected on the Fog side. I am able to query and start VMs from fog now:
From foreman, the VM starts/stops correctly, but the following is thrown:
Thanks Ace! :)
Right, Ruby 2.4 has done some changes apparently.
Pushed another commit for that, hopefully that'll work even better for you with it :)
Hey Ace,
It doesn't seem to like integer instead of fixnum.
[4] pry(main)> compute.servers[1].ready?
Fog::Hyperv::Errors::ServiceError: :"2" is not one of [:Unknown, :Running, :Off, :Stopping, :Saved, :Paused, :Starting, :Reset, :Saving, :Pausing, :Resuming, :FastSaved, :FastSaving, itical, :StoppingCritical, :SavedCritical, :PausedCritical, :StartingCritical, :ResetCritical, :SavingCritical, :PausingCritical, :ResumingCritical, :FastSavedCritical, :FastSavingCri
from /home/kevin/test_8/new/fog-hyperv/lib/fog/hyperv/fog_extensions/enum.rb:38:in `state='
[5] pry(main)>
I was able to get it working with Numeric:
However, that caused a problem getting the power state in foreman:
Issue is that state returns a symbol:
I was able to resolve this by modifying create_getter like this:
def create_getter
ensure_value_getter
model.class_eval <<-EOS, __FILE__, __LINE__
def #{name}_num
_values = #{name}_values
return nil if self.#{name}.nil?
if self.#{name}.is_a?(Fixnum)
self.#{name}
elsif self.#{name}.is_a?(Symbol)
_values[self.#{name}]
else
if _values.is_a?(Hash)
_values.key(self.#{name})
else
_values.index(self.#{name})
end
end
end
EOS
But I'm unsure if that would have other unintended consequences.
Kevin
Big thanks for the debugging help, I've got an idea about how to properly solve the foreman power issue as well, without causing issues in other ways. I won't have time to push that code until later today though.
On 25 Jan 2018 15:47, "ksagle77" notifications@github.com wrote:
Hey Ace,
It doesn't seem to like integer instead of fixnum.
[4] pry(main)> compute.servers[1].ready? Fog::Hyperv::Errors::ServiceError: :"2" is not one of [:Unknown, :Running, :Off, :Stopping, :Saved, :Paused, :Starting, :Reset, :Saving, :Pausing, :Resuming, :FastSaved, :FastSaving, itical, :StoppingCritical, :SavedCritical, :PausedCritical, :StartingCritical, :ResetCritical, :SavingCritical, :PausingCritical, :ResumingCritical, :FastSavedCritical, :FastSavingCri from /home/kevin/test_8/new/fog-hyperv/lib/fog/hyperv/fog_extensions/enum.rb:38:in `state=' [5] pry(main)>
I was able to get it working with Numeric:
[image: image] https://user-images.githubusercontent.com/34070189/35391889-fce40e68-01ad-11e8-9eed-f50b96b07b3b.png
However, that caused a problem getting the power state in foreman:
[image: image] https://user-images.githubusercontent.com/34070189/35393213-518c3590-01b2-11e8-94f2-fd76fc7f7403.png
Issue is that state returns a symbol:
[image: image] https://user-images.githubusercontent.com/34070189/35393665-a01383ca-01b3-11e8-9d28-89a4910d2b63.png
I was able to resolve this by modifying create_getter like this:
def create_getter ensure_value_getter model.class_eval <<-EOS, __FILE__, __LINE__ def #{name}_num _values = #{name}_values return nil if self.#{name}.nil? if self.#{name}.is_a?(Fixnum) self.#{name} elsif self.#{name}.is_a?(Symbol) _values[self.#{name}] else if _values.is_a?(Hash) _values.key(self.#{name}) else _values.index(self.#{name}) end end end EOS
But I'm unsure if that would have other unintended consequences. [image: image] https://user-images.githubusercontent.com/34070189/35393826-1aca4b30-01b4-11e8-8ff4-dc5bd3ed11f0.png
[image: image] https://user-images.githubusercontent.com/34070189/35393843-25cbe0b6-01b4-11e8-91da-5cdecff9d748.png
Kevin
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/ace13/fog-hyperv/issues/19#issuecomment-360487441, or mute the thread https://github.com/notifications/unsubscribe-auth/AAgnvKSC98BE4JxTuPPWI3WtvUdF8Rgyks5tOJPkgaJpZM4Rp2tb .
Pushed a new commit to both fog-hyperv
and foreman_hyperv
, hopefully that should take care of that last issue.
Thanks again for the debugging and reporting :heart:
I can confirm that your patch resolves the issue. Small note: the gem version still contains the bugged code.
Tagged and pushed a new version with all these fixes
Hey,
I'm seeing the following issue, likely related to https://github.com/ace13/fog-hyperv/commit/4574e20c073e79ce03b3069e0b5d4f4476de3c6c#diff-71f294f976a361bc4b9099a12f5c25ae.
State is returned as null from fog at command line:
In the foreman, VMs all show as powered off.
Clicking on one of the VMs throws the following:
If I comment out the following line in lib/fog/hyperv/compute.rb:
I am able to see the VM details with N/A as the state.
Trying to power on the VM throws the following:
However, the VM does actually start:
Kevin