Skip to content

Commit

Permalink
pass distro_target to suse-connect
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Apr 18, 2014
1 parent 95b55bd commit f3bb2ea
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/clients/inst_scc.rb
Expand Up @@ -129,18 +129,22 @@ def register_base_system
@registration = ::Registration::Registration.new(url)

::Registration::SccHelpers.catch_registration_errors do
distro_target = ::Registration::SwMgmt.find_base_product["register_target"]
log.info "Registering system, distro_target: #{distro_target}"

if !::Registration::Registration.is_registered?
log.info "Registering system: #{distro_target}"

Popup.Feedback(_("Registering the System..."),
_("Contacting the SUSE Customer Center server")) do

@registration.register(email, reg_code)
base_product = ::Registration::SwMgmt.base_product_to_register
@registration.register_products([base_product])
end
end

if !options.base_registered
# then register the product(s)
base_product = ::Registration::SwMgmt.base_product_to_register
product_services = Popup.Feedback(
_("Registering Product..."),
_("Contacting the SUSE Customer Center server")) do
Expand Down
8 changes: 8 additions & 0 deletions src/lib/registration/helpers.rb
Expand Up @@ -113,6 +113,14 @@ def self.run_network_configuration
Yast::WFM.call("inst_lan", [{"skip_detection" => true}])
end

# return base version
# "12-1.47" => "12"
# "12-1" => "12"
# "12.1-1.47" => "12.1"
# "12.1-1" => "12.1"
def self.base_version(version)
version.sub(/-.*\z/, "")
end

private

Expand Down
3 changes: 2 additions & 1 deletion src/lib/registration/registration.rb
Expand Up @@ -38,9 +38,10 @@ def initialize(url = nil)
@url = url
end

def register(email, reg_code)
def register(email, reg_code, distro_target)
settings = default_connect_params.merge({
:token => reg_code,
:distro_target => distro_target
# TODO FIXME: how to pass email?: "email" => email
})

Expand Down
13 changes: 13 additions & 0 deletions test/helpers_spec.rb
Expand Up @@ -144,4 +144,17 @@
end
end

describe ".base_version" do
it "returns the version if build suffix is missing" do
expect(Registration::Helpers.base_version("12")).to eq("12")
expect(Registration::Helpers.base_version("12.1")).to eq("12.1")
end

it "returns base version without build suffix" do
expect(Registration::Helpers.base_version("12.1-1.47")).to eq("12.1")
expect(Registration::Helpers.base_version("12.1-1")).to eq("12.1")
expect(Registration::Helpers.base_version("12-1.47")).to eq("12")
expect(Registration::Helpers.base_version("12-1")).to eq("12")
end
end
end
2 changes: 1 addition & 1 deletion test/registration_spec.rb
Expand Up @@ -29,7 +29,7 @@
.and_return([username, password])
)

Registration::Registration.new.register("email", reg_code)
Registration::Registration.new.register("email", reg_code, "sles-12-x86_64")
end
end

Expand Down

0 comments on commit f3bb2ea

Please sign in to comment.