Skip to content

Commit

Permalink
added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Jun 2, 2014
1 parent cbe66f0 commit 041dcbc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/lib/registration/sw_mgmt.rb
Expand Up @@ -44,7 +44,8 @@ class SwMgmt
textdomain "registration"

ZYPP_DIR = "/etc/zypp"
BACKUP_FILE = "/var/adm/backup/upgrade/sw_mgmt.tar.gz"

# directories to backup and remove at upgrade
BACKUP_DIRS = [ "/etc/zypp/repos.d", "/etc/zypp/services.d",
"/etc/zypp/credentials.d" ]

Expand Down Expand Up @@ -79,6 +80,9 @@ def self.zypp_config_writable!
`mount -o bind #{tmpdir}/zypp #{ZYPP_DIR}`
end

# backup SW management configuration to
# /var/adm/backup/upgrade/sw_mgmt-<time_stamp>.tar.gz file
# @param root_dir [String] mount point of the target system
def self.backup(root_dir)
time_stamp = Time.now.localtime.strftime("%Y%m%d-%H%M%S")
target_file = File.join(root_dir, "/var/adm/backup/upgrade/sw_mgmt-#{time_stamp}.tar.gz")
Expand All @@ -94,6 +98,7 @@ def self.backup(root_dir)
log.info "Backup file #{target_file} size: #{File.stat(target_file).size}"
end

# @param root_dir [String] mount point of the target system
def self.remove_old_repositories!(root_dir)
BACKUP_DIRS.each do |dir|
remove = File.join(root_dir, dir, "*")
Expand All @@ -102,6 +107,8 @@ def self.remove_old_repositories!(root_dir)
end
end

# prepare the target system for upgrade
# @param root_dir [String] mount point of the target system
def self.prepare_for_upgrade!(root_dir)
log.info "Preparing the target system at #{root_dir} for upgrade"
backup(root_dir)
Expand Down
6 changes: 4 additions & 2 deletions test/sw_mgmt_spec.rb
Expand Up @@ -208,7 +208,8 @@
expect(File).to receive(:exist?).with(File.join(root_dir, target_dir, "NCCcredentials")).and_return(true)
expect(File).to receive(:exist?).with(File.join(root_dir, target_dir, "SCCcredentials")).and_return(false)

expect(FileUtils).to receive(:cp).with(File.join(root_dir, target_dir, "NCCcredentials"), File.join(target_dir, "SCCcredentials"))
expect(FileUtils).to receive(:cp).with(File.join(root_dir, target_dir, "NCCcredentials"),
File.join(target_dir, "SCCcredentials"))

expect { Registration::SwMgmt.copy_old_credentials(root_dir) }.to_not raise_error
end
Expand All @@ -217,7 +218,8 @@
expect(File).to receive(:exist?).with(File.join(root_dir, target_dir, "NCCcredentials")).and_return(false)
expect(File).to receive(:exist?).with(File.join(root_dir, target_dir, "SCCcredentials")).and_return(true)

expect(FileUtils).to receive(:cp).with(File.join(root_dir, target_dir, "SCCcredentials"), File.join(target_dir, "SCCcredentials"))
expect(FileUtils).to receive(:cp).with(File.join(root_dir, target_dir, "SCCcredentials"),
File.join(target_dir, "SCCcredentials"))

expect { Registration::SwMgmt.copy_old_credentials(root_dir) }.to_not raise_error
end
Expand Down

0 comments on commit 041dcbc

Please sign in to comment.