Class: Actions::Katello::ContentViewPuppetEnvironment::Clone

Inherits:
Base
  • Object
show all
Defined in:
app/lib/actions/katello/content_view_puppet_environment/clone.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#new_puppet_environmentObject

Returns the value of attribute new_puppet_environment.



5
6
7
# File 'app/lib/actions/katello/content_view_puppet_environment/clone.rb', line 5

def new_puppet_environment
  @new_puppet_environment
end

Instance Method Details

#plan(from_version, options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/lib/actions/katello/content_view_puppet_environment/clone.rb', line 7

def plan(from_version, options)
  environment = options.fetch(:environment, nil)
  new_version = options.fetch(:new_version, nil)
  puppet_modules_present = options.fetch(:puppet_modules_present, true)
  source = from_version.content_view_puppet_environments.archived.first

  #don't create a cvpe if no puppet modules are present, but reuse it if it is present
  if environment
    clone = find_or_build_puppet_env(from_version, environment, puppet_modules_present)
    return if clone.new_record? && !puppet_modules_present #CVPE is not needed
  else
    clone = find_or_build_puppet_archive(new_version)
  end

  sequence do
    if clone.puppet_environment.nil? && !puppet_modules_present
      plan_action(ContentViewPuppetEnvironment::Destroy, clone)
    else
      clone = setup_puppet_environment_clone(from_version, clone)

      self.new_puppet_environment = clone
      plan_action(Pulp::Repository::CopyPuppetModule,
                  source_pulp_id: source.pulp_id,
                  target_pulp_id: clone.pulp_id,
                  criteria: nil)

      concurrence do
        plan_action(Katello::Repository::MetadataGenerate, clone) if environment
        plan_action(Pulp::ContentViewPuppetEnvironment::IndexContent, id: clone.id)
      end
    end
  end
end