[yast-commit] r59551 - in /branches/SuSE-Linux-11_2-Branch/registration: VERSION package/yast2-registration.changes src/modules/YSR.pm
Author: jdsn Date: Sat Nov 14 04:43:52 2009 New Revision: 59551 URL: http://svn.opensuse.org/viewcvs/yast?rev=59551&view=rev Log: fixes in REST API to prevent server error and loops (bnc#553244) 2.18.3 Modified: branches/SuSE-Linux-11_2-Branch/registration/VERSION branches/SuSE-Linux-11_2-Branch/registration/package/yast2-registration.changes branches/SuSE-Linux-11_2-Branch/registration/src/modules/YSR.pm Modified: branches/SuSE-Linux-11_2-Branch/registration/VERSION URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_2-Branch/registration/VERSION?rev=59551&r1=59550&r2=59551&view=diff ============================================================================== --- branches/SuSE-Linux-11_2-Branch/registration/VERSION (original) +++ branches/SuSE-Linux-11_2-Branch/registration/VERSION Sat Nov 14 04:43:52 2009 @@ -1 +1 @@ -2.18.2 +2.18.3 Modified: branches/SuSE-Linux-11_2-Branch/registration/package/yast2-registration.changes URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_2-Branch/registration/package/yast2-registration.changes?rev=59551&r1=59550&r2=59551&view=diff ============================================================================== --- branches/SuSE-Linux-11_2-Branch/registration/package/yast2-registration.changes (original) +++ branches/SuSE-Linux-11_2-Branch/registration/package/yast2-registration.changes Sat Nov 14 04:43:52 2009 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Sat Nov 14 04:42:20 CET 2009 - jdsn@suse.de + +- fixes in REST API to prevent server error and loops (bnc#553244) +- 2.18.3 + +------------------------------------------------------------------- Thu Nov 5 16:22:53 CET 2009 - jdsn@suse.de - fix XML format for stateless registration API Modified: branches/SuSE-Linux-11_2-Branch/registration/src/modules/YSR.pm URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_2-Branch/registration/src/modules/YSR.pm?rev=59551&r1=59550&r2=59551&view=diff ============================================================================== --- branches/SuSE-Linux-11_2-Branch/registration/src/modules/YSR.pm (original) +++ branches/SuSE-Linux-11_2-Branch/registration/src/modules/YSR.pm Sat Nov 14 04:43:52 2009 @@ -189,6 +189,7 @@ my $self = shift; my $ctx = shift; my $arguments = shift; + my $SRregisterFlagFile = '/var/lib/yastws/registration_successful'; unless ( defined $ctx && ref($ctx) eq "HASH" ) { @@ -260,8 +261,9 @@ if ( $exitcode == 0 ) { + # successful registration, so we need to save the last ZMD config + $self->saveLastZmdConfig(); $tasklist = $self->getTaskList() || {}; - my $ret = $self->changerepos($tasklist); if ( ref($ret) eq 'HASH' ) @@ -278,7 +280,23 @@ } ${$regret}{'success'} = 'Successfully ran registration'; - ${$regret}{'tasklist'} = XMLout( {'item' => $tasklist}, rootname => 'tasklist', KeyAttr => { item => "+ALIAS" }, NoAttr => 1); + # prepare the tasklist for XML conversion + foreach my $k (keys %{$tasklist}) + { + if ( exists ${${$tasklist}{$k}}{'CATALOGS'} ) + { + ${${$tasklist}{$k}}{'CATALOGS'} = { 'catalog' => ${${$tasklist}{$k}}{'CATALOGS'} }; + } + } + ${$regret}{'tasklist'} = XMLout( {'item' => $tasklist}, rootname => 'tasklist', KeyAttr => { item => "+ALIAS", catalog => "+ALIAS" }, NoAttr => 1); + + # write flagfile for successful registration + open(FLAGFILE, "> $SRregisterFlagFile"); + print FLAGFILE localtime(); + close FLAGFILE; + + # to be on the safe side for a following registration request, we need to delete the context data + $self->del_ctx(); } elsif ( $exitcode == 3 ) { @@ -312,6 +330,7 @@ my $SRconf = '/etc/suseRegister.conf'; my $SRcert = '/etc/ssl/certs/registration-server.pem'; my $SRcredentials = '/etc/zypp/credentials.d/NCCcredentials'; + my $SRregisterFlagFile = '/var/lib/yastws/registration_successful'; my $url = undef; my $cert = undef; @@ -347,8 +366,8 @@ } # read the guid - if (-e $SRcredentials) - { + if ( -e $SRcredentials && -e $SRregisterFlagFile ) + { if (open(CRED, "< $SRcredentials") ) { while(<CRED>) @@ -366,6 +385,9 @@ $cert = '' unless defined $cert; $guid = '' unless defined $guid; + # delete a flagfile that might be still there if no guid is found + unlink($SRregisterFlagFile) if $guid eq ''; + return { "regserverurl" => $url, "regserverca" => $cert, "guid" => $guid }; @@ -472,6 +494,7 @@ foreach $catalog (keys %{$todo}) { + $pAny = ${$todo}{$catalog}; if ( not defined $catalog || $catalog eq '' ) { push @log, "A catalog returned by SuseRegister has no or an invalid name."; @@ -499,7 +522,7 @@ elsif ( ${$pAny}{"TASK"} eq 'a' ) { push @log, "According to SuseRegister a catalog has to be enabled: $catalog ($pService)"; - my @zCMD = ('zypper', '--non-interactive', 'modifyrepo', '--enable', ${$pAny}{'ALIAS'}); + my @zCMD = ('zypper', '--non-interactive', 'modifyrepo', '--enable', "${$pAny}{'ALIAS'}"); if ( system(@zCMD) == 0 ) { push @log, "Enabled catalog: ${$pAny}{'ALIAS'} ($pService)"; @@ -623,7 +646,7 @@ push @log, "According to SuseRegister a service should be left enabled: $pService"; push @log, "Now checking the catalogs of the service: $pService"; - my @zCMD = ('zypper', '--non-interactive', 'refresh-services', $pService); + my @zCMD = ('zypper', '--non-interactive', 'refresh', '--services'); if ( system(@zCMD) == 0 ) { push @log, "Successfully refreshed service: $pService"; @@ -655,7 +678,7 @@ push @log, "Now checking the catalogs of the service: $pService"; - my @zrCMD = ('zypper', '--non-interactive', 'refresh-services', $pService); + my @zrCMD = ('zypper', '--non-interactive', 'refresh', '--services'); if ( system(@zrCMD) == 0 ) { push @log, "Successfully refreshed service: $pService"; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
jdsn@svn.opensuse.org