ref: refs/heads/master
commit bb8640073aa2cdee3ceb766d4feb5825c2e50f6b
Author: J. Daniel Schmidt
Date: Wed Oct 21 15:19:06 2009 +0200
small changes to make it more rubyish
---
.../registration/configuration_controller.rb | 6 +++---
plugins/registration/app/models/register.rb | 9 ++++++---
webservice/lib/paths.rb | 3 +++
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/plugins/registration/app/controllers/registration/configuration_controller.rb b/plugins/registration/app/controllers/registration/configuration_controller.rb
index 7262e53..3793cdc 100644
--- a/plugins/registration/app/controllers/registration/configuration_controller.rb
+++ b/plugins/registration/app/controllers/registration/configuration_controller.rb
@@ -34,17 +34,17 @@ class Registration::ConfigurationController < ApplicationController
end
- @register = Register.new({})
+ @register = Register.new
@register.registrationserver = newurl if newurl
@register.certificate = newca if newca
- @register.save
+ @register.save || raise ("Error: Could not save the new registration configuration.")
render :show
end
def show
permission_check("org.opensuse.yast.modules.ysr.getregistrationconfig")
# do not run registration, only get the config
- @register = Register.new({})
+ @register = Register.new
end
def index
diff --git a/plugins/registration/app/models/register.rb b/plugins/registration/app/models/register.rb
index 9ff925a..658acfe 100644
--- a/plugins/registration/app/models/register.rb
+++ b/plugins/registration/app/models/register.rb
@@ -15,7 +15,7 @@ class Register
@reg = ''
- def initialize(hash)
+ def initialize(hash={})
# initialize context
init_context hash
# read the configuration
@@ -31,7 +31,7 @@ class Register
'nohwdata' => '1',
'nooptional' => '1',
'debugMode' => '2',
- 'logfile' => '/root/.suse_register.log' }
+ 'logfile' => Paths::REGISTRATION_LOG }
@context.merge! hash if hash.class == Hash
end
@@ -52,13 +52,16 @@ class Register
# don't know how to pass only one hash, so split it into two. FIXME change later if possible!
# @reg = YastService.Call("YSR::statelessregister", { 'ctx' => ctx, 'arguments' => args } )
+
+ # TODO: check the hashes and do a rescue if it fails
+
ctx = Hash.new
self.context.each { |k, v| ctx[k] = [ 's', v.to_s ] }
args = Hash.new
self.arguments.each { |k, v| args[k] = [ 'a{ss}', { 'value' => v.to_s } ] }
@reg = YastService.Call("YSR::statelessregister", ctx, args )
- return @reg['exitcode'] || 99
+ @reg['exitcode'] rescue 99
end
def save
diff --git a/webservice/lib/paths.rb b/webservice/lib/paths.rb
index 8e92f59..875e63f 100644
--- a/webservice/lib/paths.rb
+++ b/webservice/lib/paths.rb
@@ -12,4 +12,7 @@ module Paths
# Configuration place where is stored configuration place. Read-only.
CONFIG=File.join(ROOT,"etc","webyast")
+
+# Logfile for the registration - default is the YaST default: /root/.suse_register.log
+ REGISTRATION_LOG=File.join(ROOT, "root", ".suse_register.log")
end
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org