Sha256: 66464faba58f90e7199512e4d294e4ea14ced318cb872e8f5ded359300fd32db

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

module Fog
  module Compute
    class OracleCloud
      class Real
      	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
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-oraclecloud-0.1.1 lib/fog/oraclecloud/requests/compute/create_orchestration.rb