Hello community,
here is the log from the commit of package suseRegister
checked in at Fri Oct 24 15:31:34 CEST 2008.
--------
--- suseRegister/suseRegister.changes 2008-10-16 13:58:45.000000000 +0200
+++ /mounts/work_src_done/STABLE/suseRegister/suseRegister.changes 2008-10-24 15:27:07.839427000 +0200
@@ -1,0 +2,6 @@
+Tue Oct 21 16:07:57 CEST 2008 - mc(a)suse.de
+
+- use lscpu for hypervisor detection
+- improve error detection (bnc#437784)
+
+-------------------------------------------------------------------
calling whatdependson for head-i586
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ suseRegister.spec ++++++
--- /var/tmp/diff_new_pack.w16712/_old 2008-10-24 15:30:51.000000000 +0200
+++ /var/tmp/diff_new_pack.w16712/_new 2008-10-24 15:30:51.000000000 +0200
@@ -20,7 +20,7 @@
Name: suseRegister
Version: 1.3
-Release: 6
+Release: 7
Summary: Registration Tool
Group: Productivity/Other
License: GPL v2 or later
@@ -36,6 +36,7 @@
Requires: perl-Crypt-SSLeay
Requires: uuid-runtime
Requires: coreutils
+Requires: util-linux
Requires: sysconfig
Requires: hwinfo
Requires: zypper >= 0.12.6
@@ -88,6 +89,9 @@
/usr/lib/suseRegister/bin/*
%changelog
+* Tue Oct 21 2008 mc(a)suse.de
+- use lscpu for hypervisor detection
+- improve error detection (bnc#437784)
* Thu Oct 16 2008 mc(a)suse.de
- fix requires
- fix log message
++++++ suseRegister-1.3.tar.bz2 ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/suseRegister-1.3/SRPrivate.pm new/suseRegister-1.3/SRPrivate.pm
--- old/suseRegister-1.3/SRPrivate.pm 2008-10-16 12:35:18.000000000 +0200
+++ new/suseRegister-1.3/SRPrivate.pm 2008-10-24 15:24:28.000000000 +0200
@@ -127,7 +127,7 @@
}
elsif($_ =~ /^hostGUID\s*=\s*(\w*)\s*/ && defined $1 && $1 ne "")
{
- $ctx->{hostGUID} = $1;
+ $ctx->{FallbackHostGUID} = $1;
}
elsif($_ =~ /^addRegSrvSrc\s*=\s*(\w*)\s*/ && defined $1)
{
@@ -164,49 +164,13 @@
{
return ($code, $msg);
}
-
- ########## host GUID (virtualization) #############
- if(-d "/proc/xen" &&
- -e $ctx->{xenstoreread})
+ ########## host GUID (virtualization) #############
+ ($code, $msg) = detectVirtualization($ctx);
+ if($code != 0)
{
- printLog($ctx, "debug2", "Found XEN");
-
- my $err = "";
- my $val = "";
-
- ($code, $err, $val) = executeCommand($ctx, $ctx->{xenstoreread}, undef, ("domid"));
-
- if($code == 0 && defined $val && $val eq "0")
- {
- printLog($ctx, "debug2", "We are Domain-0");
-
- # we are Domain-0
- if(-e $ctx->{xenstorewrite} && -e $ctx->{xenstorechmod})
- {
- printLog($ctx, "debug1", "Write /tool/SR/HostDeviceID to xenbus");
-
- executeCommand($ctx, $ctx->{xenstorewrite}, undef, ("/tool/SR/HostDeviceID", "$ctx->{guid}"));
- executeCommand($ctx, $ctx->{xenstorechmod}, undef, ("/tool/SR/HostDeviceID", "r"));
- }
- }
- elsif($code == 0 && defined $val && $val ne "")
- {
- printLog($ctx, "debug2", "try to read /tool/SR/HostDeviceID from xenbus");
-
- ($code, $err, $val) = executeCommand($ctx, $ctx->{xenstoreread}, undef, ("/tool/SR/HostDeviceID"));
- if(defined $val && $val ne "")
- {
- printLog($ctx, "debug2", "Got /tool/SR/HostDeviceID: $val");
-
- $ctx->{hostGUID} = $val;
- }
- }
- else
- {
- printLog($ctx, "debug1", "Cannot read from xenstore: $code");
- }
- }
+ return ($code, $msg);
+ }
############## some initial values ########################
@@ -864,11 +828,18 @@
$writer->characters($ctx->{guid});
$writer->endTag("guid");
- if(defined $ctx->{hostGUID} && $ctx->{hostGUID} ne "")
+ if(defined $ctx->{virtType} && $ctx->{virtType} ne "")
{
- $writer->startTag("host");
- $writer->characters($ctx->{hostGUID});
- $writer->endTag("host");
+ if(defined $ctx->{hostGUID} && $ctx->{hostGUID} ne "")
+ {
+ $writer->startTag("host", type => $ctx->{virtType} );
+ $writer->characters($ctx->{hostGUID});
+ $writer->endTag("host");
+ }
+ else
+ {
+ $writer->emptyTag("host", type => $ctx->{virtType});
+ }
}
else
{
@@ -1076,11 +1047,23 @@
if($@)
{
printLog($ctx, "error", "Request failed: '$url'");
- if($@ =~ /certificate verify failed/)
+ if($@ =~ /SSL negotiation failed:\s+[^:]*:[^:]*:[^:]*:[^:]*:(.*) at / &&
+ defined $1 && $1 ne "")
+ {
+ printLog($ctx, "error", "$1", 0, 1);
+ $ctx->{errorcode} = 16;
+ $ctx->{errormsg} = "$1";
+ }
+ elsif($@ =~ /SSL negotiation failed/)
{
- printLog($ctx, "error", "Certificate verify failed.", 0, 1);
+ printLog($ctx, "error", "SSL negotiation failed", 0, 1);
$ctx->{errorcode} = 16;
- $ctx->{errormsg} = "Certificate verify failed.";
+ $ctx->{errormsg} = "SSL negotiation failed";
+ }
+ else
+ {
+ $ctx->{errorcode} = 16;
+ $ctx->{errormsg} = "Request failed.";
}
printLog($ctx, "debug2", $@, 1, 0);
@@ -1502,6 +1485,7 @@
{
$ctx->{args}->{secret}->{value} = "secret";
}
+
my $cmdtxt = "Commandline params: no-optional:$ctx->{nooptional} forceregistration:$ctx->{forcereg} ";
$cmdtxt .= "no-hw-data:$ctx->{nohwdata} batch:$ctx->{batch} ";
@@ -2114,8 +2098,8 @@
open(CRED, "> $fullpath") or do {
return logPrintReturn($ctx, "Cannot open file fullpath for write: $!\n", 12);
};
- print CRED "username=$ctx->{guid}\n";
- print CRED "password=$ctx->{secret}\n";
+ print CRED "username=".$ctx->{guid}."\n";
+ print CRED "password=".$ctx->{secret}."\n";
close CRED;
my $mode = 0600;
chmod $mode, "$fullpath";
@@ -2311,6 +2295,102 @@
return ($code, $err, $out);
}
+
+sub detectVirtualization
+{
+ my $ctx = shift;
+ my $code = 1;
+ my $err = "";
+ my $val = "";
+
+ if(-d "/proc/xen")
+ {
+ printLog($ctx, "debug2", "Found XEN");
+
+ if(-e $ctx->{xenstoreread})
+ {
+ my $err = "";
+ my $val = "";
+
+ ($code, $err, $val) = executeCommand($ctx, $ctx->{xenstoreread}, undef, ("domid"));
+
+ if($code == 0 && defined $val && $val eq "0")
+ {
+ printLog($ctx, "debug2", "We are Domain-0");
+
+ # we are Domain-0
+ if(-e $ctx->{xenstorewrite} && -e $ctx->{xenstorechmod})
+ {
+ printLog($ctx, "debug1", "Write /tool/SR/HostDeviceID to xenbus");
+
+ executeCommand($ctx, $ctx->{xenstorewrite}, undef, ("/tool/SR/HostDeviceID", "$ctx->{guid}"));
+ executeCommand($ctx, $ctx->{xenstorechmod}, undef, ("/tool/SR/HostDeviceID", "r"));
+ }
+ }
+ elsif($code == 0 && defined $val && $val ne "")
+ {
+ $ctx->{virtType} = "Xen";
+
+ printLog($ctx, "debug2", "try to read /tool/SR/HostDeviceID from xenbus");
+
+ ($code, $err, $val) = executeCommand($ctx, $ctx->{xenstoreread}, undef, ("/tool/SR/HostDeviceID"));
+ if(defined $val && $val ne "")
+ {
+ printLog($ctx, "debug2", "Got /tool/SR/HostDeviceID: $val");
+
+ $ctx->{hostGUID} = $val;
+ }
+ else
+ {
+ $ctx->{hostGUID} = "Y";
+ }
+ }
+ else
+ {
+ printLog($ctx, "debug1", "Cannot read from xenstore: $code");
+
+ if(! -e "proc/xen/xsd_port")
+ {
+ $ctx->{virtType} = "Xen";
+ $ctx->{hostGUID} = "Y";
+ }
+ }
+ }
+ }
+ else
+ {
+ my ($code, $err, $out) = executeCommand($ctx, $ctx->{lscpu}, undef);
+ if($code != 0)
+ {
+ printLog($ctx, "warn", "Cannot execute lscpu: $code $err");
+ }
+ else
+ {
+ foreach my $line (split(/\n/, $out))
+ {
+ if($line =~ /^Hypervisor vendor ID:\s*(.*)\s*$/ && defined $1)
+ {
+ $ctx->{virtType} = "$1";
+ $ctx->{hostGUID} = "Y";
+ last;
+ }
+ }
+ }
+
+ if(!defined $ctx->{virtType} || $ctx->{virtType} eq "")
+ {
+ # search for fallback.
+ if(defined $ctx->{FallbackHostGUID} && $ctx->{FallbackHostGUID} ne "")
+ {
+ $ctx->{virtType} = "suseRegister.conf";
+ $ctx->{hostGUID} = $ctx->{FallbackHostGUID};
+ }
+ }
+ }
+
+ return (0, "");
+}
+
#
# FIXME: old curl variant. Remove this function if the new one works.
#
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/suseRegister-1.3/SuseRegister.pm new/suseRegister-1.3/SuseRegister.pm
--- old/suseRegister-1.3/SuseRegister.pm 2008-10-16 12:35:18.000000000 +0200
+++ new/suseRegister-1.3/SuseRegister.pm 2008-10-24 15:24:28.000000000 +0200
@@ -233,7 +233,9 @@
$ctx->{extraCurlOption} = [];
$ctx->{hostGUID} = undef;
-
+ $ctx->{virtType} = "";
+ $ctx->{FallbackHostGUID} = undef;
+
$ctx->{zmdConfig} = {};
$ctx->{ostarget} = "";
@@ -253,6 +255,7 @@
$ctx->{xenstoreread} = "/usr/bin/xenstore-read";
$ctx->{xenstorewrite} = "/usr/bin/xenstore-write";
$ctx->{xenstorechmod} = "/usr/bin/xenstore-chmod";
+ $ctx->{lscpu} = "/usr/bin/lscpu";
$ctx->{createGuid} = "/usr/bin/uuidgen";
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: opensuse-commit+help(a)opensuse.org