Skip to content
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

fixes #9249 - associated_host fixed for all compute resources #2147

Closed
wants to merge 1 commit into from

Conversation

unorthodoxgeek
Copy link
Member

No description provided.

@dLobatog
Copy link
Member

Thanks @unorthodoxgeek , this seems to work well.

Could you take this one step further and remove the code duplication by adding a method in the parent class (ComputeResource)? Something along the lines of

def associate_by(name, attributes)
 Host.authorized(:view_hosts, Host).joins(:primary_interface).
  where(:nics => {:primary => true}).
  where("nics.#{name}" => attributes).
  first
end

then change the methods in the specific CRs to associate_by('mac', vm.mac) and associate_by('ip', [vm.public_ip_address, vm.private_ip_address]). That's just what I came up with in 1 minute, maybe it can be done even DRYer 😄

@unorthodoxgeek
Copy link
Member Author

@elobato - done

@dLobatog
Copy link
Member

👏 thanks @unorthodoxgeek , merged as 81a02cd , I opened this issue for a future refactoring of the tests.

@dLobatog dLobatog closed this Feb 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants