Sha256: 6641271a30858c29263aec3427452d91871f40ee0172c9177c1284849237cc33

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

require 'fog/core/model'

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

	      attribute :account
	      attribute :boot_order
	      attribute :disk_attach
	      attribute :domain
	     	attribute :entry
	      attribute :error_reason
	      attribute :fingerprint
	      attribute :hostname
	      attribute :hypervisor
	      attribute :image_format
	      attribute :imagelist
	      attribute :ip
	      attribute :label
	      attribute :networking
	      attribute :placement_requirements
	      attribute :platform
	      attribute :priority
	      attribute :quota
	      attribute :quota_reservation
	      attribute :resolvers
	      attribute :reverse_dns
	      attribute :shape
	      attribute :site
	      attribute :sshkeys
	      attribute :start_time
	      attribute :state
	      attribute :storage_attachments
	      attribute :tags
	      attribute :uri
	      attribute :vcable_id
	      attribute :virtio
	      attribute :vnc 

	      def initialize(attributes={})
	      	self.shape ||= 'oc3'
	      	super
	      end

	      def ready?
	      	state == 'running'
	      end

	      def clean_name 
	      	name.sub %r{\/.*\/}, ''
	      end

 				def save
          #identity ? update : create
          create
        end

        def create
        	requires :name, :shape, :imagelist, :sshkeys
          
          data = service.create_instance(name, shape, imagelist, label, sshkeys)
          merge_attributes(data.body['instances'][0])
        end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fog-oraclecloud-0.1.15 lib/fog/oraclecloud/models/compute/instance.rb
fog-oraclecloud-0.1.14 lib/fog/oraclecloud/models/compute/instance.rb
fog-oraclecloud-0.1.13 lib/fog/oraclecloud/models/compute/instance.rb