Sha256: f07b8fa429c5eb872f34e8807891a566f63df527f881af58838a2999d1af2ea3

Contents?: true

Size: 1.39 KB

Versions: 14

Compression:

Stored size: 1.39 KB

Contents

module Fog
  module Compute
    class Ecloud
      module Shared
        def validate_node_service_data(service_data)
          required_opts = [:name, :port, :enabled, :ip_address]
          unless required_opts.all? { |opt| service_data.has_key?(opt) }
            raise ArgumentError.new("Required Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}")
          end
        end
      end

      class Real
        include Shared

        def node_service_create(service_data)
          validate_node_service_data(service_data)

          request(
            :body => generate_node_service_request(service_data),
            :expects => 201,
            :method => "POST",
            :headers => {},
            :uri => service_data[:uri],
            :parse => true
          )
        end

        private

        def generate_node_service_request(service_data)
          xml = Builder::XmlMarkup.new
          xml.CreateNodeService(:name => service_data[:name]) do
            xml.IpAddress(:href => service_data[:ip_address], :name => service_data[:ip_address].scan(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)[0])
            xml.Port service_data[:port]
            xml.Enabled service_data[:enabled]
            if service_data[:description]
              xml.Description service_data[:description]
            end
          end
        end
      end
    end
  end
end          

Version data entries

14 entries across 14 versions & 8 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/ecloud/requests/compute/node_service_create.rb
fog-nirvanix-1.8.1 lib/fog/ecloud/requests/compute/node_service_create.rb
fog-parser-fix-1.6.1 lib/fog/ecloud/requests/compute/node_service_create.rb
fog-test-again-1.6.0 lib/fog/ecloud/requests/compute/node_service_create.rb
fog-parser-fix-1.6.0 lib/fog/ecloud/requests/compute/node_service_create.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/ecloud/requests/compute/node_service_create.rb
fog-sgonyea-1.8.1 lib/fog/ecloud/requests/compute/node_service_create.rb
fog-1.8.0 lib/fog/ecloud/requests/compute/node_service_create.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/ecloud/requests/compute/node_service_create.rb
fog-1.7.0 lib/fog/ecloud/requests/compute/node_service_create.rb
fog-1.6.0 lib/fog/ecloud/requests/compute/node_service_create.rb
fog-1.5.0 lib/fog/ecloud/requests/compute/node_service_create.rb
rackspace-fog-1.4.2 lib/rackspace-fog/ecloud/requests/compute/node_service_create.rb
fog-1.4.0 lib/fog/ecloud/requests/compute/node_service_create.rb