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

Subclass IsoDatastore under Storage #17

Merged
merged 1 commit into from
Dec 14, 2022

Conversation

nasark
Copy link
Member

@nasark nasark commented Dec 6, 2022

@nasark nasark force-pushed the move_iso_datastore branch from 6cab720 to 4b52799 Compare December 12, 2022 20:46
@miq-bot
Copy link
Member

miq-bot commented Dec 12, 2022

Some comments on commit nasark@4b52799

spec/models/manageiq/providers/redhat/infra_manager/iso_datastore_spec.rb

  • ⚠️ - 13 - Detected expect_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.

@miq-bot
Copy link
Member

miq-bot commented Dec 12, 2022

Checked commit nasark@4b52799 with ruby 2.6.10, rubocop 1.28.2, haml-lint 0.35.0, and yamllint
6 files checked, 2 offenses detected

spec/models/manageiq/providers/redhat/infra_manager/ovirt_services/v4_spec.rb

Comment on lines +355 to +356

iso_images
Copy link
Member

Choose a reason for hiding this comment

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

Since OvirtServices is a simple class we should be able to simply inherit from Ovirt::InfraManager::OvirtServices without duplicating the code. Don't want to hold this up but we can probably delete all this code in a follow-up

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I'll take note for a future follow-up PR

Comment on lines +2 to +37
def storagedomains
collector.storagedomains.each do |storagedomain|
storage_type = storagedomain.dig(:storage, :type).upcase
ems_ref = ManageIQ::Providers::Redhat::InfraManager.make_ems_ref(storagedomain.try(:href))
location = case storage_type
when 'LOCALFS', 'ISO'
ems_ref
when 'NFS', 'GLUSTERFS'
"#{storagedomain.dig(:storage, :address)}:#{storagedomain.dig(:storage, :path)}"
else
storagedomain.dig(:storage, :volume_group, :id)
end

free = storagedomain.try(:available).to_i
used = storagedomain.try(:used).to_i
total = free + used
committed = storagedomain.try(:committed).to_i

storage_domain_type = storagedomain.dig(:type, :downcase)
type = storage_domain_type == 'iso' ? "IsoDatastore" : "Storage"

persister.storages.find_or_build(ems_ref).assign_attributes(
:ems_ref => ems_ref,
:name => storagedomain.try(:name),
:store_type => storage_type,
:storage_domain_type => storage_domain_type,
:total_space => total,
:free_space => free,
:uncommitted => total - committed,
:multiplehostaccess => true,
:location => location,
:master => storagedomain.try(:master),
:type => "ManageIQ::Providers::Redhat::InfraManager::#{type}"
)
end
end
Copy link
Member

Choose a reason for hiding this comment

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

Similar comment here, if we let auto_sti_class work then we don't need to specify :type => "ManageIQ::Providers::Redhat::InfraManager::#{type}" then we don't need to override this method at all.

@agrare agrare closed this Dec 14, 2022
@agrare agrare reopened this Dec 14, 2022
@agrare agrare merged commit a7341ed into ManageIQ:master Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants