diff --git a/app/models/manageiq/providers/openstack/inventory/persister.rb b/app/models/manageiq/providers/openstack/inventory/persister.rb index 17c29a6b5..dcfb09e6f 100644 --- a/app/models/manageiq/providers/openstack/inventory/persister.rb +++ b/app/models/manageiq/providers/openstack/inventory/persister.rb @@ -8,7 +8,7 @@ class ManageIQ::Providers::Openstack::Inventory::Persister < ManagerRefresh::Inv attr_reader :collector # @param manager [ManageIQ::Providers::BaseManager] A manager object # @param target [Object] A refresh Target object - # @param target [ManagerRefresh::Inventory::Collector] A Collector object + # @param collector [ManagerRefresh::Inventory::Collector] A Collector object def initialize(manager, target = nil, collector = nil) @manager = manager @target = target @@ -21,15 +21,19 @@ def initialize(manager, target = nil, collector = nil) protected - def cloud - ManageIQ::Providers::Openstack::InventoryCollectionDefault::CloudManager + def strategy + nil end - def network - ManageIQ::Providers::Openstack::InventoryCollectionDefault::NetworkManager + def parent + manager.presence end - def storage - ManageIQ::Providers::Openstack::InventoryCollectionDefault::StorageManager + def shared_options + { + :parent => parent, + :strategy => strategy, + :targeted => targeted? + } end end diff --git a/app/models/manageiq/providers/openstack/inventory/persister/cinder_manager.rb b/app/models/manageiq/providers/openstack/inventory/persister/cinder_manager.rb index 5ffe3d127..2ac50fb34 100644 --- a/app/models/manageiq/providers/openstack/inventory/persister/cinder_manager.rb +++ b/app/models/manageiq/providers/openstack/inventory/persister/cinder_manager.rb @@ -1,28 +1,31 @@ class ManageIQ::Providers::Openstack::Inventory::Persister::CinderManager < ManageIQ::Providers::Openstack::Inventory::Persister + include ManageIQ::Providers::Openstack::Inventory::Persister::Definitions::CloudCollections + include ManageIQ::Providers::Openstack::Inventory::Persister::Definitions::NetworkCollections + include ManageIQ::Providers::Openstack::Inventory::Persister::Definitions::StorageCollections + def initialize_inventory_collections - add_inventory_collections(storage, - %i( - cloud_volumes - cloud_volume_snapshots - cloud_volume_backups - ), - :builder_params => {:ext_management_system => manager}) + initialize_storage_inventory_collections + + initialize_cloud_inventory_collections + end + + def initialize_cloud_inventory_collections + %i(vms + availability_zones + hardwares + cloud_tenants + disks).each do |name| + + add_collection(cloud, name, shared_cloud_properties) do |builder| + builder.add_properties(:strategy => :local_db_cache_all) unless name == :disks + builder.add_properties(:complete => false) if name == :disks + end + end + end - add_inventory_collections(cloud, - %i( - vms - availability_zones - hardwares - cloud_tenants - ), - :parent => manager.parent_manager, - :strategy => :local_db_cache_all) + private - add_inventory_collections(cloud, - %i( - disks - ), - :parent => manager.parent_manager, - :complete => false) + def shared_cloud_properties + { :parent => manager.parent_manager } end end diff --git a/app/models/manageiq/providers/openstack/inventory/persister/cloud_manager.rb b/app/models/manageiq/providers/openstack/inventory/persister/cloud_manager.rb index a13eb1fe2..9fca368d6 100644 --- a/app/models/manageiq/providers/openstack/inventory/persister/cloud_manager.rb +++ b/app/models/manageiq/providers/openstack/inventory/persister/cloud_manager.rb @@ -1,58 +1,7 @@ class ManageIQ::Providers::Openstack::Inventory::Persister::CloudManager < ManageIQ::Providers::Openstack::Inventory::Persister - def initialize_inventory_collections - add_inventory_collections( - cloud, - %i( - availability_zones - cloud_resource_quotas - cloud_services - cloud_tenants - flavors - host_aggregates - miq_templates - orchestration_stacks - vms - ), - :builder_params => {:ext_management_system => manager} - ) - - add_inventory_collections( - cloud, - %i( - key_pairs - ), - :builder_params => {:resource => manager} - ) - - add_inventory_collections( - cloud, - %i( - hardwares - operating_systems - disks - networks - orchestration_templates - orchestration_stacks_resources - orchestration_stacks_outputs - orchestration_stacks_parameters - ) - ) + include ManageIQ::Providers::Openstack::Inventory::Persister::Definitions::CloudCollections - add_inventory_collection( - cloud.vm_and_miq_template_ancestry( - :dependency_attributes => { - :vms => [collections[:vms]], - :miq_templates => [collections[:miq_templates]] - } - ) - ) - - add_inventory_collection( - cloud.orchestration_stack_ancestry( - :dependency_attributes => { - :orchestration_stacks => [collections[:orchestration_stacks]], - } - ) - ) + def initialize_inventory_collections + initialize_cloud_inventory_collections end end diff --git a/app/models/manageiq/providers/openstack/inventory/persister/definitions/cloud_collections.rb b/app/models/manageiq/providers/openstack/inventory/persister/definitions/cloud_collections.rb new file mode 100644 index 000000000..937fcebcb --- /dev/null +++ b/app/models/manageiq/providers/openstack/inventory/persister/definitions/cloud_collections.rb @@ -0,0 +1,166 @@ +module ManageIQ::Providers::Openstack::Inventory::Persister::Definitions::CloudCollections + extend ActiveSupport::Concern + + include ManageIQ::Providers::Openstack::Inventory::Persister::Definitions::Utils + + # used also in ovirt, so automatic model_classes are not possible in many cases + def initialize_cloud_inventory_collections + add_vms + + add_miq_templates + + add_availability_zones + + add_cloud_tenants + + add_flavors + + add_key_pairs + + unless targeted? + add_cloud_resource_quotas + + add_cloud_services + + add_host_aggregates + end + + add_orchestration_stacks_with_ems_param + + %i(hardwares + operating_systems + disks + networks + orchestration_stacks_resources + orchestration_stacks_outputs + orchestration_stacks_parameters).each do |name| + + add_collection(cloud, name) + end + + add_orchestration_templates + + add_vm_and_miq_template_ancestry + + add_orchestration_stack_ancestry + end + + # ------ IC provider specific definitions ------------------------- + + # model_class defined due to ovirt dependency + def add_vms + add_collection_with_ems_param(cloud, :vms) do |builder| + builder.add_properties(:model_class => ManageIQ::Providers::Openstack::CloudManager::Vm) + end + end + + def add_miq_templates + add_collection(cloud, :miq_templates) do |builder| + builder.add_properties(:model_class => ::MiqTemplate) + + builder.add_builder_params(:ext_management_system => manager) + + # Extra added to automatic attributes + builder.add_inventory_attributes(%i(cloud_tenant cloud_tenants)) + end + end + + # model_class defined due to ovirt dependency + def add_availability_zones + add_collection_with_ems_param(cloud, :availability_zones) do |builder| + builder.add_properties(:model_class => ManageIQ::Providers::Openstack::CloudManager::AvailabilityZone) + end + end + + # model_class defined due to ovirt dependency + def add_cloud_tenants + add_collection_with_ems_param(cloud, :cloud_tenants) do |builder| + builder.add_properties(:model_class => ManageIQ::Providers::Openstack::CloudManager::CloudTenant) + end + end + + # model_class defined due to ovirt dependency + def add_flavors + add_collection_with_ems_param(cloud, :flavors) do |builder| + builder.add_properties(:model_class => ManageIQ::Providers::Openstack::CloudManager::Flavor) + end + end + + # model_class defined due to ovirt dependency + def add_cloud_resource_quotas + add_collection_with_ems_param(cloud, :cloud_resource_quotas) do |builder| + builder.add_properties(:model_class => ManageIQ::Providers::Openstack::CloudManager::CloudResourceQuota) + end + end + + def add_cloud_services + add_collection_with_ems_param(cloud, :cloud_services) + end + + # model_class defined due to ovirt dependency + def add_host_aggregates + add_collection_with_ems_param(cloud, :host_aggregates) do |builder| + builder.add_properties(:model_class => ManageIQ::Providers::Openstack::CloudManager::HostAggregate) + end + end + + def add_orchestration_stacks(extra_properties = {}) + add_collection(cloud, :orchestration_stacks, extra_properties) do |builder| + builder.add_properties(:model_class => ManageIQ::Providers::CloudManager::OrchestrationStack) + + yield builder if block_given? + end + end + + def add_orchestration_templates + add_collection(cloud, :orchestration_templates) do |builder| + builder.add_properties(:model_class => ::OrchestrationTemplate) + end + end + + # TODO: mslemr - parent model class used anywhere? + def add_key_pairs(extra_properties = {}) + add_collection(cloud, :key_pairs, extra_properties) do |builder| + builder.add_properties( + :model_class => ManageIQ::Providers::Openstack::CloudManager::AuthKeyPair, + ) + + builder.add_builder_params(:resource => manager) unless targeted? + end + end + + # TODO: mslemr - same as amazon! + def add_vm_and_miq_template_ancestry + add_collection(cloud, :vm_and_miq_template_ancestry, {}, {:auto_inventory_attributes => false, :auto_model_class => false, :without_model_class => true}) do |builder| + builder.add_dependency_attributes( + :vms => [collections[:vms]], + :miq_templates => [collections[:miq_templates]] + ) + end + end + + # TODO: mslemr - almost same as amazon! + # Needed remove_dependency_attributes for core basic definition + def add_orchestration_stack_ancestry + add_collection(cloud, :orchestration_stack_ancestry, {}, {:auto_inventory_attributes => false, :auto_model_class => false, :without_model_class => true}) do |builder| + builder.add_dependency_attributes( + :orchestration_stacks => [collections[:orchestration_stacks]] + ) + + if targeted? + builder.add_dependency_attributes( + :orchestration_stacks_resources => [collections[:orchestration_stacks_resources]] + ) + end + end + end + + protected + + # Shortcut for better code readability + def add_orchestration_stacks_with_ems_param + add_orchestration_stacks do |builder| + builder.add_builder_params(:ext_management_system => manager) + end + end +end diff --git a/app/models/manageiq/providers/openstack/inventory/persister/definitions/network_collections.rb b/app/models/manageiq/providers/openstack/inventory/persister/definitions/network_collections.rb new file mode 100644 index 000000000..1aa4f2f3e --- /dev/null +++ b/app/models/manageiq/providers/openstack/inventory/persister/definitions/network_collections.rb @@ -0,0 +1,95 @@ +module ManageIQ::Providers::Openstack::Inventory::Persister::Definitions::NetworkCollections + extend ActiveSupport::Concern + + include ManageIQ::Providers::Openstack::Inventory::Persister::Definitions::Utils + + def initialize_network_inventory_collections + add_cloud_networks + + add_cloud_subnets + + add_cloud_subnet_network_ports + + add_firewall_rules + + add_floating_ips + + add_network_ports + + add_network_routers + + add_security_groups + end + + # ------ IC provider specific definitions ------------------------- + + # model_class defined due to ovirt dependency + def add_cloud_networks + add_collection(network, :cloud_networks) do |builder| + builder.add_properties(:model_class => ManageIQ::Providers::Openstack::NetworkManager::CloudNetwork) + + ems_network_builder_param(builder) + end + end + + # model_class defined due to ovirt dependency + def add_cloud_subnets + add_collection(network, :cloud_subnets) do |builder| + builder.add_properties(:model_class => ManageIQ::Providers::Openstack::NetworkManager::CloudSubnet) + + ems_network_builder_param(builder) + end + end + + def add_cloud_subnet_network_ports + add_collection(network, :cloud_subnet_network_ports) do |builder| + builder.add_properties( + :parent_inventory_collections => %i(vms network_ports) + ) + end + end + + def add_firewall_rules + add_collection(network, :firewall_rules) do |builder| + builder.add_properties( + :manager_ref => %i(ems_ref) + ) + end + end + + # model_class defined due to ovirt dependency + def add_floating_ips + add_collection(network, :floating_ips) do |builder| + builder.add_properties(:model_class => ManageIQ::Providers::Openstack::NetworkManager::FloatingIp) + + ems_network_builder_param(builder) + end + end + + def add_network_ports + add_collection(network, :network_ports) do |builder| + builder.add_properties(:model_class => ManageIQ::Providers::Openstack::NetworkManager::NetworkPort) + builder.add_properties(:delete_method => :disconnect_port) + + ems_network_builder_param(builder) + end + end + + # model_class defined due to ovirt dependency + def add_network_routers + add_collection(network, :network_routers) do |builder| + builder.add_properties(:model_class => ManageIQ::Providers::Openstack::NetworkManager::NetworkRouter) + + ems_network_builder_param(builder) + end + end + + # model_class defined due to ovirt dependency + def add_security_groups + add_collection(network, :security_groups) do |builder| + builder.add_properties(:model_class => ManageIQ::Providers::Openstack::NetworkManager::SecurityGroup) + + ems_network_builder_param(builder) + end + end +end diff --git a/app/models/manageiq/providers/openstack/inventory/persister/definitions/storage_collections.rb b/app/models/manageiq/providers/openstack/inventory/persister/definitions/storage_collections.rb new file mode 100644 index 000000000..e84880a39 --- /dev/null +++ b/app/models/manageiq/providers/openstack/inventory/persister/definitions/storage_collections.rb @@ -0,0 +1,19 @@ +module ManageIQ::Providers::Openstack::Inventory::Persister::Definitions::StorageCollections + extend ActiveSupport::Concern + + def initialize_storage_inventory_collections + %i(cloud_volumes + cloud_volume_snapshots + cloud_volume_backups).each do |name| + + add_collection(cloud, name) do |builder| + if targeted? + builder.add_properties(:parent => manager.cinder_manager) + builder.add_builder_params(:ext_management_system => manager.cinder_manager) + else + builder.add_builder_params(:ext_management_system => manager) + end + end + end + end +end diff --git a/app/models/manageiq/providers/openstack/inventory/persister/definitions/utils.rb b/app/models/manageiq/providers/openstack/inventory/persister/definitions/utils.rb new file mode 100644 index 000000000..08022dcce --- /dev/null +++ b/app/models/manageiq/providers/openstack/inventory/persister/definitions/utils.rb @@ -0,0 +1,23 @@ +module ManageIQ::Providers::Openstack::Inventory::Persister::Definitions::Utils + extend ActiveSupport::Concern + + protected + + # Shortcut for better code readability + def add_collection_with_ems_param(builder_class, collection_name, extra_properties = {}, settings = {}) + add_collection(builder_class, collection_name, extra_properties, settings) do |builder| + ems_builder_param(builder) + + yield builder if block_given? + end + end + + def ems_builder_param(builder) + builder.add_builder_params(:ext_management_system => manager) + end + + def ems_network_builder_param(builder) + ems = targeted? ? manager.network_manager : manager + builder.add_builder_params(:ext_management_system => ems) + end +end diff --git a/app/models/manageiq/providers/openstack/inventory/persister/network_manager.rb b/app/models/manageiq/providers/openstack/inventory/persister/network_manager.rb index 8110482a2..23b987523 100644 --- a/app/models/manageiq/providers/openstack/inventory/persister/network_manager.rb +++ b/app/models/manageiq/providers/openstack/inventory/persister/network_manager.rb @@ -1,37 +1,32 @@ class ManageIQ::Providers::Openstack::Inventory::Persister::NetworkManager < ManageIQ::Providers::Openstack::Inventory::Persister + include ManageIQ::Providers::Openstack::Inventory::Persister::Definitions::CloudCollections + include ManageIQ::Providers::Openstack::Inventory::Persister::Definitions::NetworkCollections + def initialize_inventory_collections - add_inventory_collections( - network, - %i( - cloud_networks - cloud_subnets - floating_ips - network_ports - network_routers - security_groups - ), - :builder_params => {:ext_management_system => manager} - ) - - add_inventory_collections( - network, - %i( - cloud_subnet_network_ports - firewall_rules - ) - ) - - add_inventory_collections( - cloud, - %i( - vms - orchestration_stacks - orchestration_stacks_resources - availability_zones - cloud_tenants - ), - :parent => manager.parent_manager, - :strategy => :local_db_cache_all - ) + initialize_network_inventory_collections + + initialize_cloud_inventory_collections + end + + protected + + def initialize_cloud_inventory_collections + %i(vms + orchestration_stacks + orchestration_stacks_resources + availability_zones + cloud_tenants).each do |name| + + add_collection(cloud, name, shared_cloud_properties) + end + + add_orchestration_stacks(shared_cloud_properties) + end + + private + + def shared_cloud_properties + {:parent => manager.parent_manager, + :strategy => :local_db_cache_all} end end diff --git a/app/models/manageiq/providers/openstack/inventory/persister/target_collection.rb b/app/models/manageiq/providers/openstack/inventory/persister/target_collection.rb index d6748e273..76dca818e 100644 --- a/app/models/manageiq/providers/openstack/inventory/persister/target_collection.rb +++ b/app/models/manageiq/providers/openstack/inventory/persister/target_collection.rb @@ -1,104 +1,31 @@ class ManageIQ::Providers::Openstack::Inventory::Persister::TargetCollection < ManageIQ::Providers::Openstack::Inventory::Persister - def initialize_inventory_collections - ######### Cloud ########## - # Top level models with direct references for Cloud - add_inventory_collections_with_references( - cloud, - %i(vms miq_templates availability_zones orchestration_stacks cloud_tenants flavors), - :builder_params => {:ext_management_system => manager} - ) - - add_inventory_collection_with_references( - cloud, - :key_pairs, - name_references(:key_pairs) - ) - - # Child models with references in the Parent InventoryCollections for Cloud - add_inventory_collections( - cloud, - %i(hardwares operating_systems networks disks orchestration_stacks_resources - orchestration_stacks_outputs orchestration_stacks_parameters), - :strategy => strategy, - :targeted => true - ) - - add_inventory_collection(cloud.orchestration_templates) - - ######## Networking ######## - add_inventory_collections_with_references( - network, - %i(cloud_networks cloud_subnets security_groups floating_ips network_ports network_routers), - :parent => manager.network_manager, - :builder_params => {:ext_management_system => manager.network_manager} - ) + include ManageIQ::Providers::Openstack::Inventory::Persister::Definitions::CloudCollections + include ManageIQ::Providers::Openstack::Inventory::Persister::Definitions::NetworkCollections + include ManageIQ::Providers::Openstack::Inventory::Persister::Definitions::StorageCollections - add_inventory_collections( - network, - %i( - cloud_subnet_network_ports firewall_rules - ), - :strategy => strategy, - :targeted => true, - :parent => manager.network_manager - ) - - ######## Storage ######## - add_inventory_collections_with_references( - storage, - %i(cloud_volumes cloud_volume_backups cloud_volume_snapshots), - :parent => manager.cinder_manager, - :builder_params => {:ext_management_system => manager.cinder_manager} - ) - - ######## Custom processing of Ancestry ########## - add_inventory_collection( - cloud.vm_and_miq_template_ancestry( - :dependency_attributes => { - :vms => [collections[:vms]], - :miq_templates => [collections[:miq_templates]] - } - ) - ) - - add_inventory_collection( - cloud.orchestration_stack_ancestry( - :dependency_attributes => { - :orchestration_stacks => [collections[:orchestration_stacks]], - :orchestration_stacks_resources => [collections[:orchestration_stacks_resources]] - } - ) - ) - end - - private - - def add_inventory_collections_with_references(inventory_collections_data, names, options = {}) - names.each do |name| - add_inventory_collection_with_references(inventory_collections_data, name, references(name), options) - end - end - - def add_inventory_collection_with_references(inventory_collections_data, name, manager_refs, options = {}) - options = inventory_collections_data.send( - name, - :manager_uuids => manager_refs, - :strategy => strategy, - :targeted => true - ).merge(options) - - add_inventory_collection(options) + def targeted? + true end def strategy :local_db_find_missing_references end - def references(collection) - target.manager_refs_by_association.try(:[], collection).try(:[], :ems_ref).try(:to_a) || [] + def parent + if @init_network_collections + manager.try(:network_manager) + else + manager.presence + end end - def name_references(collection) - target.manager_refs_by_association.try(:[], collection).try(:[], :name).try(:to_a) || [] + def initialize_inventory_collections + initialize_cloud_inventory_collections + + @init_network_collections = true + initialize_network_inventory_collections + @init_network_collections = false + + initialize_storage_inventory_collections end end diff --git a/app/models/manageiq/providers/openstack/inventory_collection_default/cloud_manager.rb b/app/models/manageiq/providers/openstack/inventory_collection_default/cloud_manager.rb deleted file mode 100644 index 4aa151b49..000000000 --- a/app/models/manageiq/providers/openstack/inventory_collection_default/cloud_manager.rb +++ /dev/null @@ -1,288 +0,0 @@ -class ManageIQ::Providers::Openstack::InventoryCollectionDefault::CloudManager < ManagerRefresh::InventoryCollectionDefault::CloudManager - class << self - def availability_zones(extra_attributes = {}) - attributes = { - :model_class => ManageIQ::Providers::Openstack::CloudManager::AvailabilityZone, - :inventory_object_attributes => [ - :type, - :ems_ref, - :name - ] - } - super(attributes.merge!(extra_attributes)) - end - - def cloud_resource_quotas(extra_attributes = {}) - attributes = { - :model_class => ManageIQ::Providers::Openstack::CloudManager::CloudResourceQuota, - :association => :cloud_resource_quotas, - :inventory_object_attributes => [ - :ems_ref, - :type, - :service_name, - :name, - :value, - :cloud_tenant - ] - } - attributes.merge!(extra_attributes) - end - - def cloud_services(extra_attributes = {}) - attributes = { - :model_class => CloudService, - :association => :cloud_services, - :inventory_object_attributes => [ - :ems_ref, - :source, - :executable_name, - :hostname, - :status, - :scheduling_disabled, - :scheduling_disabled_reason, - :host, - :system_service, - :availability_zone - ] - } - attributes.merge!(extra_attributes) - end - - def cloud_tenants(extra_attributes = {}) - attributes = { - :model_class => ManageIQ::Providers::Openstack::CloudManager::CloudTenant, - :association => :cloud_tenants, - :inventory_object_attributes => [ - :type, - :name, - :description, - :enabled, - :parent, - :ems_ref - ] - } - attributes.merge!(extra_attributes) - end - - def disks(extra_attributes = {}) - attributes = { - :inventory_object_attributes => [ - :device_name, - :device_type, - :controller_type, - :size, - :location, - :backing, - :hardware - ] - } - super(attributes.merge!(extra_attributes)) - end - - def flavors(extra_attributes = {}) - attributes = { - :model_class => ManageIQ::Providers::Openstack::CloudManager::Flavor, - :inventory_object_attributes => [ - :type, - :name, - :enabled, - :cpus, - :memory, - :publicly_available, - :root_disk_size, - :swap_disk_size, - :ephemeral_disk_size, - :ephemeral_disk_count, - :cloud_tenants - ] - } - super(attributes.merge!(extra_attributes)) - end - - def hardwares(extra_attributes = {}) - attributes = { - :inventory_object_attributes => [ - :vm_or_template, - :cpu_sockets, - :cpu_total_cores, - :cpu_speed, - :memory_mb, - :disk_capacity, - :bitness, - :guest_os, - :disk_size_minimum, - :memory_mb_minimum, - :root_device_type, - :size_on_disk, - :virtualization_type - ] - } - super(attributes.merge!(extra_attributes)) - end - - def operating_systems(extra_attributes = {}) - attributes = { - :inventory_object_attributes => [ - :vm_or_template, - :product_name, - :distribution, - :version, - ] - } - - super(attributes.merge!(extra_attributes)) - end - - def host_aggregates(extra_attributes = {}) - attributes = { - :model_class => ManageIQ::Providers::Openstack::CloudManager::HostAggregate, - :association => :host_aggregates, - :inventory_object_attributes => [ - :ems_ref, - :type, - :name, - :metadata, - :hosts - ] - } - attributes.merge!(extra_attributes) - end - - def key_pairs(extra_attributes = {}) - attributes = { - :model_class => ManageIQ::Providers::Openstack::CloudManager::AuthKeyPair, - :inventory_object_attributes => [ - :type, - :name, - :fingerprint - ] - } - super(attributes.merge!(extra_attributes)) - end - - def miq_templates(extra_attributes = {}) - attributes = { - :inventory_object_attributes => [ - :type, - :uid_ems, - :name, - :vendor, - :raw_power_state, - :template, - :publicly_available, - :location, - :cloud_tenant, - :cloud_tenants, - :genealogy_parent - ] - } - super(attributes.merge!(extra_attributes)) - end - - def networks(extra_attributes = {}) - attributes = { - :inventory_object_attributes => [ - :hardware, - :description, - :ipaddress - ] - } - super(attributes.merge!(extra_attributes)) - end - - def orchestration_stacks_outputs(extra_attributes = {}) - attributes = { - :inventory_object_attributes => [ - :ems_ref, - :key, - :value, - :description, - :stack - ] - } - super(attributes.merge!(extra_attributes)) - end - - def orchestration_stacks_parameters(extra_attributes = {}) - attributes = { - :inventory_object_attributes => [ - :ems_ref, - :name, - :value, - :stack - ] - } - super(attributes.merge!(extra_attributes)) - end - - def orchestration_stacks_resources(extra_attributes = {}) - attributes = { - :inventory_object_attributes => [ - :ems_ref, - :logical_resource, - :physical_resource, - :resource_category, - :resource_status, - :resource_status_reason, - :last_updated, - :stack - ] - } - super(attributes.merge!(extra_attributes)) - end - - def orchestration_stacks(extra_attributes = {}) - attributes = { - :model_class => ManageIQ::Providers::CloudManager::OrchestrationStack, - :inventory_object_attributes => [ - :type, - :name, - :description, - :status, - :status_reason, - :parent, - :orchestration_template, - :cloud_tenant - ] - } - super(attributes.merge!(extra_attributes)) - end - - def orchestration_templates(extra_attributes = {}) - attributes = { - :inventory_object_attributes => [ - :type, - :name, - :description, - :content, - :orderable - ] - } - super(attributes.merge!(extra_attributes)) - end - - def vms(extra_attributes = {}) - attributes = { - :model_class => ManageIQ::Providers::Openstack::CloudManager::Vm, - :inventory_object_attributes => [ - :type, - :uid_ems, - :name, - :vendor, - :raw_power_state, - :connection_state, - :location, - :host, - :ems_cluster, - :availability_zone, - :key_pairs, - :cloud_tenant, - :genealogy_parent, - :flavor, - :orchestration_stack - ] - } - super(attributes.merge!(extra_attributes)) - end - end -end diff --git a/app/models/manageiq/providers/openstack/inventory_collection_default/network_manager.rb b/app/models/manageiq/providers/openstack/inventory_collection_default/network_manager.rb deleted file mode 100644 index 31d05f7b0..000000000 --- a/app/models/manageiq/providers/openstack/inventory_collection_default/network_manager.rb +++ /dev/null @@ -1,188 +0,0 @@ -class ManageIQ::Providers::Openstack::InventoryCollectionDefault::NetworkManager < ManagerRefresh::InventoryCollectionDefault::NetworkManager - class << self - def network_ports(extra_attributes = {}) - attributes = { - :model_class => ::ManageIQ::Providers::Openstack::NetworkManager::NetworkPort, - :association => :network_ports, - :delete_method => :disconnect_port, - :inventory_object_attributes => [ - :type, - :name, - :status, - :admin_state_up, - :mac_address, - :device_owner, - :device_ref, - :device, - :cloud_tenant, - :binding_host_id, - :binding_virtual_interface_type, - :binding_virtual_interface_details, - :binding_virtual_nic_type, - :binding_profile, - :extra_dhcp_opts, - :allowed_address_pairs, - :security_groups - ] - } - - super(attributes.merge!(extra_attributes)) - end - - def network_routers(extra_attributes = {}) - attributes = { - :model_class => ::ManageIQ::Providers::Openstack::NetworkManager::NetworkRouter, - :association => :network_routers, - :inventory_object_attributes => [ - :type, - :name, - :admin_state_up, - :status, - :external_gateway_info, - :distributed, - :routes, - :high_availability, - :cloud_tenant, - :cloud_network - ] - } - - attributes.merge!(extra_attributes) - end - - def floating_ips(extra_attributes = {}) - attributes = { - :model_class => ManageIQ::Providers::Openstack::NetworkManager::FloatingIp, - :association => :floating_ips, - :inventory_object_attributes => [ - :type, - :address, - :fixed_ip_address, - :status, - :cloud_tenant, - :cloud_network, - :network_port, - :vm - ] - } - - super(attributes.merge!(extra_attributes)) - end - - def cloud_subnets(extra_attributes = {}) - attributes = { - :model_class => ManageIQ::Providers::Openstack::NetworkManager::CloudSubnet, - :association => :cloud_subnets, - :inventory_object_attributes => [ - :type, - :name, - :cidr, - :status, - :network_protocol, - :gateway, - :dhcp_enabled, - :dns_nameservers, - :ipv6_router_advertisement_mode, - :ipv6_address_mode, - :allocation_pools, - :host_routes, - :ip_version, - :parent_cloud_subnet, - :cloud_tenant, - :cloud_network, - :network_router - ] - } - - super(attributes.merge!(extra_attributes)) - end - - def cloud_networks(extra_attributes = {}) - attributes = { - :model_class => ManageIQ::Providers::Openstack::NetworkManager::CloudNetwork, - :association => :cloud_networks, - :inventory_object_attributes => [ - :type, - :name, - :shared, - :status, - :enabled, - :external_facing, - :provider_physical_network, - :provider_network_type, - :provider_segmentation_id, - :port_security_enabled, - :qos_policy_id, - :vlan_transparent, - :maximum_transmission_unit, - :cloud_tenant, - :orchestration_stack - ] - } - - super(attributes.merge!(extra_attributes)) - end - - def firewall_rules(extra_attributes = {}) - attributes = { - :manager_ref => [:ems_ref], - :inventory_object_attributes => [ - :resource, - :source_security_group, - :direction, - :host_protocol, - :network_protocol, - :port, - :end_port, - :source_ip_range - ] - } - - super(attributes.merge!(extra_attributes)) - end - - def security_groups(extra_attributes = {}) - attributes = { - :model_class => ManageIQ::Providers::Openstack::NetworkManager::SecurityGroup, - :association => :security_groups, - :inventory_object_attributes => [ - :type, - :name, - :description, - :cloud_tenant, - :orchestration_stack - ] - } - - super(attributes.merge!(extra_attributes)) - end - - def network_port_security_groups(extra_attributes = {}) - attributes = { - :model_class => NetworkPortSecurityGroup, - :manager_ref => [:security_group, :network_port], - :association => :network_port_security_groups, - } - - attributes.merge!(extra_attributes) - end - - def cloud_subnet_network_ports(extra_attributes = {}) - attributes = { - :model_class => CloudSubnetNetworkPort, - :manager_ref => [:address, :cloud_subnet, :network_port], - :association => :cloud_subnet_network_ports, - :parent_inventory_collections => [:vms, :network_ports], - } - - extra_attributes[:targeted_arel] = lambda do |inventory_collection| - manager_uuids = inventory_collection.parent_inventory_collections.flat_map { |c| c.manager_uuids.to_a } - inventory_collection.parent.cloud_subnet_network_ports.references(:network_ports).where( - :network_ports => {:ems_ref => manager_uuids} - ) - end - - attributes.merge!(extra_attributes) - end - end -end diff --git a/app/models/manageiq/providers/openstack/inventory_collection_default/storage_manager.rb b/app/models/manageiq/providers/openstack/inventory_collection_default/storage_manager.rb deleted file mode 100644 index 47bc0b3be..000000000 --- a/app/models/manageiq/providers/openstack/inventory_collection_default/storage_manager.rb +++ /dev/null @@ -1,65 +0,0 @@ -class ManageIQ::Providers::Openstack::InventoryCollectionDefault::StorageManager < ManagerRefresh::InventoryCollectionDefault::StorageManager - class << self - def cloud_volume_backups(extra_attributes = {}) - attributes = { - :model_class => ManageIQ::Providers::Openstack::CloudManager::CloudVolumeBackup, - :association => :cloud_volume_backups, - :inventory_object_attributes => [ - :type, - :ems_ref, - :status, - :creation_time, - :size, - :object_count, - :is_incremental, - :has_dependent_backups, - :name, - :description, - :cloud_volume, - :availability_zone - ] - } - - attributes.merge!(extra_attributes) - end - - def cloud_volume_snapshots(extra_attributes = {}) - attributes = { - :model_class => ManageIQ::Providers::Openstack::CloudManager::CloudVolumeSnapshot, - :inventory_object_attributes => [ - :type, - :ems_ref, - :status, - :creation_time, - :size, - :name, - :description, - :cloud_volume, - :cloud_tenant - ] - } - super(attributes.merge!(extra_attributes)) - end - - def cloud_volumes(extra_attributes = {}) - attributes = { - :model_class => ManageIQ::Providers::Openstack::CloudManager::CloudVolume, - :inventory_object_attributes => [ - :type, - :ems_ref, - :status, - :bootable, - :volume_type, - :creation_time, - :size, - :name, - :description, - :base_snapshot, - :availability_zone, - :cloud_tenant - ] - } - super(attributes.merge!(extra_attributes)) - end - end -end