Sha256: 618342bc0f8e89725d91b43e44a38f797cbdc9266b7a0b60a14b705f19fdf854

Contents?: true

Size: 1.54 KB

Versions: 70

Compression:

Stored size: 1.54 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
    end
  end
end

Version data entries

70 entries across 70 versions & 9 rubygems

Version Path
fog-1.22.0 lib/fog/vsphere/requests/compute/list_folders.rb
fog-1.21.0 lib/fog/vsphere/requests/compute/list_folders.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/vsphere/requests/compute/list_folders.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/vsphere/requests/compute/list_folders.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/vsphere/requests/compute/list_folders.rb
fog-1.20.0 lib/fog/vsphere/requests/compute/list_folders.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/vsphere/requests/compute/list_folders.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/vsphere/requests/compute/list_folders.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/vsphere/requests/compute/list_folders.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/vsphere/requests/compute/list_folders.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/vsphere/requests/compute/list_folders.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/vsphere/requests/compute/list_folders.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/vsphere/requests/compute/list_folders.rb
fog-1.19.0 lib/fog/vsphere/requests/compute/list_folders.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/vsphere/requests/compute/list_folders.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/vsphere/requests/compute/list_folders.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/vsphere/requests/compute/list_folders.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/vsphere/requests/compute/list_folders.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/vsphere/requests/compute/list_folders.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/vsphere/requests/compute/list_folders.rb