Sha256: bb871344379eb17fcae7ab0550e380cec3a6339c343e2c14ec84c59897943c38

Contents?: true

Size: 795 Bytes

Versions: 11

Compression:

Stored size: 795 Bytes

Contents

require 'fog/core/collection'
require 'fog/vsphere/models/compute/snapshot'

module Fog
  module Compute
    class Vsphere
      class Snapshots < Fog::Collection
        attribute :server_id, :alias => :instance_uuid
        attribute :parent_snapshot
        model Fog::Compute::Vsphere::Snapshot

        def all(filters = {})
          if parent_snapshot
            load service.list_child_snapshots(parent_snapshot, filters)
          else
            requires :server_id
            load service.list_vm_snapshots(server_id, filters)
          end
        end

        def get(snapshot_ref)
          all.each do |snapshot|
            snapshot = snapshot.get_child(snapshot_ref)
            return snapshot if snapshot
          end
          nil
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fog-vsphere-2.1.1 lib/fog/vsphere/models/compute/snapshots.rb
fog-vsphere-2.1.0 lib/fog/vsphere/models/compute/snapshots.rb
fog-vsphere-2.0.1 lib/fog/vsphere/models/compute/snapshots.rb
fog-vsphere-2.0.0 lib/fog/vsphere/models/compute/snapshots.rb
fog-vsphere-1.13.1 lib/fog/vsphere/models/compute/snapshots.rb
fog-vsphere-1.13.0 lib/fog/vsphere/models/compute/snapshots.rb
fog-vsphere-1.12.0 lib/fog/vsphere/models/compute/snapshots.rb
fog-vsphere-1.11.3 lib/fog/vsphere/models/compute/snapshots.rb
fog-vsphere-1.11.2 lib/fog/vsphere/models/compute/snapshots.rb
fog-vsphere-1.11.1 lib/fog/vsphere/models/compute/snapshots.rb
fog-vsphere-1.11.0 lib/fog/vsphere/models/compute/snapshots.rb