lib/ironfan/dsl/component.rb in ironfan-5.0.11 vs lib/ironfan/dsl/component.rb in ironfan-6.0.0
- old
+ new
@@ -4,18 +4,18 @@
include Gorillib::Builder
include Gorillib::Concern
include Ironfan::Plugin::Base; register_with Ironfan::Dsl::Compute
field :cluster_name, Symbol
- field :facet_name, Symbol
- field :realm_name, Symbol
- field :name, Symbol
+ field :facet_name, Symbol
+ field :realm_name, Symbol
+ field :name, Symbol
def initialize(attrs, &blk)
- attrs.merge!(facet_name: (attrs[:owner].name unless attrs[:owner].nil? or not attrs[:owner].is_a?(Facet)),
+ attrs.merge!(facet_name: (attrs[:owner].name unless attrs[:owner].nil? or not attrs[:owner].is_a?(Facet)),
cluster_name: (attrs[:owner].cluster_name unless attrs[:owner].nil?),
- realm_name: (attrs[:owner].realm_name unless attrs[:owner].nil?))
+ realm_name: (attrs[:owner].realm_name unless attrs[:owner].nil?))
super attrs, &blk
end
def self.plugin_hook owner, attrs, plugin_name, full_name, &blk
(this = new(attrs.merge(owner: owner, name: full_name), &blk))._project(owner)
@@ -32,12 +32,12 @@
end
end
def self.from_node(node = NilCheckDelegate.new(nil))
cluster_name = node['cluster_name'].to_s
- super(node).tap{|x| x.receive!(cluster_name: cluster_name,
- realm_name: cluster_name.split('_').first)}
+ realm_name = node['realm_name'].to_s
+ super(node).tap{ |x| x.receive!(cluster_name: cluster_name, realm_name: realm_name) }
end
def self.announce_name
plugin_name
end
@@ -92,11 +92,11 @@
def default_create_security_groups default=true
magic :create_security_groups, :boolean, default: default
end
end
- def set_discovery compute, keys
+ def set_discovery(compute, keys)
if server_cluster
wire_to(compute, full_server_cluster, keys)
else
# I'm defanging automatic discovery for now.
raise StandardError.new("must explicitly specify a server_cluster for discovery")
@@ -108,29 +108,26 @@
def wire_to(compute, full_server_cluster_v, keys)
discovery = {discovers: keys.reverse.inject(full_server_cluster_v){|hsh,key| {key => hsh}}}
(compute.facet_role || compute.cluster_role).override_attributes(discovery)
- # FIXME: This is Ec2-specific and probably doesn't belong here.
client_group_v = client_group(compute)
server_group_v = security_group(full_server_cluster_v)
- if create_security_groups
- group_edge(compute.cloud(:ec2), client_group_v, :authorized_by_group, server_group_v)
- group_edge(compute.cloud(:ec2), client_group_v, :authorize_group, server_group_v) if bidirectional
- end
+ group_edge(compute, client_group_v, :authorized_by_group, server_group_v)
+ group_edge(compute, client_group_v, :authorize_group, server_group_v) if bidirectional
Chef::Log.debug("discovered #{announce_name} for #{cluster_name}: #{discovery}")
end
protected
def client_group(compute)
- security_group(compute.cluster_name)
+ security_group(compute.cluster_name, (compute.name if compute.is_a?(Facet)))
end
def full_server_cluster
- "#{realm_name}_#{server_cluster}"
+ server_cluster
end
def group_edge(cloud, group_1, method, group_2)
cloud.security_group(group_1).send(method, group_2)
Chef::Log.debug("component.rb: allowing access from security group #{group_1} to #{group_2}")