class Fog::Compute::OracleCloud::Real

Public Class Methods

new(options={}) click to toggle source
# File lib/fog/oraclecloud/compute.rb, line 127
def initialize(options={})
        @username = options[:oracle_username]
        @password = options[:oracle_password]
        @identity_domain   = options[:oracle_domain]
        @api_endpoint   = options[:oracle_compute_api]

  @connection = Fog::XML::Connection.new(@api_endpoint)

  # Get authentication token
  authenticate
end

Public Instance Methods

authenticate() click to toggle source
# File lib/fog/oraclecloud/compute.rb, line 139
def authenticate()
        begin
    response = @connection.request({
        :expects  => 204,
          :method   => 'POST',
        :path     => "/authenticate/",
        :headers  => {
                'Content-Type'    => 'application/oracle-compute-v3+json'
        },
        :body                      => Fog::JSON.encode({
                'user'            => "/Compute-#{@identity_domain}/#{@username}",
                'password'=> @password
        })
    })
  rescue Excon::Errors::HTTPStatusError => error
    error
  end
  if response.nil? || !response.headers['Set-Cookie'] then
        raise Error.new('Could not authenticate to Compute Cloud Service. Check your athentication details in your config')
  end
  @auth_cookie = response.headers['Set-Cookie']
end
create_image(account, name, no_upload, file, sizes) click to toggle source
# File lib/fog/oraclecloud/requests/compute/create_image.rb, line 5
def create_image (account, name, no_upload, file, sizes)
  # Just in case it's already set
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
  body_data     = {
    'name'                      => "/Compute-#{@identity_domain}/#{@username}/#{name}",
    'account'                                       => account,
    'no_upload'                                   => no_upload,
    'file'                => file,
    'sizes'               => sizes
  }
  body_data = body_data.reject {|key, value| value.nil?}

  request(
    :method   => 'POST',
    :expects  => 201,
    :path     => "/imagelist/Compute-#{@identity_domain}/#{@username}/#{name}",
    :body     => Fog::JSON.encode(body_data),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
create_image_list(name, description, options={}) click to toggle source
# File lib/fog/oraclecloud/requests/compute/create_image_list.rb, line 5
def create_image_list (name, description, options={})
  # Just in case it's already set
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
  body_data     = {
    'name'                      => "/Compute-#{@identity_domain}/#{@username}/#{name}",
    'description'                                       => description,
    'default'                                         => options[:default]
  }
  body_data = body_data.reject {|key, value| value.nil?}
  request(
    :method   => 'POST',
    :expects  => 201,
    :path     => "/imagelist/Compute-#{@identity_domain}/#{@username}/",
    :body     => Fog::JSON.encode(body_data),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
create_instance(name, shape, imagelist, label, sshkeys) click to toggle source
# File lib/fog/oraclecloud/requests/compute/create_instance.rb, line 5
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
create_ip_association(params) click to toggle source
# File lib/fog/oraclecloud/requests/compute/create_ip_association.rb, line 5
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
create_ip_network(params) click to toggle source
# File lib/fog/oraclecloud/requests/compute/create_ip_network.rb, line 5
def create_ip_network (params)
  if !params[:name].nil? && !params[:name].start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    params[:name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:name]}"
  end            

  params = params.reject {|key, value| value.nil?}
  request(
    :method   => 'POST',
    :expects  => 201,
    :path     => "/network/v1/ipnetwork/",
    :body     => Fog::JSON.encode(params),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
create_ip_reservation(params) click to toggle source
# File lib/fog/oraclecloud/requests/compute/create_ip_reservation.rb, line 5
def create_ip_reservation (params)
  if !params[:name].nil? && !params[:name].start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    params[:name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:name]}"
  end            

  params = params.reject {|key, value| value.nil?}
  request(
    :method   => 'POST',
    :expects  => 201,
    :path     => "/ip/reservation/",
    :body     => Fog::JSON.encode(params),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
create_orchestration(name, oplans, options={}) click to toggle source
# File lib/fog/oraclecloud/requests/compute/create_orchestration.rb, line 5
def create_orchestration (name, oplans, options={})

  # Clean up names in case they haven't provided the fully resolved names
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
  oplans.map do |oplan|
    oplan['objects'].map do |object|
      if oplan['obj_type'] == 'launchplan' then
        object['instances'].map do |instance|
          if !instance['name'].start_with?("/Compute-") then
            instance['name'] = "/Compute-#{@identity_domain}/#{@username}/#{instance['name']}"
          end
        end
      else
        if !object['name'].start_with?("/Compute-") then
          object['name'] = "/Compute-#{@identity_domain}/#{@username}/#{object['name']}"
        end
      end
    end
  end
  body_data     = {
    'name'                    => "/Compute-#{@identity_domain}/#{@username}/#{name}",
    'oplans'        => oplans,
    'relationships' => options[:relationships],
    'description'   => options[:description],
    'account'       => options[:account],
    'schedule'      => options[:schedule]
  }
  body_data = body_data.reject {|key, value| value.nil?}
  request(
    :method   => 'POST',
    :expects  => 201,
    :path     => "/orchestration/",
    :body     => Fog::JSON.encode(body_data),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
create_security_application(name, protocol, options={}) click to toggle source
# File lib/fog/oraclecloud/requests/compute/create_security_application.rb, line 5
def create_security_application(name, protocol, options={})
  body_data     = {
    'name'                      => name,
    'protocol'                                          => protocol,
    'dport'                                                             => options[:dport],
    'icmptype'                                          => options[:icmptype],
    'icmpcode'                                          => options[:icmpcode],
    'description'                                       => options[:description]
  }
  body_data = body_data.reject {|key, value| value.nil?}
  request(
    :method   => 'POST',
    :expects  => 201,
    :path     => "/secapplication/",
    :body     => Fog::JSON.encode(body_data),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
create_security_association(name, seclist, vcable) click to toggle source
# File lib/fog/oraclecloud/requests/compute/create_security_association.rb, line 5
def create_security_association(name, seclist, vcable)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
  seclist.sub! "/Compute-#{@identity_domain}/#{@username}/", ''

  body_data     = {
    'name'              => "/Compute-#{@identity_domain}/#{@username}/#{name}",
    'seclist'           => "/Compute-#{@identity_domain}/#{@username}/#{seclist}",
    'vcable'                                      => vcable
  }
  body_data = body_data.reject {|key, value| value.nil?}
  request(
    :method   => 'POST',
    :expects  => 201,
    :path     => "/secassociation/",
    :body     => Fog::JSON.encode(body_data),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
create_security_ip_list(name, description, secipentries) click to toggle source
# File lib/fog/oraclecloud/requests/compute/create_security_ip_list.rb, line 5
def create_security_ip_list(name, description, secipentries)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''

  body_data     = {
    'name'                => "/Compute-#{@identity_domain}/#{@username}/#{name}",
    'description'         => description,
    'secipentries'        => secipentries,
  }
  body_data = body_data.reject {|key, value| value.nil?}
  request(
    :method   => 'POST',
    :expects  => 201,
    :path     => "/seciplist/",
    :body     => Fog::JSON.encode(body_data),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )

end
create_security_list(name, description, policy, outbound_policy) click to toggle source
# File lib/fog/oraclecloud/requests/compute/create_security_list.rb, line 5
def create_security_list(name, description, policy, outbound_policy)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''

  body_data     = {
    'name'                => "/Compute-#{@identity_domain}/#{@username}/#{name}",
    'description'         => description,
    'policy'              => policy,
    'outbound_cidr_policy'=> outbound_policy
  }
  body_data = body_data.reject {|key, value| value.nil?}
  request(
    :method   => 'POST',
    :expects  => 201,
    :path     => "/seclist/",
    :body     => Fog::JSON.encode(body_data),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )

end
create_security_rule(name, src_list, dst_list, application, action, options={}) click to toggle source
# File lib/fog/oraclecloud/requests/compute/create_security_rule.rb, line 5
def create_security_rule(name, src_list, dst_list, application, action, options={})
  body_data     = {
    'name'                      => name,
    'src_list'                                          => src_list,
    'dst_list'                                          => dst_list,
    'application'                                       => application,
    'action'                                           => action,
    'description'         => options[:description],
    'disabled'            => options[:disabled]
  }
  body_data = body_data.reject {|key, value| value.nil?}
  request(
    :method   => 'POST',
    :expects  => 201,
    :path     => "/secrule/",
    :body     => Fog::JSON.encode(body_data),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
create_ssh_key(name, enabled, key) click to toggle source
# File lib/fog/oraclecloud/requests/compute/create_ssh_key.rb, line 5
def create_ssh_key (name, enabled, key)
  # Just in case it's already set
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
  body_data     = {
      'name'                            => "/Compute-#{@identity_domain}/#{@username}/#{name}",
      'enabled'                                     => enabled,
      'key'                                             => key
  }
  body_data = body_data.reject {|key, value| value.nil?}
  request(
    :method   => 'POST',
    :expects  => 201,
    :path     => "/sshkey/",
    :body     => Fog::JSON.encode(body_data),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
create_storage_attachment(params) click to toggle source
# File lib/fog/oraclecloud/requests/compute/create_storage_attachment.rb, line 7
def create_storage_attachment (params)
  if !params[:instance_name].start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    params[:instance_name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:instance_name]}"
  end 
  if !params[:storage_volume_name].start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    params[:storage_volume_name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:storage_volume_name]}"
  end               

  params = params.reject {|key, value| value.nil?}
  request(
    :method   => 'POST',
    :expects  => 201,
    :path     => "/network/v1/ipnetwork/",
    :body     => Fog::JSON.encode(params),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
create_volume(name, size, high_latency = false, options={}) click to toggle source
# File lib/fog/oraclecloud/requests/compute/create_volume.rb, line 5
def create_volume(name, size, high_latency = false, options={})
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", '' # Just in case it's already set
  body_data     = {
    'name'                      => "/Compute-#{@identity_domain}/#{@username}/#{name}",
    'size'                                                  => size,
    'properties'          => []
  }
  body_data['properties'].push(high_latency ? "/oracle/public/storage/latency" : '/oracle/public/storage/default')
  body_data = body_data.reject {|key, value| value.nil?}

  request(
    :method   => 'POST',
    :expects  => 201,
    :path     => "/storage/volume/",
    :body     => Fog::JSON.encode(body_data),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
delete_image(name, version) click to toggle source
# File lib/fog/oraclecloud/requests/compute/delete_image.rb, line 5
def delete_image (name, version)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
  request(
    :method   => 'DELETE',
    :expects  => 204,
    :path     => "/imagelist/Compute-#{@identity_domain}/#{@username}/#{name}/entry/#{version}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
delete_image_list(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/delete_image_list.rb, line 5
def delete_image_list (name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
  request(
    :method   => 'DELETE',
    :expects  => 204,
    :path     => "/imagelist/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
delete_instance(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/delete_instance.rb, line 5
def delete_instance (name)
  if !name.start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
  end         
  request(
    :method   => 'DELETE',
    :expects  => 204,
    :path     => "/instance#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
delete_ip_network(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/delete_ip_network.rb, line 5
def delete_ip_network (name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
  request(
    :method   => 'DELETE',
    :expects  => 204,
    :path     => "/network/v1/ipnetwork/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
delete_ip_reservation(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/delete_ip_reservation.rb, line 5
def delete_ip_reservation (name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
  request(
    :method   => 'DELETE',
    :expects  => 204,
    :path     => "/ip/reservation/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
delete_orchestration(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/delete_orchestration.rb, line 5
def delete_orchestration (name)
  if !name.start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
  end         
  request(
    :method   => 'DELETE',
    :expects  => 204,
    :path     => "/orchestration#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
delete_security_application(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/delete_security_application.rb, line 5
def delete_security_application(name)
        # Just in case it's already set
        name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
       request(
    :method   => 'DELETE',
    :expects  => 204,
    :path     => "/secapplication/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
delete_security_list(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/delete_security_list.rb, line 5
def delete_security_list(name)
        # Just in case it's already set
        name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
       request(
    :method   => 'DELETE',
    :expects  => 204,
    :path     => "/seclist/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
delete_security_rule(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/delete_security_rule.rb, line 5
def delete_security_rule(name)
        # Just in case it's already set
        name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
       request(
    :method   => 'DELETE',
    :expects  => 204,
    :path     => "/secrule/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
delete_ssh_key(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/delete_ssh_key.rb, line 5
def delete_ssh_key (name)
  if !name.start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
  end         
  request(
    :method   => 'DELETE',
    :expects  => 204,
    :path     => "/sshkey#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
get_image(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/get_image.rb, line 5
                        def get_image(name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
                                response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/machineimage/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end
get_image_list(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/get_image_list.rb, line 5
                        def get_image_list(name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
                                response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/imagelist/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end
get_instance(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/get_instance.rb, line 5
                        def get_instance(name)
  if !name.start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
  end
                                response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/instance#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end
get_ip_association(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/get_ip_association.rb, line 5
def get_ip_association(name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/ip/association/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end
get_ip_network(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/get_ip_network.rb, line 5
                        def get_ip_network(name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
                                response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/network/v1/ipnetwork/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end
get_ip_reservation(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/get_ip_reservation.rb, line 5
                        def get_ip_reservation(name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
                                response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/ip/reservation/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end
get_orchestration(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/get_orchestration.rb, line 5
                        def get_orchestration(name)
  if !name.start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
  end
                                response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/orchestration#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end
get_security_application(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/get_security_application.rb, line 5
                        def get_security_application(name)
  path = "/secapplication"
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
  if name.include? '/oracle/public' then
    path += "/#{name}/"
  else 
    path += "/Compute-#{@identity_domain}/#{@username}/#{name}/"
  end
                                response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => path,
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end
get_security_ip_list(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/get_security_ip_list.rb, line 5
                        def get_security_ip_list(name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''

                                response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/seciplist/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end
get_security_list(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/get_security_list.rb, line 5
                        def get_security_list(name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''

                                response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/seclist/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end
get_security_rule(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/get_security_rule.rb, line 5
                        def get_security_rule(name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''

                                response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/secrule/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end
get_ssh_key(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/get_ssh_key.rb, line 5
def get_ssh_key(name)
  if !name.start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
  end
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/sshkey#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end
get_storage_attachment(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/get_storage_attachment.rb, line 5
                        def get_storage_attachment(name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
                                response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/storage/attachment/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end
list_image_lists() click to toggle source
# File lib/fog/oraclecloud/requests/compute/list_image_lists.rb, line 5
def list_image_lists
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/imagelist/Compute-#{@identity_domain}/#{@username}/"
  )
  response
end
list_images() click to toggle source
# File lib/fog/oraclecloud/requests/compute/list_images.rb, line 5
def list_images
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/machineimage/Compute-#{@identity_domain}/#{@username}/"
  )
  response
end
list_instances() click to toggle source
# File lib/fog/oraclecloud/requests/compute/list_instances.rb, line 5
def list_instances
  response = request(
    :expects => 200,
    :method  => 'GET',
    :path    => "/instance/Compute-#{@identity_domain}/"
  )
  response
end
list_ip_associations() click to toggle source
# File lib/fog/oraclecloud/requests/compute/list_ip_associations.rb, line 5
def list_ip_associations
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/ip/association/Compute-#{@identity_domain}/"
  )
  response
end
list_ip_networks() click to toggle source
# File lib/fog/oraclecloud/requests/compute/list_ip_networks.rb, line 5
def list_ip_networks
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/network/v1/ipnetwork/Compute-#{@identity_domain}/#{@username}/"
  )
  response
end
list_ip_reservations() click to toggle source
# File lib/fog/oraclecloud/requests/compute/list_ip_reservations.rb, line 5
def list_ip_reservations
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/ip/reservation/Compute-#{@identity_domain}/#{@username}/"
  )
  response
end
list_orchestrations() click to toggle source
# File lib/fog/oraclecloud/requests/compute/list_orchestrations.rb, line 5
def list_orchestrations
  response = request(
    :expects => 200,
    :method  => 'GET',
    :path    => "/orchestration/Compute-#{@identity_domain}/"
  )
  response
end
list_security_applications(public_list=false) click to toggle source
# File lib/fog/oraclecloud/requests/compute/list_security_applications.rb, line 5
def list_security_applications(public_list=false)
  path = "/secapplication"
  if public_list then
    path += "/oracle/public/"
  else 
    path += "/Compute-#{@identity_domain}/#{@username}/"
  end
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => path
  )
  response
end
list_security_lists() click to toggle source
# File lib/fog/oraclecloud/requests/compute/list_security_lists.rb, line 5
def list_security_lists
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/seclist/Compute-#{@identity_domain}/#{@username}/"
  )
  response
end
list_security_rules() click to toggle source
# File lib/fog/oraclecloud/requests/compute/list_security_rules.rb, line 5
def list_security_rules
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/secrule/Compute-#{@identity_domain}/#{@username}/"
  )
  response
end
list_ssh_keys() click to toggle source
# File lib/fog/oraclecloud/requests/compute/list_ssh_keys.rb, line 5
def list_ssh_keys
  response = request(
    :expects => 200,
    :method  => 'GET',
    :path    => "/sshkey/Compute-#{@identity_domain}/"
  )
  response
end
list_storage_attachments() click to toggle source
# File lib/fog/oraclecloud/requests/compute/list_storage_attachments.rb, line 5
def list_storage_attachments
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/storage/attachment/Compute-#{@identity_domain}/#{@username}/"
  )
  response
end
list_volumes() click to toggle source
# File lib/fog/oraclecloud/requests/compute/list_volumes.rb, line 5
def list_volumes
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/storage/volume/Compute-#{@identity_domain}/#{@username}/"
  )
  response
end
request(params, parse_json = true, &block) click to toggle source
# File lib/fog/oraclecloud/compute.rb, line 162
def request(params, parse_json = true, &block)
                                begin
    Fog::Logger.debug("Sending #{params[:body].to_s} to (#{params[:method]}):#{params[:path]}")
                                        response = @connection.request(params.merge!({
                                                :headers  => {
                                                        'Cookie' => @auth_cookie
                                                }.merge!(params[:headers] || {})
                                        }), &block)
                                rescue Excon::Errors::HTTPStatusError => error
                                        raise case error
                                        when Excon::Errors::NotFound
                                                Fog::Compute::OracleCloud::NotFound.slurp(error)
                                        when Excon::Errors::Conflict
                                                data = Fog::JSON.decode(error.response.body)
                                                raise Error.new(data['message'])
                                        else
                                                error
                                        end
                                end
                                if !response.body.empty? && parse_json
    response.body = Fog::JSON.decode(response.body)
  end
  response
end
start_orchestration(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/start_orchestration.rb, line 5
def start_orchestration (name)
  if !name.start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
  end   
  request(
    :method   => 'PUT',
    :expects  => 200,
    :path     => "/orchestration#{name}?action=start",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
stop_orchestration(name) click to toggle source
# File lib/fog/oraclecloud/requests/compute/stop_orchestration.rb, line 5
def stop_orchestration (name)
  if !name.start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
  end   
  request(
    :method   => 'PUT',
    :expects  => 200,
    :path     => "/orchestration#{name}?action=stop",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
update_image(name, options={}) click to toggle source
# File lib/fog/oraclecloud/requests/compute/update_image.rb, line 5
def update_image (name, options={})
  # Just in case it's already set
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
  body_data     = {
    'name'                      => "/Compute-#{@identity_domain}/#{@username}/#{name}",
    'description'                                       => options[:description],
    'default'                                         => options[:default]
  }
  body_data = body_data.reject {|key, value| value.nil?}
  request(
    :method   => 'PUT',
    :expects  => 200,
    :path     => "/imagelist/Compute-#{@identity_domain}/#{@username}/#{name}",
    :body     => Fog::JSON.encode(body_data),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
update_image_list(name, options={}) click to toggle source
# File lib/fog/oraclecloud/requests/compute/update_image_list.rb, line 5
def update_image_list (name, options={})
  # Just in case it's already set
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
  body_data     = {
    'name'                      => "/Compute-#{@identity_domain}/#{@username}/#{name}",
    'description'                                       => options[:description],
    'default'                                         => options[:default]
  }
  body_data = body_data.reject {|key, value| value.nil?}
  request(
    :method   => 'PUT',
    :expects  => 200,
    :path     => "/imagelist/Compute-#{@identity_domain}/#{@username}/#{name}",
    :body     => Fog::JSON.encode(body_data),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
update_ip_reservation(params) click to toggle source
# File lib/fog/oraclecloud/requests/compute/update_ip_reservation.rb, line 7
def update_ip_reservation (params) 
  params[:name].sub! "/Compute-#{@identity_domain}/#{@username}/", ''
  params[:name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:name]}"
  params = params.reject {|key, value| value.nil?}
  request(
    :method   => 'PUT',
    :expects  => 200,
    :path     => "/ip/reservation#{params[:name]}",
    :body     => Fog::JSON.encode(params),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
update_orchestration(name, oplans, options={}) click to toggle source
# File lib/fog/oraclecloud/requests/compute/update_orchestration.rb, line 5
def update_orchestration (name, oplans, options={})

  # Clean up names in case they haven't provided the fully resolved names
  if !name.start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
  end   
  oplans.map do |oplan|
    oplan['objects'].map do |object|
      if oplan['obj_type'] == 'launchplan' then
        object['instances'].map do |instance|
          if !instance['name'].start_with?("/Compute-") then
            instance['name'] = "/Compute-#{@identity_domain}/#{@username}/#{instance['name']}"
          end
        end
      else
        if !object['name'].start_with?("/Compute-") then
          object['name'] = "/Compute-#{@identity_domain}/#{@username}/#{object['name']}"
        end
      end
    end
  end
  body_data     = {
    'name'                    => name,
    'oplans'        => oplans,
    'relationships' => options[:relationships],
    'description'   => options[:description],
    'account'       => options[:account],
    'schedule'      => options[:schedule]
  }
  body_data = body_data.reject {|key, value| value.nil?}
  request(
    :method   => 'PUT',
    :expects  => 200,
    :path     => "/orchestration#{name}",
    :body     => Fog::JSON.encode(body_data),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end
update_ssh_key(uri, name, enabled, key) click to toggle source
# File lib/fog/oraclecloud/requests/compute/update_ssh_key.rb, line 5
def update_ssh_key (uri, name, enabled, key)
  if !name.start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
  end   
  body_data     = {
    'name'                      => name,
    'enabled'                                       => enabled,
    'key'                                               => key
  }
  body_data = body_data.reject {|key, value| value.nil?}
  request(
    :method   => 'PUT',
    :expects  => 200,
    :path     => "/sshkey#{name}",
    :body     => Fog::JSON.encode(body_data),
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json'
    }
  )
end