Sha256: 33b6c709ec7ed00f99bb135722560dba3b79981d30eb4fb7edb6ee7efddd51a0

Contents?: true

Size: 1013 Bytes

Versions: 30

Compression:

Stored size: 1013 Bytes

Contents

module Fog
  module Compute
    class Vsphere
      class Real
        def create_folder(datacenter, path, name)
          #Path cannot be nil but it can be an empty string
          raise ArgumentError, "Path cannot be nil" if path.nil?

          parent_folder = get_raw_vmfolder(path, datacenter)
          begin
            new_folder = parent_folder.CreateFolder(:name => name)
            # output is cleaned up to return the new path
            # new path will be path/name, example: "Production/Pool1"
            new_folder.path.reject { |a| a.first.class == "Folder" }.map { |a| a.first.name }.join("/").sub(/^\/?Datacenters\/#{datacenter}\/vm\/?/, '')
          end
        end
      end
      class Mock
        def create_folder(datacenter, path, name)
          self.data[:folders][name] = {
            'name'       => name,
            'datacenter' => datacenter,
            'path'       => "#{path}/#{name}",
            'type'       => 'vm'
          }
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
fog-vsphere-1.7.0.1 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-2.1.1 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-2.1.0 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-2.0.1 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-2.0.0 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-1.13.1 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-1.13.0 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-1.12.0 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-1.11.3 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-1.11.2 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-1.11.1 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-1.11.0 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-1.10.0 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-1.9.2 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-1.9.1 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-1.9.0 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-1.8.0 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-1.7.1 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-1.7.0 lib/fog/vsphere/requests/compute/create_folder.rb
fog-vsphere-1.6.0 lib/fog/vsphere/requests/compute/create_folder.rb