Skip to content

Commit

Permalink
share creating the default suse-connect options
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Apr 18, 2014
1 parent dd9a9b2 commit 86a6bc5
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions src/lib/registration/registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,10 @@ def initialize(url = nil)
end

def register(email, reg_code)
settings = {
settings = default_connect_params.merge({
:token => reg_code,
:verbose => ENV["Y2DEBUG"] == "1"
# TODO FIXME: how to pass email?: "email" => email
}

# set the current language to receive translated error messages
# TODO FIXME: @scc.language = ::Registration::Helpers.language

if @url
log.info "Using custom registration URL: #{@url.inspect}"
settings[:url] = @url
end
})

login, password = SUSE::Connect::YaST.announce_system(settings)
@credentials = SUSE::Connect::Credentials.new(login, password, SCC_CREDENTIALS)
Expand All @@ -70,19 +61,14 @@ def register_products(products)
product_services = products.map do |product|
log.info("Registering product: #{product["name"]}")

params = {
params = default_connect_params.merge({
:product_ident => {
:arch => product["arch"],
:product_ident => product["name"],
:product_version => product["version"],
:release_type => product["release_type"]
}
}

if @url
log.info "Using custom registration URL: #{@url.inspect}"
params[:url] = @url
end
})

# use product specific reg. key (e.g. for addons)
params[:token] = product["reg_key"] if product["reg_key"]
Expand All @@ -107,15 +93,31 @@ def get_addon_list
# extensions for base product
base_product = ::Registration::Storage::BaseProduct.instance.product

params = {
params = default_connect_params.merge({
:product_ident => base_product["name"]
}
})

SUSE::Connect::YaST.list_products(params)
end

def self.is_registered?
File.exist?(SCC_CREDENTIALS)
SUSE::Connect::System.registered?
end

private

def default_connect_params
ret = {
:language => ::Registration::Helpers.language,
:verbose => ENV["Y2DEBUG"] == "1"
}

if @url
log.info "Using custom registration URL: #{@url.inspect}"
ret[:url] = @url
end

ret
end
end
end

0 comments on commit 86a6bc5

Please sign in to comment.