The analysis of suse_register

The script is divided into 4 parts. The example is run by:suse_register --restore-repos -i -L /root/.suse_register.log

1 Define 3 procedures: logPrintExit, mailToRoot and usage      (Line 48-150)

2 Get parameters from comand line, and set the parameters to data      (Line 151-219)

3 Initalize the ctx variable, which contains all the information for register and relative operations.
my $ctx = SUSE::SuseRegister::init_ctx($data);  (Line 220)
SUSE::SuseRegister::init_ctx($data), this function initialize the ctx, which includes configFile(/etc/suseRegister.conf), sysconfigFile(/etc/sysconfig/suse_register), CA_PATH(/etc/ssl/certs), URL(https://secure-www.novell.com/center/regsvc/), system information, products in the server, etc.
It call following subprocedures:
SUSE::SRPrivate::initGUID($ctx),
SUSE::SRPrivate::zyppRefresh($ctx),
SUSE::SRPrivate::readSystemValues($ctx),
SUSE::SRPrivate::listProducts($ctx),
SUSE::SRPrivate::intersection
3.0 SUSE::SRPrivate::initGUID($ctx)
This function read the user and password from $ctx->{CREDENTIAL_DIR}."/".$ctx->{CREDENTIAL_FILE} (/etc/zypp/credentials.d/NCCcredentials), set them into ctx->{guid} and $ctx->{secret}.
3.1 SUSE::SRPrivate::zyppRefresh($ctx) 
This function fresh the zypper repos with: zypper ref --service
3.2 SUSE::SRPrivate::readSystemValues($ctx)
This function gets the system information with these functions
3.2.0 Get system configure files
$ctx->{sysconfigFile},$ctx->{configFile}(/etc/suseRegister.conf)
Set $ctx->{URL} from $ctx->{configFile}.
3.2.1 SUSE::SRPrivate::initGUID($ctx)
Refer to 3.0
3.2.2 getProducts($ctx)
Execute command: zypper --no-refresh --quiet --xmlout --non-interactive products --installed-only, and parse the parameters into ctx->{InstalledProduct}
The result of the xml format is below:
<?xml version='1.0'?>
<stream>
<product-list>
<product name="SUSE_SLED" version="11" release="0" epoch="0" arch="i586" productline="sled" registerrelease="" vendor="SUSE LINUX Products GmbH, Nuernberg, Germany" summary="SUSE Linux Enterprise Desktop 11" shortname="" flavor="DVD" isbase="1" repo="@System" installed="1">
<description>SUSE Linux Enterprise offers a comprehensive
        suite of products built on a single code base.
        The platform addresses business needs from
        the smallest thin-client devices to the worlda??s
        most powerful high-performance computing
        and mainframe servers. SUSE Linux Enterprise
        offers common management tools and technology
        certifications across the platform, and
        each product is enterprise-class. SUSE Linux
        Enterprise provides more than a cute desktop
        product or a basic server offering. It is the
        only Linux platform for enterprise computing,
        and it is now replacing UNIX* and Windows*
        as well.</description>
</product>
</product-list>
For example, "SUSE_SLED"=>$data->{NAME},"11"=>$data->{VERSION},"DVD"=>$release,"i586"=>$data->{ARCH}, and put into $ctx->{installedProducts}.

3.2.3 detectVirtualization($ctx)
Get host GUID
3.3 SUSE::SRPrivate::listProducts($ctx)
Get the product information from server($ctx->{URL}). And parse the information into ctx->{ServerknownProducts}. It manily calls one function
sendData to implement this.
For example, the server address is https://secure-www.novell.com/center/regsvc-1.0/?command=listproducts&lang=en-US&version=1.0, and response from
server is bellow and put into $ctx->{serverKnownProducts}:
<?xml version="1.0" encoding="UTF-8"?><productlist xmlns="http://www.novell.com/xml/center/regsvc-1_0
lang="en"><product>ATI Video Drivers</product><product>ATI Video Drivers SP2</product><product>ATI Video
 Drivers SP3</product><product>JeOS</product><product>NAM_AGA</product><product>NOWS-SBE</product>
 <product>Novell-Open-Enterprise-Server-SP1</product><product>Novell-Open-Enterprise-Server-SP1-migration
 </product><product>Novell-Open-Enterprise-Server-SP2</product><product>Novell-Open-Enterprise-Server-SP2-migration
 </product><product>Novell-Open-Enterprise-Server-i386</product><product>Novell-Open-Enterprise-Server-x86_64
 </product><product>RES</product><product>SLES9-SLD-SP-i386</product><product>SLES9-SLD-SP-x86_64</product>
 <product>SUSE-Linux-Enterprise-Desktop-SP1</product><product>SUSE-Linux-Enterprise-Desktop-SP1-migration
 </product><product>SUSE-Linux-Enterprise-Desktop-SP2</product><product>SUSE-Linux-Enterprise-Desktop-SP2-migration
 </product><product>SUSE-Linux-Enterprise-Desktop-SP3</product><product>SUSE-Linux-Enterprise-Desktop-SP3-migration
 </product><product>SUSE-Linux-Enterprise-Desktop-i386</product><product>SUSE-Linux-Enterprise-Desktop-x86_64
 </product><product>SUSE-Linux-Enterprise-HA-Server</product><product>SUSE-Linux-Enterprise-Mono-Extension
 </product><product>SUSE-Linux-Enterprise-POS</product><product>SUSE-Linux-Enterprise-RT</product><product>
 SUSE-Linux-Enterprise-SDK-DVD-i386</product><product>SUSE-Linux-Enterprise-SDK-DVD-ia64</product><product>
 SUSE-Linux-Enterprise-SDK-DVD-ppc</product><product>SUSE-Linux-Enterprise-SDK-DVD-s390x</product><product>
 SUSE-Linux-Enterprise-SDK-DVD-x86_64</product><product>SUSE-Linux-Enterprise-SDK-SP1</product><product>
 SUSE-Linux-Enterprise-SDK-SP1-migration</product><product>SUSE-Linux-Enterprise-SDK-SP2</product><product>
 SUSE-Linux-Enterprise-SDK-SP2-migration</product><product>SUSE-Linux-Enterprise-SDK-SP3</product><product>
 SUSE-Linux-Enterprise-SDK-SP3-migration</product><product>SUSE-Linux-Enterprise-SDK-i386</product><product>
 SUSE-Linux-Enterprise-SDK-ia64</product><product>SUSE-Linux-Enterprise-SDK-ppc</product><product>
 SUSE-Linux-Enterprise-SDK-s390x</product><product>SUSE-Linux-Enterprise-SDK-x86_64</product><product>
 SUSE-Linux-Enterprise-SMT-SP2</product><product>SUSE-Linux-Enterprise-SMT-SP3</product><product>
 SUSE-Linux-Enterprise-Server-10-SP1-SAP-AiO</product><product>SUSE-Linux-Enterprise-Server-SP1</product><product>
 SUSE-Linux-Enterprise-Server-SP1-migration</product><product>SUSE-Linux-Enterprise-Server-SP2</product><product>
 SUSE-Linux-Enterprise-Server-SP2-SAP-AiO</product><product>SUSE-Linux-Enterprise-Server-SP2-migration</product>
 <product>SUSE-Linux-Enterprise-Server-SP3</product><product>SUSE-Linux-Enterprise-Server-SP3-SAP-APL</product>
 <product>SUSE-Linux-Enterprise-Server-SP3-SAP-APL-migration</product><product>SUSE-Linux-Enterprise-Server-SP3-migration
 </product><product>SUSE-Linux-Enterprise-Server-i386</product><product>SUSE-Linux-Enterprise-Server-ia64</product>
 <product>SUSE-Linux-Enterprise-Server-ppc</product><product>SUSE-Linux-Enterprise-Server-s390x</product><product>
 SUSE-Linux-Enterprise-Server-x86_64</product><product>SUSE-Linux-Enterprise-Thin-Client</product><product>
 SUSE-Linux-Enterprise-Virtual-Machine-Driver-Pack</product><product>SUSE-Linux-SLES-i386</product><product>
 SUSE-Linux-SLES-x86_64</product><product>SUSE_SLED</product><product>SUSE_SLED-SP1-migration</product><product>
 SUSE_SLES</product><product>SUSE_SLES-SP1-migration</product><product>ZENworks Pulsar</product><product>
 ZENworks_Orchestrator</product><product>Zenworks Linux Management</product><product>nVidia Video Drivers</product>
 <product>nVidia Video Drivers SP3</product><product>openSUSE</product><product>openSUSE-10.2-CD-download</product>
 <product>openSUSE-10.2-CD-retail</product><product>openSUSE-10.2-DVD9-retail</product><product>openSUSE-10.2-FTP
 </product><product>openSUSE-10.2-Promo</product><product>openSUSE-10.2-dvd5-download</product><product>openSUSE-10.3-CD-download
 </product><product>openSUSE-10.3-DVD</product><product>openSUSE-10.3-DVD-Magazine</product><product>openSUSE-10.3-DVD-ct
 </product><product>openSUSE-10.3-FTP</product><product>openSUSE-10.3-GNOME-download</product><product>openSUSE-10.3-KDE-download
 </product><product>openSUSE-10.3-Live-Gnome</product><product>openSUSE-10.3-Live-KDE</product><product>openSUSE-10.3-OSS-Gnome
 </product><product>openSUSE-10.3-OSS-KDE</product><product>openSUSE-10.3-Promo</product><product>openSUSE-10.3-dvd5-download
 </product><product>openSUSE-10.3-retail</product><product>openSUSE-DVD</product><product>openSUSE-DVD-Cover</product>
 <product>openSUSE-DVD-Magazine</product><product>openSUSE-FTP</product><product>openSUSE-Live-Gnome</product>
 <product>openSUSE-Live-KDE</product><product>openSUSE-OSS-Gnome</product><product>openSUSE-OSS-KDE</product>
 <product>openSUSE-Promo</product><product>openSUSE-retail</product><product>sentinel_log_manager_1010_32_i586
 </product><product>sentinel_log_manager_1010_64_x86_64</product><product>sentinel_log_manager_1100_64_iso_x86_64
 </product><product>sentinel_log_manager_1100_64_vmx_x86_64</product><product>sentinel_log_manager_1100_64_xen_x86_64
 </product><product>sle-11-WebYaST</product><product>sle-hae</product><product>sle-hae-SP1-migration</product>
 <product>sle-mono</product><product>sle-pos</product><product>sle-pos-SP1-migration</product><product>sle-sdk
 </product><product>sle-sdk-SP1-migration</product><product>sle-slms</product><product>sle-smt</product>
 <product>sle-studioonsite</product><product>suse-meego</product><product>suse-moblin</product><product>
 webyast_on_sles11_for_slmsncc_integration_i586</product></productlist>
 
3.4 SUSE::SRPrivate::intersection
Check the intersection between the installed products and server known ones.

4 Register information to the server and update repos
         
4.1 SUSE::SuseRegister::listParams($ctx), show list of parameters of ctx

4.2 SUSE::SuseRegister::register($ctx), build the ctx into xml message and send to register message
For example, register information is bellow:
<?xml version="1.0" encoding="utf-8"?><register xmlns="http://www.novell.com/xml/center/regsvc-1_0" accept="mandatory" client_version="1.3.0"><guid>35fa3dc594134eeca61d0bf4ffd2ff0a</guid><host /><product version="11" release="DVD" arch="i586">SUSE_SLED</product><param id="netcard"><![CDATA[24: PCI 200.0: 0200 Ethernet controller
  [Created at pci.318]
  UDI: /org/freedesktop/Hal/devices/pci_10ec_8168
  Unique ID: rBUF.YQjbF99dfr4
  Parent ID: hoOk.dFyVbcq0vm4
  SysFS ID: /devices/pci0000:00/0000:00:1c.2/0000:02:00.0
  SysFS BusID: 0000:02:00.0
  Hardware Class: network
  Model: "Realtek RTL8111/8168B PCI Express Gigabit Ethernet controller"
  Vendor: pci 0x10ec "Realtek Semiconductor Co., Ltd."
  Device: pci 0x8168 "RTL8111/8168B PCI Express Gigabit Ethernet controller"
  SubVendor: pci 0x10ec "Realtek Semiconductor Co., Ltd."
  SubDevice: pci 0x8168
  Revision: 0x02
  Driver: "r8169"
  Driver Modules: "r8169"
  Device File: eth0
  I/O Ports: 0xde00-0xdeff (rw)
  Memory Range: 0xfddff000-0xfddfffff (rw,non-prefetchable)
  Memory Range: 0xfdcf0000-0xfdcfffff (rw,prefetchable)
  Memory Range: 0xfdc00000-0xfdc1ffff (ro,prefetchable,disabled)
  IRQ: 220 (no events)
  HW Address: 00:19:0f:01:bb:7c
  Link detected: no
  Module Alias: "pci:v000010ECd00008168sv000010ECsd00008168bc02sc00i00"
  Driver Info #0:
    Driver Status: r8169 is active
    Driver Activation Cmd: "modprobe r8169"
  Config Status: cfg=no, avail=yes, need=no, active=unknown
  Attached to: #13 (PCI bridge)

25: PCI 300.0: 0200 Ethernet controller
  [Created at pci.318]
  UDI: /org/freedesktop/Hal/devices/pci_10ec_8168_0
  Unique ID: JNkJ.YQjbF99dfr4
  Parent ID: Z7uZ.f4r+Yl3RyX5
  SysFS ID: /devices/pci0000:00/0000:00:1c.3/0000:03:00.0
  SysFS BusID: 0000:03:00.0
  Hardware Class: network
  Model: "Realtek RTL8111/8168B PCI Express Gigabit Ethernet controller"
  Vendor: pci 0x10ec "Realtek Semiconductor Co., Ltd."
  Device: pci 0x8168 "RTL8111/8168B PCI Express Gigabit Ethernet controller"
  SubVendor: pci 0x10ec "Realtek Semiconductor Co., Ltd."
  SubDevice: pci 0x8168
  Revision: 0x02
  Driver: "r8169"
  Driver Modules: "r8169"
  Device File: eth1
  I/O Ports: 0xce00-0xceff (rw)
  Memory Range: 0xfdbff000-0xfdbfffff (rw,non-prefetchable)
  Memory Range: 0xfdaf0000-0xfdafffff (rw,prefetchable)
  Memory Range: 0xfda00000-0xfda1ffff (ro,prefetchable,disabled)
  IRQ: 219 (430399 events)
  HW Address: 00:19:0f:01:bb:7d
  Link detected: yes
  Module Alias: "pci:v000010ECd00008168sv000010ECsd00008168bc02sc00i00"
  Driver Info #0:
    Driver Status: r8169 is active
    Driver Activation Cmd: "modprobe r8169"
  Config Status: cfg=no, avail=yes, need=no, active=unknown
  Attached to: #14 (PCI bridge)]]></param><param id="cpu-count"><![CDATA[CPUSockets: 1
CPUCores  : 1
]]></param><param id="isdn" /><param id="hostname">MSF-DuHyrgD</param><param id="platform">i386</param><param id="sound"><![CDATA[11: PCI 1b.0: 0403 Audio device
  [Created at pci.318]
  UDI: /org/freedesktop/Hal/devices/pci_8086_27d8
  Unique ID: u1Nb.d1vUVVWpvZ5
  SysFS ID: /devices/pci0000:00/0000:00:1b.0
  SysFS BusID: 0000:00:1b.0
  Hardware Class: sound
  Model: "Intel DeskTop Board D945GTP"
  Vendor: pci 0x8086 "Intel Corporation"
  Device: pci 0x27d8 "82801G (ICH7 Family) High Definition Audio Controller"
  SubVendor: pci 0x8086 "Intel Corporation"
  SubDevice: pci 0x27d8 "DeskTop Board D945GTP"
  Revision: 0x02
  Driver: "HDA Intel"
  Driver Modules: "snd_hda_intel"
  Memory Range: 0xfdff8000-0xfdffbfff (rw,non-prefetchable)
  IRQ: 16 (102011 events)
  Module Alias: "pci:v00008086d000027D8sv00008086sd000027D8bc04sc03i00"
  Driver Info #0:
    Driver Status: snd_hda_intel is active
    Driver Activation Cmd: "modprobe snd_hda_intel"
  Config Status: cfg=no, avail=yes, need=no, active=unknown]]></param><param id="gfxcard"><![CDATA[09: PCI 02.0: 0300 VGA compatible controller (VGA)
  [Created at pci.318]
  UDI: /org/freedesktop/Hal/devices/pci_8086_27ae
  Unique ID: _Znp.GP3zrmbAw5B
  SysFS ID: /devices/pci0000:00/0000:00:02.0
  SysFS BusID: 0000:00:02.0
  Hardware Class: graphics card
  Model: "Intel 945 GME"
  Vendor: pci 0x8086 "Intel Corporation"
  Device: pci 0x27ae "945 GME"
  SubVendor: pci 0x8086 "Intel Corporation"
  SubDevice: pci 0x27ae
  Revision: 0x03
  Memory Range: 0xfde80000-0xfdefffff (rw,non-prefetchable)
  I/O Ports: 0xff00-0xff07 (rw)
  Memory Range: 0xd0000000-0xdfffffff (rw,prefetchable)
  Memory Range: 0xfdf80000-0xfdfbffff (rw,non-prefetchable)
  IRQ: 16 (102011 events)
  I/O Ports: 0x3c0-0x3df (rw)
  Module Alias: "pci:v00008086d000027AEsv00008086sd000027AEbc03sc00i00"
  Driver Info #0:
    XFree86 v4 Server Module: intel
  Driver Info #1:
    XFree86 v4 Server Module: intel
    3D Support: yes
    Extensions: dri
  Config Status: cfg=no, avail=yes, need=no, active=unknown

10: PCI 02.1: 0380 Display controller
  [Created at pci.318]
  UDI: /org/freedesktop/Hal/devices/pci_8086_27a6
  Unique ID: ruGf.87xrQUqUSGD
  SysFS ID: /devices/pci0000:00/0000:00:02.1
  SysFS BusID: 0000:00:02.1
  Hardware Class: graphics card
  Model: "Intel Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller"
  Vendor: pci 0x8086 "Intel Corporation"
  Device: pci 0x27a6 "Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller"
  SubVendor: pci 0x8086 "Intel Corporation"
  SubDevice: pci 0x27ae
  Revision: 0x03
  Memory Range: 0xfdf00000-0xfdf7ffff (rw,non-prefetchable,disabled)
  Module Alias: "pci:v00008086d000027A6sv00008086sd000027AEbc03sc80i00"
  Config Status: cfg=no, avail=yes, need=no, active=unknown

Primary display adapter: #9]]></param><param id="installed-langs">en_US,en_US</param><param id="sys"><![CDATA[02: None 00.0: 10107 System
  [Created at sys.63]
  Unique ID: rdCR.n_7QNeEnh23
  Hardware Class: system
  Model: "System"
  Formfactor: "desktop"
  Driver Info #0:
    Driver Status: thermal,fan are active
    Driver Activation Cmd: "modprobe thermal; modprobe fan"
  Config Status: cfg=no, avail=yes, need=no, active=unknown]]></param><param id="timezone">America/New_York</param><param id="cpu"><![CDATA[01: None 00.0: 10103 CPU
  [Created at cpu.301]
  Unique ID: rdCR.j8NaKXDZtZ6
  Hardware Class: cpu
  Arch: Intel
  Vendor: "GenuineIntel"
  Model: 6.28.2 "Intel(R) Atom(TM) CPU N270   @ 1.60GHz"
  Features: fpu,vme,de,pse,tsc,msr,pae,mce,cx8,apic,sep,mtrr,pge,mca,cmov,pat,clflush,dts,acpi,mmx,fxsr,sse,sse2,ss,ht,tm,pbe,nx,constant_tsc,arch_perfmon,pebs,bts,pni,monitor,ds_cpl,est,tm2,ssse3,xtpr,lahf_lm
  Clock: 1600 MHz
  BogoMips: 3199.98
  Cache: 512 kb
  Units/Processor: 2
  Config Status: cfg=new, avail=yes, need=no, active=unknown

02: None 01.0: 10103 CPU
  [Created at cpu.301]
  Unique ID: wkFv.j8NaKXDZtZ6
  Hardware Class: cpu
  Arch: Intel
  Vendor: "GenuineIntel"
  Model: 6.28.2 "Intel(R) Atom(TM) CPU N270   @ 1.60GHz"
  Features: fpu,vme,de,pse,tsc,msr,pae,mce,cx8,apic,sep,mtrr,pge,mca,cmov,pat,clflush,dts,acpi,mmx,fxsr,sse,sse2,ss,ht,tm,pbe,nx,constant_tsc,arch_perfmon,pebs,bts,pni,monitor,ds_cpl,est,tm2,ssse3,xtpr,lahf_lm
  Clock: 800 MHz
  BogoMips: 3200.22
  Cache: 512 kb
  Units/Processor: 2
  Config Status: cfg=new, avail=yes, need=no, active=unknown]]></param><param id="processor">i686</param><param id="secret">32575dc9fd07443fb5e56cc483fd8f2e</param><param id="ostarget-bak"><![CDATA["SUSE Linux Enterprise Desktop 11 (i586)"]]></param><param id="memory"><![CDATA[01: None 00.0: 10102 Main Memory
  [Created at memory.61]
  Unique ID: rdCR.CxwsZFjVASF
  Hardware Class: memory
  Model: "Main Memory"
  Memory Range: 0x00000000-0x3dc21fff (rw)
  Memory Size: 960 MB
  Config Status: cfg=new, avail=yes, need=no, active=unknown]]></param><param id="ostarget">sle-11-i586</param><param id="dsl" /></register>

The response information is like bellow:

<?xml version="1.0" encoding="UTF-8"?><zmdconfig xmlns="http://www.novell.com/xml/center/regsvc-1_0" lang="en"><guid>
35fa3dc594134eeca61d0bf4ffd2ff0a</guid><service id="nu_novell_com" description="Rogue External Production" type="nu">
<param id="url">https://nu.novell.com</param><param name="catalog" url="https://nu.novell.com/repo/$RCE/SLED11-Updates/sle-11-i586/"
>SLED11-Updates</param></service><service id="download_nvidia_com_sle11" type="zypp" description="nVidia Video Drivers
 for SLE11"><param id="url">http://download.nvidia.com/novell/sle11</param><param name="catalog">nVidia-Driver-SLE11<
 /param></service><service id="www2_ati_com_sle11" type="zypp" description="ATI Video Drivers for SLE11"><param id=
 "url">http://www2.ati.com/suse/sle11</param><param name="catalog">ATI-Driver-SLE11</param></service></zmdconfig>

The response information is parsed and put into $ctx->{newzmdconfig}.

4.3 SUSE::SuseRegister::manageUpdateSources($ctx)
Add repos from $ctx->{newzmdconfig}. For example, as to the response from server, two repos are added:
ATI-Driver-SLE11:http://www2.ati.com/suse/sle11
nVidia-Driver-SLE11:http://download.nvidia.com/novell/sle11

 

Reference:

1.http://www.novell.com/support/viewContent.do?externalId=3303599


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值