Sha256: 133de332e008dfd17f1052189602503d3b4c67bda17da98e356cf236f277f83e

Contents?: true

Size: 1.36 KB

Versions: 48

Compression:

Stored size: 1.36 KB

Contents

module Fog
  module Compute
    class OpenStack
      class Real

        def list_security_groups(server_id = nil)
          path = "os-security-groups.json"
          if server_id
            path = "servers/#{server_id}/#{path}"
          end
          request(
            :expects  => [200],
            :method   => 'GET',
            :path     => path
          )
        end

      end

      class Mock
        def list_security_groups(server_id = nil)
          security_groups = self.data[:security_groups].values

          groups = if server_id then
                     server_group_names =
                       Array(self.data[:server_security_group_map][server_id])

                     server_group_names.map do |name|
                       security_groups.find do |sg|
                         sg['name'] == name
                       end
                     end.compact
                   else
                     security_groups
                   end

          Excon::Response.new(
            :body     => { 'security_groups' => groups },
            :headers  => {
              "X-Compute-Request-Id" => "req-#{Fog::Mock.random_base64(36)}",
              "Content-Type" => "application/json",
              "Date" => Date.new
            },
            :status   => 200
          )
        end
      end # mock
    end # openstack
  end # compute
end # fog

Version data entries

48 entries across 48 versions & 3 rubygems

Version Path
fog-1.22.0 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-1.21.0 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-1.20.0 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-1.19.0 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/openstack/requests/compute/list_security_groups.rb