Hello community, here is the log from the commit of package SUSEConnect for openSUSE:Factory checked in at 2017-05-17 10:54:14 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/SUSEConnect (Old) and /work/SRC/openSUSE:Factory/.SUSEConnect.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "SUSEConnect" Wed May 17 10:54:14 2017 rev:2 rq:494946 version:0.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/SUSEConnect/SUSEConnect.changes 2017-03-16 09:36:21.342756078 +0100 +++ /work/SRC/openSUSE:Factory/.SUSEConnect.new/SUSEConnect.changes 2017-05-17 10:54:15.839588572 +0200 @@ -1,0 +2,12 @@ +Fri May 5 07:41:44 UTC 2017 - [email protected] + +- Update to 0.3.0: + - Single product deactivation feature (fate#320572) + +------------------------------------------------------------------- +Tue Mar 21 15:24:58 UTC 2017 - [email protected] + +- Update to 0.2.43: + - RPM spec fix for openSUSE:Factory rpmlint compliance (bsc#1028660) + +------------------------------------------------------------------- Old: ---- suse-connect-0.2.42.gem New: ---- suse-connect-0.3.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ SUSEConnect.spec ++++++ --- /var/tmp/diff_new_pack.l9aLvQ/_old 2017-05-17 10:54:16.679470418 +0200 +++ /var/tmp/diff_new_pack.l9aLvQ/_new 2017-05-17 10:54:16.683469855 +0200 @@ -1,7 +1,7 @@ # # spec file for package SUSEConnect # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,28 +12,23 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugzilla.suse.com/ # - Name: SUSEConnect -Version: 0.2.42 +Version: 0.3.0 Release: 0 %define mod_name suse-connect %define mod_full_name %{mod_name}-%{version} -Requires: ca-certificates-mozilla -Requires: coreutils -Requires: hwinfo -Requires: net-tools -Requires: util-linux -Requires: zypper +Requires: coreutils, util-linux, net-tools, hwinfo, zypper, ca-certificates-mozilla Requires: zypper >= 1.11.32 Conflicts: suseRegister, yast2-registration < 3.1.129.7 Obsoletes: ruby2.1-rubygem-suse-connect < %{version} -Obsoletes: ruby2.2-rubygem-suse-connect < %{version} -Provides: ruby2.2-rubygem-suse-connect = %{version} +%if ! 0%{?is_opensuse} +Provides: ruby2.1-rubygem-suse-connect = %{version} +%endif %ifarch x86_64 aarch64 Requires: dmidecode ++++++ SUSEConnect.5.gz ++++++ ++++++ SUSEConnect.8.gz ++++++ --- /var/tmp/diff_new_pack.l9aLvQ/_old 2017-05-17 10:54:16.767458039 +0200 +++ /var/tmp/diff_new_pack.l9aLvQ/_new 2017-05-17 10:54:16.771457477 +0200 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "SUSECONNECT" "8" "March 2017" "" "SUSEConnect" +.TH "SUSECONNECT" "8" "May 2017" "" "SUSEConnect" . .SH "NAME" \fBSUSEConnect\fR \- SUSE Customer Center registration tool @@ -25,7 +25,7 @@ . .TP \fB\-p\fR, \fB\-\-product <PRODUCT>\fR -Activate PRODUCT\. Defaults to the base SUSE Linux Enterprise product on this system\. Product identifiers can be obtained with \fB\-\-list\-extensions\fR\. Format: \fIname\fR/\fIversion\fR/\fIarchitecture\fR +Specify a product for activation/deactivation\. Only one product can be processed at a time\. Defaults to the base SUSE Linux Enterprise product on this system\. Product identifiers can be obtained with \fB\-\-list\-extensions\fR\. Format: \fIname\fR/\fIversion\fR/\fIarchitecture\fR . .TP \fB\-r\fR, \fB\-\-regcode <REGCODE>\fR @@ -33,7 +33,7 @@ . .TP \fB\-d\fR, \fB\-\-de\-register\fR -De\-registers a system and removes all services installed by SUSEConnect\. After de\-registration, the system no longer consumes a subscription slot in SCC\. +De\-registers the system and base product, or in conjunction with \-\-product, a single extension, and removes all its services installed by SUSEConnect\. After de\-registration, the system no longer consumes a subscription slot in SCC\. . .TP \fB\-\-list\-extensions\fR ++++++ suse-connect-0.2.42.gem -> suse-connect-0.3.0.gem ++++++ Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/suse/connect/api.rb new/lib/suse/connect/api.rb --- old/lib/suse/connect/api.rb 2017-03-03 10:57:02.000000000 +0100 +++ new/lib/suse/connect/api.rb 2017-05-05 14:35:19.000000000 +0200 @@ -104,6 +104,24 @@ @connection.post('/connect/systems/products', auth: auth, params: payload) end + # Deactivate a product, freeing a slot for another activation. Returns the service + # associated to the product. + # + # @param auth [String] authorization string which will be injected in 'Authorization' header in request. + # In this case we expect Base64 encoded string with login and password + # @param product [SUSE::Connect::Remote::Product] product to be deactivated + # + # @return [OpenStruct] responding to body(response from SCC) and code(natural HTTP response code). + def deactivate_product(auth, product) + payload = { + identifier: product.identifier, + version: product.version, + arch: product.arch, + release_type: product.release_type + } + @connection.delete('/connect/systems/products', auth: auth, params: payload) + end + # Upgrade a product and receive the updated service for the system. # # @param auth [String] authorization string which will be injected in 'Authorization' header in request. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/suse/connect/cli.rb new/lib/suse/connect/cli.rb --- old/lib/suse/connect/cli.rb 2017-03-03 10:57:02.000000000 +0100 +++ new/lib/suse/connect/cli.rb 2017-05-05 14:35:19.000000000 +0200 @@ -75,6 +75,14 @@ # Zypper errors are in the range 1-7 and 100-105 (which connect will not cause) log.fatal "Error: zypper returned (#{e.exitstatus}) with '#{e.output}'" exit e.exitstatus + rescue SystemNotRegisteredError + log.fatal 'Deregistration failed. Check if the system has been '\ + 'registered using the --status-text option or use the '\ + '--regcode parameter to register it.' + exit 69 + rescue BaseProductDeactivationError + log.fatal 'Can not deregister base product. Use SUSEConnect -d to deactivate the whole system.' + exit 70 end private @@ -94,11 +102,13 @@ @opts.separator '' @opts.separator 'Manage subscriptions at https://scc.suse.com' @opts.separator '' - @opts.on('-p', '--product [PRODUCT]', 'Activate PRODUCT. Defaults to the base SUSE Linux', - 'Enterprise product on this system.', - 'Product identifiers can be obtained with', - '\'--list-extensions\'.', - 'Format: <internal name>/<version>/<architecture>') do |opt| + @opts.on('-p', '--product [PRODUCT]', + 'Specify a product for activation/deactivation. Only', + 'one product can be processed at a time. Defaults to', + 'the base SUSE Linux Enterprise product on this ', + 'system. Product identifiers can be obtained', + 'with `--list-extensions`.', + 'Format: <name>/<version>/<architecture>') do |opt| check_if_param(opt, 'Please provide a product identifier') # rubocop:disable RegexpLiteral check_if_param((opt =~ /\S+\/\S+\/\S+/), 'Please provide the product identifier in this format: ' \ @@ -108,17 +118,20 @@ @options[:product] = Remote::Product.new(identifier: identifier, version: version, arch: arch) end - @opts.on('-r', '--regcode [REGCODE]', 'Subscription registration code for the product to', + @opts.on('-r', '--regcode [REGCODE]', + 'Subscription registration code for the product to', 'be registered.', 'Relates that product to the specified subscription,', 'and enables software repositories for that product.') do |opt| @options[:token] = opt end - @opts.on('-d', '--de-register', 'De-registers a system and removes all services', - 'installed by SUSEConnect. After de-registration,', - 'the system no longer consumes a subscription slot', - 'in SCC.') do |_opt| + @opts.on('-d', '--de-register', + 'De-registers the system and base product, or in', + 'conjunction with --product, a single extension, and', + 'removes all its services installed by SUSEConnect.', + 'After de-registration the system no longer consumes', + 'a subscription slot in SCC.') do |_opt| @options[:deregister] = true end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/suse/connect/client.rb new/lib/suse/connect/client.rb --- old/lib/suse/connect/client.rb 2017-03-03 10:57:02.000000000 +0100 +++ new/lib/suse/connect/client.rb 2017-05-05 14:35:19.000000000 +0200 @@ -31,10 +31,22 @@ print_success_message product end + # Deregisters a whole system or a single product + # # @returns: Empty body and 204 status code def deregister! - @api.deregister(system_auth) - System.cleanup! + raise SystemNotRegisteredError unless registered? + if @config.product + raise BaseProductDeactivationError if @config.product == Zypper.base_product + service = deactivate_product @config.product + System.remove_service service + Zypper.remove_release_package @config.product.identifier + print_success_message @config.product, action: 'Deregistered' + else + @api.deregister(system_auth) + System.cleanup! + log.info 'Successfully deregistered system.' + end end # Announce system via SCC/Registration Proxy @@ -68,6 +80,15 @@ Remote::Service.new(result) end + # Deactivate a product + # + # @param product [SUSE::Connect::Remote::Product] + # @returns: Service for this product + def deactivate_product(product) + result = @api.deactivate_product(system_auth, product).body + Remote::Service.new(result) + end + # Upgrade a product # System upgrade (eg SLES11 -> SLES12) without regcode # @@ -145,7 +166,7 @@ # Announces the system to the server, receiving and storing its credentials. # When already announced, sends the current hardware details to the server def announce_or_update - if System.credentials? + if registered? update_system else login, password = announce_system(nil, @config.instance_data_file) @@ -153,8 +174,12 @@ end end - def print_success_message(product) - log.info "Registered #{product.identifier} #{product.version} #{product.arch}" + def registered? + System.credentials? + end + + def print_success_message(product, action: 'Registered') + log.info "#{action} #{product.identifier} #{product.version} #{product.arch}" log.info "Rooted at: #{@config.filesystem_root}" if @config.filesystem_root log.info "To server: #{@config.url}" if @config.url log.info "Using E-Mail: #{@config.email}" if @config.email diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/suse/connect/errors.rb new/lib/suse/connect/errors.rb --- old/lib/suse/connect/errors.rb 2017-03-03 10:57:02.000000000 +0100 +++ new/lib/suse/connect/errors.rb 2017-05-05 14:35:19.000000000 +0200 @@ -10,6 +10,8 @@ class SystemCallError < StandardError; end class UnsupportedStatusFormat < StandardError; end class NetworkError < StandardError; end + class SystemNotRegisteredError < StandardError; end + class BaseProductDeactivationError < StandardError; end # Basic error for API interactions. Collects HTTP response (which includes # status code and response body) for future showing to user via {Cli} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/suse/connect/status.rb new/lib/suse/connect/status.rb --- old/lib/suse/connect/status.rb 2017-03-03 10:57:02.000000000 +0100 +++ new/lib/suse/connect/status.rb 2017-05-05 14:35:19.000000000 +0200 @@ -1,5 +1,6 @@ require 'time' require 'erb' +require 'suse/toolkit/renderer' module SUSE module Connect @@ -9,6 +10,8 @@ # from the registration server. This information is merged and printed out. # rubocop:disable ClassLength class Status + prepend SUSE::Toolkit::Renderer + attr_reader :client def initialize(config) @@ -33,9 +36,7 @@ end def print_extensions_list - file = File.read File.join(File.dirname(__FILE__), 'templates/extensions_list.text.erb') - template = ERB.new(file, 0, '-<>') - puts template.result(binding).gsub('\e', "\e") + puts render('extensions_list.text') end # Gather all extensions that can be installed on this system @@ -45,15 +46,11 @@ end def print_product_statuses(format = :text) - case format - when :text - status_output = text_product_status - when :json - status_output = json_product_status + if %i(text json).include?(format) + puts send("#{format}_product_status") else raise UnsupportedStatusFormat, "Unsupported output format '#{format}'" end - puts status_output end def system_products @@ -72,6 +69,8 @@ activation_code: build_product_activation_code(extension), name: extension.friendly_name, free: extension.free, + installed: installed_products.any? {|p| p == extension }, + activated: activated_products.any? {|p| p == extension }, extensions: extract_extensions(extension) } end if product.extensions diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/suse/connect/system.rb new/lib/suse/connect/system.rb --- old/lib/suse/connect/system.rb 2017-03-03 10:57:02.000000000 +0100 +++ new/lib/suse/connect/system.rb 2017-05-05 14:35:19.000000000 +0200 @@ -43,6 +43,12 @@ service end + def remove_service(service) + raise ArgumentError, 'only Remote::Service accepted' unless service.is_a? Remote::Service + Zypper.remove_service service.name + service + end + def hostname hostname = Socket.gethostname if hostname && hostname != '(none)' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/suse/connect/templates/extension_item.text.erb new/lib/suse/connect/templates/extension_item.text.erb --- old/lib/suse/connect/templates/extension_item.text.erb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/suse/connect/templates/extension_item.text.erb 2017-05-05 14:35:19.000000000 +0200 @@ -0,0 +1,11 @@ +\e[1m<%= extension[:name] %>\e[0m<% + if extension[:installed] + %> \e[32m(Installed)\e[0m + <%= ' ' if defined?(nested) %>De-Install with: <%= ' ' unless defined?(nested) %>SUSEConnect \e[31m-d\e[0m -p <%= extension[:activation_code] %><% + else %><% + if extension[:activated] + %> \e[33m(Activated)\e[0m<% + end %> + <%= ' ' if defined?(nested) %>Install with: <%= ' ' unless defined?(nested) %>SUSEConnect<%= ' ' if any_installed %> -p <%= extension[:activation_code] %><% unless extension[:free] %> -r \e[32m\e[1mREGCODE\e[0m<% + end %><% + end %> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/suse/connect/templates/extensions_list.text.erb new/lib/suse/connect/templates/extensions_list.text.erb --- old/lib/suse/connect/templates/extensions_list.text.erb 2017-03-03 10:57:02.000000000 +0100 +++ new/lib/suse/connect/templates/extensions_list.text.erb 2017-05-05 14:35:19.000000000 +0200 @@ -1,36 +1,21 @@ \e[1mAVAILABLE EXTENSIONS AND MODULES\e[0m -<% if grouped_extensions[true] %> -\e[1mFREE EXTENSIONS\e[0m - -<% grouped_extensions[true].each do |extension| -%> - \e[1m<%= extension[:name] %>\e[0m - Install with: SUSEConnect -p <%= extension[:activation_code] %> -<% extension[:extensions].each do |additional_extension| -%> - \e[1m<%= additional_extension[:name] %>\e[0m - Install with: SUSEConnect -p <%= additional_extension[:activation_code] %> - - <% end -%> - -<% end -%> -<% end -%> - -<% if grouped_extensions[false] %> -\e[1mPAID EXTENSIONS\e[0m - -<% grouped_extensions[false].each do |extension| -%> - \e[1m<%= extension[:name] %>\e[0m - Install with: SUSEConnect -p <%= extension[:activation_code] %> -r \e[32m\e[1mREGCODE\e[0m -<% extension[:extensions].each do |additional_extension| -%> - - \e[1m<%= additional_extension[:name] %>\e[0m - Install with: SUSEConnect -p <%= additional_extension[:activation_code] %> -r \e[32m\e[1mREGCODE\e[0m - <% end -%> - -<% end -%> -<% end -%> - +<% +any_installed = installed_products.select {|x| !x.isbase }.any? +{ true => 'FREE EXTENSIONS', false => 'PAID EXTENSIONS' }.each do |type_key, title| + if grouped_extensions[type_key] %> +\e[1m<%= title %>\e[0m + +<% grouped_extensions[type_key].each do |extension| -%> + <%= render 'extension_item.text', locals: { extension: extension, any_installed: any_installed } %> +<% extension[:extensions].each do |extension| -%> + <%= render 'extension_item.text', locals: { extension: extension, nested: true, any_installed: any_installed } %> +<% end + end + end +end %> \e[1mMORE INFORMATION\e[0m You can find more information about available modules here: https://www.suse.com/products/server/features/modules.html + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/suse/connect/version.rb new/lib/suse/connect/version.rb --- old/lib/suse/connect/version.rb 2017-03-03 10:57:02.000000000 +0100 +++ new/lib/suse/connect/version.rb 2017-05-05 14:35:19.000000000 +0200 @@ -1,6 +1,6 @@ module SUSE # Provides access to version number of a gem module Connect - VERSION = '0.2.42' + VERSION = '0.3.0' end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/suse/connect/zypper.rb new/lib/suse/connect/zypper.rb --- old/lib/suse/connect/zypper.rb 2017-03-03 10:57:02.000000000 +0100 +++ new/lib/suse/connect/zypper.rb 2017-05-05 14:35:19.000000000 +0200 @@ -151,6 +151,10 @@ call("--no-refresh --non-interactive install --no-recommends -t product #{identifier}") if identifier end + def remove_release_package(identifier) + call("--no-refresh --non-interactive remove -t product #{identifier}") if identifier + end + # rubocop:disable AccessorMethodName def set_release_version(version) call("--non-interactive --releasever #{version} ref -f") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/suse/toolkit/renderer.rb new/lib/suse/toolkit/renderer.rb --- old/lib/suse/toolkit/renderer.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/suse/toolkit/renderer.rb 2017-05-05 14:35:19.000000000 +0200 @@ -0,0 +1,17 @@ +module SUSE + module Toolkit + # Provides templates and partials interface + module Renderer + def initialize(*arguments) + @templates = {} + super + end + + def render(filename, locals: binding) + bind = locals.is_a?(Binding) ? locals : OpenStruct.new(locals).instance_eval { binding } + @templates[filename] ||= ERB.new File.read(File.expand_path("../../connect/templates/#{filename}.erb", __FILE__)), 0, '-<>' + @templates[filename].result(bind).gsub('\e', "\e") + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/suse/toolkit/utilities.rb new/lib/suse/toolkit/utilities.rb --- old/lib/suse/toolkit/utilities.rb 2017-03-03 10:57:02.000000000 +0100 +++ new/lib/suse/toolkit/utilities.rb 2017-05-05 14:35:19.000000000 +0200 @@ -21,7 +21,7 @@ rescue raise SUSE::Connect::CannotBuildBasicAuth, - "Cannot read username and password from #{SUSE::Connect::Credentials::GLOBAL_CREDENTIALS_FILE}" + "\nCannot read username and password from #{SUSE::Connect::Credentials.system_credentials_file}." end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2017-03-03 10:57:02.000000000 +0100 +++ new/metadata 2017-05-05 14:35:19.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: suse-connect version: !ruby/object:Gem::Version - version: 0.2.42 + version: 0.3.0 platform: ruby authors: - SUSE Customer Center Team autorequire: bindir: bin cert_chain: [] -date: 2017-03-03 00:00:00.000000000 Z +date: 2017-05-05 00:00:00.000000000 Z dependencies: [] description: This package provides a command line tool and rubygem library for connecting a client system to the SUSE Customer Center. It will connect the system to your @@ -49,6 +49,7 @@ - lib/suse/connect/ssl_certificate.rb - lib/suse/connect/status.rb - lib/suse/connect/system.rb +- lib/suse/connect/templates/extension_item.text.erb - lib/suse/connect/templates/extensions_list.text.erb - lib/suse/connect/templates/product_statuses.text.erb - lib/suse/connect/version.rb @@ -59,6 +60,7 @@ - lib/suse/toolkit/cast.rb - lib/suse/toolkit/curlrc_dotfile.rb - lib/suse/toolkit/product_equality.rb +- lib/suse/toolkit/renderer.rb - lib/suse/toolkit/system_calls.rb - lib/suse/toolkit/utilities.rb homepage: https://github.com/SUSE/connect
