Hello community, here is the log from the commit of package yast2-slp for openSUSE:Factory checked in at 2014-02-06 10:49:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-slp (Old) and /work/SRC/openSUSE:Factory/.yast2-slp.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-slp" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-slp/yast2-slp.changes 2013-11-18 14:59:33.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-slp.new/yast2-slp.changes 2014-02-06 11:11:49.000000000 +0100 @@ -1,0 +2,6 @@ +Fri Jan 31 10:18:53 UTC 2014 - [email protected] + +- Add SlpService module (fate#316384) +- 3.1.2 + +------------------------------------------------------------------- Old: ---- yast2-slp-3.1.1.tar.bz2 New: ---- yast2-slp-3.1.2.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-slp.spec ++++++ --- /var/tmp/diff_new_pack.9lH3E9/_old 2014-02-06 11:11:50.000000000 +0100 +++ /var/tmp/diff_new_pack.9lH3E9/_new 2014-02-06 11:11:50.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package yast2-slp # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2014 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 @@ -17,7 +17,7 @@ Name: yast2-slp -Version: 3.1.1 +Version: 3.1.2 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -28,9 +28,10 @@ BuildRequires: libtool BuildRequires: openslp-devel BuildRequires: perl-XML-Writer +BuildRequires: rubygem-rspec BuildRequires: yast2 BuildRequires: yast2-core-devel -BuildRequires: yast2-devtools >= 3.0.6 +BuildRequires: yast2-devtools >= 3.1.10 %if 0%{?suse_version} < 1220 BuildRequires: libxcrypt-devel %endif @@ -41,6 +42,7 @@ Summary: YaST2 - SLP Agent and Browser License: GPL-2.0+ Group: System/YaST +Url: https://github.com/yast/yast-slp %description This module enables YaST modules to register services with SLP. @@ -62,6 +64,7 @@ %{yast_plugindir}/libpy2ag_slp.so %{yast_plugindir}/libpy2ag_slp.la %{yast_moduledir}/SLP.rb +%{yast_moduledir}/SlpService.rb %doc %{yast_docdir} %changelog ++++++ yast2-slp-3.1.1.tar.bz2 -> yast2-slp-3.1.2.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-slp-3.1.1/VERSION new/yast2-slp-3.1.2/VERSION --- old/yast2-slp-3.1.1/VERSION 2013-11-15 13:19:35.000000000 +0100 +++ new/yast2-slp-3.1.2/VERSION 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -3.1.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-slp-3.1.1/package/yast2-slp.changes new/yast2-slp-3.1.2/package/yast2-slp.changes --- old/yast2-slp-3.1.1/package/yast2-slp.changes 2013-11-15 13:19:35.000000000 +0100 +++ new/yast2-slp-3.1.2/package/yast2-slp.changes 2014-02-04 11:16:53.000000000 +0100 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Fri Jan 31 10:18:53 UTC 2014 - [email protected] + +- Add SlpService module (fate#316384) +- 3.1.2 + +------------------------------------------------------------------- Wed Nov 13 15:56:18 UTC 2013 - [email protected] - Add explicit COPYING file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-slp-3.1.1/package/yast2-slp.spec new/yast2-slp-3.1.2/package/yast2-slp.spec --- old/yast2-slp-3.1.1/package/yast2-slp.spec 2013-11-15 13:19:35.000000000 +0100 +++ new/yast2-slp-3.1.2/package/yast2-slp.spec 2014-02-04 11:16:53.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-slp -Version: 3.1.1 +Version: 3.1.2 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -26,7 +26,8 @@ Group: System/YaST License: GPL-2.0+ BuildRequires: gcc-c++ openslp-devel doxygen perl-XML-Writer yast2-core-devel yast2 libtool -BuildRequires: yast2-devtools >= 3.0.6 +BuildRequires: yast2-devtools >= 3.1.10 +BuildRequires: rubygem-rspec %if 0%{?suse_version} < 1220 BuildRequires: libxcrypt-devel %endif @@ -34,6 +35,7 @@ Requires: yast2-ruby-bindings >= 1.0.0 Summary: YaST2 - SLP Agent and Browser +Url: https://github.com/yast/yast-slp %description This module enables YaST modules to register services with SLP. @@ -56,4 +58,5 @@ %{yast_plugindir}/libpy2ag_slp.so %{yast_plugindir}/libpy2ag_slp.la %{yast_moduledir}/SLP.rb +%{yast_moduledir}/SlpService.rb %doc %{yast_docdir} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-slp-3.1.1/src/Makefile.am new/yast2-slp-3.1.2/src/Makefile.am --- old/yast2-slp-3.1.1/src/Makefile.am 2013-11-15 13:19:35.000000000 +0100 +++ new/yast2-slp-3.1.2/src/Makefile.am 2014-02-04 11:16:53.000000000 +0100 @@ -1,7 +1,8 @@ # Sources for slp module_DATA = \ - modules/SLP.rb + modules/SLP.rb \ + modules/SlpService.rb EXTRA_DIST = $(module_DATA) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-slp-3.1.1/src/modules/SlpService.rb new/yast2-slp-3.1.2/src/modules/SlpService.rb --- old/yast2-slp-3.1.1/src/modules/SlpService.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-slp-3.1.2/src/modules/SlpService.rb 2014-02-04 11:16:53.000000000 +0100 @@ -0,0 +1,178 @@ +# = API for consuming SLP services in Yast +# The purpose of this module is to have a more developer friendly +# API for searching and manipulating SLP services. It hides the complexity of +# SLP protocol queries by concentrating the discovery call into a single method +# taking into account the service type along with its attributes. +# +# @example A simple query for available ldap services +# +# Yast::SlpService.find('ldap') # return a service object or nil if none found +# Yast::SlpService.all('ldap') # return all discovered services in a collection +# +# @example A query for installation server service with scope and protocol parameters +# +# Yast::SlpService.all('install.suse', :scope=>'some-scope', :protocol=>'ftp') +# +# +# @example Another query narrowing the results by criteria for service attributes +# +# Yast::SlpService.all('install.suse', :machine=>'x86_64') +# +# +# @example How to access the obtained service properties +# +# service = Yast::SlpService.find('ldap', :port=>389, :description=>'main') +# service.name # => 'ldap' +# service.ip # => '10.10.10.10' +# service.port # => 389 +# service.slp_type # => 'service:ldap' +# service.slp_url # => 'service:ldap://server.me:389' +# service.protocol # => 'ldap' +# service.host # => 'server.me' +# service.lifetime # => 65535 +# service.attributes.description # => 'Main LDAP server' +# +# The matching of the attributes is case insensitive. +# +# @example How to get a list of available service types +# +# Yast::SlpService.types.each do |type| +# puts type.name +# puts type.protocol +# end +# +# The rule is: if the service name is equal to protocol name, don't pass the protocol +# name as parameter to the search query (this is typical i.e. for ntp, ssh or ldap services). + +require 'resolv' +require 'ostruct' + +module Yast + Yast.import 'SLP' + + class SlpServiceClass < Module + + SCHEME = 'service' + DELIMITER = ':' + + def find(service_name, params={}) + service = nil + service_type = create_service_type(service_name, params[:protocol]) + discover_service(service_type, params[:scope]).each do |slp_response| + service = Service.create(params.merge(:name=>service_name, :data=>slp_response)) + break if service + end + service + end + + def all(service_name, params={}) + service_type = create_service_type(service_name, params[:protocol]) + services = discover_service(service_type, params[:scope]).map do |slp_response| + Service.create(params.merge(:name=>service_name, :data=>slp_response)) + end + services.compact + end + + def types + available_services = [] + discovered_services = discover_service_types + return available_services if discovered_services.empty? + + discovered_services.each do |slp_service_type| + available_services << parse_slp_type(slp_service_type) + end + available_services + end + + private + + def create_service_type(service_name, protocol) + [SCHEME, service_name, protocol].compact.join(DELIMITER) + end + + def parse_slp_type(service_type) + type_parts = service_type.split(DELIMITER) + case type_parts.size + when 2 + name = protocol = type_parts.last + when 3 + name = type_parts[1] + protocol = type_parts[2] + else + raise "Incorrect slp service type: #{service.inspect}" + end + OpenStruct.new :name => name, :protocol => protocol + end + + def discover_service(service_name, scope='') + SLP.FindSrvs(service_name, scope) + end + + def discover_service_types + SLP.FindSrvTypes('*', '') + end + + class Service + + def self.create params + service = new(params) + return service if service.verified? + end + + attr_reader :name, :ip, :host, :protocol, :port, :params + attr_reader :slp_type, :slp_url, :lifetime, :attributes + + def initialize(params) + @name = params.delete(:name) + slp_data = params.delete(:data) + @ip = slp_data['ip'] + @port = slp_data['pcPort'] + @slp_type = slp_data['pcSrvType'] + @slp_url = slp_data['srvurl'] + @protocol = params.delete(:protocol) || slp_type.split(DELIMITER).last + @host = DnsCache.resolve(ip) + @lifetime = slp_data['lifetime'] + @attributes = OpenStruct.new(SLP.GetUnicastAttrMap(slp_url, ip)) + @params = params + end + + def verified? + params.all? do |key, value| + if respond_to?(key) + result = send(key).to_s + result.match(/#{value}/i) + elsif attributes.respond_to?(key) + result = attributes.send(key).to_s + result.match(/#{value}/i) + else + true + end + end + end + end + + module DnsCache + def self.resolve(ip_address) + host = find(ip_address) + return host if host + + host = Resolv.getname(ip_address) + update(ip_address => host) + host + end + + def self.entries + @entries ||= {} + end + + def self.find ip_address + entries[ip_address] + end + + def self.update entry + entries.merge!(entry) + end + end + end + SlpService = SlpServiceClass.new +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-slp-3.1.1/test/Makefile.am new/yast2-slp-3.1.2/test/Makefile.am --- old/yast2-slp-3.1.1/test/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-slp-3.1.2/test/Makefile.am 2014-02-04 11:16:53.000000000 +0100 @@ -0,0 +1,8 @@ +TESTS = \ + slp_service_test.rb + +TEST_EXTENSIONS = .rb +RB_LOG_COMPILER = rspec +VERBOSE = 1 +EXTRA_DIST = $(TESTS) + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-slp-3.1.1/test/slp_service_test.rb new/yast2-slp-3.1.2/test/slp_service_test.rb --- old/yast2-slp-3.1.1/test/slp_service_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-slp-3.1.2/test/slp_service_test.rb 2014-02-04 11:16:53.000000000 +0100 @@ -0,0 +1,101 @@ +#!/usr/bin/env rspec +# +ENV['Y2DIR'] = File.expand_path('../../src', __FILE__) + +require 'yast' + +Yast.import 'SlpService' + +describe Yast::SlpService do + before do + @service = double('service', + :name=>'install.suse', :ip=>'10.100.2.16', + :host => 'fallback.suse.cz', :protocol => 'http', + :lifetime => 65535, :port => 0) + + @attributes = double('attributes', :machine=>'x86_64', :description=>'SLE_10_SP4_SDK') + + + Yast::SlpService.stub(:discover_service).and_return( + [ + { + 'ip' => '10.100.2.16', + 'pcFamily' => 'IP', + 'pcHost' => '10.100.2.16', + 'pcPort' => 0, + 'pcSrvPart' => '/install/SLP/SLE-10-SP4-SDK-RC3/x86_64/DVD1', + 'pcSrvType' => 'service:install.suse:http', + 'srvurl' => 'service:install.suse:http://10.100.2.16/install/SLP/SLE-10-SP4-SDK-RC3/x86_64/DVD1', + 'lifetime' => 65535 + } + ] + ) + + Yast::SLP.stub(:GetUnicastAttrMap).and_return( + { + 'machine' => 'x86_64', + 'description' => 'SLE_10_SP4_SDK' + } + ) + + Yast::SLP.stub(:FindSrvTypes).and_return( + [ + 'service:smtp', + 'service:install.suse:http', + 'service:ntp', + 'service:ldap' + ] + ) + + ::Resolv.stub(:getname).and_return('fallback.suse.cz') + end + + describe '#find' do + it 'returns the first discovered service that matches the service name and params' do + service = Yast::SlpService.find('install.suse', :machine=>'x86_64') + expect(service.name).to eq(@service.name) + expect(service.ip).to eq(@service.ip) + expect(service.host).to eq(@service.host) + expect(service.protocol).to eq(@service.protocol) + expect(service.port).to eq(@service.port) + expect(service.lifetime).to eq(@service.lifetime) + expect(service).to respond_to(:attributes) + expect(service.attributes).to respond_to(:machine) + expect(service.attributes.machine).to eq(@attributes.machine) + expect(service.attributes).to respond_to(:description) + expect(service.attributes.description).to eq(@attributes.description) + end + + it 'returns nil if no matching service found' do + service = Yast::SlpService.find('install.suse', :machine=>'Dell') + expect(service).to eq(nil) + end + end + + describe '#all' do + it 'returns a collection of services' do + services = Yast::SlpService.all('install.suse') + expect(services.size).to eq(1) + service = services.first + expect(service).to be_a(Yast::SlpServiceClass::Service) + expect(service.name).to eq(@service.name) + expect(service.ip).to eq(@service.ip) + expect(service.host).to eq(@service.host) + expect(service.protocol).to eq(@service.protocol) + end + end + + describe '#types' do + before do + @type = double('type', :name => 'install.suse', :protocol => 'http') + end + + it 'returns a collection of discovered service types' do + service_types = Yast::SlpService.types + expect(service_types).to respond_to(:each) + type = service_types.find {|t| t.name == @type.name } + expect(type).not_to eq(nil) + expect(type.protocol).to eq(@type.protocol) + end + end +end -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
