Class: RbVmomi::VIM::Datastore::FakeDatastoreFolder
- Inherits:
-
Object
- Object
- RbVmomi::VIM::Datastore::FakeDatastoreFolder
- Includes:
- RVC::InventoryObject
- Defined in:
- lib/rvc/extensions/Datastore.rb
Instance Attribute Summary collapse
-
#datastore ⇒ Object
readonly
Returns the value of attribute datastore.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #children ⇒ Object
- #datastore_path ⇒ Object
- #display_info ⇒ Object
- #eql?(x) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(datastore, path) ⇒ FakeDatastoreFolder
constructor
A new instance of FakeDatastoreFolder.
- #parent ⇒ Object
- #search_result_to_object(x) ⇒ Object
- #traverse_one(arc) ⇒ Object
Methods included from RVC::InventoryObject
Constructor Details
#initialize(datastore, path) ⇒ FakeDatastoreFolder
Returns a new instance of FakeDatastoreFolder.
66 67 68 69 |
# File 'lib/rvc/extensions/Datastore.rb', line 66 def initialize datastore, path @datastore = datastore @path = path end |
Instance Attribute Details
#datastore ⇒ Object (readonly)
Returns the value of attribute datastore.
64 65 66 |
# File 'lib/rvc/extensions/Datastore.rb', line 64 def datastore @datastore end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
64 65 66 |
# File 'lib/rvc/extensions/Datastore.rb', line 64 def path @path end |
Class Method Details
.folder? ⇒ Boolean
119 120 121 |
# File 'lib/rvc/extensions/Datastore.rb', line 119 def self.folder? true end |
Instance Method Details
#children ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/rvc/extensions/Datastore.rb', line 85 def children results = @datastore.browser.SearchDatastore_Task( :datastorePath => datastore_path, :searchSpec => { :details => { :fileType => true, :fileSize => true, :fileOwner => false, :modification => false } } ).wait_for_completion Hash[results.file.map { |x| [x.path, search_result_to_object(x)] }] end |
#datastore_path ⇒ Object
71 72 73 74 |
# File 'lib/rvc/extensions/Datastore.rb', line 71 def datastore_path @ds_name ||= @datastore.name "[#{@ds_name}] #{@path}" end |
#display_info ⇒ Object
133 134 135 136 137 |
# File 'lib/rvc/extensions/Datastore.rb', line 133 def display_info puts "Datastore Folder" puts "datastore: #{@datastore.name}" puts "path: #{@path}" end |
#eql?(x) ⇒ Boolean
139 140 141 142 |
# File 'lib/rvc/extensions/Datastore.rb', line 139 def eql? x @datastore == x.instance_variable_get(:@datastore) && @path == x.instance_variable_get(:@path) end |
#hash ⇒ Object
144 145 146 |
# File 'lib/rvc/extensions/Datastore.rb', line 144 def hash @datastore.hash ^ @path.hash end |
#parent ⇒ Object
123 124 125 126 127 128 129 130 131 |
# File 'lib/rvc/extensions/Datastore.rb', line 123 def parent els = path.split '/' if els.empty? @datastore else parent_path = els[0...-1].join '/' RbVmomi::VIM::Datastore::FakeDatastoreFolder.new(@datastore, parent_path) end end |
#search_result_to_object(x) ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/rvc/extensions/Datastore.rb', line 76 def search_result_to_object x case x when RbVmomi::VIM::FolderFileInfo RbVmomi::VIM::Datastore::FakeDatastoreFolder.new(@datastore, "#{@path}/#{x.path}") when RbVmomi::VIM::FileInfo RbVmomi::VIM::Datastore::FakeDatastoreFile.new(@datastore, "#{@path}/#{x.path}", x) end end |
#traverse_one(arc) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/rvc/extensions/Datastore.rb', line 101 def traverse_one arc browser, ds_name = @datastore.collect :browser, :name results = browser.SearchDatastore_Task( :datastorePath => "[#{ds_name}] #{@path}", :searchSpec => { :details => { :fileType => true, :fileSize => true, :fileOwner => false, :modification => false }, :matchPattern => [arc] } ).wait_for_completion return unless results.file.size == 1 search_result_to_object results.file[0] end |