Module: PuppetX::IntechWIFI::Declare_Environment_Resources::ServiceHelpers
- Defined in:
- lib/puppet_x/intechwifi/declare_environment_resources.rb
Class Method Summary collapse
- .CalculateServiceSecurityGroupName(name, service_name) ⇒ Object
- .CalculateServiceSecurityGroups(name, roles, services) ⇒ Object
- .GetPathValue(data, path, nodata) ⇒ Object
- .Services(role) ⇒ Object
- .TranscodeRule(name, roles, service, env_format) ⇒ Object
Class Method Details
.CalculateServiceSecurityGroupName(name, service_name) ⇒ Object
704 705 706 |
# File 'lib/puppet_x/intechwifi/declare_environment_resources.rb', line 704 def self.CalculateServiceSecurityGroupName(name, service_name) sprintf("%{name}_%{service}", { :name => name, :service => service_name}) end |
.CalculateServiceSecurityGroups(name, roles, services) ⇒ Object
679 680 681 682 683 684 685 686 687 688 689 690 691 |
# File 'lib/puppet_x/intechwifi/declare_environment_resources.rb', line 679 def self.CalculateServiceSecurityGroups(name, roles, services) services.map{|key, value| { CalculateServiceSecurityGroupName(name, key) => { :service => key, :in => GetPathValue(value, ["network", "in"], []).map{|rule| TranscodeRule(name, roles, key, rule) }.flatten, :out => GetPathValue(value, ["network", "out"], []).map{|rule| TranscodeRule(name, roles, key, rule)}.flatten } } }.reduce({}){|hash,kv| hash.merge(kv)} end |
.GetPathValue(data, path, nodata) ⇒ Object
693 694 695 696 697 698 699 700 701 702 |
# File 'lib/puppet_x/intechwifi/declare_environment_resources.rb', line 693 def self.GetPathValue(data, path, nodata) path = [path] if !path.kind_of?(Array) if !data.has_key?(path[0]) nodata elsif path.length > 1 GetPathValue(data[path[0]], path[1..-1], nodata) else data[path[0]] end end |
.Services(role) ⇒ Object
741 742 743 |
# File 'lib/puppet_x/intechwifi/declare_environment_resources.rb', line 741 def self.Services(role) role.has_key?("services") ? role["services"] : [] end |
.TranscodeRule(name, roles, service, env_format) ⇒ Object
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 |
# File 'lib/puppet_x/intechwifi/declare_environment_resources.rb', line 708 def self.TranscodeRule(name, roles, service, env_format) segments = env_format.split('|') case segments[2] when 'rss' location_type = 'sg' case segments[3] when 'elb' # This is the fun one! location_ident = roles.select{|role_name, role_data| role_data['services'].include?(service) }.map{|role_name, role_data| "#{name}_#{role_name}_elb" } end when 'service' location_type = 'sg' location_ident = [CalculateServiceSecurityGroupName(name, segments[3])] when 'rds' location_type = 'sg' location_ident = ["#{name}_#{segments[3]}"] else location_type = segments[2] location_ident = [segments[3]] end location_ident.map{|loc_ident| "#{segments[0]}|#{segments[1]}|#{location_type}|#{loc_ident}" } end |