Sha256: af40cb30a428a1da30baef0118eb0d9e82961218227d4283034e7f57877283aa

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

module Fog
  module Compute
    class Vsphere
      class Real
        def vm_take_snapshot(options = {})
          raise ArgumentError, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
          raise ArgumentError, "name is a required parameter" unless options.key? 'name'
          vm = get_vm_ref(options['instance_uuid'])
          task = vm.CreateSnapshot_Task(
            name: options['name'],
            description: options['description'] || '',
            memory: options['memory'] || true,
            quiesce: options['quiesce'] || false
          )

          task.wait_for_completion

          {
            'task_state' => task.info.state,
            'was_cancelled' => task.info.cancelled
          }
        end
      end

      class Mock
        def vm_take_snapshot(options = {})
          raise ArgumentError, "instance_uuid is a required parameter" unless options.key? 'instance_uuid'
          raise ArgumentError, "name is a required parameter" unless options.key? 'name'
          {
            'task_state' => 'success',
            'was_cancelled' => false
          }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-1.36.0 lib/fog/vsphere/requests/compute/vm_take_snapshot.rb