From 92dd8d0cdece7602f39bc5a04e43fa3472e097b4 Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Wed, 22 Aug 2018 17:49:51 +0200 Subject: [PATCH 1/3] Models for containers service catalog Models for containers service catalog --- app/models/ext_management_system.rb | 3 +++ .../inventory/persister/builder/container_manager.rb | 12 ++++++++++++ app/models/service_instance.rb | 5 +++++ app/models/service_offering.rb | 7 +++++++ app/models/service_plan.rb | 6 ++++++ 5 files changed, 33 insertions(+) create mode 100644 app/models/service_instance.rb create mode 100644 app/models/service_offering.rb create mode 100644 app/models/service_plan.rb diff --git a/app/models/ext_management_system.rb b/app/models/ext_management_system.rb index 3fc9c4e20d1..696eed6645f 100644 --- a/app/models/ext_management_system.rb +++ b/app/models/ext_management_system.rb @@ -79,6 +79,9 @@ def self.api_allowed_attributes has_many :cloud_subnets, :foreign_key => :ems_id, :dependent => :destroy has_many :vms_and_templates_advanced_settings, :through => :vms_and_templates, :source => :advanced_settings + has_many :service_offerings, :foreign_key => :ems_id, :dependent => :destroy, :inverse_of => :ext_management_system + has_many :service_instances, :foreign_key => :ems_id, :dependent => :destroy, :inverse_of => :ext_management_system + has_many :service_plans, :foreign_key => :ems_id, :dependent => :destroy, :inverse_of => :ext_management_system validates :name, :presence => true, :uniqueness => {:scope => [:tenant_id]} validates :hostname, :presence => true, :if => :hostname_required? diff --git a/app/models/manageiq/providers/inventory/persister/builder/container_manager.rb b/app/models/manageiq/providers/inventory/persister/builder/container_manager.rb index 73bf053cf4f..0016fe490e7 100644 --- a/app/models/manageiq/providers/inventory/persister/builder/container_manager.rb +++ b/app/models/manageiq/providers/inventory/persister/builder/container_manager.rb @@ -228,6 +228,18 @@ def persistent_volume_claims add_common_default_values end + def service_offerings + add_common_default_values + end + + def service_plans + add_common_default_values + end + + def service_instances + add_common_default_values + end + protected def custom_reconnect_block diff --git a/app/models/service_instance.rb b/app/models/service_instance.rb new file mode 100644 index 00000000000..4f3fbdc5ee7 --- /dev/null +++ b/app/models/service_instance.rb @@ -0,0 +1,5 @@ +class ServiceInstance < ApplicationRecord + belongs_to :ext_management_system, :foreign_key => "ems_id", :inverse_of => :service_instances + belongs_to :service_offering + belongs_to :service_plan +end diff --git a/app/models/service_offering.rb b/app/models/service_offering.rb new file mode 100644 index 00000000000..f1a0571c970 --- /dev/null +++ b/app/models/service_offering.rb @@ -0,0 +1,7 @@ +class ServiceOffering < ApplicationRecord + belongs_to :ext_management_system, :foreign_key => "ems_id", :inverse_of => :service_offerings + belongs_to :service_broker + + has_many :service_plans, :dependent => :nullify + has_many :service_instances, :dependent => :nullify +end diff --git a/app/models/service_plan.rb b/app/models/service_plan.rb new file mode 100644 index 00000000000..6e55aa32d7b --- /dev/null +++ b/app/models/service_plan.rb @@ -0,0 +1,6 @@ +class ServicePlan < ApplicationRecord + belongs_to :ext_management_system, :foreign_key => "ems_id", :inverse_of => :service_plans + belongs_to :service_offering + + has_many :service_instances, :dependent => :nullify +end From 8314f41daa44479bd11b2fc524acd8d1e8aeb5b9 Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Mon, 27 Aug 2018 10:51:39 +0200 Subject: [PATCH 2/3] Rename ServicePlan to ServiceParametersSet --- app/models/ext_management_system.rb | 2 +- .../inventory/persister/builder/container_manager.rb | 2 +- app/models/service_instance.rb | 2 +- app/models/service_offering.rb | 2 +- app/models/{service_plan.rb => service_parameters_set.rb} | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) rename app/models/{service_plan.rb => service_parameters_set.rb} (64%) diff --git a/app/models/ext_management_system.rb b/app/models/ext_management_system.rb index 696eed6645f..a9508de68c1 100644 --- a/app/models/ext_management_system.rb +++ b/app/models/ext_management_system.rb @@ -81,7 +81,7 @@ def self.api_allowed_attributes has_many :vms_and_templates_advanced_settings, :through => :vms_and_templates, :source => :advanced_settings has_many :service_offerings, :foreign_key => :ems_id, :dependent => :destroy, :inverse_of => :ext_management_system has_many :service_instances, :foreign_key => :ems_id, :dependent => :destroy, :inverse_of => :ext_management_system - has_many :service_plans, :foreign_key => :ems_id, :dependent => :destroy, :inverse_of => :ext_management_system + has_many :service_parameters_sets, :foreign_key => :ems_id, :dependent => :destroy, :inverse_of => :ext_management_system validates :name, :presence => true, :uniqueness => {:scope => [:tenant_id]} validates :hostname, :presence => true, :if => :hostname_required? diff --git a/app/models/manageiq/providers/inventory/persister/builder/container_manager.rb b/app/models/manageiq/providers/inventory/persister/builder/container_manager.rb index 0016fe490e7..8994fede4ee 100644 --- a/app/models/manageiq/providers/inventory/persister/builder/container_manager.rb +++ b/app/models/manageiq/providers/inventory/persister/builder/container_manager.rb @@ -232,7 +232,7 @@ def service_offerings add_common_default_values end - def service_plans + def service_parameters_sets add_common_default_values end diff --git a/app/models/service_instance.rb b/app/models/service_instance.rb index 4f3fbdc5ee7..0dab90934d0 100644 --- a/app/models/service_instance.rb +++ b/app/models/service_instance.rb @@ -1,5 +1,5 @@ class ServiceInstance < ApplicationRecord belongs_to :ext_management_system, :foreign_key => "ems_id", :inverse_of => :service_instances belongs_to :service_offering - belongs_to :service_plan + belongs_to :service_parameters_set end diff --git a/app/models/service_offering.rb b/app/models/service_offering.rb index f1a0571c970..1681e9f4f0c 100644 --- a/app/models/service_offering.rb +++ b/app/models/service_offering.rb @@ -2,6 +2,6 @@ class ServiceOffering < ApplicationRecord belongs_to :ext_management_system, :foreign_key => "ems_id", :inverse_of => :service_offerings belongs_to :service_broker - has_many :service_plans, :dependent => :nullify + has_many :service_parameters_sets, :dependent => :nullify has_many :service_instances, :dependent => :nullify end diff --git a/app/models/service_plan.rb b/app/models/service_parameters_set.rb similarity index 64% rename from app/models/service_plan.rb rename to app/models/service_parameters_set.rb index 6e55aa32d7b..0748bba1cf9 100644 --- a/app/models/service_plan.rb +++ b/app/models/service_parameters_set.rb @@ -1,5 +1,5 @@ -class ServicePlan < ApplicationRecord - belongs_to :ext_management_system, :foreign_key => "ems_id", :inverse_of => :service_plans +class ServiceParametersSet < ApplicationRecord + belongs_to :ext_management_system, :foreign_key => "ems_id", :inverse_of => :service_parameters_sets belongs_to :service_offering has_many :service_instances, :dependent => :nullify From 3b772fc88fcb3e189760e15f6cfd55000c2030f5 Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Mon, 27 Aug 2018 11:23:23 +0200 Subject: [PATCH 3/3] Remove service instances for now --- app/models/ext_management_system.rb | 1 - .../inventory/persister/builder/container_manager.rb | 4 ---- app/models/service_instance.rb | 5 ----- app/models/service_offering.rb | 1 - app/models/service_parameters_set.rb | 2 -- 5 files changed, 13 deletions(-) delete mode 100644 app/models/service_instance.rb diff --git a/app/models/ext_management_system.rb b/app/models/ext_management_system.rb index a9508de68c1..e60c9c3f320 100644 --- a/app/models/ext_management_system.rb +++ b/app/models/ext_management_system.rb @@ -80,7 +80,6 @@ def self.api_allowed_attributes has_many :vms_and_templates_advanced_settings, :through => :vms_and_templates, :source => :advanced_settings has_many :service_offerings, :foreign_key => :ems_id, :dependent => :destroy, :inverse_of => :ext_management_system - has_many :service_instances, :foreign_key => :ems_id, :dependent => :destroy, :inverse_of => :ext_management_system has_many :service_parameters_sets, :foreign_key => :ems_id, :dependent => :destroy, :inverse_of => :ext_management_system validates :name, :presence => true, :uniqueness => {:scope => [:tenant_id]} diff --git a/app/models/manageiq/providers/inventory/persister/builder/container_manager.rb b/app/models/manageiq/providers/inventory/persister/builder/container_manager.rb index 8994fede4ee..574898b35e5 100644 --- a/app/models/manageiq/providers/inventory/persister/builder/container_manager.rb +++ b/app/models/manageiq/providers/inventory/persister/builder/container_manager.rb @@ -236,10 +236,6 @@ def service_parameters_sets add_common_default_values end - def service_instances - add_common_default_values - end - protected def custom_reconnect_block diff --git a/app/models/service_instance.rb b/app/models/service_instance.rb deleted file mode 100644 index 0dab90934d0..00000000000 --- a/app/models/service_instance.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ServiceInstance < ApplicationRecord - belongs_to :ext_management_system, :foreign_key => "ems_id", :inverse_of => :service_instances - belongs_to :service_offering - belongs_to :service_parameters_set -end diff --git a/app/models/service_offering.rb b/app/models/service_offering.rb index 1681e9f4f0c..3f69272393f 100644 --- a/app/models/service_offering.rb +++ b/app/models/service_offering.rb @@ -3,5 +3,4 @@ class ServiceOffering < ApplicationRecord belongs_to :service_broker has_many :service_parameters_sets, :dependent => :nullify - has_many :service_instances, :dependent => :nullify end diff --git a/app/models/service_parameters_set.rb b/app/models/service_parameters_set.rb index 0748bba1cf9..33220d54d6c 100644 --- a/app/models/service_parameters_set.rb +++ b/app/models/service_parameters_set.rb @@ -1,6 +1,4 @@ class ServiceParametersSet < ApplicationRecord belongs_to :ext_management_system, :foreign_key => "ems_id", :inverse_of => :service_parameters_sets belongs_to :service_offering - - has_many :service_instances, :dependent => :nullify end