Class: MMS::Resource::Snapshot
Instance Attribute Summary collapse
#client, #data, #id
Class Method Summary
collapse
-
._find(client, group_id, cluster_id, host_id, id) ⇒ MMS::Resource::Snapshot
-
._find_by_cluster(client, group_id, cluster_id, id) ⇒ Object
-
._find_by_host(client, group_id, host_id, id) ⇒ Object
-
.table_header ⇒ Object
Instance Method Summary
collapse
#_load, find, #from_hash, #invalidate_cache, #set_client, #set_data, #to_hash
Instance Attribute Details
#complete ⇒ Object
Returns the value of attribute complete.
9
10
11
|
# File 'lib/mms/resource/snapshot.rb', line 9
def complete
@complete
end
|
#created_date ⇒ Object
Returns the value of attribute created_date.
10
11
12
|
# File 'lib/mms/resource/snapshot.rb', line 10
def created_date
@created_date
end
|
#created_increment ⇒ Object
Returns the value of attribute created_increment.
11
12
13
|
# File 'lib/mms/resource/snapshot.rb', line 11
def created_increment
@created_increment
end
|
#expires ⇒ Object
Returns the value of attribute expires.
12
13
14
|
# File 'lib/mms/resource/snapshot.rb', line 12
def expires
@expires
end
|
#is_possibly_inconsistent ⇒ Object
Returns the value of attribute is_possibly_inconsistent.
14
15
16
|
# File 'lib/mms/resource/snapshot.rb', line 14
def is_possibly_inconsistent
@is_possibly_inconsistent
end
|
#name ⇒ Object
Returns the value of attribute name.
7
8
9
|
# File 'lib/mms/resource/snapshot.rb', line 7
def name
@name
end
|
#parts ⇒ Object
Returns the value of attribute parts.
13
14
15
|
# File 'lib/mms/resource/snapshot.rb', line 13
def parts
@parts
end
|
Class Method Details
._find(client, group_id, cluster_id, host_id, id) ⇒ MMS::Resource::Snapshot
104
105
106
|
# File 'lib/mms/resource/snapshot.rb', line 104
def self._find(client, group_id, cluster_id, host_id, id)
host_id.nil? ? self._find_by_cluster(client, group_id, cluster_id, id) : self._find_by_host(client, group_id, host_id, id)
end
|
._find_by_cluster(client, group_id, cluster_id, id) ⇒ Object
108
109
110
|
# File 'lib/mms/resource/snapshot.rb', line 108
def self._find_by_cluster(client, group_id, cluster_id, id)
client.get('/groups/' + group_id + '/clusters/' + cluster_id + '/snapshots/' + id.to_s)
end
|
._find_by_host(client, group_id, host_id, id) ⇒ Object
112
113
114
|
# File 'lib/mms/resource/snapshot.rb', line 112
def self._find_by_host(client, group_id, host_id, id)
client.get('/groups/' + group_id + '/hosts/' + host_id + '/snapshots/' + id.to_s)
end
|
95
96
97
|
# File 'lib/mms/resource/snapshot.rb', line 95
def self.
['Group', 'Cluster', 'SnapshotId', 'Complete', 'Created increment', 'Name (created date)', 'Expires', 'Inconsistent']
end
|
Instance Method Details
56
57
58
|
# File 'lib/mms/resource/snapshot.rb', line 56
def cluster
MMS::Resource::Cluster.find(@client, @data['groupId'], @data['clusterId'])
end
|
#cluster_name ⇒ String, NilClass
32
33
34
|
# File 'lib/mms/resource/snapshot.rb', line 32
def cluster_name
cluster.name if is_cluster
end
|
#config_name ⇒ String, NilClass
37
38
39
|
# File 'lib/mms/resource/snapshot.rb', line 37
def config_name
'config' if is_config
end
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/mms/resource/snapshot.rb', line 61
def create_restorejob
data = {:snapshotId => @id}
job_data_list = @client.post '/groups/' + cluster.group.id + '/clusters/' + cluster.id + '/restoreJobs', data
if job_data_list.nil?
raise MMS::ResourceError.new("Cannot create job from snapshot `#{self.id}`", self)
end
job_data_list.map do |job_data|
j = MMS::Resource::RestoreJob.new
j.set_client(@client)
j.set_data(job_data)
j
end
end
|
#is_cluster ⇒ TrueClass, FalseClass
17
18
19
|
# File 'lib/mms/resource/snapshot.rb', line 17
def is_cluster
@parts.length > 1
end
|
#is_config ⇒ TrueClass, FalseClass
22
23
24
|
# File 'lib/mms/resource/snapshot.rb', line 22
def is_config
@parts.length == 1 and @parts.first['typeName'] == 'REPLICA_SET' and !@parts.first['hostId'].nil?
end
|
#is_replica ⇒ TrueClass, FalseClass
27
28
29
|
# File 'lib/mms/resource/snapshot.rb', line 27
def is_replica
@parts.length == 1 and @parts.first['typeName'] == 'REPLICA_SET' and !@parts.first['clusterId'].nil?
end
|
#replica_name ⇒ String, NilClass
42
43
44
|
# File 'lib/mms/resource/snapshot.rb', line 42
def replica_name
@parts.first['replicaSetName'] if is_replica
end
|
#source_name ⇒ String, NilClass
47
48
49
50
51
52
53
|
# File 'lib/mms/resource/snapshot.rb', line 47
def source_name
name = nil
name = replica_name if is_replica
name = config_name if is_config
name = cluster_name if is_cluster
name
end
|
#table_row ⇒ Object
77
78
79
|
# File 'lib/mms/resource/snapshot.rb', line 77
def table_row
[cluster.group.name, cluster.name, @id, @complete, @created_increment, @name, @expires, @is_possibly_inconsistent]
end
|
#table_section ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/mms/resource/snapshot.rb', line 81
def table_section
rows = []
rows << table_row
rows << :separator
part_count = 0
@parts.each do |part|
file_size_mb = part['fileSizeBytes'].to_i / (1024*1024)
rows << [{:value => "part #{part_count}", :colspan => 4, :alignment => :right}, part['typeName'], part['replicaSetName'], "#{file_size_mb} MB"]
part_count += 1
end
rows << :separator
rows
end
|