Class: Profitbricks::Snapshot
- Defined in:
- lib/profitbricks/snapshot.rb
Class Method Summary collapse
-
.all ⇒ Array <Snapshot>
Provides a list of all snapshots available to this account.
-
.create(options = {}) ⇒ Boolean
Creates a snapshot of an existing storage device.
-
.find(options = {}) ⇒ Snapshot
Returns information about a particular Snapshot.
Instance Method Summary collapse
-
#delete ⇒ Boolean
Deletes a snapshot.
-
#initialize(hash, parent = nil) ⇒ Snapshot
constructor
A new instance of Snapshot.
-
#rollback(options = {}) ⇒ Boolean
Using the rollback option you may redeploy the snapshotted state on a storage.
-
#update(options = {}) ⇒ Boolean
Updates meta data of a snapshot.
Methods inherited from Model
#attributes, belongs_to, has_many, #reload
Constructor Details
#initialize(hash, parent = nil) ⇒ Snapshot
Returns a new instance of Snapshot.
4 5 6 |
# File 'lib/profitbricks/snapshot.rb', line 4 def initialize(hash, parent=nil) super(hash) end |
Class Method Details
.all ⇒ Array <Snapshot>
Provides a list of all snapshots available to this account
51 52 53 54 55 56 |
# File 'lib/profitbricks/snapshot.rb', line 51 def all resp = Profitbricks.request :get_all_snapshots [resp].flatten.compact.collect do |snapshot| PB::Snapshot.new(snapshot) end end |
.create(options = {}) ⇒ Boolean
Creates a snapshot of an existing storage device.
The size of the snapshot will be the same as the size of the storage it was taken from independent of how much of it is in use. Any snapshot will be charged to your account and billed like an HD storage of the same size.
67 68 69 70 71 |
# File 'lib/profitbricks/snapshot.rb', line 67 def create( = {}) [:snapshot_name] = .delete :name if [:name] response = Profitbricks.request :create_snapshot, true end |
.find(options = {}) ⇒ Snapshot
Returns information about a particular Snapshot
79 80 81 82 83 84 85 86 |
# File 'lib/profitbricks/snapshot.rb', line 79 def find( = {}) if [:name] return PB::Snapshot.all().select { |s| s.name == [:name] }.first end raise "Unable to locate the Snapshot named '#{[:name]}'" unless [:id] response = Profitbricks.request :get_snapshot, snapshot_id: [:id] PB::Snapshot.new(response) end |
Instance Method Details
#delete ⇒ Boolean
Deletes a snapshot. Please be aware that deleted snapshots and related data in this snapshot cannot be recovered anymore.
30 31 32 33 |
# File 'lib/profitbricks/snapshot.rb', line 30 def delete response = Profitbricks.request :delete_snapshot, snapshot_id: self.id return true end |
#rollback(options = {}) ⇒ Boolean
Using the rollback option you may redeploy the snapshotted state on a storage.
Attention: The current state of the storage will be lost unless you create another snapshot before rolling back.
42 43 44 45 |
# File 'lib/profitbricks/snapshot.rb', line 42 def rollback( = {}) response = Profitbricks.request :rollback_snapshot, .merge(:snapshot_id => self.id) return true end |
#update(options = {}) ⇒ Boolean
Updates meta data of a snapshot. This meta data can be relevant as they trigger other features like Live Vertical Scaling of CPU or RAM.
20 21 22 23 24 25 |
# File 'lib/profitbricks/snapshot.rb', line 20 def update( = {}) update_attributes_from_hash [:snapshot_name] = .delete :name if [:name] response = Profitbricks.request :update_snapshot, .merge(:snapshot_id => self.id) return true end |