[sles-beta] SLES12 RC1 SUSEConnect distingush between virtiual and physical server?
Josef Reidinger
jreidinger at suse.com
Tue Aug 12 00:14:34 MDT 2014
On Mon, 11 Aug 2014 16:55:47 +0000
<urs.frey at post.ch> wrote:
> Hi
>
> I finally found an old note of mine showing me, that once in SLES12
> beta6 the
> file /usr/lib64/ruby/gems/2.0.0/gems/suse-connect-0.0.17/lib/suse/connect/system.rb,
> there was this sequence to distinguish between virtual and physical
> installation when registering.
>
> Within the file
> /usr/lib64/ruby/gems/2.0.0/gems/suse-connect-0.0.17/lib/suse/connect/system.rb
> I can see this sequence
>
> module SUSE
> module Connect
> # System class allowing to interact with underlying system
> class System
>
> class << self
>
> def hwinfo
> info = {
> :cpu_type => `uname -p`,
> :cpu_count => `grep "processor" /proc/cpuinfo | wc
> -l`, :platform_type => `uname -i`,
> :hostname => `hostname`
> }
>
> info.values.each(&:chomp!)
> dmidecode = `dmidecode`
> virt_zoo = ['vmware', 'virtual machine', 'qemu', 'domu']
> info[:virtualized] = (virt_zoo).any? {|ident|
> dmidecode.downcase.include? ident } if dmidecode info
> end
>
> # returns username and password from SCC_CREDENTIALS_FILE
>
> So dmidecode is used to detect a virtual machine
>
>
> Now with SLES12 RC1 this sequence has gone, there are some hypervisor
> definitions now
>
> h05cnh:~ #
> cat /usr/lib64/ruby/gems/2.1.0/gems/suse-connect-0.2.7/lib/suse/connect/system.rb
> require 'suse/toolkit/hwinfo'
>
> module SUSE
> module Connect
> # System class allowing to interact with underlying system
> class System
> class << self
>
> include SUSE::Toolkit::Hwinfo
>
> attr_accessor :filesystem_root
>
> def prefix_path(path)
> filesystem_root ? File.join(filesystem_root, path) : path
> end
>
> def hwinfo
> if x86?
> {
> hostname: hostname,
> cpus: cpus,
> sockets: sockets,
> hypervisor: hypervisor,
> arch: arch,
> uuid: uuid
> }
> else
> {
> hostname: hostname,
> arch: arch
> }
> end
> end
>
> From the toolkit hwinfo,rb I can see some Hypervisor definitions
> h05cnh:~ #
> cat /usr/lib64/ruby/gems/2.1.0/gems/suse-connect-0.2.7/lib/suse/toolkit/hwinfo.rb
> require 'suse/toolkit/system_calls'
>
> # Collects system hardware information
> module SUSE::Toolkit::Hwinfo
>
> include SUSE::Toolkit::SystemCalls
>
> def cpus
> output['CPU(s)'].to_i
> end
>
> def sockets
> output['Socket(s)'].to_i
> end
>
> def hypervisor
> output['Hypervisor vendor']
> end
>
> Can somebody please show me, how now SUSEConnect can distinguish
> between a HP-ProLiant Server, a XEN client, a KVM client and a VMWare
> ESXi client. It is really of interest to see how it is done.
> ( Believing is one thing. But understanding the process gives me
> confidence. )
>
> Thank you very much, indeed
>
> Best regards
>
>
Hi Urs,
I check current code on github and it uses now lscpu call -
https://github.com/SUSE/connect/blob/master/lib/suse/connect/hwinfo/x86.rb#L45
from which it create pairs of keys and values. and there should by
Hypervisor vendor key.
Josef
More information about the sles-beta
mailing list