Class: Registration::MigrationRepositories

Inherits:
Object
  • Object
show all
Includes:
Yast::Logger
Defined in:
src/lib/registration/migration_repositories.rb

Overview

this class activates the migration services and repositories

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMigrationRepositories


37
38
39
40
41
42
# File 'src/lib/registration/migration_repositories.rb', line 37

def initialize
  @repositories = []
  @services = []
  # install updates by default
  @install_updates = true
end

Instance Attribute Details

#install_updatesObject

Returns the value of attribute install_updates


35
36
37
# File 'src/lib/registration/migration_repositories.rb', line 35

def install_updates
  @install_updates
end

#repositoriesObject

Returns the value of attribute repositories


35
36
37
# File 'src/lib/registration/migration_repositories.rb', line 35

def repositories
  @repositories
end

#servicesObject

Returns the value of attribute services


35
36
37
# File 'src/lib/registration/migration_repositories.rb', line 35

def services
  @services
end

Class Method Details

.resetObject

reset the libzypp migration setup


27
28
29
30
31
32
33
# File 'src/lib/registration/migration_repositories.rb', line 27

def self.reset
  # reset the solver
  Yast::Pkg.SetSolverFlags("reset" => true)

  # deselect all pre-selected packages or patches
  Yast::Pkg.PkgReset
end

Instance Method Details

#activate_repositoriesObject

configure libzypp repositories to allow online migration (used for activating the user changes)


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'src/lib/registration/migration_repositories.rb', line 66

def activate_repositories
  all_repos = Yast::Pkg.SourceGetCurrent(false)

  all_repos.each do |repo|
    repo_data = Yast::Pkg.SourceGeneralData(repo)

    # enabled migration repositories, disable the others, change
    # the status if it is different than expected
    next if repositories.include?(repo) == repo_data["enabled"]

    # switch the repository state
    new_state = !repo_data["enabled"]
    log.info "#{new_state ? "Enabling" : "Disabling"} repository #{repo_data["alias"]}"
    Yast::Pkg.SourceSetEnabled(repo, new_state)
  end

  activate_solver
end

#activate_servicesObject

configure libzypp services to allow online migration (used for activating the default migration setup from the registration server)


53
54
55
56
57
58
59
60
61
62
# File 'src/lib/registration/migration_repositories.rb', line 53

def activate_services
  # disable the update repositories if not required
  if !install_updates
    # note: the module update repositories are kept enabled
    # see https://bugzilla.suse.com/show_bug.cgi?id=953536
    SwMgmt.set_repos_state(services_repositories(only_updates: true), false)
  end

  activate_solver
end

#service_with_update_repo?Boolean

does any configured service contain an update repo?


47
48
49
# File 'src/lib/registration/migration_repositories.rb', line 47

def service_with_update_repo?
  services_repositories.any? { |repo| repo["is_update_repo"] }
end