class Fog::OracleCloud::SOA::Real

Public Class Methods

new(options={}) click to toggle source
# File lib/fog/oraclecloud/soa.rb, line 20
def initialize(options={})
        @username = options[:oracle_username]
        @password = options[:oracle_password]
        @identity_domain   = options[:oracle_domain]
  region_url = options[:oracle_region] == 'emea' ? 'https://jcs.emea.oraclecloud.com' : 'https://jaas.oraclecloud.com'
  Excon.ssl_verify_peer = false

  @connection = Fog::XML::Connection.new(region_url)
end

Public Instance Methods

auth_header() click to toggle source
# File lib/fog/oraclecloud/soa.rb, line 38
def auth_header
        auth_header ||= 'Basic ' + Base64.encode64("#{@username}:#{@password}").gsub("\n",'')
end
create_instance(config, options) click to toggle source
# File lib/fog/oraclecloud/requests/soa/create_instance.rb, line 5
def create_instance(config, options)  
  if !config[:cloudStorageContainer].start_with?("/Storage-")
    config[:cloudStorageContainer] = "/Storage-#{@identity_domain}/#{config[:cloudStorageContainer]}"
  end

  parameters = options.select{|key, value| [:adminPassword, :adminPort, :adminUserName, :backupVolumeSize, :clusterName, :contentPort, :dbaName, :dbaPassword, :dbServiceName, :deploymentChannelPort, :domainMode, :domainName, :domainPartitionCount, :domainVolumeSize, :edition, :ipReservations, :managedServerCount, :msInitialHeapMB, :msJvmArgs, :msMaxHeapMB, :msMaxPermMB, :msPermMb, :nodeManagerPassword, :nodeManagerPort, :nodeManagerUserName, :overwriteMsJvmArgs, :pdbName, :securedAdminPort, :securedContentPort, :shape, :VMsPublicKey, :version].include?(key)}
  parameters.reject! { |key,value| value.nil?}
  config.reject! { |key,value| value.nil?}
  # Currently only support weblogic
  parameters[:type] = "weblogic"
  config[:parameters] = [parameters]
  body_data = config

  request({
    :method   => 'POST',
    :expects  => 202,
    :path     => "/paas/service/soa/api/v1.1/instances/#{@identity_domain}",
    :body     => Fog::JSON.encode(body_data),
    :headers  => {
     'Content-Type'=>'application/json'
    }
  }, false)
end
delete_instance(service_name, dba_name, dba_password, options={}) click to toggle source
# File lib/fog/oraclecloud/requests/soa/delete_instance.rb, line 6
def delete_instance(service_name, dba_name, dba_password, options={})
  body_data = {
    'dbaName'     => dba_name,
    'dbaPassword' => dba_password,
    'forceDelete' => options[:force_delete],
    'skipBackupOnTerminate' => options[:skip_backup]
  }

  body_data = body_data.reject {|key, value| value.nil?}
  request(
    :method   => 'PUT',
    :expects  => 202,
    :path     => "/paas/service/soa/api/v1.1/instances/#{@identity_domain}/#{service_name}",
    :body     => Fog::JSON.encode(body_data)
  )
end
get_instance(instance_id) click to toggle source
# File lib/fog/oraclecloud/requests/soa/get_instance.rb, line 6
def get_instance(instance_id)
                                response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/paas/service/soa/api/v1.1/instances/#{@identity_domain}/#{instance_id}"
  )
  response
end
get_job_status(type, job_id) click to toggle source
# File lib/fog/oraclecloud/requests/soa/get_job_status.rb, line 6
def get_job_status(type, job_id)
                                response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/paas/service/soa/api/v1.1/instances/#{@identity_domain}/status/#{type}/job/#{job_id}"
  )
  response.body['message']
end
list_instances() click to toggle source
# File lib/fog/oraclecloud/requests/soa/list_instances.rb, line 5
def list_instances
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/paas/service/soa/api/v1.1/instances/#{@identity_domain}?outputLevel=verbose"
  )
  response
end
password() click to toggle source
# File lib/fog/oraclecloud/soa.rb, line 34
def password
  @password
end
request(params, parse_json = true, &block) click to toggle source
# File lib/fog/oraclecloud/soa.rb, line 42
def request(params, parse_json = true, &block)
                                begin
    Fog::Logger.debug("Sending #{params[:body].to_s} to #{params[:path]}")
                                        response = @connection.request(params.merge!({
                                                :headers  => {
                                                        'Authorization' => auth_header,
                                                        'X-ID-TENANT-NAME' => @identity_domain,
        'Content-Type' => 'application/json',
        'Accept'       => 'application/json'
                                                }.merge!(params[:headers] || {})
                                        }), &block)
                                rescue Excon::Errors::HTTPStatusError => error
                                        raise case error
                                        when Excon::Errors::NotFound
                                                Fog::OracleCloud::SOA::NotFound.slurp(error)
                                        else
                                                error
                                        end
                                end
                                if !response.body.empty? && parse_json
                                        # The Oracle Cloud doesn't return the Content-Type header as application/json, rather as application/vnd.com.oracle.oracloud.provisioning.Pod+json
                                        # Should add check here to validate, but not sure if this might change in future
    response.body = Fog::JSON.decode(response.body)
  end
  response
end
username() click to toggle source
# File lib/fog/oraclecloud/soa.rb, line 30
def username
  @username
end