Sha256: b804c1aa7ac8f652eaec5267ea2b70f478daa5d64ad22936339292d4e6185f3f

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

require 'fog/core/model'

module Fog
  module Compute
  	class OracleCloud
	    class IpReservation < Fog::Model
	      identity  :name

	      attribute :account
	      attribute :ip
	      attribute :parentpool
	      attribute :permanent
	      attribute :quota
	      attribute :tags
	      attribute :uri
	      attribute :used

 				def save
          begin
            # Check if it's already created
            res = Fog::Compute[:oraclecloud].ip_reservations.get(name)
            update
          rescue Fog::Compute::OracleCloud::NotFound    
            # It wasn't found. 
            create
          end
        end

        def create 
          requires :name
          data = service.create_ip_reservation({
          	:name => name,
          	:parentpool => parentpool || '/oracle/public/ippool', 
          	:permanent => permanent || true,
          	:tags => tags
          })
          merge_attributes(data.body)
        end

        def update
          requires :name, :parentpool
        	data = service.update_ip_reservation({
        		:name => name,
        		:parentpool => parentpool,
        		:permanent => permanent,
        		:tags => tags
        	})
        	merge_attributes(data.body)
        end

        def destroy
        	requires :name
        	service.delete_ip_reservation(name)
        end

	    end
	  end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-oraclecloud-0.1.17 lib/fog/oraclecloud/models/compute/ip_reservation.rb
fog-oraclecloud-0.1.16 lib/fog/oraclecloud/models/compute/ip_reservation.rb