Class: Fog::Compute::Proxmox::Snapshots

Inherits:
Proxmox::Collection show all
Defined in:
lib/fog/compute/proxmox/models/snapshots.rb

Overview

class Snapshots Collection of snapshots

Instance Attribute Summary

Attributes inherited from Proxmox::Collection

#response

Instance Method Summary collapse

Methods inherited from Proxmox::Collection

#clear_ignored_attributes, #create, #destroy, #find_by_id, #load_response, #not_implemented, #read, #summary

Instance Method Details

#allObject


36
37
38
39
40
# File 'lib/fog/compute/proxmox/models/snapshots.rb', line 36

def all
  requires :server
  path_params = { node: server.node, type: server.type, vmid: server.vmid }
  load_response(service.list_snapshots(path_params), 'snapshots')
end

#get(name) ⇒ Object


42
43
44
45
46
47
48
49
50
51
# File 'lib/fog/compute/proxmox/models/snapshots.rb', line 42

def get(name)
  requires :server
  cached_snapshot = find { |snapshot| snapshot.name == name }
  return cached_snapshot if cached_snapshot
  path_params = { node: server.node, type: server.type, vmid: server.vmid, snapname: name }
  snapshot_hash = service.get_snapshot(path_params)
  Fog::Compute::Proxmox::Snapshot.new(
    snapshot_hash.merge(service: service, server: server, name: name)
  )
end

#new(attributes = {}) ⇒ Object


31
32
33
34
# File 'lib/fog/compute/proxmox/models/snapshots.rb', line 31

def new(attributes = {})
  requires :server
  super({ server: server }.merge!(attributes))
end