Skip to content

Commit

Permalink
improved obtaining registration URL
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Mar 31, 2014
1 parent e2e9b2a commit 65ed582
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 15 deletions.
65 changes: 50 additions & 15 deletions src/lib/registration/helpers.rb
Expand Up @@ -74,22 +74,12 @@ def self.language
# for details
# @return [String,nil] registration URL, nil means use the default
def self.registration_url
if Yast::Mode.installation
# boot command line if present
boot_url = boot_reg_url
return boot_url if boot_url
end

# SLP discovery
# TODO FIXME: replace "true" by reading the SLP option from configuration file
if Yast::Mode.installation || true
slp_url = slp_service_url
return slp_url if slp_url
end

# TODO FIXME: read the URL from configuration file to use the same URL
# at re-registration at installed system
# note: autoyast mode is handled in scc_auto client
return reg_url_at_upgrade if Yast::Mode.update
return reg_url_at_installation if Yast::Mode.installation
return reg_url_at_runnig_system if Yast::Mode.normal

log.warn "Unknown mode: #{Mode.mode} using default URL"
# no custom URL, use the default
nil
end
Expand Down Expand Up @@ -130,6 +120,51 @@ def self.run_network_configuration

private

# get registration URL in installation mode
def self.reg_url_at_installation
# boot command line if present
boot_url = boot_reg_url
return boot_url if boot_url

# SLP discovery
slp_url = slp_service_url
return slp_url if slp_url

# use the default
nil
end

# get registration URL in upgrade mode
def self.reg_url_at_upgrade
# boot command line if present
boot_url = boot_reg_url
return boot_url if boot_url

# TODO FIXME: read the URL from the old configuration file
# (old suse_register.conf or old SCC config file)

# try SLP if not registered
slp_url = slp_service_url
return slp_url if slp_url

# use the default
nil
end

# get registration URL in running system
def self.reg_url_at_runnig_system
# TODO FIXME: read the URL from configuration file to use the same URL
# at re-registration as in installation

# try SLP if not registered yet
slp_url = slp_service_url
return slp_url if slp_url

# use the default
nil
end


# return the boot command line parameter
def self.boot_reg_url
parameters = Yast::Linuxrc.InstallInf("Cmdline")
Expand Down
4 changes: 4 additions & 0 deletions test/helpers_spec.rb
Expand Up @@ -23,6 +23,8 @@
context "at installation" do
before do
allow(yast_mode).to receive(:installation).and_return(true)
allow(yast_mode).to receive(:update).and_return(false)
allow(yast_mode).to receive(:normal).and_return(false)
end

context "no local registration server is announced via SLP" do
Expand Down Expand Up @@ -78,6 +80,8 @@

context "at installed system" do
before do
allow(yast_mode).to receive(:normal).and_return(true)
allow(yast_mode).to receive(:update).and_return(false)
allow(yast_mode).to receive(:installation).and_return(false)
# FIXME: stub SLP service discovery, later add config file reading
expect(yast_wfm).to receive(:call).with("discover_registration_services").and_return(nil)
Expand Down

0 comments on commit 65ed582

Please sign in to comment.