-
Notifications
You must be signed in to change notification settings - Fork 91
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 'default_security_group' method to CloudTenant #347
Add 'default_security_group' method to CloudTenant #347
Conversation
369b00c
to
bb393fa
Compare
bb393fa
to
2ec415b
Compare
Checked commit mansam@2ec415b with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 spec/models/manageiq/providers/openstack/cloud_manager/cloud_tenant_spec.rb
|
Looks good to me, merging 👍 |
return default if default | ||
# if there's not a security group named "default", | ||
# then return the security group with the most VMs in it. | ||
security_groups.sort { |sg| sg.vms.count }.last |
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.
btw. this looks pretty inefficient, there can be a lot of security groups
This method is really bad. the large number of security groups and then the N+1 count for each of the vm counts is really bad. Also, making this a virtual attribute means it is exposed for everyone - it probably needs to move to the core It still is a bunch of work, but at least is done on the database: I'll ping @Ladas |
@mansam thanks - will look into that |
@mansam you are right - it looks like that is using a Will try and think up another way to avoid the N+1 queries |
Adds a
default_security_group
instance method to CloudTenant that returns a security group nameddefault
if that CloudTenant has one, or else returns the security group with the highest population of VMs.