Sha256: 269bce79c6e1b1e74e04e55c7747508f7280f0c38798f7489cf18358402f4877

Contents?: true

Size: 1.51 KB

Versions: 2

Compression:

Stored size: 1.51 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        = "compute"
    self.resource_name  = "os-security-group"
    self.resources_name = "os-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

2 entries across 2 versions & 1 rubygems

Version Path
yao-0.0.2 lib/yao/resources/security_group.rb
yao-0.0.2.rc3 lib/yao/resources/security_group.rb