[sles-beta] SLES12 RC1 SUSEConnect distingush between virtiual and physical server?

urs.frey at post.ch urs.frey at post.ch
Tue Aug 12 05:38:00 MDT 2014


Hi Darren
It is up to you to decide how deep you want to go with your tests and try to understand the process of SUSEConnect

Best regards

Urs Frey                                              
Post CH AG
Informationstechnologie
IT Betrieb 
Webergutstrasse 12 
3030 Bern (Zollikofen) 
Telefon : ++41 (0)58 338 58 70 
FAX     : ++41 (0)58 667 30 07 
E-Mail:   urs.frey at post.ch


-----Ursprüngliche Nachricht-----
Von: Darren Thompson (AkurIT) [mailto:darrent at akurit.com.au] 
Gesendet: Tuesday, August 12, 2014 1:11 PM
An: Frey Urs, IT222
Cc: <jreidinger at suse.com>; <sles-beta at lists.suse.com>
Betreff: Re: [sles-beta] SLES12 RC1 SUSEConnect distingush between virtiual and physical server?

Is it worth me running the same shell script on a XEN host to. Compare the output?

On 12/08/2014, at 18:06, <urs.frey at post.ch> wrote:

> Hello Josef
> 
> OK, thank you very much!
> I see:
> In fact you are doing nothing other than
> 
>  def hypervisor
>    output['Hypervisor vendor']
>  end
> 
>  def output
>    @output ||= execute('lscpu', false).split("\n").reduce({}) do |hash, line|
>      k, v = line.split(':')
>      hash[k] = v.strip
>      hash
>    end
>  end
> 
> Which is in bash shell:
> 
> KVM:
> =====
> h05cnh:~ # lscpu | grep "Hypervisor vendor"| cut -d":" -f2 | awk '{print $1}'
> KVM
> h05cnh:~ #
> 
> 
> VMware ESXi
> ==========
> v03er9:~ # lscpu| grep "Hypervisor vendor"| cut -d":" -f2 | awk '{print $1}'
> VMware
> v03er9:~ #
> 
> HP ProLiant
> =========
> h05cni:~ # lscpu| grep "Hypervisor vendor"| cut -d":" -f2 | awk '{print $1}'
> h05cni:~ #
> 
> 
> And therefore if "Hypervisor vendor" Output has some value, you know : "This is a virtual machine installation"
> 
> Is this correct?
> 
> Thank you very much
> 
> Best regards
> 
> 
> Urs Frey                                              
> Post CH AG
> Informationstechnologie
> IT Betrieb 
> Webergutstrasse 12 
> 3030 Bern (Zollikofen) 
> Telefon : ++41 (0)58 338 58 70 
> FAX     : ++41 (0)58 667 30 07 
> E-Mail:   urs.frey at post.ch
> 
> -----Ursprüngliche Nachricht-----
> Von: Josef Reidinger [mailto:jreidinger at suse.com] 
> Gesendet: Tuesday, August 12, 2014 8:15 AM
> An: sles-beta at lists.suse.com
> Cc: Frey Urs, IT222
> Betreff: Re: [sles-beta] SLES12 RC1 SUSEConnect distingush between virtiual and physical server?
> 
> 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
> _______________________________________________
> sles-beta mailing list
> sles-beta at lists.suse.com
> http://lists.suse.com/mailman/listinfo/sles-beta


More information about the sles-beta mailing list