Class: HammerCLIKatello::ContentViewPurgeCommand

Inherits:
Command
  • Object
show all
Includes:
HammerCLIForemanTasks::Async, ApipieHelper, OrganizationOptions
Defined in:
lib/hammer_cli_katello/content_view_purge.rb

Defined Under Namespace

Classes: ContentViewIdParamSource

Instance Method Summary collapse

Methods included from OrganizationOptions

included, #org_options

Methods included from ApipieHelper

#call, #destroy, #index, #show, #update

Methods included from ResolverCommons

included

Instance Method Details

#executeObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/hammer_cli_katello/content_view_purge.rb', line 53

def execute
  options['option_versions_to_keep'] = option_versions_to_keep
  if option_versions_to_keep.negative?
    output.print_error _("Invalid value for --versions-to-keep: value must be 0 or greater.")
    return HammerCLI::EX_USAGE
  end

  # Check if there is something to do
  if option_count
    warn _("The --count option is deprecated and will be removed in the next release.")
    options['option_versions_to_keep'] = option_count
  end
  if options['option_versions_to_keep'] >= old_unused_versions.size
    output.print_error _("No versions to delete.")
    HammerCLI::EX_NOT_FOUND
  else
    versions_to_purge = old_unused_versions.slice(0, old_unused_versions.size -
      options['option_versions_to_keep'])

    versions_to_purge.each do |v|
      purge_version(v)
    end
    HammerCLI::EX_OK
  end
end

#option_sourcesObject



43
44
45
46
47
48
49
50
51
# File 'lib/hammer_cli_katello/content_view_purge.rb', line 43

def option_sources
  sources = super
  sources.find_by_name('IdResolution').insert_relative(
    :after,
    'IdParams',
    ContentViewIdParamSource.new(self)
  )
  sources
end