Sha256: 3fd579e66a42c54c85561c7fe1ee9b81cd873a0f4820ca6032ed57b95a846361

Contents?: true

Size: 1.6 KB

Versions: 19

Compression:

Stored size: 1.6 KB

Contents

module Fog
  module Compute
    class OpenStack
      class Real

        def create_security_group(name, description)
          data = {
            'security_group' => {
              'name'       => name,
              'description' => description
            }
          }

          request(
            :body     => Fog::JSON.encode(data),
            :expects  => 200,
            :method   => 'POST',
            :path     => 'os-security-groups.json'
          )
        end

      end

      class Mock
        def create_security_group(name, description)
          Fog::Identity::OpenStack.new(:openstack_auth_url => credentials[:openstack_auth_url])
          tenant_id = Fog::Identity::OpenStack::Mock.data[current_tenant][:tenants].keys.first
          security_group_id = Fog::Mock.random_numbers(2).to_i
          self.data[:security_groups][security_group_id.to_s] = {
            'tenant_id' => tenant_id,
            'rules'     => [],
            'id'        => security_group_id,
            'name'      => name,
            'description' => description
          }

          response = Excon::Response.new
          response.status = 200
          response.headers = {
            'X-Compute-Request-Id' => "req-#{Fog::Mock.random_hex(32)}",
            'Content-Type'   => 'application/json',
            'Content-Length' => Fog::Mock.random_numbers(3).to_s,
            'Date'           => Date.new}
          response.body = {
            'security_group' => self.data[:security_groups][security_group_id.to_s]
          }
          response
        end
      end # mock
    end # openstack
  end # compute
end # fog

Version data entries

19 entries across 19 versions & 2 rubygems

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