Class: Fog::Compute::ProfitBricks::Snapshot

Inherits:
Models::ProfitBricks::Base show all
Includes:
Helpers::ProfitBricks::DataHelper
Defined in:
lib/fog/profitbricks/models/compute/snapshot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::ProfitBricks::DataHelper

#flatten

Methods inherited from Models::ProfitBricks::Base

#request_status, #wait_for

Constructor Details

#initialize(attributes = {}) ⇒ Snapshot

Returns a new instance of Snapshot.



40
41
42
# File 'lib/fog/profitbricks/models/compute/snapshot.rb', line 40

def initialize(attributes = {})
  super
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



38
39
40
# File 'lib/fog/profitbricks/models/compute/snapshot.rb', line 38

def options
  @options
end

Instance Method Details

#deleteObject



67
68
69
70
71
# File 'lib/fog/profitbricks/models/compute/snapshot.rb', line 67

def delete
  requires :id
  service.delete_snapshot(id)
  true
end

#failed?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/fog/profitbricks/models/compute/snapshot.rb', line 77

def failed?
  state == 'ERROR'
end

#ready?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/fog/profitbricks/models/compute/snapshot.rb', line 73

def ready?
  state == 'AVAILABLE'
end

#updateObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fog/profitbricks/models/compute/snapshot.rb', line 44

def update
  requires :id

  options = {}
  options[:name]                = name if name
  options[:description]         = description if description
  options[:cpuHotPlug]          = cpu_hot_plug if cpu_hot_plug
  options[:cpuHotUnplug]        = cpu_hot_unplug if cpu_hot_unplug
  options[:ramHotPlug]          = ram_hot_plug if ram_hot_plug
  options[:ramHotUnplug]        = ram_hot_unplug if ram_hot_unplug
  options[:nicHotPlug]          = nic_hot_plug if nic_hot_plug
  options[:nicHotUnplug]        = nic_hot_unplug if nic_hot_unplug
  options[:discVirtioHotPlug]   = disc_virtio_hot_plug if disc_virtio_hot_plug
  options[:discVirtioHotUnplug] = disc_virtio_hot_unplug if disc_virtio_hot_unplug
  options[:discScsiHotPlug]     = disc_scsi_hot_plug if disc_scsi_hot_plug
  options[:discScsiHotUnplug]   = disc_scsi_hot_unplug if disc_scsi_hot_unplug
  options[:licenceType]         = licence_type if licence_type

  data = service.update_snapshot(id, options)
  merge_attributes(flatten(data.body))
  true
end