Sha256: 9c3229648296680be29179b28cad10722dcce8e9be1991e7c45e747a968f2ef4

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

module Fog
  module Compute
    class OracleCloud
      class Real
      	def create_ip_association (params)
          params = params.reject {|key, value| value.nil?}
          puts Fog::JSON.encode(params)
          request(
            :method   => 'POST',
            :expects  => 201,
            :path     => "/ip/association/",
            :body     => Fog::JSON.encode(params),
            :headers  => {
              'Content-Type' => 'application/oracle-compute-v3+json'
            }
          )
      	end
      end

      class Mock
        def create_ip_association (params)
          response = Excon::Response.new
          name = SecureRandom.uuid

          self.data[:ip_associations][name] = {
            'name' => "/Compute-#{@identity_domain}/#{@username}/#{name}",
            'account' => "/Compute-#{@identity_domain}/#{@username}",
            'uri' => "#{@api_endpoint}ip/reservation/Compute-#{@identity_domain}/#{@username}/#{name}",
            'parentpool' => params[:parentpool],
            'vcable' => params[:vcable]
          }
          instance = self.data[:instances].detect { |i|i[1]['vcable_id'] = params[:vcable]}
          if instance.nil? then
            # TODO: Add error handling. And don't create ip association
          else
            # Update it's networking
            instance[1]['networking']['eth0']['nat']="#{params[:parentpool]}"
          end
          response.status = 201
          response.body = self.data[:ip_associations][name]
          response
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-oraclecloud-0.1.17 lib/fog/oraclecloud/requests/compute/create_ip_association.rb