Sha256: 464e6e1405777107592c8856d9753c9a8595d880e94c33d5e560bbcff9f8582e

Contents?: true

Size: 1.99 KB

Versions: 23

Compression:

Stored size: 1.99 KB

Contents

require 'fog/core/model'

module Fog
  module Compute
    class OpenStack
      class SecurityGroup < Fog::Model
        identity  :id

        attribute :name
        attribute :description
        attribute :security_group_rules, :aliases => "rules"
        attribute :tenant_id

        def security_group_rules
          Fog::Compute::OpenStack::SecurityGroupRules.new(:service => service).load(attributes[:security_group_rules])
        end

        def rules
          Fog::Logger.deprecation('#rules is deprecated. Use #security_group_rules instead')
          attributes[:security_group_rules]
        end

        # no one should be calling this because it doesn't do anything
        # useful but we deprecated the rules attribute and need to maintain the API
        def rules=(new_rules)
          Fog::Logger.deprecation('#rules= is deprecated. Use the Fog::Compute::Openstack::SecurityGroupRules collection to create new rules.')
          attributes[:security_group_rules] = new_rules
        end

        def save
          requires :name, :description
          data = service.create_security_group(name, description)
          merge_attributes(data.body['security_group'])
          true
        end

        def destroy
          requires :id
          service.delete_security_group(id)
          true
        end

        def create_security_group_rule(min, max, ip_protocol = "tcp", cidr = "0.0.0.0/0", group_id = nil)
          Fog::Logger.deprecation('#create_security_group_rule is deprecated. Use the Fog::Compute::Openstack::SecurityGroupRules collection to create new rules.')
          requires :id
          service.create_security_group_rule(id, ip_protocol, min, max, cidr, group_id)
        end

        def delete_security_group_rule(rule_id)
          Fog::Logger.deprecation('#create_security_group_rule is deprecated. Use the Fog::Compute::Openstack::SecurityGroupRule objects to destroy rules.')
          service.delete_security_group_rule(rule_id)
          true
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 4 rubygems

Version Path
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/openstack/models/compute/security_group.rb
fog-1.32.0 lib/fog/openstack/models/compute/security_group.rb
fog-1.31.0 lib/fog/openstack/models/compute/security_group.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/openstack/models/compute/security_group.rb
fog-1.30.0 lib/fog/openstack/models/compute/security_group.rb
fog-1.29.0 lib/fog/openstack/models/compute/security_group.rb
fog-1.28.0 lib/fog/openstack/models/compute/security_group.rb
fog-1.27.0 lib/fog/openstack/models/compute/security_group.rb
fog-1.26.0 lib/fog/openstack/models/compute/security_group.rb
fog-1.25.0 lib/fog/openstack/models/compute/security_group.rb
nsidc-fog-1.24.1 lib/fog/openstack/models/compute/security_group.rb
fog-1.24.0 lib/fog/openstack/models/compute/security_group.rb
ns-fog-1.22.11 lib/fog/openstack/models/compute/security_group.rb
ns-fog-1.22.10 lib/fog/openstack/models/compute/security_group.rb
ns-fog-1.22.9 lib/fog/openstack/models/compute/security_group.rb
ns-fog-1.22.8 lib/fog/openstack/models/compute/security_group.rb
ns-fog-1.22.7 lib/fog/openstack/models/compute/security_group.rb
ns-fog-1.22.6 lib/fog/openstack/models/compute/security_group.rb
fog-1.23.0 lib/fog/openstack/models/compute/security_group.rb
ns-fog-1.22.4 lib/fog/openstack/models/compute/security_group.rb