Sha256: 49240b83d42b375e2503968eebf0e6b06d3c1ce7eae7d12f4728492d106bcc32

Contents?: true

Size: 1.58 KB

Versions: 6

Compression:

Stored size: 1.58 KB

Contents

require 'yao/resources/security_group_rule'
module Yao::Resources
  class SecurityGroup < Base
    include ProjectAssociationable

    friendly_attributes :name, :description

    # @return [Array<Yao::Resources::SecurityGroupRule>]
    def rules
      self[["rules", SecurityGroupRule].join("__")] ||= (case self.class.service
      when "compute"
        self["rules"].map{|r| SecurityGroupRule.new(r) }
      when "network"
        self["security_group_rules"].map{|r| SecurityGroupRule.new(r) }
      end)
    end

    self.service        = "network"
    self.resource_name  = "security-group"
    self.resources_name = "security-groups"
  end
end

Yao.config.param :security_group_service, "compute" do |service|
  case service
  when "compute"
    Yao::Resources::SecurityGroup.service        = service
    Yao::Resources::SecurityGroup.resource_name  = "os-security-group"
    Yao::Resources::SecurityGroup.resources_name = "os-security-groups"

    Yao::Resources::SecurityGroupRule.service        = service
    Yao::Resources::SecurityGroupRule.resource_name  = "os-security-group-rule"
    Yao::Resources::SecurityGroupRule.resources_name = "os-security-group-rules"
  when "network"
    Yao::Resources::SecurityGroup.service        = service
    Yao::Resources::SecurityGroup.resource_name  = "security-group"
    Yao::Resources::SecurityGroup.resources_name = "security-groups"

    Yao::Resources::SecurityGroupRule.service        = service
    Yao::Resources::SecurityGroupRule.resource_name  = "security-group-rule"
    Yao::Resources::SecurityGroupRule.resources_name = "security-group-rules"
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
yao-0.21.0 lib/yao/resources/security_group.rb
yao-0.20.0 lib/yao/resources/security_group.rb
yao-0.19.0 lib/yao/resources/security_group.rb
yao-0.18.0 lib/yao/resources/security_group.rb
yao-0.17.0 lib/yao/resources/security_group.rb
yao-0.16.0 lib/yao/resources/security_group.rb