Sha256: 2d475ba9dfa4b9bb0919da9b9accd583ba8e6f895881924d126a32ff38fa80ac

Contents?: true

Size: 1.36 KB

Versions: 21

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

21 entries across 21 versions & 4 rubygems

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