Sha256: febf22bbda308c59ca82b012ec21902768e2cea5f1b60c9d7a8834c39c1ed02c

Contents?: true

Size: 1.35 KB

Versions: 23

Compression:

Stored size: 1.35 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 =
                       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

23 entries across 23 versions & 7 rubygems

Version Path
cifrado-0.2.1 vendor/fog/lib/fog/openstack/requests/compute/list_security_groups.rb
cifrado-0.2.0 vendor/fog/lib/fog/openstack/requests/compute/list_security_groups.rb
gapinc-fog-1.12.1.1 lib/fog/openstack/requests/compute/list_security_groups.rb
gapinc-fog-1.12.1a lib/fog/openstack/requests/compute/list_security_groups.rb
gapinc-fog-1.12.1 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-1.12.1 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-1.12.0 lib/fog/openstack/requests/compute/list_security_groups.rb
hpfog-0.0.20 lib/fog/openstack/requests/compute/list_security_groups.rb
vagrant-shell-0.2.6 vendor/bundle/gems/fog-1.10.1/lib/fog/openstack/requests/compute/list_security_groups.rb
vagrant-shell-0.2.5 vendor/bundle/gems/fog-1.10.1/lib/fog/openstack/requests/compute/list_security_groups.rb
fog-1.11.1 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-1.11.0 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-1.10.1 lib/fog/openstack/requests/compute/list_security_groups.rb
fog-test-me-1.10.0 lib/fog/openstack/requests/compute/list_security_groups.rb
cifrado-0.1.3 vendor/fog/lib/fog/openstack/requests/compute/list_security_groups.rb
fog-1.10.0 lib/fog/openstack/requests/compute/list_security_groups.rb
cifrado-0.1.2 vendor/fog/lib/fog/openstack/requests/compute/list_security_groups.rb
cifrado-0.1.1 vendor/fog/lib/fog/openstack/requests/compute/list_security_groups.rb
cifrado-0.1 vendor/fog/lib/fog/openstack/requests/compute/list_security_groups.rb
fog-1.9.0 lib/fog/openstack/requests/compute/list_security_groups.rb