Skip to content

Commit

Permalink
Add polymorphic relationship to container_node
Browse files Browse the repository at this point in the history
This polymorphic association will allow container nodes to "live on" an
arbitrary entity belonging to another provider.

The purpose for this association is to capture the idea that Kubernetes
Container Nodes are actually running inside a VM or Physical host owned by
another provider.

https://trello.com/c/4wkBDSS6/128-5-containernode-cross-provider-associations
  • Loading branch information
blomquisg committed Apr 2, 2015
1 parent 41cd228 commit d6db737
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions vmdb/app/models/container_node.rb
@@ -1,6 +1,7 @@
class ContainerNode < ActiveRecord::Base
include ReportableMixin
# :name, :uid, :creation_timestamp, :resource_version
belongs_to :ext_management_system, :foreign_key => "ems_id"
has_many :container_groups
belongs_to :ext_management_system, :foreign_key => "ems_id"
has_many :container_groups
belongs_to :lives_on, :polymorphic => true
end
@@ -0,0 +1,11 @@
class AddContainerNodeCrossProviderAssociation < ActiveRecord::Migration
def up
add_column :container_nodes, :lives_on_type, :string
add_column :container_nodes, :lives_on_id, :bigint
end

def down
remove_column :container_nodes, :lives_on_type
remove_column :container_nodes, :lives_on_id
end
end

0 comments on commit d6db737

Please sign in to comment.