Class: RVC::SnapshotFolder
- Inherits:
-
Object
- Object
- RVC::SnapshotFolder
show all
- Includes:
- InventoryObject
- Defined in:
- lib/rvc/extensions/VirtualMachine.rb
Instance Attribute Summary
#rvc_arc, #rvc_parent
Class Method Summary
collapse
Instance Method Summary
collapse
included, #ls_text, #rvc_link, #rvc_path, #rvc_path_str, #rvc_relative_path, #rvc_relative_path_str, #traverse_one
#field, #fields
#field, #field_properties, #perfmetrics
Constructor Details
Returns a new instance of SnapshotFolder.
263
264
265
266
|
# File 'lib/rvc/extensions/VirtualMachine.rb', line 263
def initialize vm, ids
@vm = vm
@ids = ids
end
|
Class Method Details
.to_s ⇒ Object
268
269
270
|
# File 'lib/rvc/extensions/VirtualMachine.rb', line 268
def self.to_s
'Snapshot'
end
|
Instance Method Details
#children ⇒ Object
285
286
287
288
289
290
291
292
293
294
295
296
297
|
# File 'lib/rvc/extensions/VirtualMachine.rb', line 285
def children
tree = find_tree
{}.tap do |h|
tree.childSnapshotList.each do |x|
name = x.name
name = x.name + '.1' if h.member? x.name
while h.member? name
name = name.succ
end
h[name] = RVC::SnapshotFolder.new(@vm, @ids+[x.id])
end
end
end
|
#display_info ⇒ Object
299
300
301
302
303
304
305
306
|
# File 'lib/rvc/extensions/VirtualMachine.rb', line 299
def display_info
tree = find_tree
puts "id: #{tree.id}"
puts "name: #{tree.name}"
puts "description: #{tree.description}"
puts "state: #{tree.state}"
puts "creation time: #{tree.createTime}"
end
|
#find_tree ⇒ Object
272
273
274
275
276
277
278
279
280
281
282
283
|
# File 'lib/rvc/extensions/VirtualMachine.rb', line 272
def find_tree
cur = nil
info = @vm.snapshot
fail "snapshot not found" unless info
children = info.rootSnapshotList
@ids.each do |id|
cur = children.find { |x| x.id == id }
fail "snapshot not found" unless cur
children = cur.childSnapshotList
end
cur
end
|