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

Limit CloudTenants' related VMs to the non-archived ones #15329

Merged
merged 1 commit into from
Jun 14, 2017

Conversation

skateman
Copy link
Member

@skateman skateman commented Jun 7, 2017

When archiving a cloud instance, its cloud tenant value does not get nullified. This causes the cloud topology screen to render unwanted archived VMs. This method filters out the archived VMs and I'm planning to use it in the topology service.

https://bugzilla.redhat.com/show_bug.cgi?id=1456031

@@ -158,4 +158,8 @@ def self.post_refresh_ems(ems_id, _)
def self.tenant_joins_clause(scope)
scope.includes(:source_tenant).includes(:ext_management_system)
end

def active_vms
vms.where.not(:ems_id => nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should have in VmOrTemplate

scope :active, -> { where.not(:ems_id => nil) }

then here:

has_many :active_vms, -> {active}, :foreign_key => :cloud_tenant_id, :class_name => "Vm"

@skateman skateman force-pushed the cloud-tenant-active-vms branch from 88f2d4e to 870fc28 Compare June 7, 2017 09:09
@@ -14,6 +14,7 @@ class CloudTenant < ApplicationRecord
has_many :network_routers
has_many :vms
has_many :vms_and_templates
has_many :active_vms, -> { active }, :foreign_key => :cloud_tenant_id, :class_name => "Vm"
Copy link
Contributor

@Ladas Ladas Jun 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be that we just need has_many :vms, -> { active }

it's consistent with the behavior elsewhere, where we delete e.g. availability_zone_id. Seems like we've forgot to delete the cloud_tenant_id here. So has_mane :vms, -> { active } is equivalent to having cloud_tenant_id deleted, but it's cleaner because we can keep the foreign key.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it might break existing reports relying on that relation

@skateman skateman force-pushed the cloud-tenant-active-vms branch from 870fc28 to 5116d71 Compare June 8, 2017 08:27
@skateman skateman changed the title Add a method to CloudTenant to retrieve non-archived VMs only Limit CloudTenants' related VMs to the non-archived ones Jun 8, 2017
Copy link
Contributor

@lpichler lpichler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

  • reports are not affected because we have no reports based on cloud tenants
  • it can affect API
    call for example:
    http://localhost:3000/api/cloud_tenants/1000000000002\?attributes\=vms - but is is probably ok

@skateman skateman closed this Jun 8, 2017
@skateman skateman reopened this Jun 8, 2017
@skateman
Copy link
Member Author

skateman commented Jun 8, 2017

restart ci

@skateman skateman force-pushed the cloud-tenant-active-vms branch from 5116d71 to 0f49153 Compare June 12, 2017 09:17
@skateman skateman force-pushed the cloud-tenant-active-vms branch from 0f49153 to 8ea6c77 Compare June 12, 2017 11:17
@miq-bot
Copy link
Member

miq-bot commented Jun 12, 2017

Checked commit skateman@8ea6c77 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 0 offenses detected
Everything looks fine. 🏆

Copy link
Contributor

@Ladas Ladas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great 👍

@Ladas
Copy link
Contributor

Ladas commented Jun 14, 2017

@miq-bot assign @blomquisg

@miq-bot miq-bot assigned blomquisg and unassigned Ladas Jun 14, 2017
@blomquisg blomquisg merged commit 9e19b17 into ManageIQ:master Jun 14, 2017
@blomquisg blomquisg added this to the Sprint 63 Ending Jun 19, 2017 milestone Jun 14, 2017
simaishi pushed a commit that referenced this pull request Jun 14, 2017
Limit CloudTenants' related VMs to the non-archived ones
(cherry picked from commit 9e19b17)

https://bugzilla.redhat.com/show_bug.cgi?id=1461596
@simaishi
Copy link
Contributor

Fine backport details:

$ git log -1
commit 50cf2edbc6f51241261a09bb0531b3b3257b4f50
Author: Greg Blomquist <[email protected]>
Date:   Wed Jun 14 13:51:36 2017 -0400

    Merge pull request #15329 from skateman/cloud-tenant-active-vms
    
    Limit CloudTenants' related VMs to the non-archived ones
    (cherry picked from commit 9e19b17fd7984eb1b099de7d68de6cde806aa466)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1461596

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants