Sha256: 4f9882b7340f10bf5bbe5e3b3c0241d500c9361b419425c03707aec959e8c1e8

Contents?: true

Size: 1.54 KB

Versions: 3

Compression:

Stored size: 1.54 KB

Contents

module FogExtensions
  module Vsphere
    module Snapshots
      module Real
        # Extends fog-vsphere gem for a remove Snapshot method.
        def remove_snapshot(options = {})
          raise ArgumentError, 'snapshot is a required parameter' unless options.key? 'snapshot'
          raise ArgumentError, 'removeChildren is a required parameter' unless options.key? 'removeChildren'

          raise ArgumentError, 'snapshot is a required parameter' unless ::Fog::Compute::Vsphere::Snapshot === options['snapshot']

          task = options['snapshot'].mo_ref.RemoveSnapshot_Task(
            removeChildren: options['removeChildren']
          )
          task.wait_for_completion

          {
            'task_state' => task.info.state
          }
        end

        # Extends fog-vsphere gem for a rename Snapshot method.
        # Does not have a return value, VMWare API throws a fault if there are errors
        def rename_snapshot(options = {})
          raise ArgumentError, 'snapshot is a required parameter' unless options.key? 'snapshot'
          raise ArgumentError, 'name is a required parameter' unless options.key? 'name'
          raise ArgumentError, 'description is a required parameter' unless options.key? 'description'

          raise ArgumentError, 'snapshot is a required parameter' unless ::Fog::Compute::Vsphere::Snapshot === options['snapshot']

          options['snapshot'].mo_ref.RenameSnapshot(
            name: options['name'],
            description: options['description']
          )
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_snapshot_management-1.5.1 app/models/concerns/fog_extensions/vsphere/snapshots/real.rb
foreman_snapshot_management-1.5.0 app/models/concerns/fog_extensions/vsphere/snapshots/real.rb
foreman_snapshot_management-1.4.0 app/models/concerns/fog_extensions/vsphere/snapshots/real.rb