Sha256: 463a19b5ae0fa023a2f289c639b8c5d0458d9ff01c851d5becd0ad92f7e3e84b

Contents?: true

Size: 1.5 KB

Versions: 39

Compression:

Stored size: 1.5 KB

Contents

require 'yao/resources/security_group_rule'
module Yao::Resources
  class SecurityGroup < Base
    friendly_attributes :name, :description, :tenant_id

    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

39 entries across 39 versions & 1 rubygems

Version Path
yao-0.7.0 lib/yao/resources/security_group.rb
yao-0.6.3 lib/yao/resources/security_group.rb
yao-0.6.2 lib/yao/resources/security_group.rb
yao-0.6.1 lib/yao/resources/security_group.rb
yao-0.6.0 lib/yao/resources/security_group.rb
yao-0.5.0 lib/yao/resources/security_group.rb
yao-0.4.3 lib/yao/resources/security_group.rb
yao-0.4.2 lib/yao/resources/security_group.rb
yao-0.4.1 lib/yao/resources/security_group.rb
yao-0.4.0 lib/yao/resources/security_group.rb
yao-0.3.8 lib/yao/resources/security_group.rb
yao-0.3.7 lib/yao/resources/security_group.rb
yao-0.3.6 lib/yao/resources/security_group.rb
yao-0.3.5 lib/yao/resources/security_group.rb
yao-0.3.4 lib/yao/resources/security_group.rb
yao-0.3.3 lib/yao/resources/security_group.rb
yao-0.3.2 lib/yao/resources/security_group.rb
yao-0.3.1 lib/yao/resources/security_group.rb
yao-0.3.0 lib/yao/resources/security_group.rb
yao-0.2.13 lib/yao/resources/security_group.rb