Sha256: bae14bb760cfcb3aee9e3b04fe4b65553a9fe56a57c36ffe1e9fdabad88ae9c3

Contents?: true

Size: 869 Bytes

Versions: 23

Compression:

Stored size: 869 Bytes

Contents

module Fog
  module Vsphere
    class Compute
      class Real
        def folder_destroy(path, datacenter_name)
          folder = get_raw_vmfolder(path, datacenter_name)
          raise Fog::Vsphere::Errors::NotFound, "No such folder #{path}" unless folder
          raise Fog::Vsphere::Errors::ServiceError, "Folder #{path} is not empty" unless folder.childEntity.empty?

          task = folder.Destroy_Task
          task.wait_for_completion
          { 'task_state' => task.info.state }
        end
      end
      class Mock
        def folder_destroy(path, datacenter_name)
          vms = list_virtual_machines(folder: path, datacenter: datacenter_name)
          unless vms.empty?
            raise Fog::Vsphere::Errors::ServiceError, "Folder #{path} is not empty"
          end
          { 'task_state' => 'success' }
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
fog-vsphere-3.7.0 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.6.8 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.6.7 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.6.6 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.6.5 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.6.4 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.6.3 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.6.2 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.5.3 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.6.0 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.5.2 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.5.1 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.5.0 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.4.0 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.3.1 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.3.0 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.2.5 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.2.2 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.2.1 lib/fog/vsphere/requests/compute/folder_destroy.rb
fog-vsphere-3.2.0 lib/fog/vsphere/requests/compute/folder_destroy.rb