Sha256: 0c5b5e55518f1f013f0e54fc3442585ec159d02dc1f216eef0663f8d0428c2f4
Contents?: true
Size: 1.79 KB
Versions: 19
Compression:
Stored size: 1.79 KB
Contents
module Fog module Compute class Vsphere class Real # Grabs all sub folders within a given path folder. # # ==== Parameters # * filters<~Hash>: # * :datacenter<~String> - *REQUIRED* Your datacenter where you're # looking for folders. Example: 'my-datacenter-name' (passed if you # are using the models/collections) # eg: vspconn.datacenters.first.vm_folders('mypath') # * :path<~String> - Your path where you're looking for # more folders, if return = none you will get an error. If you don't # define it will look in the main datacenter folder for any folders # in that datacenter. # # Example Usage Testing Only: # vspconn = Fog::Compute[:vsphere] # mydc = vspconn.datacenters.first # folders = mydc.vm_folders # def list_folders(filters = { }) path = filters[:path] || filters['path'] || '' datacenter_name = filters[:datacenter] get_raw_vmfolders(path, datacenter_name).map do |folder| folder_attributes(folder, datacenter_name) end end protected def get_raw_vmfolders(path, datacenter_name) folder = get_raw_vmfolder(path, datacenter_name) child_folders(folder).flatten.compact end def child_folders folder [folder, folder.childEntity.grep(RbVmomi::VIM::Folder).map(&method(:child_folders)).flatten] end end class Mock def list_folders(options = {}) options.reject! {|k,v| v.nil? } # ignore options with nil value self.data[:folders].values.select {|folder| options.all? {|k,v| folder[k.to_s] == v.to_s }} end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems