Skip to content

Commit

Permalink
collect product rename also for the base product (bsc#925700)
Browse files Browse the repository at this point in the history
- the internal SLES-for-SAP product identifier has been changed

- 3.1.129.1
  • Loading branch information
lslezak committed Apr 8, 2015
1 parent bdb8057 commit f788a37
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
7 changes: 7 additions & 0 deletions package/yast2-registration.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Apr 8 15:31:18 UTC 2015 - lslezak@suse.cz

- collect product rename also for the base product (the internal
SLES-for-SAP product identifier has been changed) (bsc#925700)
- 3.1.129.1

-------------------------------------------------------------------
Thu Nov 6 08:32:36 UTC 2014 - lslezak@suse.cz

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-registration.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-registration
Version: 3.1.129
Version: 3.1.129.1
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
17 changes: 13 additions & 4 deletions src/lib/registration/registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def register_product(product, email = nil)
log.info "Register product result: #{service}"
set_registered(product_ident)

renames = collect_renames([service.product])
SwMgmt.update_product_renames(renames)

service
end
end
Expand All @@ -79,6 +82,9 @@ def upgrade_product(product)
log.info "Upgrade product result: #{service}"
set_registered(product_ident)

renames = collect_renames([service.product])
SwMgmt.update_product_renames(renames)

service
end
end
Expand Down Expand Up @@ -225,12 +231,15 @@ def connect_params(params = {})
default_params.merge(params)
end

def collect_renames(addons)
# collect product renames
# @param products [Array<SUSE::Connect::Remote::Product>] remote products received from SCC
# @return [Hash] hash with product renames: { old_name => new_name }
def collect_renames(products)
renames = {}

addons.each do |addon|
if addon.former_identifier && addon.identifier != addon.former_identifier
renames[addon.former_identifier] = addon.identifier
products.each do |product|
if product.former_identifier && product.identifier != product.former_identifier
renames[product.former_identifier] = product.identifier
end
end

Expand Down
14 changes: 10 additions & 4 deletions test/registration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@

it "adds the selected product and returns added zypp services" do
product = {
"arch" => "x86_64",
"name" => "sle-sdk",
"version" => "12",
"release_type" => nil
"arch" => "x86_64",
"name" => "sle-sdk",
"version" => "12",
"release_type" => nil,
"identifier" => "SLES_SAP",
"former_identifier" => "SUSE_SLES_SAP"
}

service_data = {
Expand All @@ -58,6 +60,10 @@
expect(available_addons.find { |addon| addon.identifier == "sle-sdk" }).to \
receive(:registered)

# the received product renames are passed to the software management
expect(Registration::SwMgmt).to receive(:update_product_renames)
.with("SUSE_SLES_SAP" => "SLES_SAP")

allow(File).to receive(:exist?).with(
SUSE::Connect::Credentials::GLOBAL_CREDENTIALS_FILE).and_return(true)
allow(File).to receive(:read).with(
Expand Down

0 comments on commit f788a37

Please sign in to comment.