Sha256: 0b2f9bdb780eecac45b010ec6bd9e13220603e1bbf51789303ed810b1b87c37e
Contents?: true
Size: 1.88 KB
Versions: 28
Compression:
Stored size: 1.88 KB
Contents
module Fog module Compute class Google class TargetInstance < Fog::Model identity :name attribute :creation_timestamp, :aliases => "creationTimestamp" attribute :description attribute :id attribute :instance attribute :kind attribute :nat_policy, :aliases => "natPolicy" attribute :self_link, :aliases => "selfLink" attribute :zone def save requires :identity, :zone options = { :description => description, :zone => zone, :nat_policy => nat_policy, :instance => instance } data = service.insert_target_instance(identity, zone, options) operation = Fog::Compute::Google::Operations.new(:service => service) .get(data.name, data.zone) operation.wait_for { ready? } reload end def destroy(async = true) requires :name, :zone data = service.delete_target_instance(name, zone) operation = Fog::Compute::Google::Operations.new(:service => service) .get(data.name, data.zone) operation.wait_for { ready? } unless async operation end def ready? service.get_target_instance(name, zone) true rescue ::Google::Apis::ClientError => e raise e unless e.status_code == 404 false end def reload requires :name, :zone begin data = collection.get(name, zone) new_attributes = data.attributes merge_attributes(new_attributes) return self rescue Excon::Errors::SocketError return nil end end RUNNING_STATE = "READY".freeze end end end end
Version data entries
28 entries across 28 versions & 2 rubygems