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

Move IsoDatastore from core #22239

Merged
merged 2 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions app/models/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ def self.create_from_params(params, endpoints, authentications)
has_many :customization_scripts, :foreign_key => "manager_id", :dependent => :destroy, :inverse_of => :ext_management_system
has_many :cloud_subnets, :foreign_key => :ems_id, :dependent => :destroy

has_one :iso_datastore, :foreign_key => "ems_id", :dependent => :destroy, :inverse_of => :ext_management_system

belongs_to :zone
belongs_to :zone_before_pause, :class_name => "Zone", :inverse_of => :paused_ext_management_systems # used for maintenance mode

Expand All @@ -129,6 +127,8 @@ def self.create_from_params(params, endpoints, authentications)
has_many :ems_licenses, :foreign_key => :ems_id, :dependent => :destroy, :inverse_of => :ext_management_system
has_many :ems_extensions, :foreign_key => :ems_id, :dependent => :destroy, :inverse_of => :ext_management_system

has_many :iso_images, :through => :storages

validates :name, :presence => true, :uniqueness_when_changed => {:scope => [:tenant_id]}
validates :hostname, :presence => true, :if => :hostname_required?
validates :zone, :presence => true
Expand Down Expand Up @@ -994,11 +994,6 @@ def self.class_by_ems(class_name)
end
delegate :class_by_ems, :to => :class

# @return [Boolean] true if a datastore exists for this type of ems
def self.datastore?
IsoDatastore.where(:ems_id => all).exists?
end

def tenant_identity
User.super_admin.tap { |u| u.current_group = tenant.default_miq_group }
end
Expand Down
53 changes: 0 additions & 53 deletions app/models/iso_datastore.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/models/iso_image.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class IsoImage < ApplicationRecord
belongs_to :iso_datastore
belongs_to :storage
Copy link
Member

Choose a reason for hiding this comment

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

Love this because it opens us up to creating these from other provider storage types like VMware when we do a datastore ssa. This would make it a lot simpler to get a list of ISOs when doing vm reconfigure to connect a cdrom or provision from an ISO

belongs_to :pxe_image_type

has_many :customization_templates, :through => :pxe_image_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,14 @@ def vm_resource_pools
)
end

def iso_images
add_properties(
:parent_inventory_collections => %i[storages],
:manager_ref => %i[name],
:model_class => IsoImage
)
end

private

def root_folder_relationship_save_block
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_request_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ def allowed_images(options = {})

def get_iso_images
template = VmOrTemplate.find_by(:id => get_value(@values[:src_vm_id]))
template.try(:ext_management_system).try(:iso_datastore).try(:iso_images) || []
template.try(:ext_management_system).try(:iso_images) || []
end

def allowed_iso_images(_options = {})
Expand Down
2 changes: 2 additions & 0 deletions app/models/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Storage < ApplicationRecord
has_many :storage_files, :dependent => :destroy
has_many :storage_files_files, -> { where("rsc_type = 'file'") }, :class_name => "StorageFile", :foreign_key => "storage_id"
has_many :files, -> { where("rsc_type = 'file'") }, :class_name => "StorageFile", :foreign_key => "storage_id"
has_many :iso_images, :dependent => :destroy

has_many :miq_events, :as => :target, :dependent => :destroy

Expand Down Expand Up @@ -80,6 +81,7 @@ class Storage < ApplicationRecord
supports(:delete) { _("Only storage without VMs and Hosts can be removed") if vms_and_templates.any? || hosts.any? }

supports_not :evacuate
supports_not :iso_datastore

def to_s
name
Expand Down
2 changes: 0 additions & 2 deletions locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,6 @@ en:
Host: Host
HostInitiator: Host Initiators
HostPerformance: Performance - Host
IsoDatastore: ISO Datastore
IsoImage: ISO Image
LdapDomain: LDAP Domain
LdapRegion: LDAP Region
Expand Down Expand Up @@ -1778,7 +1777,6 @@ en:
hosts: Hosts
host_initiator: Host Initiator
host_services: Services
iso_datastore: ISO Datastore
iso_image: ISO Image
lans: vLANs
last_compliance: Last Compliance History
Expand Down
53 changes: 0 additions & 53 deletions spec/models/iso_datastore_spec.rb

This file was deleted.