Class: RbVmomi::VIM::Datastore::FakeDatastoreFolder
- Inherits:
-
Object
- Object
- RbVmomi::VIM::Datastore::FakeDatastoreFolder
show all
- Includes:
- RVC::InventoryObject
- Defined in:
- lib/rvc/extensions/Datastore.rb
Instance Attribute Summary collapse
#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
#field, #fields
#field, #field_properties, #perfmetrics
Constructor Details
Returns a new instance of FakeDatastoreFolder.
71
72
73
74
|
# File 'lib/rvc/extensions/Datastore.rb', line 71
def initialize datastore, path
@datastore = datastore
@path = path
end
|
Instance Attribute Details
#datastore ⇒ Object
Returns the value of attribute datastore.
69
70
71
|
# File 'lib/rvc/extensions/Datastore.rb', line 69
def datastore
@datastore
end
|
#path ⇒ Object
Returns the value of attribute path.
69
70
71
|
# File 'lib/rvc/extensions/Datastore.rb', line 69
def path
@path
end
|
Class Method Details
.folder? ⇒ Boolean
124
125
126
|
# File 'lib/rvc/extensions/Datastore.rb', line 124
def self.folder?
true
end
|
Instance Method Details
#children ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/rvc/extensions/Datastore.rb', line 90
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
76
77
78
79
|
# File 'lib/rvc/extensions/Datastore.rb', line 76
def datastore_path
@ds_name ||= @datastore.name
"[#{@ds_name}] #{@path}"
end
|
#display_info ⇒ Object
138
139
140
141
142
|
# File 'lib/rvc/extensions/Datastore.rb', line 138
def display_info
puts "Datastore Folder"
puts "datastore: #{@datastore.name}"
puts "path: #{@path}"
end
|
#eql?(x) ⇒ Boolean
144
145
146
147
|
# File 'lib/rvc/extensions/Datastore.rb', line 144
def eql? x
@datastore == x.instance_variable_get(:@datastore) &&
@path == x.instance_variable_get(:@path)
end
|
#hash ⇒ Object
149
150
151
|
# File 'lib/rvc/extensions/Datastore.rb', line 149
def hash
@datastore.hash ^ @path.hash
end
|
#parent ⇒ Object
128
129
130
131
132
133
134
135
136
|
# File 'lib/rvc/extensions/Datastore.rb', line 128
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
81
82
83
84
85
86
87
88
|
# File 'lib/rvc/extensions/Datastore.rb', line 81
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/rvc/extensions/Datastore.rb', line 106
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
|