Skip to content

Commit

Permalink
Merge branch 'master' into review_140417_email_parameter
Browse files Browse the repository at this point in the history
* master:
  move YaST class to SUSE::Connect module
  Product - added "version", "arch" and "free" attributes
  update sles12-beta5 image id
  use sles12-beta5 image for connect testing

Conflicts:
	lib/suse/connect/yast.rb
  • Loading branch information
Dominik Bamberger committed Apr 22, 2014
2 parents bd7eaa7 + 34d7659 commit c5c7bc0
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 64 deletions.
2 changes: 1 addition & 1 deletion kitchen/lib/cloud_vm.rb
Expand Up @@ -23,7 +23,7 @@ def connection
end

def create(name = 'SUSEConnect_testing')
image = connection.get_image('77a84bd3-bd75-4c0d-b007-80a3f0646fe5')
image = connection.get_image('19724f29-9713-4277-b359-2029508acf16')
flavor = connection.get_flavor(2)
address = connection.get_floating_ips.select {|ip| ip.instance_id.nil? }.first || connection.create_floating_ip

Expand Down
2 changes: 1 addition & 1 deletion lib/suse/connect/client.rb
Expand Up @@ -50,7 +50,7 @@ def activate_product(product_ident, email = nil)
def list_products(product_ident)
result = @api.addons(basic_auth, product_ident).body
result.map do |product|
SUSE::Connect::Product.new(product['name'], '', '', product['zypper_name'])
SUSE::Connect::Product.new(product)
end
end

Expand Down
15 changes: 9 additions & 6 deletions lib/suse/connect/product.rb
Expand Up @@ -2,14 +2,17 @@
# TODO: Maybe we should get rid of this class?
class SUSE::Connect::Product # rubocop:disable Documentation

attr_reader :short_name, :long_name, :description, :product_ident
attr_reader :short_name, :long_name, :description, :product_ident, :version, :arch, :free

# Constructor
def initialize(short_name, long_name, description, product_ident)
@short_name = short_name
@long_name = long_name
@description = description
@product_ident = product_ident
def initialize(product)
@short_name = product['name']
@long_name = product['long_name']
@description = product['description']
@product_ident = product['zypper_name']
@version = product['zypper_version']
@arch = product['arch']
@free = product['free']
end

end
102 changes: 53 additions & 49 deletions lib/suse/connect/yast.rb
@@ -1,57 +1,61 @@
# YaST class provides methods emulating SCC's API.
class SUSE::Connect::YaST
module SUSE
module Connect

class << self
# YaST class provides methods emulating SCC's API.
class YaST
class << self

# Announces the system to SCC / the registration server.
# Usually expects a token / regcode to identify the correct subscription.
# Additionally, distro_target should be set to avoid calls to Zypper.
# Gets system credentials from SCC.
# Additionally, returns the credentials for convenience.
#
# @param [Hash] params
# * :token [String] registration code/token
# * :hostname [String]
# * :distro_target [String]
# * :parent [String]
# * :hwinfo [Hash]
#
# @return [Array <String>] SCC / system credentials - login and password tuple
def announce_system(params = {})
Client.new(params).announce_system(params[:distro_target])
end
# Announces the system to SCC / the registration server.
# Usually expects a token / regcode to identify the correct subscription.
# Additionally, distro_target should be set to avoid calls to Zypper.
# Gets system credentials from SCC.
# Additionally, returns the credentials for convenience.
#
# @param [Hash] params
# * :token [String] registration code/token
# * :hostname [String]
# * :distro_target [String]
# * :parent [String]
# * :hwinfo [Hash]
#
# @return [Array <String>] SCC / system credentials - login and password tuple
def announce_system(params = {})
Client.new(params).announce_system(params[:distro_target])
end

# Activates a product on SCC / the registration server.
# Expects a product_ident to identify the correct service.
# Mostly requires token / regcode (except for free extensions or upgrades).
# Gets a service for the product from SCC.
# Additionally, returns the service for convenience.
#
# @param [Hash] params
# - :token [String]
# - :product_ident [String]
# - :product_version [String]
# - :arch [String]
# - :email [String]
#
# @return [Service] Service
def activate_product(params = {})
Client.new(params).activate_product(params[:product_ident], params[:email])
end
# Activates a product on SCC / the registration server.
# Expects a product_ident to identify the correct service.
# Mostly requires token / regcode (except for free extensions or upgrades).
# Gets a service for the product from SCC.
# Additionally, returns the service for convenience.
#
# @param [Hash] params
# - :token [String]
# - :product_ident [String]
# - :product_version [String]
# - :arch [String]
# - :email [String]
#
# @return [Service] Service
def activate_product(params = {})
Client.new(params).activate_product(params[:product_ident], params[:email])
end

# Lists all available products for a system.
# Accepts a parameter product_ident, which scopes the result set down to all
# products for the system that are extensions to the specified product.
# Gets the list from SCC and returns them.
#
# @param [Hash] params
# * :product_ident [String]
#
# @return [Array <Product>] array of {Product}s
def list_products(params = {})
Client.new(params).list_products(params[:product_ident])
# Lists all available products for a system.
# Accepts a parameter product_ident, which scopes the result set down to all
# products for the system that are extensions to the specified product.
# Gets the list from SCC and returns them.
#
# @param [Hash] params
# * :product_ident [String]
#
# @return [Array <Product>] array of {Product}s
def list_products(params = {})
Client.new(params).list_products(params[:product_ident])
end

end
end

end

end
29 changes: 22 additions & 7 deletions spec/connect/product_spec.rb
Expand Up @@ -3,13 +3,16 @@
describe SUSE::Connect::Product do

subject do
extension_attrs = [
'SLEEK',
'SUSE LINUX ENTERPRISE EXTENSION KDE',
'SLEEK puts the modern yet familiar GUI back into SLE that you love',
'SLEEK-12'
]
SUSE::Connect::Product.new(*extension_attrs)
extension = {
'name' => 'SLEEK',
'long_name' => 'SUSE LINUX ENTERPRISE EXTENSION KDE',
'description' => 'SLEEK puts the modern yet familiar GUI back into SLE that you love',
'zypper_name' => 'SLEEK-12',
'zypper_version' => '12',
'arch' => 'x86_64',
'free' => true
}
SUSE::Connect::Product.new(extension)
end

it 'has attribute short_name' do
Expand All @@ -28,4 +31,16 @@
expect(subject.product_ident).not_to be_nil
end

it 'has attribute version' do
expect(subject.version).not_to be_nil
end

it 'has attribute arch' do
expect(subject.arch).not_to be_nil
end

it 'has attribute free' do
expect(subject.free).not_to be_nil
end

end

0 comments on commit c5c7bc0

Please sign in to comment.