Sha256: bc7e8268b82b2bd13c89005c0a4f9509e2d5eda3f025d04f3b48a665960dd6bf

Contents?: true

Size: 1.8 KB

Versions: 11

Compression:

Stored size: 1.8 KB

Contents

module Fog
  module Compute
    class OracleCloud
      class Real
      	def create_instance (name, shape, imagelist, label, sshkeys)
          # This will create an instance using a Launchplan. Consider using an orchestration plan for more control
          # Just in case it's already set
          name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
          body_data     = {
            'instances'    => [{
              'name'             		=> "/Compute-#{@identity_domain}/#{@username}/#{name}",
              'shape'					      => shape,
              'imagelist'					  => imagelist,
              'label'               => label,
              'sshkeys'             => sshkeys
            }]
          }
          body_data = body_data.reject {|key, value| value.nil?}
          request(
            :method   => 'POST',
            :expects  => 201,
            :path     => "/launchplan/",
            :body     => Fog::JSON.encode(body_data),
            :headers  => {
              'Content-Type' => 'application/oracle-compute-v3+json'
            }
          )
      	end
      end

      class Mock
        def create_instance (name, shape, imagelist, label, sshkeys)
          response = Excon::Response.new
          name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''

          self.data[:instances][name] = {
            'name' => "/Compute-#{@identity_domain}/#{@username}/#{name}",
            'shape' => shape,
            'imagelist' => imagelist,
            'label' => label,
            'sshkeys' => sshkeys,
            'state' => 'running'
          }
          response.status = 201
          response.body = {
            'instances' => [self.data[:instances][name]]
          }
          response
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fog-oraclecloud-0.1.12 lib/fog/oraclecloud/requests/compute/create_instance.rb
fog-oraclecloud-0.1.11 lib/fog/oraclecloud/requests/compute/create_instance.rb
fog-oraclecloud-0.1.10 lib/fog/oraclecloud/requests/compute/create_instance.rb
fog-oraclecloud-0.1.9 lib/fog/oraclecloud/requests/compute/create_instance.rb
fog-oraclecloud-0.1.8 lib/fog/oraclecloud/requests/compute/create_instance.rb
fog-oraclecloud-0.1.7 lib/fog/oraclecloud/requests/compute/create_instance.rb
fog-oraclecloud-0.1.6 lib/fog/oraclecloud/requests/compute/create_instance.rb
fog-oraclecloud-0.1.5 lib/fog/oraclecloud/requests/compute/create_instance.rb
fog-oraclecloud-0.1.4 lib/fog/oraclecloud/requests/compute/create_instance.rb
fog-oraclecloud-0.1.3 lib/fog/oraclecloud/requests/compute/create_instance.rb
fog-oraclecloud-0.1.2 lib/fog/oraclecloud/requests/compute/create_instance.rb