Class: MMS::Resource::Snapshot
- Inherits:
-
MMS::Resource
- Object
- MMS::Resource
- MMS::Resource::Snapshot
- Defined in:
- lib/mms/resource/snapshot.rb
Instance Attribute Summary collapse
-
#cluster ⇒ Object
Returns the value of attribute cluster.
-
#complete ⇒ Object
Returns the value of attribute complete.
-
#created_date ⇒ Object
Returns the value of attribute created_date.
-
#created_increment ⇒ Object
Returns the value of attribute created_increment.
-
#expires ⇒ Object
Returns the value of attribute expires.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parts ⇒ Object
Returns the value of attribute parts.
Attributes inherited from MMS::Resource
Instance Method Summary collapse
- #_from_hash(data) ⇒ Object
- #_load(id) ⇒ Object
- #create_restorejob ⇒ Object
-
#initialize(id, cluster_id, group_id, data = nil) ⇒ Snapshot
constructor
A new instance of Snapshot.
Methods inherited from MMS::Resource
Constructor Details
#initialize(id, cluster_id, group_id, data = nil) ⇒ Snapshot
Returns a new instance of Snapshot.
14 15 16 17 18 |
# File 'lib/mms/resource/snapshot.rb', line 14 def initialize(id, cluster_id, group_id, data = nil) @cluster = MMS::Resource::Cluster.new cluster_id, group_id super id, data end |
Instance Attribute Details
#cluster ⇒ Object
Returns the value of attribute cluster.
6 7 8 |
# File 'lib/mms/resource/snapshot.rb', line 6 def cluster @cluster end |
#complete ⇒ Object
Returns the value of attribute complete.
8 9 10 |
# File 'lib/mms/resource/snapshot.rb', line 8 def complete @complete end |
#created_date ⇒ Object
Returns the value of attribute created_date.
9 10 11 |
# File 'lib/mms/resource/snapshot.rb', line 9 def created_date @created_date end |
#created_increment ⇒ Object
Returns the value of attribute created_increment.
10 11 12 |
# File 'lib/mms/resource/snapshot.rb', line 10 def created_increment @created_increment end |
#expires ⇒ Object
Returns the value of attribute expires.
11 12 13 |
# File 'lib/mms/resource/snapshot.rb', line 11 def expires @expires end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/mms/resource/snapshot.rb', line 5 def name @name end |
#parts ⇒ Object
Returns the value of attribute parts.
12 13 14 |
# File 'lib/mms/resource/snapshot.rb', line 12 def parts @parts end |
Instance Method Details
#_from_hash(data) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/mms/resource/snapshot.rb', line 49 def _from_hash(data) @complete = data['complete'] @created_date = data['created']['date'] @created_increment = data['created']['increment'] @expires = data['expires'] @parts = data['parts'] @name = @created_date end |
#_load(id) ⇒ Object
20 21 22 |
# File 'lib/mms/resource/snapshot.rb', line 20 def _load(id) MMS::Client.instance.get '/groups/' + @cluster.group.id + '/clusters/' + @cluster.id + '/snapshots/' + id.to_s end |
#create_restorejob ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mms/resource/snapshot.rb', line 24 def create_restorejob data = {:snapshotId => @id} jobs = MMS::Client.instance.post '/groups/' + @cluster.group.id + '/clusters/' + @cluster.id + '/restoreJobs', data if jobs.nil? raise "Cannot create job from snapshot `#{self.id}`" end job_list = [] # work around due to bug in MMS API; cannot read restoreJob using provided info. restore_jobs = @cluster.restorejobs jobs.each do |job| _list = restore_jobs.select {|restorejob| restorejob.id == job['id'] } _list.each do |restorejob| begin job_list.push MMS::Resource::RestoreJob.new(restorejob.id, restorejob.cluster.id, restorejob.cluster.group.id) rescue => e puts "load error #{e.message}" end end end job_list end |