Sha256: 97d0d629a5818cc05513e651c2c6a50f89dcf91b81b9bd75aa8d906fcdf412f3

Contents?: true

Size: 1.96 KB

Versions: 65

Compression:

Stored size: 1.96 KB

Contents

module Fog
  module Compute
    class Cloudstack
      class SecurityGroupRule < Fog::Model

        identity  :id,                :aliases => 'ruleid'

        attribute :security_group_id, :type => :string
        attribute :protocol,          :type => :string
        attribute :start_port,        :type => :integer, :aliases => 'startport'
        attribute :end_port,          :type => :integer, :aliases => 'endport'
        attribute :cidr,              :type => :string
        attribute :direction,         :type => :string

        def destroy
          data = service.send("revoke_security_group_#{self.direction}", "id" => self.id)
          job = service.jobs.new(data["revokesecuritygroup#{self.direction}"])
          job.wait_for { ready? }
          job.successful?
        end

        def port_range
          (self.start_port..self.end_port)
        end

        def save
          requires :security_group_id, :cidr, :direction

          data = service.send("authorize_security_group_#{self.direction}".to_sym, params)
          job = service.jobs.new(data["authorizesecuritygroup#{self.direction}response"])
          job.wait_for { ready? }
          # durty
          merge_attributes(job.result.send("#{self.direction}_rules").last)
          self
        end

        def security_group
          service.security_groups.get(self.security_group_id)
        end

        def reload
          requires :id, :security_group_id, :cidr

          merge_attributes(security_group.rules.get(self.id))
        end

        private

        def params
          options = {
            "securitygroupid" => self.security_group_id,
            "protocol"        => self.protocol,
            "cidrlist"        => self.cidr
          }
          options.merge!("startport" => self.start_port) unless self.start_port.nil?
          options.merge("endport" => self.end_port) unless self.end_port.nil?
        end

      end # SecurityGroupRule
    end # Cloudstack
  end # Compute
end # Fog

Version data entries

65 entries across 65 versions & 6 rubygems

Version Path
fog-maestrodev-1.15.0.20130927082724 lib/fog/cloudstack/models/compute/security_group_rule.rb
fog-maestrodev-1.15.0.20130829165835 lib/fog/cloudstack/models/compute/security_group_rule.rb
fog-1.15.0 lib/fog/cloudstack/models/compute/security_group_rule.rb
gapinc-fog-1.14.0 lib/fog/cloudstack/models/compute/security_group_rule.rb
fog-maestrodev-1.14.0.20130806165225 lib/fog/cloudstack/models/compute/security_group_rule.rb
fog-1.14.0 lib/fog/cloudstack/models/compute/security_group_rule.rb
fog-1.13.0 lib/fog/cloudstack/models/compute/security_group_rule.rb
gapinc-fog-1.12.1.2 lib/fog/cloudstack/models/compute/security_group_rule.rb
gapinc-fog-1.12.1.1 lib/fog/cloudstack/models/compute/security_group_rule.rb
gapinc-fog-1.12.1a lib/fog/cloudstack/models/compute/security_group_rule.rb
gapinc-fog-1.12.1 lib/fog/cloudstack/models/compute/security_group_rule.rb
fog-1.12.1 lib/fog/cloudstack/models/compute/security_group_rule.rb
fog-1.12.0 lib/fog/cloudstack/models/compute/security_group_rule.rb
hpfog-0.0.20 lib/fog/cloudstack/models/compute/security_group_rule.rb
vagrant-shell-0.2.6 vendor/bundle/gems/fog-1.10.1/lib/fog/cloudstack/models/compute/security_group_rule.rb
vagrant-shell-0.2.5 vendor/bundle/gems/fog-1.10.1/lib/fog/cloudstack/models/compute/security_group_rule.rb
fog-1.11.1 lib/fog/cloudstack/models/compute/security_group_rule.rb
fog-1.11.0 lib/fog/cloudstack/models/compute/security_group_rule.rb
fog-1.10.1 lib/fog/cloudstack/models/compute/security_group_rule.rb
fog-test-me-1.10.0 lib/fog/cloudstack/models/compute/security_group_rule.rb