Class: HP::Cloud::SnapshotHelper
- Inherits:
-
BaseHelper
- Object
- BaseHelper
- HP::Cloud::SnapshotHelper
- Defined in:
- lib/hpcloud/snapshot_helper.rb
Constant Summary collapse
- @@volumous =
nil
Instance Attribute Summary collapse
-
#created ⇒ Object
Returns the value of attribute created.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#size ⇒ Object
Returns the value of attribute size.
-
#status ⇒ Object
Returns the value of attribute status.
-
#volume ⇒ Object
Returns the value of attribute volume.
Attributes inherited from BaseHelper
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(connection, foggy = nil) ⇒ SnapshotHelper
constructor
A new instance of SnapshotHelper.
- #save ⇒ Object
- #set_volume(volume_name_id) ⇒ Object
Methods inherited from BaseHelper
#destroy, #is_valid?, #set_error, #to_hash
Constructor Details
#initialize(connection, foggy = nil) ⇒ SnapshotHelper
Returns a new instance of SnapshotHelper.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/hpcloud/snapshot_helper.rb', line 32 def initialize(connection, foggy = nil) super(connection, foggy) return if foggy.nil? @id = foggy.id @name = foggy.name set_volume(foggy.volume_id) @size = foggy.size @created = foggy.created_at @status = foggy.status @description = foggy.description end |
Instance Attribute Details
#created ⇒ Object
Returns the value of attribute created.
26 27 28 |
# File 'lib/hpcloud/snapshot_helper.rb', line 26 def created @created end |
#description ⇒ Object
Returns the value of attribute description.
26 27 28 |
# File 'lib/hpcloud/snapshot_helper.rb', line 26 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
26 27 28 |
# File 'lib/hpcloud/snapshot_helper.rb', line 26 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
26 27 28 |
# File 'lib/hpcloud/snapshot_helper.rb', line 26 def name @name end |
#size ⇒ Object
Returns the value of attribute size.
26 27 28 |
# File 'lib/hpcloud/snapshot_helper.rb', line 26 def size @size end |
#status ⇒ Object
Returns the value of attribute status.
26 27 28 |
# File 'lib/hpcloud/snapshot_helper.rb', line 26 def status @status end |
#volume ⇒ Object
Returns the value of attribute volume.
26 27 28 |
# File 'lib/hpcloud/snapshot_helper.rb', line 26 def volume @volume end |
Class Method Details
.clear_cache ⇒ Object
73 74 75 |
# File 'lib/hpcloud/snapshot_helper.rb', line 73 def self.clear_cache @@volumous = nil end |
.get_keys ⇒ Object
28 29 30 |
# File 'lib/hpcloud/snapshot_helper.rb', line 28 def self.get_keys() return [ "id", "name", "volume", "size", "created", "status", "description" ] end |
Instance Method Details
#save ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/hpcloud/snapshot_helper.rb', line 54 def save return false if is_valid? == false if @fog.nil? hsh = {:name => @name, :volume_id => @volume_obj.id, :description => @description} snapshot = @connection.block.snapshots.create(hsh) if snapshot.nil? set_error("Error creating snapshot '#{@name}'") return false end @id = snapshot.id @fog = snapshot return true else raise "Update not implemented" end end |
#set_volume(volume_name_id) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/hpcloud/snapshot_helper.rb', line 44 def set_volume(volume_name_id) @@volumous = Volumes.new if @@volumous.nil? @volume_obj = @@volumous.get(volume_name_id.to_s) if @volume_obj.is_valid? == false return false end @volume = @volume_obj.name return true end |