--- service-models.rb.1 2011-05-16 00:12:47.750369582 -0400 +++ service-models.rb 2011-05-16 00:32:19.925942907 -0400 @@ -4,6 +4,29 @@ A few inline notes are included as comments below. +Updated to restore Template->Service association and to add the +concept of specifying missing config parameters at runtime (i.e. with +the depoyment/instance) + +Still an open question is the approach to managing the package list + associated with the service. Potentially, we need this in two places: + 1) the package (and package group) list passed to image factory in + the 'build' operation + 2) the package dep list included in the puppet manifest/service + config scripts + +What we'd like to avoid is having to manage two separate package lists, +so one of these will need to be generated from the other. So again, +we've got two options: +1) Manage the package list as a custom package group in pulp and + generate a puppet recipe snippet that includes this as a dependency + list whenever we send the puppet script content to audrey +2) Manage the package list as a puppet dependency list and + automatically append these packages to the list of packages chosen + explicitly by the user in the image builder UI. + +The model below assumes option 1) above, but again, at the moment it's +still an open question. # no changes here for services unless we add an explicit # relationship to Service -- for now we only know this @@ -13,6 +36,8 @@ has_many :images has_many :instances has_and_belongs_to_many :assemblies + + has_and_belongs_to_many :services end # Updated Deployable association to indicate that the configured @@ -57,6 +82,9 @@ class Service < ActiveRecord::Base has_many :service_config_scripts, :dependent => :destroy has_many :service_params, :dependent => :destroy + + has_and_belongs_to_many :templates + has_many :configured_services, :dependent => :destroy end class CreateServices < ActiveRecord::Migration @@ -97,6 +125,7 @@ class ServiceParam < ActiveRecord::Base belongs_to :service validates_presence_of :name + has_many :service_param_values # value_type: fixed or compute-from-instance; # for fixed 'value' in associated ServiceParamValue objects is actual value # for compute-from-instance value is key @@ -119,6 +148,8 @@ belongs_to :service belongs_to :deployable_assembly has_many :service_params + + has_many :launched_services end class CreateConfiguredServices < ActiveRecord::Migration def self.up @@ -131,6 +162,8 @@ # Filled-in value for ServiceParam class ServiceParamValue < ActiveRecord::Base + # can be either ConfiguredService or LaunchedService + belongs_to :service_obj, :polymorphic => true belongs_to :configured_service belongs_to :service_param validates_presence_of :value @@ -141,9 +174,39 @@ class CreateServiceParams < ActiveRecord::Migration def self.up create_table :service_params do |t| - t.integer :configured_service_id + t.integer :service_obj_id + t.integer :service_obj_type t.integer :service_param_id t.string :value end end end + +class Deployment < ActiveRecord::Base + belongs_to :deployable + has_many :instances +end + +class Instance < ActiveRecord::Base + belongs_to :deployment + belongs_to :assembly + has_many :launched_services +end + +# A particular service attached to an instance. This references a +# ConfiguredService object on the appropriate DeployableAssembly for +# the appropriate instance and fills in any ServiceParamValues omitted +# in the ConfiguredService. +class LaunchedService < ActiveRecord::Base + belongs_to :configured_service + belongs_to :instance + has_many :service_params +end +class CreateLaunchedServices < ActiveRecord::Migration + def self.up + create_table :launched_services do |t| + t.integer :configured_service_id + t.integer :instance_id + end + end +end